8158507: JShell: new jdk.jshell.MemoryFileManager(StandardJavaFileManager, JShell) creates a jdk.jshell.MemoryFileManager$REPLClassLoader classloader, which should be performed within a doPrivileged block
Remove the ClassLoader and other unused code in support of in-process execution. This is now supported through the SPI. Reviewed-by: jlahoda
This commit is contained in:
parent
4404741f80
commit
fc65d375a3
@ -71,8 +71,6 @@ class MemoryFileManager implements JavaFileManager {
|
||||
|
||||
private ClassFileCreationListener classListener = null;
|
||||
|
||||
private final ClassLoader loader = new REPLClassLoader();
|
||||
|
||||
private final JShell proc;
|
||||
|
||||
// Upcoming Jigsaw
|
||||
@ -168,21 +166,6 @@ class MemoryFileManager implements JavaFileManager {
|
||||
}
|
||||
}
|
||||
|
||||
// For restoring process-local execution support
|
||||
class REPLClassLoader extends ClassLoader {
|
||||
|
||||
@Override
|
||||
protected Class<?> findClass(String name) throws ClassNotFoundException {
|
||||
OutputMemoryJavaFileObject fo = classObjects.get(name);
|
||||
proc.debug(DBG_FMGR, "findClass %s = %s\n", name, fo);
|
||||
if (fo == null) {
|
||||
throw new ClassNotFoundException("Not ours");
|
||||
}
|
||||
byte[] b = fo.getBytes();
|
||||
return super.defineClass(name, b, 0, b.length, null);
|
||||
}
|
||||
}
|
||||
|
||||
public MemoryFileManager(StandardJavaFileManager standardManager, JShell proc) {
|
||||
this.stdFileManager = standardManager;
|
||||
this.proc = proc;
|
||||
@ -199,33 +182,6 @@ class MemoryFileManager implements JavaFileManager {
|
||||
}
|
||||
}
|
||||
|
||||
// For restoring process-local execution support
|
||||
public Class<?> findGeneratedClass(String genClassFullName) throws ClassNotFoundException {
|
||||
for (OutputMemoryJavaFileObject co : generatedClasses()) {
|
||||
if (co.className.equals(genClassFullName)) {
|
||||
Class<?> klass = loadClass(co.className);
|
||||
proc.debug(DBG_FMGR, "Loaded %s\n", klass);
|
||||
return klass;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// For restoring process-local execution support
|
||||
public byte[] findGeneratedBytes(String genClassFullName) throws ClassNotFoundException {
|
||||
for (OutputMemoryJavaFileObject co : generatedClasses()) {
|
||||
if (co.className.equals(genClassFullName)) {
|
||||
return co.getBytes();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// For restoring process-local execution support
|
||||
public Class<?> loadClass(String name) throws ClassNotFoundException {
|
||||
return getClassLoader(null).loadClass(name);
|
||||
}
|
||||
|
||||
public JavaFileObject createSourceFileObject(Object origin, String name, String code) {
|
||||
return new SourceMemoryJavaFileObject(origin, name, code);
|
||||
}
|
||||
@ -288,7 +244,7 @@ class MemoryFileManager implements JavaFileManager {
|
||||
@Override @DefinedBy(Api.COMPILER)
|
||||
public ClassLoader getClassLoader(JavaFileManager.Location location) {
|
||||
proc.debug(DBG_FMGR, "getClassLoader: location\n", location);
|
||||
return loader;
|
||||
return stdFileManager.getClassLoader(location);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user