Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 349447

Summary: [1.7] Add Java 7 support for API Tools
Product: [Eclipse Project] PDE Reporter: Michael Rennie <Michael_Rennie>
Component: API ToolsAssignee: Michael Rennie <Michael_Rennie>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P1 CC: ankur_sharma, curtis.windatt.public, daniel_megert, darin.eclipse, deepakazad, kim.moir, Olivier_Thomann
Version: 3.7   
Target Milestone: 3.7.1   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 349706    
Bug Blocks:    
Attachments:
Description Flags
update
none
Proposed fix
none
Builder Tests v1
none
patch for merging BETA_JAVA7 branch
none
patch for merging into 3.7.1 none

Description Michael Rennie CLA 2011-06-15 10:22:31 EDT
3.7.

For 3.7.1 we need to add Java 7 support to API Tools - make sure our TypeBuilder is working correctly and that we correctly create ASTs + handle the new ASTNode kinds.

We also need to create the EE fragment for system library reference checks (for the builder).

This should be done by end of June, so that we have enough time for team wide
testing and fixing in July.
Comment 1 Olivier Thomann CLA 2011-06-15 10:44:39 EDT
I'll take care of the API description part for JavaSE-1.7 EE.
Comment 2 Michael Rennie CLA 2011-06-15 11:43:54 EDT
I have branched api.tools and api.tools.tests for BETA_JAVA7
Comment 3 Michael Rennie CLA 2011-06-15 12:18:45 EDT
Created attachment 198040 [details]
update

This patch makes sure we are creating the correct level of AST in API tools. Our ASTVisitors should not need updating as we only care about types (TypeDeclaration, etc) and Javadoc nodes.
Comment 4 Michael Rennie CLA 2011-06-15 13:23:02 EDT
I get NPEs from the non-plugin JUnit tests:


java.lang.NullPointerException
	at org.eclipse.pde.api.tools.model.tests.ClassFileScannerTests.getRefSet(ClassFileScannerTests.java:55)
	at org.eclipse.pde.api.tools.model.tests.ClassFileScannerTests.testScanInnerStaticInnerClass(ClassFileScannerTests.java:205)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at junit.framework.TestCase.runTest(TestCase.java:168)
	at junit.framework.TestCase.runBare(TestCase.java:134)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at junit.framework.TestSuite.runTest(TestSuite.java:243)
	at junit.framework.TestSuite.run(TestSuite.java:238)
	at junit.framework.TestSuite.runTest(TestSuite.java:243)
	at junit.framework.TestSuite.run(TestSuite.java:238)
	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
	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)
Comment 5 Michael Rennie CLA 2011-06-15 15:02:51 EDT
(In reply to comment #4)
> I get NPEs from the non-plugin JUnit tests:

The plug-in test suite is even worse: 201 failures + 7 errors after only having run 400 tests.
Comment 6 Michael Rennie CLA 2011-06-15 15:18:20 EDT
All of the tests pass on the IBM 1.7 VM, but fail on the Oracle 1.7 VM:

java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b145)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b15, mixed mode)
Comment 7 Dani Megert CLA 2011-06-16 01:40:33 EDT
That Oracle VM probably has a JIT bug which we already reported to Oracle. Please retry with -Xint. If that's not the case then verify that your tests don't depend on the order.
Comment 8 Curtis Windatt CLA 2011-06-16 10:51:15 EDT
Plug-in tests all pass using Sun VM with -Xint argument
Comment 9 Curtis Windatt CLA 2011-06-16 11:15:28 EDT
(In reply to comment #8)
> Plug-in tests all pass using Sun VM with -Xint argument

I had mistakenly run the tests on the wrong VM.  Rerunning them resulted in two failures in the preference tests (seems like configuration problems, not VM problems).

junit.framework.AssertionFailedError: The value for RESTRICTION_NOINSTANTIATE should be 'Error' expected:<2> but was:<1>
	at junit.framework.Assert.fail(Assert.java:47)
	at junit.framework.Assert.failNotEquals(Assert.java:283)
	at junit.framework.Assert.assertEquals(Assert.java:64)
	at junit.framework.Assert.assertEquals(Assert.java:195)
	at org.eclipse.pde.api.tools.util.tests.PreferencesTests.testGetNonDefaultValue(PreferencesTests.java:78)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at junit.framework.TestCase.runTest(TestCase.java:168)
	at junit.framework.TestCase.runBare(TestCase.java:134)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at junit.framework.TestSuite.runTest(TestSuite.java:243)
	at junit.framework.TestSuite.run(TestSuite.java:238)
	at junit.framework.TestSuite.runTest(TestSuite.java:243)
	at junit.framework.TestSuite.run(TestSuite.java:238)
	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
	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.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
	at org.eclipse.pde.internal.junit.runtime.PlatformUITestHarness$1.run(PlatformUITestHarness.java:47)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3561)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3210)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
	at org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication.runApp(NonUIThreadTestApplication.java:54)
	at org.eclipse.pde.internal.junit.runtime.UITestApplication.runApp(UITestApplication.java:41)
	at org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication.start(NonUIThreadTestApplication.java:48)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Comment 10 Curtis Windatt CLA 2011-06-16 12:23:08 EDT
