JRuby version 9.3.13.0
Platform 6.5.13-1rodete2
Expected behavior:
- There is a class
org.example.C which is in a jar which is not on the class path, call this C_jar
- There is a class
org.example.C which is in a jar which is on the class path, call this C_classpath
C_jar is loaded via URLClassLoader and instantiated in Java code. This is done to isolate the different versions of C.
- Use Ruby to evaluate an object expression which results in an instance of an object with the class
C_jar
- Use the
Java module to reference the class C, expecting to get C_classpath (i.e. Java::OrgExample::C)
Actual behavior:
- Using the
Java module syntax to access C results in C_jar
Workaround:
- Use the
Java module syntax to access C before any Ruby expression which evaluates to an object of class C_jar
In Java.java, generateClassProxy calls addToJavaPackageModule without checking the class loader of the class it generated a proxy for. Effectively, manipulating values from non-JRubyClassLoader classes pollutes the Java module with incompatible classes.
JRuby version 9.3.13.0
Platform 6.5.13-1rodete2
Expected behavior:
org.example.Cwhich is in a jar which is not on the class path, call thisC_jarorg.example.Cwhich is in a jar which is on the class path, call thisC_classpathC_jaris loaded viaURLClassLoaderand instantiated in Java code. This is done to isolate the different versions ofC.C_jarJavamodule to reference the classC, expecting to getC_classpath(i.e.Java::OrgExample::C)Actual behavior:
Javamodule syntax to accessCresults inC_jarWorkaround:
Javamodule syntax to accessCbefore any Ruby expression which evaluates to an object of classC_jarIn Java.java,
generateClassProxycallsaddToJavaPackageModulewithout checking the class loader of the class it generated a proxy for. Effectively, manipulating values from non-JRubyClassLoaderclasses pollutes theJavamodule with incompatible classes.