Bug 62639 - [1.5] Cheetah and extending Vector
Summary: [1.5] Cheetah and extending Vector
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 RC1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2004-05-18 10:16 EDT by Brian Skaarup CLA
Modified: 2004-05-28 16:08 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Skaarup CLA 2004-05-18 10:16:45 EDT
Using Eclipse 
Version: 3.0.0
Build id: 200405140800
with 3.0.0.cheetah05

This:
public class V extends java.util.Vector{
	public synchronized boolean addAll(java.util.Collection arg0) {
		return super.addAll(arg0);
	}
}
gives this error:
Severity	Description	Resource	In Folder	Location	Creation Time
2	Internal compiler error
java.lang.Error: Undefined base type: .
	at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromSignature(LookupEnvironment.java:648)
	at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromTypeSignature(LookupEnvironment.java:689)
	at
org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.cachePartsFrom(BinaryTypeBinding.java:201)
	at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:312)
	at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:297)
	at org.eclipse.jdt.internal.compiler.Compiler.accept(Compiler.java:191)
	at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:81)
	at
org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:43)
	at
org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.java:49)
	at
org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.memberTypes(BinaryTypeBinding.java:587)
	at
org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.memberTypes(ParameterizedTypeBinding.java:404)
	at
org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.getMemberType(ParameterizedTypeBinding.java:270)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.findMemberType(Scope.java:609)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getTypeOrPackage(Scope.java:1666)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getType(Scope.java:1553)
	at
org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference.getTypeBinding(QualifiedTypeReference.java:39)
	at
org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveType(TypeReference.java:110)
	at
org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.resolveTypesFor(SourceTypeBinding.java:837)
	at
org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.methods(SourceTypeBinding.java:696)
	at
org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.faultInTypesForFieldsAndMethods(SourceTypeBinding.java:370)
	at
org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.faultInTypes(CompilationUnitScope.java:344)
	at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:499)
	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:333)
	at
org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:209)
	at
org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:159)
	at
org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build(BatchImageBuilder.java:49)
	at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll(JavaBuilder.java:212)
	at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:135)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:532)
	at
org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:607)
	at org.eclipse.core.runtime.Platform.run(Platform.java:668)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:148)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:225)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:178)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:205)
	at
org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:607)
	at org.eclipse.core.runtime.Platform.run(Platform.java:668)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:208)
	at
org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:244)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:273)
	at org.eclipse.core.internal.resources.Workspace.build(Workspace.java:198)
	at
org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock$3.run(OptionsConfigurationBlock.java:455)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:66)
	V.java	T1	line 0	18. maj 2004 16:03:22
Comment 1 Philipe Mulet CLA 2004-05-19 13:07:00 EDT
Cannot reproduce. There must be other types involved in it. Is it an 
incremental recompilation ?
Comment 2 Philipe Mulet CLA 2004-05-19 18:14:09 EDT
Please reopen once reproducing steps are available.
Comment 3 Brian Skaarup CLA 2004-05-24 03:59:29 EDT
If I do this (I have had a colleuge to do the same, resulting in the same error):
Unpack M9 to d:\M9-1
run eclipse.exe (using j2se 1.4.2_04)
Add the cheetah update 0.0.5
Add new java project
Add new class V extending Vector in default package
Add method addAll
Added the j2sdk1.5.0 JRE in Preferences
Select the 1.5 JRE & click OK (rebuilds all)
Change compliance level to 1.5 in Preferences and press OK
Undefined base type: .

Swithcing back to 1.4 compliance, the error disappears
Comment 4 Philipe Mulet CLA 2004-05-24 07:54:31 EDT
Cannot reproduce still. It works just fine for me, issuing the following 
warning:

----------
1. WARNING in V.java (at line 5)
	return super.addAll(arg0);
	       ^^^^^^^^^^^^^^^^^^
Unsafe type operation: Should not invoke the method addAll(Collection<? 
extends E>) of raw type Vector. References to generic type Vector<E> should be 
parameterized
----------
1 problem (1 warning)

I can only bet this is a bug in the JDK1.5 libraries themselves. I am using 
beta2-b50, which doesn't seem to expose this issue any longer. The trace 
indicates that an inconsistent signature in some binaries.
Comment 5 Philipe Mulet CLA 2004-05-24 08:45:31 EDT
Replaced the Error exception with generation of a problem requiring to abort 
instead.
Comment 6 Brian Skaarup CLA 2004-05-24 08:54:51 EDT
beta2-b50?
Where did you get it?
I only have build 1.5.0-beta-b32c
Comment 7 Philipe Mulet CLA 2004-05-24 09:10:54 EDT
From private channels in IBM. You need to interact with Sun to gain access to 
it.
Comment 8 Philipe Mulet CLA 2004-05-24 19:30:52 EDT
Reproduced using beta1. Indeed beta1 contains corrupted binary signatures, 
likely supported by javac in there. 

