View | Details | Raw Unified | Return to bug 84872
Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/ClassFile.java (-9 / +44 lines)
Lines 11-16 Link Here
11
package org.eclipse.jdt.internal.core;
11
package org.eclipse.jdt.internal.core;
12
12
13
import java.io.IOException;
13
import java.io.IOException;
14
import java.io.UnsupportedEncodingException;
14
import java.util.Map;
15
import java.util.Map;
15
import java.util.zip.ZipEntry;
16
import java.util.zip.ZipEntry;
16
import java.util.zip.ZipFile;
17
import java.util.zip.ZipFile;
Lines 25-42 Link Here
25
import org.eclipse.core.runtime.IProgressMonitor;
26
import org.eclipse.core.runtime.IProgressMonitor;
26
import org.eclipse.core.runtime.IStatus;
27
import org.eclipse.core.runtime.IStatus;
27
import org.eclipse.core.runtime.Path;
28
import org.eclipse.core.runtime.Path;
28
import org.eclipse.jdt.core.*;
29
import org.eclipse.jdt.core.CompletionRequestor;
29
import org.eclipse.jdt.core.IBuffer;
30
import org.eclipse.jdt.core.IBuffer;
30
import org.eclipse.jdt.core.IClassFile;
31
import org.eclipse.jdt.core.IClassFile;
32
import org.eclipse.jdt.core.ICodeAssist;
33
import org.eclipse.jdt.core.ICodeCompletionRequestor;
31
import org.eclipse.jdt.core.ICompilationUnit;
34
import org.eclipse.jdt.core.ICompilationUnit;
35
import org.eclipse.jdt.core.ICompletionRequestor;
32
import org.eclipse.jdt.core.IJavaElement;
36
import org.eclipse.jdt.core.IJavaElement;
33
import org.eclipse.jdt.core.IJavaModelMarker;
37
import org.eclipse.jdt.core.IJavaModelMarker;
34
import org.eclipse.jdt.core.IJavaModelStatusConstants;
38
import org.eclipse.jdt.core.IJavaModelStatusConstants;
39
import org.eclipse.jdt.core.IMember;
40
import org.eclipse.jdt.core.IPackageFragment;
35
import org.eclipse.jdt.core.IPackageFragmentRoot;
41
import org.eclipse.jdt.core.IPackageFragmentRoot;
36
import org.eclipse.jdt.core.IParent;
42
import org.eclipse.jdt.core.IParent;
37
import org.eclipse.jdt.core.ISourceRange;
43
import org.eclipse.jdt.core.ISourceRange;
44
import org.eclipse.jdt.core.ISourceReference;
38
import org.eclipse.jdt.core.IType;
45
import org.eclipse.jdt.core.IType;
46
import org.eclipse.jdt.core.JavaConventions;
47
import org.eclipse.jdt.core.JavaCore;
39
import org.eclipse.jdt.core.JavaModelException;
48
import org.eclipse.jdt.core.JavaModelException;
49
import org.eclipse.jdt.core.Signature;
50
import org.eclipse.jdt.core.WorkingCopyOwner;
40
import org.eclipse.jdt.core.compiler.IProblem;
51
import org.eclipse.jdt.core.compiler.IProblem;
41
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
52
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
42
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
53
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
Lines 47-60 Link Here
47
import org.eclipse.jdt.internal.core.util.Util;
58
import org.eclipse.jdt.internal.core.util.Util;
48
59
49
/**
60
/**
61
 * Noel - see https://bugs.eclipse.org/bugs/show_bug.cgi?id=84872
50
 * @see IClassFile
62
 * @see IClassFile
51
 */
63
 */
