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 120401 Details for
Bug 258145
Fup of bug 252555, JME is thrown when package-info.java exists twice in the same project
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix and test
patch.txt (text/plain), 4.14 KB, created by
Srikanth Sankaran
on 2008-12-14 01:47:12 EST
(
hide
)
Description:
Proposed fix and test
Filename:
MIME Type:
Creator:
Srikanth Sankaran
Created:
2008-12-14 01:47:12 EST
Size:
4.14 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.builder >Index: src/org/eclipse/jdt/core/tests/builder/PackageInfoTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/PackageInfoTest.java,v >retrieving revision 1.10 >diff -u -r1.10 PackageInfoTest.java >--- src/org/eclipse/jdt/core/tests/builder/PackageInfoTest.java 24 Nov 2008 08:22:41 -0000 1.10 >+++ src/org/eclipse/jdt/core/tests/builder/PackageInfoTest.java 14 Dec 2008 06:18:09 -0000 >@@ -37,6 +37,45 @@ > public static Test suite() { > return buildTestSuite(PackageInfoTest.class); > } >+ >+//test for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=258145 : JME on duplicate package-info >+public void test258145() throws JavaModelException { >+ IPath projectPath = env.addProject("Project", "1.5"); //$NON-NLS-1$ >+ env.addExternalJars(projectPath, Util.getJavaClassLibs()); >+ fullBuild(projectPath); >+ >+ // remove old package fragment root so that names don't collide >+ env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$ >+ >+ IPath root = env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$ >+ env.setOutputFolder(projectPath, "bin"); //$NON-NLS-1$ >+ >+ IPath otherRoot = env.addPackageFragmentRoot(projectPath, "test"); //$NON-NLS-1$ >+ env.setOutputFolder(projectPath, "bin"); //$NON-NLS-1$ >+ >+ env.addPackage(root, "my.foo"); >+ env.addFile(root, "my/foo/package-info.java", //$NON-NLS-1$ //$NON-NLS-2$ >+ "/**\n" + >+ "* A demo package for foo.\n" + >+ "*/\n" + >+ "package my.foo;\n" >+ ); >+ >+ fullBuild(projectPath); >+ >+ env.addPackage(otherRoot, "my.foo"); >+ >+ >+ IPath otherPackageInfoPath = env.addFile(otherRoot, "my/foo/package-info.java", //$NON-NLS-1$ //$NON-NLS-2$ >+ "/**\n" + >+ "* A demo package for foo.\n" + >+ "*/\n" + >+ "package my.foo;\n" >+ ); >+ >+ incrementalBuild(projectPath); >+ expectingOnlySpecificProblemFor(otherPackageInfoPath, new Problem("my/foo/package-info.java", "The type package-info is already defined", otherPackageInfoPath, 0, 0, CategorizedProblem.CAT_TYPE, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$ >+} > public void test001() throws JavaModelException { > IPath projectPath = env.addProject("Project", "1.5"); //$NON-NLS-1$ > env.addExternalJars(projectPath, Util.getJavaClassLibs()); >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/internal/core/SourceType.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceType.java,v >retrieving revision 1.147 >diff -u -r1.147 SourceType.java >--- model/org/eclipse/jdt/internal/core/SourceType.java 25 Nov 2008 18:08:53 -0000 1.147 >+++ model/org/eclipse/jdt/internal/core/SourceType.java 14 Dec 2008 06:18:12 -0000 >@@ -22,6 +22,7 @@ > import org.eclipse.jdt.internal.codeassist.CompletionEngine; > import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; > import org.eclipse.jdt.internal.compiler.lookup.Binding; >+import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; > import org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy; > import org.eclipse.jdt.internal.core.util.MementoTokenizer; > import org.eclipse.jdt.internal.core.util.Messages; >@@ -405,6 +406,26 @@ > list.toArray(array); > return array; > } >+ >+/** >+ * @see IMember >+ */ >+public ISourceRange getNameRange() throws JavaModelException { >+ try { >+ return super.getNameRange(); >+ } catch (JavaModelException e) { >+ if (e.getJavaModelStatus().getCode() != IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST) { >+ throw e; >+ } >+ if (!CharOperation.equals(getElementName().toCharArray(), TypeConstants.PACKAGE_INFO_NAME)) { >+ throw e; >+ } >+ // else silently swallow the exception as the synthetic interface type package-info has no >+ // source range really. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=258145 >+ return new SourceRange(0, 1); >+ } >+} >+ > /** > * @see IType > */
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 258145
:
120401
|
120507
|
120567