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 100433 Details for
Bug 205917
JavaCore#create(String, WorkingCopyOwner) should deal with null owner
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix and regression test
205917.txt (text/plain), 3.36 KB, created by
Jerome Lanneluc
on 2008-05-15 09:18:31 EDT
(
hide
)
Description:
Proposed fix and regression test
Filename:
MIME Type:
Creator:
Jerome Lanneluc
Created:
2008-05-15 09:18:31 EDT
Size:
3.36 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/core/JavaCore.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java,v >retrieving revision 1.614 >diff -u -r1.614 JavaCore.java >--- model/org/eclipse/jdt/core/JavaCore.java 28 Apr 2008 19:45:56 -0000 1.614 >+++ model/org/eclipse/jdt/core/JavaCore.java 15 May 2008 13:16:12 -0000 >@@ -2335,13 +2335,13 @@ > * Returns the Java model element corresponding to the given handle identifier > * generated by <code>IJavaElement.getHandleIdentifier()</code>, or > * <code>null</code> if unable to create the associated element. >- * If the returned Java element is an <code>ICompilationUnit</code>, its owner >- * is the given owner if such a working copy exists, otherwise the compilation unit >- * is a primary compilation unit. >+ * If the returned Java element is an <code>ICompilationUnit</code> or an element >+ * inside a compilation unit, the compilation unit's owner is the given owner if such a >+ * working copy exists, otherwise the compilation unit is a primary compilation unit. > * > * @param handleIdentifier the given handle identifier > * @param owner the owner of the returned compilation unit, ignored if the returned >- * element is not a compilation unit >+ * element is not a compilation unit, or an element inside a compilation unit > * @return the Java element corresponding to the handle identifier > * @since 3.0 > */ >@@ -2349,6 +2349,8 @@ > if (handleIdentifier == null) { > return null; > } >+ if (owner == null) >+ owner = DefaultWorkingCopyOwner.PRIMARY; > MementoTokenizer memento = new MementoTokenizer(handleIdentifier); > JavaModel model = JavaModelManager.getJavaModelManager().getJavaModel(); > return model.getHandleFromMemento(memento, owner); >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/MementoTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/MementoTests.java,v >retrieving revision 1.22 >diff -u -r1.22 MementoTests.java >--- src/org/eclipse/jdt/core/tests/model/MementoTests.java 24 Oct 2007 13:50:40 -0000 1.22 >+++ src/org/eclipse/jdt/core/tests/model/MementoTests.java 15 May 2008 13:16:14 -0000 >@@ -267,7 +267,7 @@ > /** > * Tests that a compilation unit can be persisted and restored using its memento. > */ >-public void testCompilationUnitMemento() { >+public void testCompilationUnitMemento1() { > ICompilationUnit cu = getCompilationUnit("/P/src/p/X.java"); > assertMemento( > "=P/src<p{X.java", >@@ -278,6 +278,17 @@ > "=P/src<{Y.java", > cu); > } >+/* >+ * Ensure that restoring a compilation unit memento with a null owner doesn't create an >+ * invalid handle >+ * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=205917 ) >+ */ >+public void testCompilationUnitMemento2() throws Exception { >+ ICompilationUnit cu = getCompilationUnit("/P/src/p/X.java"); >+ String handleIdentifier = cu.getHandleIdentifier(); >+ cu = (ICompilationUnit) JavaCore.create(handleIdentifier, null); >+ assertEquals(cu, cu); // should not throw an NPE >+} > /** > * Tests that a binary field in an external jar can be persisted and restored using its memento. > */
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 205917
: 100433