Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XALANJ-2664: Determine the parent ClassLoader for ByteArrayClassLoader #186

Merged
merged 1 commit into from
Apr 18, 2024

Conversation

jamesnetherton
Copy link
Contributor

No description provided.

@jkesselm
Copy link
Contributor

The change looks harmless, but an explanation/justification would still be good practice, eg mention what breaks without the super(parent).

@jamesnetherton
Copy link
Contributor Author

@jkesselm there's an overview here:

https://issues.apache.org/jira/browse/XALANJ-2664

My use case is for XSLT with Apache Camel Quarkus where we support running applications natively on GraalVM. We have to do translet compilation at build time since it can't be done dynamically at runtime with GraalVM.

Due to how Quarkus organises its ClassLoaders for the build time augmentation phase, relying on the system ClassLoader is not guaranteed to work.

Hence using get ObjectFactory to figure out the parent ClassLoader. Which seems to be consistent with how things are done elsewhere, like in TransletClassLoader:

TransletClassLoader loader = (TransletClassLoader)
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
return new TransletClassLoader(ObjectFactory.findClassLoader());
}
});

static final class TransletClassLoader extends ClassLoader {
TransletClassLoader(ClassLoader parent) {
super(parent);
}
/**
* Access to final protected superclass member from outer class.
*/
Class defineClass(final byte[] b) {
return defineClass(null, b, 0, b.length);
}
}

@jkesselm jkesselm merged commit 6fd607c into apache:master Apr 18, 2024
1 check passed
@jamesnetherton jamesnetherton deleted the XALANJ-2664 branch April 18, 2024 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants