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

JMockit on Java 11 #534

Closed
risicle opened this issue Jul 29, 2018 · 3 comments

Comments

3 participants
@risicle
Copy link

commented Jul 29, 2018

  • Version of JMockit that was used:

1.40

  • Description of the problem:

This is a stub issue for JMockit on Java 11. I'll have a go at getting jmockit's test suite running on java 11 to see if that passes, but for now I seem to be getting:

java.lang.UnsupportedOperationException: class redefinition failed: attempted to change the class NestHost or NestMembers attribute
        at java.instrument/sun.instrument.InstrumentationImpl.redefineClasses0(Native Method)
        at mypackage.MyTest$1.<init>(MyTest.java:52)
        ...

When instantiating a MockUp derivative that works fine on java <= 10.

@jmockit jmockit deleted a comment from don-vip Aug 2, 2018

@jmockit jmockit deleted a comment from don-vip Aug 2, 2018

simon04 pushed a commit to openstreetmap/josm that referenced this issue Aug 4, 2018

floscher pushed a commit to floscher/josm that referenced this issue Aug 4, 2018

@rliesenfeld

This comment has been minimized.

Copy link
Member

commented Aug 18, 2018

Support for the new "NestHost" and "NestMembers" classfile attributes will be added once JDK 11 is released.

@jmockit jmockit deleted a comment from risicle Aug 18, 2018

@jmockit jmockit deleted a comment from risicle Aug 18, 2018

@jmockit jmockit deleted a comment from don-vip Aug 18, 2018

@jmockit jmockit locked and limited conversation to collaborators Aug 18, 2018

@rliesenfeld rliesenfeld added the other label Sep 12, 2018

@rliesenfeld

This comment has been minimized.

Copy link
Member

commented Sep 12, 2018

I tested it with a simple test which applies an anonymous MockUp to a small class, but there is no failure (compiling with "-source 1.11" and "-target 1.11").

@jmockit jmockit unlocked this conversation Sep 12, 2018

@rliesenfeld rliesenfeld reopened this Sep 13, 2018

@don-vip

This comment has been minimized.

Copy link

commented Sep 13, 2018

Here you go:

public class ExportProfileActionTest {

    private static class JOptionPaneSimpleMocker extends mockit.MockUp<javax.swing.JOptionPane> {

        @mockit.Mock
        protected Object showInputDialog(
            final java.awt.Component parentComponent,
            final Object message,
            final String title,
            final int messageType,
            final javax.swing.Icon icon,
            final Object[] selectionValues,
            final Object initialSelectionValue
        ) {
            return null;
        }

        @mockit.Mock
        protected void showMessageDialog(
            final java.awt.Component parentComponent,
            final Object message,
            final String title,
            final int messageType,
            final javax.swing.Icon icon
        ) {
        }

        @mockit.Mock
        protected int showConfirmDialog(
            final java.awt.Component parentComponent,
            final Object message,
            final String title,
            final int optionType,
            final int messageType,
            final javax.swing.Icon icon
        ) {
            return 0;
        }
    }

    @org.junit.Test
    public void testAction() {
        new JOptionPaneSimpleMocker();
    }
}

Results:

java.lang.UnsupportedOperationException: class redefinition failed: attempted to change the class NestHost or NestMembers attribute
	at java.instrument/sun.instrument.InstrumentationImpl.redefineClasses0(Native Method)
	at org.openstreetmap.josm.gui.preferences.advanced.ExportProfileActionTest$JOptionPaneSimpleMocker.<init>(ExportProfileActionTest.java:6)
	at org.openstreetmap.josm.gui.preferences.advanced.ExportProfileActionTest$JOptionPaneSimpleMocker.<init>(ExportProfileActionTest.java:6)
	at org.openstreetmap.josm.gui.preferences.advanced.ExportProfileActionTest.testAction(ExportProfileActionTest.java:46)

@jmockit jmockit deleted a comment from don-vip Sep 15, 2018

@rliesenfeld rliesenfeld self-assigned this Sep 22, 2018

simon04 pushed a commit to openstreetmap/josm that referenced this issue Oct 13, 2018

floscher pushed a commit to floscher/josm that referenced this issue Oct 13, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.