Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is package com.sun.net.httpserver standard?

Tags:

java

I want to understand if package com.sun.net.httpserver is standard and required by all Java implementations or only OpenJDK-specific? I checked and even OpenJDK 13 includes it and it was there since Java 6. Documentation for those classes is public, so it seems like official, yet its package name looks like something proprietary.

like image 548
vbezhenar Avatar asked Nov 08 '19 10:11

vbezhenar


Video Answer


1 Answers

This is now clearly a public API1. As of Java 11, there is a module (jdk.httpserver) that exports the com.sun.net.httpserver and com.sun.net.httpserver.spi packages and 17 public classes.

The javadocs are published (https://docs.oracle.com/en/java/javase/11/docs/api/jdk.httpserver/com/sun/net/httpserver/package-summary.html) and there are no visible caveats in the package summary to say that these APIs are intended for internal use only.

While the jdk.httpserver is standardized, it is not guaranteed2 to be present in all (Java 11+) Java SE implementations. As the Overview page says:

This document is divided into two sections:

Java SE: The Java Platform, Standard Edition (Java SE) APIs define the core Java platform for general-purpose computing. These APIs are in modules whose names start with java.

JDK: The Java Development Kit (JDK) APIs are specific to the JDK and will not necessarily be available in all implementations of the Java SE Platform. These APIs are in modules whose names start with jdk.

The module we are are talking about falls into the second category.


1 - The old (inconsistent) package name conventions about com.sun.* and so on are mooted by Java 9+ modules and their associated explicit visibility control mechanisms.
2 - Oracle and most other publishers of Java 11+ only provide JDK distributions, so this caveat is largely moot.

like image 148
Stephen C Avatar answered Oct 04 '22 16:10

Stephen C