Bug 528818 - [9][JUnit 5] Cannot select a test method as IType.resolveType(..) throws Java Model Exception
Summary: [9][JUnit 5] Cannot select a test method as IType.resolveType(..) throws Java...
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.8   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 4.8 M6   Edit
Assignee: Jay Arthanareeswaran CLA
QA Contact: Manoj N Palat CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-12-15 04:07 EST by Noopur Gupta CLA
Modified: 2018-03-09 05:36 EST (History)
5 users (show)

See Also:
manoj.palat: review+


Attachments
Test project (2.25 KB, application/x-zip-compressed)
2017-12-15 04:09 EST, Noopur Gupta CLA
no flags Details
Testcase (1.30 KB, patch)
2018-02-20 10:44 EST, Jay Arthanareeswaran CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Noopur Gupta CLA 2017-12-15 04:07:38 EST
I20171214-0120

- In the attached project, open Test5.java, select method "m1", Run As > JUnit Test.

- Open the JUnit Run configuration that got created.
=> You can see the error at the top "Can not find test method pkg.Test5.m1 in project Prj1". 

- Click Search button for "Test method".
=> The dialog is empty.

In the Error log view, we have this exception which causes the above issues:

Java Model Exception: Java Model Status [Target.class [in java.lang.annotation [in <module:java.base>]] does not exist]
	at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException(JavaElement.java:570)
	at org.eclipse.jdt.internal.codeassist.SelectionEngine.selectType(SelectionEngine.java:1555)
	at org.eclipse.jdt.internal.core.NamedMember.resolveType(NamedMember.java:325)
	at org.eclipse.jdt.internal.core.NamedMember.resolveType(NamedMember.java:267)
	at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationTab.getResolvedType(JUnitLaunchConfigurationTab.java:754)
...
Comment 1 Noopur Gupta CLA 2017-12-15 04:09:22 EST
Created attachment 271919 [details]
Test project
Comment 2 Stephan Herrmann CLA 2018-01-25 09:05:27 EST
Testing in Build id: I20180120-1500 I get:

Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for /home/eclipse/jdt-master/eclipse/plugins/org.junit.jupiter.migrationsupport_5.0.0.v20170910-2246.jar
Caused by: java.lang.module.InvalidModuleDescriptorException: Provider class org.junit.jupiter.engine.JupiterTestEngine not in module

