Skip to content

Commit

Permalink
LDEV-5063 - change visibility to PhysicalClassloader to allow loading…
Browse files Browse the repository at this point in the history
… Proxy classes from string
  • Loading branch information
michaeloffner committed Aug 19, 2024
1 parent 4300d16 commit 5af36d0
Show file tree
Hide file tree
Showing 16 changed files with 233 additions and 390 deletions.
5 changes: 4 additions & 1 deletion core/src/main/java/lucee/commons/io/SystemUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -1621,7 +1621,9 @@ public static List<ClassLoader> getClassLoaderContext(boolean unique, StringBuil

// check ClassLoader
if (cl == null) continue;
if (cl instanceof PhysicalClassLoader) continue;
if (cl instanceof PhysicalClassLoader) {
if (!((PhysicalClassLoader) cl).isRPC()) continue;
}
if (cl instanceof ArchiveClassLoader) continue;
if (cl instanceof MemoryClassLoader) continue;

Expand All @@ -1639,6 +1641,7 @@ public static List<ClassLoader> getClassLoaderContext(boolean unique, StringBuil
}
last = ref.context[i];
}

return context;
}

Expand Down
157 changes: 0 additions & 157 deletions core/src/main/java/lucee/commons/io/res/util/ResourceClassLoader.java

This file was deleted.

10 changes: 1 addition & 9 deletions core/src/main/java/lucee/commons/lang/ClassUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,13 @@
import lucee.commons.io.IOUtil;
import lucee.commons.io.SystemUtil;
import lucee.commons.io.res.Resource;
import lucee.commons.io.res.util.ResourceClassLoader;
import lucee.runtime.PageContext;
import lucee.runtime.PageContextImpl;
import lucee.runtime.config.Config;
import lucee.runtime.config.ConfigPro;
import lucee.runtime.config.Identification;
import lucee.runtime.engine.ThreadLocalPageContext;
import lucee.runtime.exp.PageException;
import lucee.runtime.listener.JavaSettingsImpl;
import lucee.runtime.op.Caster;
import lucee.runtime.osgi.OSGiUtil;
import lucee.runtime.osgi.OSGiUtil.BundleDefinition;
Expand Down Expand Up @@ -313,11 +311,6 @@ public static Class loadClass(ClassLoader cl, String className, Class defaultVal
private static Class loadClass(ClassLoader cl, String className, Class defaultValue, Set<Throwable> exceptions) {

if (cl != null) {
// TODO do not produce a resource classloader in the first place if there are no resources
if (cl instanceof ResourceClassLoader && ((ResourceClassLoader) cl).isEmpty()) {
ClassLoader p = ((ResourceClassLoader) cl).getParent();
if (p != null) cl = p;
}
Class clazz = _loadClass(new ClassLoaderBasedClassLoading(cl), className, defaultValue, exceptions);
if (clazz != null) return clazz;
}
Expand Down Expand Up @@ -1035,10 +1028,9 @@ public static ClassLoader getClassLoader(PageContext pc, Class clazz) throws IOE
if (pc instanceof PageContextImpl) {
return ((PageContextImpl) pc).getClassLoader();
}
// NEXT this is wrong
Config config = ThreadLocalPageContext.getConfig();
if (config instanceof ConfigPro) {
return ((JavaSettingsImpl) ((ConfigPro) config).getJavaSettings()).getClassLoader(false);
return ((ConfigPro) config).getRPCClassLoader(false, null);
}
return new lucee.commons.lang.ClassLoaderHelper().getClass().getClassLoader();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,7 @@

import java.lang.instrument.UnmodifiableClassException;

public abstract class ExtendableClassLoader extends ClassLoader {

public ExtendableClassLoader() {
super();
}

public ExtendableClassLoader(ClassLoader parent) {
super(parent);
}
public interface ExtendableClassLoader {

/**
* allow to define a new Class with help of the bytecode passed to the method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/**
* ClassLoader that loads classes in memory that are not stored somewhere physically
*/
public final class MemoryClassLoader extends ExtendableClassLoader {
public final class MemoryClassLoader extends ClassLoader implements ExtendableClassLoader {
static {
boolean res = registerAsParallelCapable();
}
Expand Down
Loading

0 comments on commit 5af36d0

Please sign in to comment.