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 155298 Details for
Bug 293861
Problem with refactoring when existing jar with invalid package names
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
patch.txt (text/plain), 6.26 KB, created by
Satyam Kandula
on 2010-01-05 01:48:19 EST
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Satyam Kandula
Created:
2010-01-05 01:48:19 EST
Size:
6.26 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java,v >retrieving revision 1.76 >diff -u -r1.76 AddJarFileToIndex.java >--- search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java 24 Nov 2008 15:57:41 -0000 1.76 >+++ search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java 5 Jan 2010 06:44:55 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -22,10 +22,15 @@ > import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.core.runtime.Path; >+import org.eclipse.jdt.core.compiler.InvalidInputException; > import org.eclipse.jdt.core.search.IJavaSearchScope; > import org.eclipse.jdt.core.search.SearchEngine; > import org.eclipse.jdt.core.search.SearchParticipant; >+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; >+import org.eclipse.jdt.internal.compiler.parser.Scanner; >+import org.eclipse.jdt.internal.compiler.parser.TerminalTokens; > import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable; >+import org.eclipse.jdt.internal.compiler.util.SuffixConstants; > import org.eclipse.jdt.internal.compiler.util.Util; > import org.eclipse.jdt.internal.core.JavaModelManager; > import org.eclipse.jdt.internal.core.index.Index; >@@ -36,6 +41,7 @@ > > private static final char JAR_SEPARATOR = IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR.charAt(0); > IFile resource; >+ Scanner scanner; > > public AddJarFileToIndex(IFile resource, IndexManager manager) { > super(resource.getFullPath(), manager); >@@ -153,7 +159,8 @@ > // iterate each entry to index it > ZipEntry ze = (ZipEntry) e.nextElement(); > String zipEntryName = ze.getName(); >- if (Util.isClassFileName(zipEntryName)) >+ if (Util.isClassFileName(zipEntryName) && isValidPackageNameForClass(zipEntryName)) >+ // the class file may not be there if the package name is not valid > indexedFileNames.put(zipEntryName, EXISTS); > } > boolean needToReindex = indexedFileNames.elementSize != max; // a new file was added >@@ -195,7 +202,10 @@ > > // iterate each entry to index it > ZipEntry ze = (ZipEntry) e.nextElement(); >- if (Util.isClassFileName(ze.getName())) { >+ String zipEntryName = ze.getName(); >+ if (Util.isClassFileName(zipEntryName) && >+ isValidPackageNameForClass(zipEntryName)) { >+ // index only classes coming from valid packages - https://bugs.eclipse.org/bugs/show_bug.cgi?id=293861 > final byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip); > JavaSearchDocument entryDocument = new JavaSearchDocument(ze, zipFilePath, classFileBytes, participant); > this.manager.indexDocument(entryDocument, participant, index, this.containerPath); >@@ -228,6 +238,30 @@ > if (this.resource != null) > return super.getJobFamily(); > return this.containerPath.toOSString(); // external jar >+ } >+ private boolean isValidPackageNameForClass(String className) { >+ char[] classNameArray = className.toCharArray(); >+ if (this.scanner == null) >+ this.scanner = new Scanner(false /* comment */, true /* whitespace */, false /* nls */, >+ ClassFileConstants.JDK1_3/* sourceLevel */, null/* taskTag */, null/* taskPriorities */, true /* taskCaseSensitive */); >+ this.scanner.setSource(classNameArray); >+ this.scanner.eofPosition = classNameArray.length - SuffixConstants.SUFFIX_CLASS.length; >+ try { >+ if (this.scanner.scanIdentifier() == TerminalTokens.TokenNameIdentifier) { >+ while (this.scanner.eofPosition > this.scanner.currentPosition) { >+ if (this.scanner.getNextChar() != '/' || this.scanner.eofPosition <= this.scanner.currentPosition) { >+ return false; >+ } >+ if (this.scanner.scanIdentifier() != TerminalTokens.TokenNameIdentifier) { >+ return false; >+ } >+ } >+ return true; >+ } >+ } catch (InvalidInputException e) { >+ // invalid class name >+ } >+ return false; > } > protected Integer updatedIndexState() { > return IndexManager.REBUILDING_STATE; >#P org.eclipse.jdt.core.tests.model >#P org.eclipse.jdt.core.tests.performance >Index: src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceSearchTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceSearchTests.java,v >retrieving revision 1.43 >diff -u -r1.43 FullSourceWorkspaceSearchTests.java >--- src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceSearchTests.java 27 Oct 2009 13:05:53 -0000 1.43 >+++ src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceSearchTests.java 5 Jan 2010 06:46:40 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -19,7 +19,6 @@ > > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.core.runtime.Path; > import org.eclipse.jdt.core.IJavaElement; > import org.eclipse.jdt.core.IPackageFragment; > import org.eclipse.jdt.core.search.*; >@@ -211,7 +210,7 @@ > AbstractJavaModelTests.waitUntilIndexesReady(); > > // Remove project previous indexing >- INDEX_MANAGER.removeIndexFamily(new Path("")); >+ INDEX_MANAGER.deleteIndexFiles(); > INDEX_MANAGER.reset(); > > // Clean memory
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 293861
:
151012
|
151013
|
151410
|
152146
|
153222
|
153223
|
154621
|
154622
|
154957
|
155298
|
155299
|
155300
|
158473
|
158478
|
159164
|
180736
|
180737
|
180738
|
180739