is my jupiter outdated?
Comment 3 Noopur Gupta CLA 2018-01-27 03:08:53 EST
(In reply to Stephan Herrmann from comment #2)
> Testing in Build id: I20180120-1500 I get:
> 
> Error occurred during initialization of boot layer
> java.lang.module.FindException: Unable to derive module descriptor for
> /home/eclipse/jdt-master/eclipse/plugins/org.junit.jupiter.migrationsupport_5.0.0.v20170910-2246.jar
> 
> Caused by: java.lang.module.InvalidModuleDescriptorException: Provider class
> org.junit.jupiter.engine.JupiterTestEngine not in module
> 
> is my jupiter outdated?
This is bug 525948 comment#50.

Steps from comment #0 should still be valid.
Comment 4 Noopur Gupta CLA 2018-02-16 02:40:34 EST
Manoj, as the QA contact, can you please comment if this can be fixed for M6?
Comment 5 Jay Arthanareeswaran CLA 2018-02-20 03:19:59 EST
Reproducible and I see that in BinaryTypeFactory.rawReadTypeTestForExists() we decide that jrt-fs.jar is a mere Jar file and do a simply search in the JAR.

That makes this a relative of bug 490103.

And I see the problem reported by Stephan as well.
Comment 6 Manoj N Palat CLA 2018-02-20 04:30:34 EST
(In reply to Noopur Gupta from comment #4)
> Manoj, as the QA contact, can you please comment if this can be fixed for M6?

Well, that's the plan.
Comment 7 Jay Arthanareeswaran CLA 2018-02-20 10:44:27 EST
Created attachment 272763 [details]
Testcase
Comment 8 Eclipse Genie CLA 2018-02-20 11:48:49 EST
New Gerrit change created: https://git.eclipse.org/r/117793
Comment 9 Jay Arthanareeswaran CLA 2018-02-20 11:50:41 EST
(In reply to Eclipse Genie from comment #8)
> New Gerrit change created: https://git.eclipse.org/r/117793

Honestly, I have no idea why the code I am changing is doing what it is doing now instead of simply calling the Classfile#getBinaryTypeInfo(). This needs more testing and the code I am touching is not something I am familiar with.
Comment 10 Jay Arthanareeswaran CLA 2018-02-21 03:25:27 EST
The UI tests pass as well with the patch.
Comment 11 Jay Arthanareeswaran CLA 2018-02-21 09:53:54 EST
It would be nice to get another pair of eyes to look at this.
Comment 13 Jay Arthanareeswaran CLA 2018-02-28 01:17:53 EST
(In reply to Eclipse Genie from comment #12)
> Gerrit change https://git.eclipse.org/r/117793 was merged to [master].
> Commit:
> http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=3007f12f1412965a4ae1f913a1b2ef3ff2790433
> 

Patch merged, but I still maintain this needs a review.
Comment 14 Manoj N Palat CLA 2018-02-28 01:39:18 EST
(In reply to Jay Arthanareeswaran from comment #13)
> (In reply to Eclipse Genie from comment #12)
> > Gerrit change https://git.eclipse.org/r/117793 was merged to [master].
> > Commit:
> > http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=3007f12f1412965a4ae1f913a1b2ef3ff2790433
> > 
> 
> Patch merged, but I still maintain this needs a review.

@Jay: As mentioned offline, I had reviewed this and posted review comments [on gerrit] - but I don't see this unfortunately now - looks like the the review comments were not committed due to network outage.
Anyway, one of the comments was "CharOperation.endsWith() seems more appropriate" in case BinaryTypeFactory changes.
[I don't remember the other comment(s)- hence probably not that glaring] 
+1 with the above change
Comment 15 Andrey Loskutov CLA 2018-03-04 14:38:47 EST
There is a failure in master build since commit 3007f12f1412965a4ae1f913a1b2ef3ff2790433: test528818a	Failure	Type should not be null 

junit.framework.AssertionFailedError: Type should not be null
at org.eclipse.jdt.core.tests.model.TypeResolveTests.test528818a(TypeResolveTests.java:1208)

http://download.eclipse.org/eclipse/downloads/drops4/I20180304-0800/testresults/html/org.eclipse.jdt.core.tests.model_ep48I-unit-cen64-gtk3_linux.gtk.x86_64_8.0.html
Comment 16 Stephan Herrmann CLA 2018-03-04 14:44:55 EST
(In reply to Andrey Loskutov from comment #15)
> There is a failure in master build since commit
> 3007f12f1412965a4ae1f913a1b2ef3ff2790433: test528818a	Failure	Type should
> not be null 
> 
> junit.framework.AssertionFailedError: Type should not be null
> at
> org.eclipse.jdt.core.tests.model.TypeResolveTests.
> test528818a(TypeResolveTests.java:1208)
> 
> http://download.eclipse.org/eclipse/downloads/drops4/I20180304-0800/
> testresults/html/org.eclipse.jdt.core.tests.model_ep48I-unit-cen64-
> gtk3_linux.gtk.x86_64_8.0.html

On my local machine that test passes, at least when running only TypeResolveTests, Haven't tried a full test run.
Comment 17 Andrey Loskutov CLA 2018-03-04 14:46:11 EST
(In reply to Stephan Herrmann from comment #16)
> On my local machine that test passes, at least when running only
> TypeResolveTests, Haven't tried a full test run.

Fails on my, if executed as a single test. I'm using Java 8 by default, win 10.
Comment 18 Stephan Herrmann CLA 2018-03-04 14:57:35 EST
(In reply to Andrey Loskutov from comment #17)
> (In reply to Stephan Herrmann from comment #16)
> > On my local machine that test passes, at least when running only
> > TypeResolveTests, Haven't tried a full test run.
> 
> Fails on my, if executed as a single test. I'm using Java 8 by default, win
> 10.

Thanks for mentioning Java 8.

I see the failure now, too.

Fails during the attempt to resolve package fragment roots of /home/java/jdk1.8.0_121/jre/lib/jrt-fs.jar.

@Jay, createJava9Project() doesn't seem to make much sense at 1.8 - should we simply disable this test below 9?
Comment 19 Eclipse Genie CLA 2018-03-09 00:15:04 EST
New Gerrit change created: https://git.eclipse.org/r/119055
Comment 20 Jay Arthanareeswaran CLA 2018-03-09 00:20:57 EST
(In reply to Eclipse Genie from comment #19)
> New Gerrit change created: https://git.eclipse.org/r/119055

Patch disables the tests below JRE 9.