I get no NPEs or failures from the Non-plugin tests when run with -Xint
Comment 11 Michael Rennie CLA 2011-06-17 12:31:01 EDT
(In reply to comment #10)
> I get no NPEs or failures from the Non-plugin tests when run with -Xint

-Xint also resolves my failures, although I also do not see the PreferencesTests failure. I opened a new bug (bug 349706) to track those failures because it is a problem with the tests.
Comment 12 Curtis Windatt CLA 2011-06-24 16:02:07 EDT
Status update:

1) Olivier is still planning to create the API Description
2) New tests could be added
3) Tests pass with the fix on bug 349706
4) Patch for updating AST creation is applied and functioning correctly

I will discuss (2) more with Mike when he returns.
Comment 13 Curtis Windatt CLA 2011-06-27 15:54:27 EDT
Ankur will be working on adding builder tests.
Comment 14 Olivier Thomann CLA 2011-06-28 15:15:07 EDT
Created attachment 198770 [details]
Proposed fix

Fix to support the JavaSE-1.7 description. The fragment is ready. I'll see how I can release this into the branch only.
Comment 15 Olivier Thomann CLA 2011-06-29 14:09:12 EDT
(In reply to comment #14)
> Created attachment 198770 [details] [diff]
> Proposed fix
Released.
 
> Fix to support the JavaSE-1.7 description. The fragment is ready. I'll see how
> I can release this into the branch only.
The fragment will be released once we find out if this can be done before Java 7 is out.
Comment 16 Curtis Windatt CLA 2011-06-29 18:56:08 EDT
Created attachment 198868 [details]
Builder Tests v1

This patch adds a number of new builder usage tests to test Java 7.  Tests Try with resources, String switch statements, and Multi-Catch.  We still need at least one test case for diamond operator (not sure about polymorphic methods?).

I will apply these tests to the branch.  The tests can only run if you have a Java 7 JRE available.
Comment 17 Curtis Windatt CLA 2011-06-30 16:39:11 EDT
Added diamond operator tests to the builder suite.
Comment 18 Michael Rennie CLA 2011-07-05 11:58:02 EDT
Marking fixed.

All the AST handling has been updated and tested. All of the new code patterns have been tested and added to our builder test suite.
Comment 19 Dani Megert CLA 2011-07-19 06:33:34 EDT
Verified most of it but it looks like the EE description for 1.7 is not in the feature patch repo. Olivier, am I right here?
Comment 20 Olivier Thomann CLA 2011-07-19 09:49:30 EDT
(In reply to comment #19)
> Verified most of it but it looks like the EE description for 1.7 is not in the
> feature patch repo. Olivier, am I right here?
Yes, it is missing because I could not find the feature it belongs to. I'll talk with DJ to find out what the best way to add it is.
Comment 21 Michael Rennie CLA 2011-07-27 01:50:09 EDT
Created attachment 200411 [details]
patch for merging BETA_JAVA7 branch

Re-opening so I can attach the patches for merging the branch back into HEAD and 3.7.1
Comment 22 Michael Rennie CLA 2011-07-27 02:14:00 EDT
Created attachment 200412 [details]
patch for merging into 3.7.1
Comment 23 Michael Rennie CLA 2011-07-28 14:41:51 EDT
The patch for HEAD has been committed.
Comment 24 Michael Rennie CLA 2011-07-28 15:40:24 EDT
the patch for 3.7.1 has been committed.

marking fixed.
Comment 25 Dani Megert CLA 2011-08-03 05:55:07 EDT
*** Bug 288841 has been marked as a duplicate of this bug. ***
Comment 26 Dani Megert CLA 2011-08-03 05:56:11 EDT
The EE description for 1.7 is still not available on the update site.
Comment 27 Kim Moir CLA 2011-08-03 09:59:33 EDT
Updating the description in the update site and adding org.eclipse.pde.api.tools.ee.javase17 fragment to the org.eclipse.pde.api.tools.ee.fragments feature is covered in bug 353365.