Calculates result of getSourceName() one time, so reuse because of CU cache. Prepares SAXParserFActory one time, so avoids expensive ClassLoader lookups. Review at http://gwt-code-reviews.appspot.com/1438801 Review by: scottb@google.com git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@10162 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/javac/CompiledClass.java b/dev/core/src/com/google/gwt/dev/javac/CompiledClass.java index 19c4ff7..85f42de 100644 --- a/dev/core/src/com/google/gwt/dev/javac/CompiledClass.java +++ b/dev/core/src/com/google/gwt/dev/javac/CompiledClass.java
@@ -38,6 +38,7 @@ private final CompiledClass enclosingClass; private final String internalName; + private final String sourceName; private final boolean isLocal; private transient TypeData typeData; private CompilationUnit unit; @@ -65,6 +66,7 @@ String internalName) { this.enclosingClass = enclosingClass; this.internalName = StringInterner.get().intern(internalName); + this.sourceName = StringInterner.get().intern(InternalName.toSourceName(internalName)); this.cacheToken = diskCache.writeByteArray(classBytes); this.isLocal = isLocal; } @@ -109,7 +111,7 @@ * Returns the qualified source name, e.g. {@code java.util.Map.Entry}. */ public String getSourceName() { - return StringInterner.get().intern(InternalName.toSourceName(internalName)); + return sourceName; } public TypeData getTypeData() {
diff --git a/dev/core/test/com/google/gwt/dev/javac/CompiledClassTest.java b/dev/core/test/com/google/gwt/dev/javac/CompiledClassTest.java index 8d78d85..18f6e53 100644 --- a/dev/core/test/com/google/gwt/dev/javac/CompiledClassTest.java +++ b/dev/core/test/com/google/gwt/dev/javac/CompiledClassTest.java
@@ -26,7 +26,15 @@ static byte[] dummyByteCode = { (byte) 0xDE, (byte) 0xAD, (byte)0xBE, (byte)0xEF }; - static final String DUMMY_NAME = "com.example.DeadBeef"; + static final String DUMMY_NAME = "com/example/DeadBeef"; + + /** + * Test for {@link CompiledClass#getSourceName()}. + */ + public void testSourceName() throws Exception { + CompiledClass compiledClass = new CompiledClass(dummyByteCode, null, false, DUMMY_NAME); + assertEquals("com.example.DeadBeef", compiledClass.getSourceName()); + } public void testCompiledClassSerialization() throws Exception { CompiledClass writeObject = new CompiledClass(dummyByteCode, null, false, DUMMY_NAME);