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

Bug 327491

Summary: JdtClasspathUriResolver doesn't resolve files from JAR's root.
Product: [Modeling] TMF Reporter: Moritz Eysholdt <moritz.eysholdt>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: sebastian.zarnekow
Version: 1.0.1Flags: sebastian.zarnekow: kepler+
Target Milestone: M7   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Moritz Eysholdt CLA 2010-10-11 20:53:16 EDT
Context: org.eclipse.xtext.ui.util.JdtClasspathUriResolver

To reproduce:
Put plugins/org.eclipse.xtext_1.0.1.v201008112031.jar on the classpath. It contains:
/model/parsetree.ecore and
/parsetree.ecore

Use JdtClasspathUriResolver to resolve "classpath:/model/parsetree.ecore" and "classpath:/parsetree.ecore". It works in the first case, it doesn't in the second.
Comment 1 Sven Efftinge CLA 2012-11-19 08:24:30 EST
Seems to be a problem in JDT's PackageFragmentRoot not returning the nonJavResources for the default package.
added a test case : org.eclipse.xtext.ui.tests.core.util.JdtClasspathUriResolverTest.testClasspathUriForFileInRootInJarInWorkspaceWithFragment()
Comment 2 Sebastian Zarnekow CLA 2013-04-19 06:12:39 EDT
This looks clearly strange to me:

public Object[] getNonJavaResources() throws JavaModelException {
	if (isDefaultPackage()) {
		// We don't want to show non java resources of the default package (see PR #1G58NB8)
		return JavaElementInfo.NO_NON_JAVA_RESOURCES;
	} else {
		return storedNonJavaResources();
	}
}

We could hijack this method reflectively, though.

protected Object[] storedNonJavaResources() throws JavaModelException {
	return ((JarPackageFragmentInfo) getElementInfo()).getNonJavaResources();
}
Comment 3 Sebastian Zarnekow CLA 2013-04-19 07:08:33 EDT
Turns out that org.eclipse.jdt.core.IPackageFragmentRoot.getNonJavaResources() is the way to go for the default package.
Comment 4 Sebastian Zarnekow CLA 2013-04-19 08:04:21 EDT
Pushed to review.
Comment 5 Eclipse Webmaster CLA 2017-10-31 11:23:52 EDT
Requested via bug 522520.

-M.