Skip to content

Commit

Permalink
8304446: javap --system flag doesn't override system APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
asotona committed Nov 2, 2023
1 parent 4a85f6a commit 3734262
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/jdk.jdeps/share/classes/com/sun/tools/javap/JavapTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

package com.sun.tools.javap;

import com.sun.tools.javac.file.Locations;
import java.io.EOFException;
import java.io.FileNotFoundException;
import java.io.FilterInputStream;
Expand Down Expand Up @@ -860,6 +861,17 @@ private JavaFileObject getClassFileObject(String className) throws IOException {
if (moduleLocation != null) {
fo = fileManager.getJavaFileForInput(moduleLocation, className, JavaFileObject.Kind.CLASS);
} else {
try {
//search over JDK modules specifed by --system option first
for (Set<Location> locations: fileManager.listLocationsForModules(StandardLocation.SYSTEM_MODULES)) {
for (Location systemModule: locations) {
fo = fileManager.getJavaFileForInput(systemModule, className, JavaFileObject.Kind.CLASS);
if (fo != null) return fo;
}
}
} catch (UnsupportedOperationException e) {
//ignore when listLocationsForModules is not supported
}
fo = fileManager.getJavaFileForInput(StandardLocation.PLATFORM_CLASS_PATH, className, JavaFileObject.Kind.CLASS);
if (fo == null)
fo = fileManager.getJavaFileForInput(StandardLocation.CLASS_PATH, className, JavaFileObject.Kind.CLASS);
Expand Down

0 comments on commit 3734262

Please sign in to comment.