View | Details | Raw Unified | Return to bug 138507
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/ClassFileTests.java (-2 / +17 lines)
Lines 609-616 Link Here
609
}
609
}
610
610
611
/*
611
/*
612
 * Ensures that asking for a IClassFile in a non-Java project throws a JavaModelException
612
 * Ensures that asking for the source range of a IClassFile in a non-Java project throws a JavaModelException
613
 * (regression test for bug 132494 JavaModelException opening up class file in non java project
613
 * (regression test for bug 132494 JavaModelException opening up class file in non java project)
614
 */
614
 */
615
public void testSourceRangeNonJavaProject() throws CoreException {
615
public void testSourceRangeNonJavaProject() throws CoreException {
616
	try {
616
	try {
Lines 630-635 Link Here
630
}
630
}
631
631
632
/*
632
/*
633
 * Ensures that asking for the source range of a IClassFile not on the classpath of a Java project doesn't throw a JavaModelException
634
 * (regression test for bug 138507 exception in .class file editor for classes imported via plug-in import)
635
 */
636
public void testSourceRangeNotOnClasspath() throws CoreException {
637
	try {
638
		createJavaProject("P2", new String[] {"src"}, "bin");
639
		createFile("/P2/bin/X.class", "");
640
		IClassFile classX = getClassFile("/P2/bin/X.class");
641
		assertNull("Unxepected source range", classX.getSourceRange());
642
	} finally {
643
		deleteProject("P2");
644
	}
645
}
646
647
/*
633
 * Ensure that opening a binary type parameter when its parent has not been open yet
648
 * Ensure that opening a binary type parameter when its parent has not been open yet
634
 * doesn't throw a JavaModelException
649
 * doesn't throw a JavaModelException
635
 * (regression test for bug 101228 JME on code assist)
650
 * (regression test for bug 101228 JME on code assist)
(-)model/org/eclipse/jdt/internal/core/ClassFile.java (+2 lines)
Lines 310-315 Link Here
310
		IBuffer buffer = openBuffer(null, info);
310
		IBuffer buffer = openBuffer(null, info);
311
		if (buffer != null)
311
		if (buffer != null)
312
			return buffer;
312
			return buffer;
313
		if (status.getCode() == IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH)
314
			return null; // don't throw a JavaModelException to be able to open .class file outside the classpath (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=138507)
313
		throw new JavaModelException((IJavaModelStatus) status);
315
		throw new JavaModelException((IJavaModelStatus) status);
314
	}
316
	}
315
}
317
}

Return to bug 138507