Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/main/java/cpw/mods/cl/ModuleClassLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,21 +230,22 @@ protected <T> T loadFromModule(final String moduleName, BiFunction<ModuleReader,
}
}

protected byte[] getMaybeTransformedClassBytes(final String name, final String context) {
protected byte[] getMaybeTransformedClassBytes(final String name, final String context) throws ClassNotFoundException {
byte[] bytes = new byte[0];
try {
final var pname = name.substring(0, name.lastIndexOf('.'));
if (this.packageLookup.containsKey(pname)) {
bytes = loadFromModule(classNameToModuleName(name), (reader, ref)->this.getClassBytes(reader, ref, name));
} else {
} else if (this.parentLoaders.containsKey(pname)) {
var cname = name.replace('.','/')+".class";
try (var is = this.parentLoaders.getOrDefault(pname, ClassLoader.getPlatformClassLoader()).getResourceAsStream(cname)) {
try (var is = this.parentLoaders.get(pname).getResourceAsStream(cname)) {
Comment on lines +239 to +242
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is indeed a good idea, since this would else pipe system classes potentially through transformers.
And the call site takes care of this dynamically.

if (is != null)
bytes = is.readAllBytes();
}
}
} catch (IOException ignored) {
}
Comment thread
Su5eD marked this conversation as resolved.
Outdated
if (bytes.length == 0) throw new ClassNotFoundException(name);
return maybeTransformClassBytes(bytes, name, context);
Comment thread
Su5eD marked this conversation as resolved.
Outdated
}

Expand Down