Index: model/org/eclipse/jdt/internal/core/ClassFile.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java,v retrieving revision 1.107 diff -u -r1.107 ClassFile.java --- model/org/eclipse/jdt/internal/core/ClassFile.java 10 Apr 2005 16:01:22 -0000 1.107 +++ model/org/eclipse/jdt/internal/core/ClassFile.java 20 Apr 2005 13:22:08 -0000 @@ -11,6 +11,7 @@ package org.eclipse.jdt.internal.core; import java.io.IOException; +import java.io.UnsupportedEncodingException; import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -25,18 +26,28 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.*; +import org.eclipse.jdt.core.CompletionRequestor; import org.eclipse.jdt.core.IBuffer; import org.eclipse.jdt.core.IClassFile; +import org.eclipse.jdt.core.ICodeAssist; +import org.eclipse.jdt.core.ICodeCompletionRequestor; import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jdt.core.ICompletionRequestor; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaModelMarker; import org.eclipse.jdt.core.IJavaModelStatusConstants; +import org.eclipse.jdt.core.IMember; +import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.IParent; import org.eclipse.jdt.core.ISourceRange; +import org.eclipse.jdt.core.ISourceReference; import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.JavaConventions; +import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.core.Signature; +import org.eclipse.jdt.core.WorkingCopyOwner; import org.eclipse.jdt.core.compiler.IProblem; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException; @@ -47,14 +58,18 @@ import org.eclipse.jdt.internal.core.util.Util; /** + * Noel - see https://bugs.eclipse.org/bugs/show_bug.cgi?id=84872 * @see IClassFile */ public class ClassFile extends Openable implements IClassFile, SuffixConstants { - protected String name; + // this is stored as utf-8, since most package names are ascii + // and this field accounts for a lot of memory + private byte [] compressedName; protected BinaryType binaryType = null; private boolean checkAutomaticSourceMapping; + /* * Creates a handle to a class file. */ @@ -62,10 +77,28 @@ super(parent); // don't hold on the .class file extension to save memory // also make sure to copy the string (so that it doesn't hold on the underlying char[] that might be much bigger than necessary) - this.name = new String(name.substring(0, name.length() - 6)); // don't hold on the .class file extension to save memory + setName(new String(name.substring(0, name.length() - 6))); // don't hold on the .class file extension to save memory this.checkAutomaticSourceMapping = false; } +private final void setName(String name) { + try { + this.compressedName = name.getBytes("UTF-8"); //$NON-NLS-1$ + } catch (UnsupportedEncodingException ex) { + // should never happen + throw new RuntimeException(ex); + } +} + +protected final String getName() { + try { + return new String(this.compressedName, 0, this.compressedName.length, "UTF-8"); //$NON-NLS-1$ + } catch (UnsupportedEncodingException ex) { + // should never happen + throw new RuntimeException(ex); + } +} + /** * Creates the children elements for this class file adding the resulting * new handles and info objects to the newElements table. Returns true @@ -313,12 +346,13 @@ if (mapper == null) { return null; } else { + final String name = getName(); String prefix = null; - int index = this.name.indexOf('$'); + int index = name.indexOf('$'); if (index > -1) { - prefix = this.name.substring(0, index); + prefix = name.substring(0, index); } else { - prefix = this.name; + prefix = name; } @@ -362,7 +396,7 @@ } } public String getElementName() { - return this.name + SuffixConstants.SUFFIX_STRING_class; + return getName() + SuffixConstants.SUFFIX_STRING_class; } /** * @see IJavaElement @@ -457,9 +491,10 @@ return this.binaryType; } public String getTypeName() { + final String name = getName(); // Internal class file name doesn't contain ".class" file extension - int lastDollar = this.name.lastIndexOf('$'); - return lastDollar > -1 ? Util.localTypeName(this.name, lastDollar, this.name.length()) : this.name; + int lastDollar = name.lastIndexOf('$'); + return lastDollar > -1 ? Util.localTypeName(name, lastDollar, name.length()) : name; } /* * @see IClassFile