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

NoClassDefFoundError: org/omg/IOP/IORHelper Jmockit 1.49 and JDK-11 #728

Open
2 of 4 tasks
yarix opened this issue Jun 14, 2022 · 2 comments
Open
2 of 4 tasks

NoClassDefFoundError: org/omg/IOP/IORHelper Jmockit 1.49 and JDK-11 #728

yarix opened this issue Jun 14, 2022 · 2 comments

Comments

@yarix
Copy link

yarix commented Jun 14, 2022

Please provide the following information:

  • Version of JMockit that was used: 1.49

  • Description of the problem or enhancement request:
    while upgrading existing code from Java 8, Jmockit 1.22 to Java 11 and jmockit 1.49 - i get the following when running the test from intellij (...yes - with -javaagent:/root/.m2/repository/org/jmockit/jmockit/1.49/jmockit-1.49.jar)

any idea how to solve?

FATAL ERROR in native method: processing of -javaagent failed, processJavaStart failed
Exception in thread "main" java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:513)
	at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:525)
Caused by: java.lang.NoClassDefFoundError: org/omg/IOP/IORHelper
	at mockit.internal.startup.MockingBridgeFields.createSyntheticFieldsInJREClassToHoldMockingBridges(MockingBridgeFields.java:32)
	at mockit.internal.startup.Startup.initialize(Startup.java:56)
	at mockit.internal.startup.Startup.premain(Startup.java:48)
	... 6 more
Caused by: java.lang.ClassNotFoundException: org.omg.IOP.IORHelper
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	... 9 more
*** java.lang.instrument ASSERTION FAILED ***: "result" with message agent load/premain call failed at src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 422
  • Check the following:
  • If a defect or unexpected result, JMockit project members should be able to reproduce it.
    For that, include an example test (perhaps accompanied by a Maven/Gradle build script) which
    can be executed without changes and reproduces the failure.

  • If an enhancement or new feature request, it should be justified by an example test
    demonstrating the validity and usefulness of the desired enhancement or new feature.

  • The issue does not fall outside the scope of the project (for example, attempting to use
    JMockit APIs from Groovy or Scala code, or with an Android runtime).

  • The JDK where the problem occurs is a final release, not a development build.

@GitPopcorn
Copy link

same error, does anyone know how to fix it?

Upgrade the version of JMockit will effectively resolve this.
And I'm pretty sure you were not using the version 1.49 because there is already no importing for the type IORHelper, this type has been removed from JAVA 11.
This is the code of MockingBridgeFields.createSyntheticFieldsInJREClassToHoldMockingBridges() in JMockit 1.22

    static void createSyntheticFieldsInJREClassToHoldMockingBridges(@Nonnull Instrumentation inst) {
        ClassFileTransformer trans = new FieldAdditionTransformer();
        inst.addTransformer(trans);

        try {
            IORHelper.id();
        } finally {
            inst.removeTransformer(trans);
        }

        setMockingBridgeFields();
    }

And this is the code of ClassLoadingBridgeFields.createSyntheticFieldsInJREClassToHoldClassLoadingBridges() in JMockit 1.49

    static void createSyntheticFieldsInJREClassToHoldClassLoadingBridges(@Nonnull Instrumentation instrumentation) {
        FieldAdditionTransformer fieldAdditionTransformer = new FieldAdditionTransformer(instrumentation);
        instrumentation.addTransformer(fieldAdditionTransformer);
        NegativeArraySizeException.class.getName();
        String hostClassName = fieldAdditionTransformer.hostClassName;
        if (hostClassName == null) {
            Provider.class.getName();
            hostClassName = fieldAdditionTransformer.hostClassName;
        }

        ClassLoadingBridge.hostJREClassName = hostClassName;
    }

@mayurgithub
Copy link

same error, does anyone know how to fix it?

Upgrade the version of JMockit will effectively resolve this. And I'm pretty sure you were not using the version 1.49 because there is already no importing for the type IORHelper, this type has been removed from JAVA 11. This is the code of MockingBridgeFields.createSyntheticFieldsInJREClassToHoldMockingBridges() in JMockit 1.22

    static void createSyntheticFieldsInJREClassToHoldMockingBridges(@Nonnull Instrumentation inst) {
        ClassFileTransformer trans = new FieldAdditionTransformer();
        inst.addTransformer(trans);

        try {
            IORHelper.id();
        } finally {
            inst.removeTransformer(trans);
        }

        setMockingBridgeFields();
    }

And this is the code of ClassLoadingBridgeFields.createSyntheticFieldsInJREClassToHoldClassLoadingBridges() in JMockit 1.49

    static void createSyntheticFieldsInJREClassToHoldClassLoadingBridges(@Nonnull Instrumentation instrumentation) {
        FieldAdditionTransformer fieldAdditionTransformer = new FieldAdditionTransformer(instrumentation);
        instrumentation.addTransformer(fieldAdditionTransformer);
        NegativeArraySizeException.class.getName();
        String hostClassName = fieldAdditionTransformer.hostClassName;
        if (hostClassName == null) {
            Provider.class.getName();
            hostClassName = fieldAdditionTransformer.hostClassName;
        }

        ClassLoadingBridge.hostJREClassName = hostClassName;
    }

Thanks!! Upgrading worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants