Openj9: [Minecraft 1.12.2/ForgeModLoader] -Xshareclasses results in 'Signers of {class} do not match signers of other classes in package'

Created on 1 Nov 2020  路  10Comments  路  Source: eclipse/openj9

Java -version output

OpenJDK Runtime Environment (build 1.8.0_272-b10)
Eclipse OpenJ9 VM (build openj9-0.23.0, JRE 1.8.0 Windows 10 amd64-64-Bit Compressed References 20201022_871 (JIT enabled, AOT enabled)
OpenJ9 - 0394ef754
OMR - 582366ae5
JCL - 41f03341d5 based on jdk8u272-b10)

Summary of problem

When launching Minecraft with ForgeModLoader (MC version 1.12.2, Forge version 14.23.5.2854) with a the flag enabled for shared classes cache -Xshareclasses (that caches application classes as well as bootstrap classes), barring the first launch, all subsequent launches will result in the following error down below.

Question: Is there a way to exclude certain packages/classes to not be cached?

Diagnostic files

Error:

[15:24:20] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
[15:24:20] [main/ERROR] [LaunchWrapper]: Unable to launch
java.lang.SecurityException: Signers of 'net.minecraftforge.fml.common.launcher.FMLDeobfTweaker' do not match signers of other classes in package
    at java.lang.ClassLoader.checkPackageSigners(ClassLoader.java:461) ~[?:1.8.0_272]
    at java.lang.ClassLoader.defineClassInternal(ClassLoader.java:385) ~[?:1.8.0_272]
    at java.lang.ClassLoader.defineClass(ClassLoader.java:359) ~[?:1.8.0_272]
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[?:1.8.0_272]
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:750) ~[?:1.8.0_272]
    at java.net.URLClassLoader.findClass(URLClassLoader.java:578) ~[?:1.8.0_272]
    at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:953) ~[?:1.8.0_272]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:898) ~[?:1.8.0_272]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352) ~[?:1.8.0_272]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:881) ~[?:1.8.0_272]
    at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:106) ~[launchwrapper-1.12.jar:?]
    at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:953) ~[?:1.8.0_272]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:898) ~[?:1.8.0_272]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:881) ~[?:1.8.0_272]
    at java.lang.Class.forNameImpl(Native Method) ~[?:1.8.0_272]
    at java.lang.Class.forName(Class.java:421) ~[?:1.8.0_272]
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:98) [launchwrapper-1.12.jar:?]
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_272]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_272]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_272]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_272]
    at org.multimc.onesix.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:196) [NewLaunch.jar:?]
    at org.multimc.onesix.OneSixLauncher.launch(OneSixLauncher.java:231) [NewLaunch.jar:?]
    at org.multimc.EntryPoint.listen(EntryPoint.java:143) [NewLaunch.jar:?]
    at org.multimc.EntryPoint.main(EntryPoint.java:34) [NewLaunch.jar:?]
[15:24:20] [main/INFO] [STDERR]: [org.multimc.onesix.OneSixLauncher:launchWithMainClass:199]: Failed to start Minecraft:
[15:24:20] [main/INFO] [STDOUT]: [org.multimc.EntryPoint:main:37]: Exiting with -1
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.multimc.onesix.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:196)
    at org.multimc.onesix.OneSixLauncher.launch(OneSixLauncher.java:231)
    at org.multimc.EntryPoint.listen(EntryPoint.java:143)
    at org.multimc.EntryPoint.main(EntryPoint.java:34)
Caused by: net.minecraftforge.fml.relauncher.FMLSecurityManager$ExitTrappedException
    at net.minecraftforge.fml.relauncher.FMLSecurityManager.checkPermission(FMLSecurityManager.java:49)
    at java.lang.SecurityManager.checkExit(SecurityManager.java:761)
    at java.lang.Runtime.exit(Runtime.java:107)
    at java.lang.System.exit(System.java:345)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:138)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    ... 8 more
Exception in thread "main" net.minecraftforge.fml.relauncher.FMLSecurityManager$ExitTrappedException
    at net.minecraftforge.fml.relauncher.FMLSecurityManager.checkPermission(FMLSecurityManager.java:49)
    at java.lang.SecurityManager.checkExit(SecurityManager.java:761)
    at java.lang.Runtime.exit(Runtime.java:107)
    at java.lang.System.exit(System.java:345)
    at org.multimc.EntryPoint.main(EntryPoint.java:38)
vm question userRaised

Most helpful comment

Question: Is there a way to exclude certain packages/classes to not be cached?

Yes, you can do that by implementing com.ibm.oti.shared.SharedClassFilter (https://github.com/eclipse/openj9/blob/master/jcl/src/openj9.sharedclasses/share/classes/com/ibm/oti/shared/SharedClassFilter.java). It tells OpenJ9 JVM which classes you want, or do not want, to cache.

An example of how to filter out classes with shared cache can be found here: https://github.com/hangshao0/Demo/tree/master/SharedClassesFilter

All 10 comments

Question: Is there a way to exclude certain packages/classes to not be cached?

Yes, you can do that by implementing com.ibm.oti.shared.SharedClassFilter (https://github.com/eclipse/openj9/blob/master/jcl/src/openj9.sharedclasses/share/classes/com/ibm/oti/shared/SharedClassFilter.java). It tells OpenJ9 JVM which classes you want, or do not want, to cache.

An example of how to filter out classes with shared cache can be found here: https://github.com/hangshao0/Demo/tree/master/SharedClassesFilter

This does not happen without a custom -Xshareclasses:name

I assume the same problem occurs using -Xshareclasses when no name is specified? I expect it's not related to the name of the cache, but turning on the cache for application classes. The cache is only enabled for bootstrap classes by default.

I expect it's not related to the name of the cache

Ah that would make sense, I knew it was on by default but wasn't aware it only grabbed bootstrap classes.

Also, thank you @hangshao0 I will attempt to tinker with it and see what happens.

Note that -Xshareclasses:bootClassesOnly,name=minecraft will work to change the cache name, as it won't cache the application classes.

@hangshao0 had a look and it seems promising, just gotta find out a way to feed the class through MultiMC (the client used to run this minecraft instance off)

Hi @Rongmario, Did limiting sharedclass cache for application classes solve the issue?

@hangshao0 @tajila we should figure out why this doesn't work rather than just turning off caching, unless this is already known. Then fix it if possible, or document the limitation if not. As I expect it won't be resolved in 0.24, moving it forward.

Likely due to Minecraft LaunchClassLoader which extends URLClassLoader, but overrides URLCLassLoader.findClass().

https://github.com/Mojang/LegacyLauncher/blob/master/src/main/java/net/minecraft/launchwrapper/LaunchClassLoader.java#L95

Been busy past month, sorry for not updating; as @hangshao0 said, it attributes to the fails on using it on a normal Minecraft instance (1.16.4) as well when I have tried.

As this is a question / request for information and help, it doesn't need to be tracked in a milestone plan.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jsimomaa picture jsimomaa  路  109Comments

fjeremic picture fjeremic  路  62Comments

ChengJin01 picture ChengJin01  路  238Comments

Thihup picture Thihup  路  51Comments

pshipton picture pshipton  路  62Comments