Skip to content

Commit

Permalink
use other methods to find out if a class exists or not
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed Dec 21, 2024
1 parent 62eae2b commit e065f84
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
22 changes: 9 additions & 13 deletions core/src/main/java/lucee/commons/lang/PhysicalClassLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,29 +237,25 @@ private Class<?> loadClass(String name, boolean resolve, boolean loadFromFS) thr

@Override
public Class<?> loadClass(String name, byte[] barr) throws UnmodifiableClassException {
Class<?> clazz = null;
// Class<?> clazz = null;
Class<?> clazz = findLoadedClass(name);

synchronized (SystemUtil.createToken("PhysicalClassLoader:load", name)) {
try {
clazz = loadClass(name, false, false); // we do not load existing class from disk
}
catch (ClassNotFoundException cnf) {
LogUtil.warn("physical-classloader", cnf);
}
if (clazz == null) return _loadClass(name, barr, false);
return rename(clazz, barr);
}
}

@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
ClassNotFoundException cnfe = null;
try {
/*
* ClassNotFoundException cnfe = null; try { return super.findClass(name); } catch
* (ClassNotFoundException e) { cnfe = e; }
*/

if (super.findResource(name.replace('.', '/').concat(".class")) != null) {
return super.findClass(name);
}
catch (ClassNotFoundException e) {
cnfe = e;
}

if (addionalClassLoader != null) {
try {
Expand All @@ -273,7 +269,7 @@ protected Class<?> findClass(String name) throws ClassNotFoundException {
synchronized (SystemUtil.createToken("PhysicalClassLoader:load", name)) {
Resource res = directory.getRealResource(name.replace('.', '/').concat(".class"));
if (!res.isFile()) {
if (cnfe != null) throw cnfe;
// if (cnfe != null) throw cnfe;
throw new ClassNotFoundException("Class [" + name + "] is invalid or doesn't exist");
}

Expand Down
2 changes: 1 addition & 1 deletion loader/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<project default="core" basedir="." name="Lucee"
xmlns:resolver="antlib:org.apache.maven.resolver.ant">

<property name="version" value="6.2.0.246-SNAPSHOT"/>
<property name="version" value="6.2.0.247-SNAPSHOT"/>

<taskdef uri="antlib:org.apache.maven.resolver.ant" resource="org/apache/maven/resolver/ant/antlib.xml">
<classpath>
Expand Down
2 changes: 1 addition & 1 deletion loader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>org.lucee</groupId>
<artifactId>lucee</artifactId>
<version>6.2.0.246-SNAPSHOT</version>
<version>6.2.0.247-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Lucee Loader Build</name>
Expand Down

0 comments on commit e065f84

Please sign in to comment.