Throw ClassNotFoundException when appropriate
Currently, the ClassSource returned by ClassSource.fromMap will return null if the Class cannot be found (as that is the behavior of maps). However, other ClassSources throw a ClassNotFoundException if the class cannot be loaded. This commit changes the behavior of ClassSource.fromMap to throw a ClassNotFoundException if the class was not found in the map (or was mapped to null). This commit also changes the method to interpret a null map as an empty map.
Dieser Commit ist enthalten in:
Ursprung
818ac5cbde
Commit
ccecdf216f
@ -47,7 +47,12 @@ public abstract class ClassSource {
|
|||||||
return new ClassSource() {
|
return new ClassSource() {
|
||||||
@Override
|
@Override
|
||||||
public Class<?> loadClass(String canonicalName) throws ClassNotFoundException {
|
public Class<?> loadClass(String canonicalName) throws ClassNotFoundException {
|
||||||
return map.get(canonicalName);
|
Class<?> loaded = map == null ? null : map.get(canonicalName);
|
||||||
|
if(loaded == null){
|
||||||
|
// Throw the appropriate exception if we can't load the class
|
||||||
|
throw new ClassNotFoundException("The specified class could not be found by this ClassLoader.");
|
||||||
|
}
|
||||||
|
return loaded;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren