Does LIFT work with Java 7?

I am trying to run tests I created 2 years ago and they won't run on my new computer.  I get the following error:

java.lang.Exception: The @Rule 'ADAPTIVE_TIMEOUT' must not be static.
    at org.junit.internal.runners.rules.RuleFieldValidator.addError(RuleFieldValidator.java:116)
    at org.junit.internal.runners.rules.RuleFieldValidator.validateStatic(RuleFieldValidator.java:84)
    at org.junit.internal.runners.rules.RuleFieldValidator.validateMember(RuleFieldValidator.java:73)
    at org.junit.internal.runners.rules.RuleFieldValidator.validate(RuleFieldValidator.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.validateFields(BlockJUnit4ClassRunner.java:174)
    at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:105)
    at student.testingsupport.junit4.JUnit4TesterRunner.collectInitializationErrors(JUnit4TesterRunner.java:596)
    at org.junit.runners.ParentRunner.validate(ParentRunner.java:355)
    at org.junit.runners.ParentRunner.<init>(ParentRunner.java:76)
    at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:57)
    at student.testingsupport.junit4.JUnit4TesterRunner.<init>(JUnit4TesterRunner.java:136)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:29)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:21)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:53)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
 

It is the exact same code, and the only difference that I am aware of is that I am now using Java 7.  When I run other tests that don't use LIFT, I don't get the error.  Did Java 7 break LIFT?

Groups:

Comments

Stephen Edwards

This is a JUnit error instead of a Java 7 error

Sorry your original post didn't get a reply :-(.

There currently are no known compatibility issues between LIFT and Java 7 (or 8).

The specific error you are receiving is actually a JUnit problem, instead of a LIFT problem.  It is the result of some compatibility issues between the version of JUnit for which some customizations exist in the student.jar file, and the version you have loaded on the classpath.  My suggestion would be to try using JUnit 4.8.x by explicitly placing it on the classpath (but placed after student.jar).

This is an issue we're trying to resolve with how the library is packaged/distributed, but the quick fix is just adding the older JUnit version to your build/execute environment via the classpath.  Hope that helps!

cusack

I downloaded junit-4.8.1.jar

I downloaded junit-4.8.1.jar from http://sourceforge.net/projects/junit/files/junit/4.8.1/ ,added it to my Eclipse build path, removed the "regular" JUnit 4.0 and tried it, but now I get this error:

java.lang.NoSuchMethodError: org.junit.runners.model.TestClass.getAnnotatedFieldValues(Ljava/lang/Object;Ljava/lang/Class;Ljava/lang/Class;)Ljava/util/List;
    at student.testingsupport.junit4.MixRunner.withRules(MixRunner.java:268)
    at student.testingsupport.junit4.MixRunner.methodBlock(MixRunner.java:247)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

I have no idea what this means (I am not that familiar with the inner workings of either JUnit or LIFT).  I'm not sure I have time to debug this, so I may have to have the students submit thier code to my autograder program to run these tests.
 

Stephen Edwards
cusack

That works better.  Now I am

That works better.  Now I am getting the following exception, but it seems to be running the tests just fine so I think I will just ignore it.

Exception in thread "AWT-EventQueue-0" abbot.util.EventDispatchExceptionHandler$DummyException sun.misc.Launcher$AppClassLoader@6d06d69c
    at abbot.util.EventDispatchExceptionHandler$1.run(EventDispatchExceptionHandler.java:93)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$500(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
150306 13:51:42:011 abbot.util.EventDispatchExceptionHandler.install(EventDispatchExceptionHandler.java:115):
    The handler for event dispatch thread exceptions could not be installed
150306 13:51:47:689 abbot.util.EventDispatchExceptionHandler.install(EventDispatchExceptionHandler.java:74):
    Can't install event dispatch exception handler

Thanks for the help.

 

Stephen Edwards

That message is just a warning

That message is just a warning, and won't prevent tests from running.  It is not a terminal error.  My guess is that debugging it is not critical for you at this point.  It would probably be nice to figure out eventually whether it is fixable at some point in the future.

Scott Turner

Fixes for error and warning

So I ran into the problem with the ADAPTIVE_TIMEOUT right after I upgraded to Eclipe's Luna since Luna ships with JUnit 4.11. JUnit 4.11 changes some of the checks that it does on values annotated with @Rule and now does not allow them to be static.  I found the problem and fixed it by changing student.TestCase line 68 from

@Rule

to

@ClassRule

ADAPTIVE_TIMEOUT is declared to be static and @ClassRule premits that. I'm not sure if this will cause other problems but it seems to fix the issue with my tests.

As for the warnings, upgrading the abbott.jar from 1.0.2 to 1.2.0 removed them for me. Again, I'm not sure if that will cause issues in other code.

Steve, as a final note: I downloaded the student library code from SourceForge and the urls for the libraries in the build.properties are very out of date. www.codehaus.org doesn't exist anymore and the www.davidpashley.com link doesn't seem to have any code now. I also have no idea were to get the tester 1.5.1 library. I had to get the .class files from another version of the student-library.jar file.

cusack

Anybody know about this?

I still haven't found a solution to this problem.  Does anybody know for sure whether or not LIFT works with Java 7?  The tests still run on my computer that has Java 6, but on none of my machines that have Java 7.  This is a problem since all of our department machines and all of the machines the students have currently have Java 7 installed.

I should include more details.  Here is the error message I get when I try to run the tests:

java.lang.Exception: The @Rule 'ADAPTIVE_TIMEOUT' must not be static.
    at org.junit.internal.runners.rules.RuleFieldValidator.addError(RuleFieldValidator.java:116)
    at org.junit.internal.runners.rules.RuleFieldValidator.validateStatic(RuleFieldValidator.java:84)
    at org.junit.internal.runners.rules.RuleFieldValidator.validateMember(RuleFieldValidator.java:73)
    at org.junit.internal.runners.rules.RuleFieldValidator.validate(RuleFieldValidator.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.validateFields(BlockJUnit4ClassRunner.java:174)
    at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:105)
    at student.testingsupport.junit4.MixRunner.collectInitializationErrors(MixRunner.java:210)
    at org.junit.runners.ParentRunner.validate(ParentRunner.java:355)
    at org.junit.runners.ParentRunner.<init>(ParentRunner.java:76)
    at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:57)
    at student.testingsupport.junit4.MixRunner.<init>(MixRunner.java:79)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:29)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:21)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

A quick look at the LIFT code a while back revealed a static variable with the name indicated in the error message.  So it seems that somechange in JUnit or something occured after LIFT was written. (I looked at this a few months ago and don't recall the details right now).