Is package com.sun.net.httpserver standard?

vbezhenar :

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.

Stephen C :

This is now clearly a public API. As of Java 13, 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/13/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 guaranteed 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.


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.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=322090&siteId=1