Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 94997 Details for
Bug 221904
Java Model Exception while trying to open *.class file
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix and regression test
221904.txt (text/plain), 3.81 KB, created by
Jerome Lanneluc
on 2008-04-06 13:14:18 EDT
(
hide
)
Description:
Proposed fix and regression test
Filename:
MIME Type:
Creator:
Jerome Lanneluc
Created:
2008-04-06 13:14:18 EDT
Size:
3.81 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/internal/core/ClassFile.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java,v >retrieving revision 1.140 >diff -u -r1.140 ClassFile.java >--- model/org/eclipse/jdt/internal/core/ClassFile.java 6 Mar 2008 15:31:29 -0000 1.140 >+++ model/org/eclipse/jdt/internal/core/ClassFile.java 6 Apr 2008 17:12:42 -0000 >@@ -352,9 +352,13 @@ > IBuffer buffer = openBuffer(null, info); > if (buffer != null && !(buffer instanceof NullBuffer)) > return buffer; >- if (status.getCode() == IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH) >- 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) >- throw new JavaModelException((IJavaModelStatus) status); >+ switch (status.getCode()) { >+ case IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH: // 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 ) >+ case IJavaModelStatusConstants.INVALID_ELEMENT_TYPES: // don't throw a JavaModelException to be able to open .class file in proj==src case without source (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=221904 ) >+ return null; >+ default: >+ throw new JavaModelException((IJavaModelStatus) status); >+ } > } > } > /** >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/ClassFileTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClassFileTests.java,v >retrieving revision 1.35 >diff -u -r1.35 ClassFileTests.java >--- src/org/eclipse/jdt/core/tests/model/ClassFileTests.java 12 Mar 2008 09:30:06 -0000 1.35 >+++ src/org/eclipse/jdt/core/tests/model/ClassFileTests.java 6 Apr 2008 17:12:44 -0000 >@@ -1021,7 +1021,7 @@ > * Ensures that asking for the source range of a IClassFile in a non-Java project throws a JavaModelException > * (regression test for bug 132494 JavaModelException opening up class file in non java project) > */ >-public void testSourceRangeNonJavaProject() throws CoreException { >+public void testSourceRange1() throws CoreException { // was testSourceRangeNonJavaProject() > try { > createProject("Simple"); > createFile("/Simple/X.class", ""); >@@ -1042,7 +1042,7 @@ > * Ensures that asking for the source range of a IClassFile not on the classpath of a Java project doesn't throw a JavaModelException > * (regression test for bug 138507 exception in .class file editor for classes imported via plug-in import) > */ >-public void testSourceRangeNotOnClasspath() throws CoreException { >+public void testSourceRange2() throws CoreException { // was testSourceRangeNotOnClasspath() > try { > createJavaProject("P2", new String[] {"src"}, "bin"); > createFile("/P2/bin/X.class", ""); >@@ -1054,6 +1054,21 @@ > } > > /* >+ * Ensures that asking for the source range of a IClassFile in proj==src case without the corresponding .java file doesn't throw a JavaModelException >+ * (regression test for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=221904 ) >+ */ >+public void testSourceRange3() throws CoreException { >+ try { >+ createJavaProject("P2", new String[] {""}, ""); >+ createFile("/P2/X.class", ""); >+ IClassFile classX = getClassFile("/P2/X.class"); >+ assertNull("Unxepected source range", classX.getSourceRange()); >+ } finally { >+ deleteProject("P2"); >+ } >+} >+ >+/* > * Ensure that opening a binary type parameter when its parent has not been open yet > * doesn't throw a JavaModelException > * (regression test for bug 101228 JME on code assist)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 221904
:
91926
| 94997