Offending classfile: java.util.AbstractList$ListItr has a signature attribute:

Ljava/util/AbstractList<TE;>;.Ljava/util/AbstractList$Itr;Ljava/util/ListIterat
or<TE;>;

which should instead read (as of beta2):
Ljava/util/AbstractList<TE;>.Itr;Ljava/util/ListIterator<TE;>;

Closing as invalid. We cannot support corrupted binaries.
Comment 9 Philipe Mulet CLA 2004-05-24 19:35:18 EDT
One more question though. Why do we bother decoding the member type ListItr 
where it is only internally used ? It looks like this scenario shouldn't 
notice the broken signature, as no need to eagerly resolve the member types.
Comment 10 Philipe Mulet CLA 2004-05-24 19:36:59 EDT
Kent - pls investigate eager resolution of member types. We request too much. 
I tried javac beta2 against lib beta1, and it doesn't care about broken 
signature, when turning into verbose mode, it appears it doesn't load the 
member type, as I would expect we also did.
Comment 11 Philipe Mulet CLA 2004-05-25 05:26:46 EDT
I did some measurement, and we indeed load 6 more types than javac, which is 
~50% more than we need.

LOADED BINARIES BY ECLIPSE (sorted by type name)
SAME AS JAVAC:
[reading    java/util/AbstractCollection.class]
[reading    java/util/AbstractList.class]
[reading    java/util/Collection.class]
[reading    java/lang/Cloneable.class]
[reading    java/lang/Iterable.class]
[reading    java/util/Iterator.class]
[reading    java/util/List.class]
[reading    java/util/ListIterator.class]
[reading    java/lang/Object.class]
[reading    java/util/RandomAccess.class]
[reading    java/io/Serializable.class]
[reading    java/lang/String.class]
[reading    java/util/Vector.class]

EXTRA FILES JAVAC DOESN'T NEED
[reading    java/util/AbstractList$Itr.class]
[reading    java/util/AbstractList$ListItr.class]
[reading    java/util/Enumeration.class]
[reading    java/io/IOException.class]
[reading    java/io/ObjectOutputStream.class]
[reading    java/lang/Throwable.class]

Re-tagging for RC1 as this could benefit to our memory profile.
Comment 12 Philipe Mulet CLA 2004-05-25 06:37:28 EDT
In verbose mode, by changing Compiler#accept(IBinaryType) as below, I was able 
to trace the load of offending binaries.

public void accept(IBinaryType binaryType, PackageBinding packageBinding) {
  if (options.verbose) {
    System.out.println(
      Util.bind(
        "compilation.loadBinary" , //$NON-NLS-1$
        new String[] {
          new String(binaryType.getName())}));
    new Exception("TRACE BINARY").printStackTrace(System.out);
    System.out.println();
   }
  lookupEnvironment.createBinaryTypeFrom(binaryType, packageBinding);
}

Comment 13 Philipe Mulet CLA 2004-05-25 06:39:18 EDT
Offending invocations are:
ClassScope#checkForInheritedMemberTypes

Comment 14 Philipe Mulet CLA 2004-05-25 06:43:39 EDT
Previous comment got truncated.

Offending invocations are:
ClassScope#checkForInheritedMemberTypes
   it asks for memberTypes() just to check whether there is any. 
   --> replacing with non populating (new) predicate #hasMemberTypes()
ReferenceBinding#getMemberType(char[])
   asks for memberTypes(), without checking for name match, and thus 
   triggers all resolution (even though in this case, no name match exists).
   --> override default implementation to do name check first.

+ flow analysis is eagerly loading Throwable, where it should avoid doing so 
until some exception type hierarchy is resolved.

Comment 15 Philipe Mulet CLA 2004-05-25 09:37:55 EDT
Released changed for making binary member type resolution more lazy.
Also changed flow analysis to avoid eagerly referencing Throwable.

Note: the fix has nothing to do with Cheetah itself. It is only exposed by the 
fact one of the unnecessary loaded type had issues which caused Cheetah to 
diagnose an error in it.

Fixed in 3.0.
Comment 16 Philipe Mulet CLA 2004-05-25 09:51:01 EDT
Added regression test: NegativeTest#test429.
Also verifiable using batch compiler with -verbose command line option to see 
exactly the binaries loaded during compilation.
Comment 17 Olivier Thomann CLA 2004-05-28 16:08:55 EDT
Verified that the list of .class files requested during compilation is:

[reading    java/util/Vector.class]
[reading    java/util/AbstractList.class]
[reading    java/util/AbstractCollection.class]
[reading    java/lang/Object.class]
[reading    java/util/Collection.class]
[reading    java/lang/Iterable.class]
[reading    java/util/List.class]
[reading    java/io/Serializable.class]
[reading    java/lang/Cloneable.class]
[reading    java/util/RandomAccess.class]

Verified in 200405281200