Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle jdk.internal classes mentioned in vector superclass or interfaces during extraction #12329

Merged
merged 4 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions gradle/generation/extract-jdk-apis/ExtractJdkApis.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ static boolean isVisible(int access) {
static class Cleaner extends ClassVisitor {
private static final String PREVIEW_ANN = "jdk/internal/javac/PreviewFeature";
private static final String PREVIEW_ANN_DESCR = Type.getObjectType(PREVIEW_ANN).getDescriptor();

private static final String INTERNAL_PREFIX = "jdk/internal/";
private static final String OBJECT_CLASS = "java/lang/Object";

private final Set<String> classesToInclude;
private final Map<String, String[]> references;
Expand All @@ -134,7 +137,15 @@ static class Cleaner extends ClassVisitor {

@Override
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
interfaces = Objects.requireNonNullElse(interfaces, new String[0]);
// remove references to internal JDK classes:
if (superName.startsWith(INTERNAL_PREFIX)) {
superName = OBJECT_CLASS;
}
interfaces = Arrays.stream(interfaces).filter(c -> !c.startsWith(INTERNAL_PREFIX)).toArray(String[]::new);
// call ClassWriter and use Java 11 classfile format:
super.visit(Opcodes.V11, access, name, signature, superName, interfaces);
// add references to other classes (so we can figure out what needs to be packaged in JAR):
if (isVisible(access)) {
classesToInclude.add(name);
}
Expand Down
Binary file modified lucene/core/src/generated/jdk/jdk20.apijar
Binary file not shown.