52
64
53
public class ClassFile extends Openable implements IClassFile, SuffixConstants {
65
public class ClassFile extends Openable implements IClassFile, SuffixConstants {
54
66
55
	protected String name;
67
    // this is stored as utf-8, since most package names are ascii
68
    // and this field accounts for a lot of memory
69
    private byte [] compressedName;
56
	protected BinaryType binaryType = null;
70
	protected BinaryType binaryType = null;
57
	private boolean checkAutomaticSourceMapping;
71
	private boolean checkAutomaticSourceMapping;
72
    
58
/*
73
/*
59
 * Creates a handle to a class file.
74
 * Creates a handle to a class file.
60
 */
75
 */
Lines 62-71 Link Here
62
	super(parent);
77
	super(parent);
63
	// don't hold on the .class file extension to save memory
78
	// don't hold on the .class file extension to save memory
64
	// also make sure to copy the string (so that it doesn't hold on the underlying char[] that might be much bigger than necessary)
79
	// also make sure to copy the string (so that it doesn't hold on the underlying char[] that might be much bigger than necessary)
65
	this.name = new String(name.substring(0, name.length() - 6)); // don't hold on the .class file extension to save memory
80
	setName(new String(name.substring(0, name.length() - 6))); // don't hold on the .class file extension to save memory
66
	this.checkAutomaticSourceMapping = false;
81
	this.checkAutomaticSourceMapping = false;
67
}
82
}
68
83
84
private final void setName(String name) {
85
    try {
86
        this.compressedName = name.getBytes("UTF-8"); //$NON-NLS-1$
87
    } catch (UnsupportedEncodingException ex) {
88
        // should never happen
89
        throw new RuntimeException(ex);
90
    }    
91
}
92
93
protected final String getName() {
94
    try {
95
        return new String(this.compressedName, 0, this.compressedName.length, "UTF-8"); //$NON-NLS-1$
96
    } catch (UnsupportedEncodingException ex) {
97
        // should never happen
98
        throw new RuntimeException(ex);
99
    }
100
}
101
69
/**
102
/**
70
 * Creates the children elements for this class file adding the resulting
103
 * Creates the children elements for this class file adding the resulting
71
 * new handles and info objects to the newElements table. Returns true
104
 * new handles and info objects to the newElements table. Returns true
Lines 313-324 Link Here
313
	if (mapper == null) {
346
	if (mapper == null) {
314
		return null;
347
		return null;
315
	} else {		
348
	} else {		
349
        final String name = getName();
316
		String prefix = null;
350
		String prefix = null;
317
		int index = this.name.indexOf('$');
351
		int index = name.indexOf('$');
318
		if (index > -1) {
352
		if (index > -1) {
319
			prefix = this.name.substring(0, index);
353
			prefix = name.substring(0, index);
320
		} else {
354
		} else {
321
			prefix = this.name;
355
			prefix = name;
322
		}
356
		}
323
		
357
		
324
		
358
		
Lines 362-368 Link Here
362
	}
396
	}
363
}
397
}
364
public String getElementName() {
398
public String getElementName() {
365
	return this.name + SuffixConstants.SUFFIX_STRING_class;
399
	return getName() + SuffixConstants.SUFFIX_STRING_class;
366
}
400
}
367
/**
401
/**
368
 * @see IJavaElement
402
 * @see IJavaElement
Lines 457-465 Link Here
457
	return this.binaryType;
491
	return this.binaryType;
458
}
492
}
459
public String getTypeName() {
493
public String getTypeName() {
494
    final String name = getName();
460
	// Internal class file name doesn't contain ".class" file extension
495
	// Internal class file name doesn't contain ".class" file extension
461
	int lastDollar = this.name.lastIndexOf('$');
496
	int lastDollar = name.lastIndexOf('$');
462
	return lastDollar > -1 ? Util.localTypeName(this.name, lastDollar, this.name.length()) : this.name;
497
	return lastDollar > -1 ? Util.localTypeName(name, lastDollar, name.length()) : name;
463
}
498
}
464
/*
499
/*
465
 * @see IClassFile
500
 * @see IClassFile

Return to bug 84872