Skip to content

Commit

Permalink
Annotate some "new" APIs related to modules and class loaders. (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpovirk authored Oct 7, 2024
1 parent 5142764 commit a93551a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/java.base/share/classes/java/lang/Class.java
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ private static native Class<?> forName0(String name, boolean initialize,
*/
@SuppressWarnings("removal")
@CallerSensitive
public static Class<?> forName(Module module, String name) {
public static @Nullable Class<?> forName(Module module, String name) {
Class<?> caller = null;
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
Expand Down
4 changes: 2 additions & 2 deletions src/java.base/share/classes/java/lang/ClassLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ protected Class<?> findClass( String name) throws ClassNotFoundException {
*
* @since 9
*/
protected Class<?> findClass(String moduleName, String name) {
protected @Nullable Class<?> findClass(@Nullable String moduleName, String name) {
if (moduleName == null) {
try {
return findClass(name);
Expand Down Expand Up @@ -1358,7 +1358,7 @@ protected final void setSigners(Class<?> c, Object[] signers) {
* @see java.lang.module.ModuleReader#find(String)
* @since 9
*/
protected URL findResource(String moduleName, String name) throws IOException {
protected @Nullable URL findResource(@Nullable String moduleName, String name) throws IOException {
if (moduleName == null) {
return findResource(name);
} else {
Expand Down
12 changes: 6 additions & 6 deletions src/java.base/share/classes/java/lang/StackTraceElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ public StackTraceElement( String declaringClass, String methodName,
*
* @since 9
*/
public StackTraceElement(String classLoaderName,
String moduleName, String moduleVersion,
public StackTraceElement(@Nullable String classLoaderName,
@Nullable String moduleName, @Nullable String moduleVersion,
String declaringClass, String methodName,
String fileName, int lineNumber) {
@Nullable String fileName, int lineNumber) {
this.classLoaderName = classLoaderName;
this.moduleName = moduleName;
this.moduleVersion = moduleVersion;
Expand Down Expand Up @@ -220,7 +220,7 @@ public int getLineNumber() {
* @since 9
* @see Module#getName()
*/
public String getModuleName() {
public @Nullable String getModuleName() {
return moduleName;
}

Expand All @@ -234,7 +234,7 @@ public String getModuleName() {
* @since 9
* @see java.lang.module.ModuleDescriptor.Version
*/
public String getModuleVersion() {
public @Nullable String getModuleVersion() {
return moduleVersion;
}

Expand All @@ -249,7 +249,7 @@ public String getModuleVersion() {
* @since 9
* @see java.lang.ClassLoader#getName()
*/
public String getClassLoaderName() {
public @Nullable String getClassLoaderName() {
return classLoaderName;
}

Expand Down
2 changes: 1 addition & 1 deletion src/java.base/share/classes/java/nio/file/FileSystems.java
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ public static FileSystem newFileSystem(Path path) throws IOException {
* @since 13
*/
public static FileSystem newFileSystem(Path path, Map<String,?> env,
ClassLoader loader)
@Nullable ClassLoader loader)
throws IOException
{
if (path == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,11 @@ public interface ClassFileTransformer {
*
* @since 9
*/
default byte[]
default byte @Nullable []
transform( Module module,
ClassLoader loader,
@Nullable ClassLoader loader,
String className,
Class<?> classBeingRedefined,
@Nullable Class<?> classBeingRedefined,
ProtectionDomain protectionDomain,
byte[] classfileBuffer)
throws IllegalClassFormatException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public static DocumentBuilderFactory newNSInstance() {
* @since 13
*/
public static DocumentBuilderFactory newNSInstance(String factoryClassName,
ClassLoader classLoader) {
@Nullable ClassLoader classLoader) {
return makeNSAware(FactoryFinder.newInstance(
DocumentBuilderFactory.class, factoryClassName, classLoader, false));
}
Expand Down

0 comments on commit a93551a

Please sign in to comment.