mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8241770: Module xxxAnnotation() methods throw NCDFE if module-info.class found as resource in unnamed module
Reviewed-by: mchung
This commit is contained in:
parent
96fadefaa3
commit
c563c3d15b
3 changed files with 110 additions and 48 deletions
|
@ -42,7 +42,6 @@ import java.security.AccessController;
|
|||
import java.security.PrivilegedAction;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
@ -1504,6 +1503,24 @@ public final class Module implements AnnotatedElement {
|
|||
throw new ClassNotFoundException(cn);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected Class<?> loadClass(String cn, boolean resolve)
|
||||
throws ClassNotFoundException
|
||||
{
|
||||
synchronized (getClassLoadingLock(cn)) {
|
||||
Class<?> c = findLoadedClass(cn);
|
||||
if (c == null) {
|
||||
if (cn.equals(MODULE_INFO)) {
|
||||
c = findClass(cn);
|
||||
} else {
|
||||
c = super.loadClass(cn, resolve);
|
||||
}
|
||||
}
|
||||
if (resolve)
|
||||
resolveClass(c);
|
||||
return c;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -212,6 +212,14 @@ public final class ModuleInfoWriter {
|
|||
write(descriptor, null, null, out);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a byte array containing the given module descriptor in
|
||||
* module-info.class format.
|
||||
*/
|
||||
public static byte[] toBytes(ModuleDescriptor descriptor) {
|
||||
return toModuleInfo(descriptor, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@code ByteBuffer} containing the given module descriptor
|
||||
* in module-info.class format.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue