Bug 176991 - IllegalStateException thrown: Wrong number of type parameters supplied
Summary: IllegalStateException thrown: Wrong number of type parameters supplied
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.3   Edit
Hardware: PC Windows XP
: P1 critical (vote)
Target Milestone: 1.5.4   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 177215 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-03-12 10:27 EDT by Sérgio Agostinho CLA
Modified: 2007-11-08 11:13 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sérgio Agostinho CLA 2007-03-12 10:27:26 EDT
I was trying to expose the Java runtime library, by adding the JRE_LIB variable to "AspectJ Build -> Inpath". When I try to clean and build, I get the following internal compiler error (the error occurs in an aspect which tries the use static crosscutting in a J2SE class):

java.lang.IllegalStateException
at org.aspectj.weaver.ResolvedMemberImpl.parameterizedWith(ResolvedMemberImpl.java:616)
at org.aspectj.weaver.ResolvedMemberImpl.parameterizedWith(ResolvedMemberImpl.java:597)
at org.aspectj.weaver.ReferenceType.getDeclaredMethods(ReferenceType.java:512)
at org.aspectj.weaver.ResolvedType.addAndRecurse(ResolvedType.java:263)
at org.aspectj.weaver.ResolvedType.addAndRecurse(ResolvedType.java:302)
at org.a ... nternal.AspectJBuildManager$CompilerThread.run(AspectJBuildManager.java:191)

IllegalStateException thrown: Wrong number of type parameters supplied

I am using JDK 1.5.0, Eclipse 3.2.1, and AJDT 1.4.1.
Comment 1 Dana P'Simer CLA 2007-08-06 19:38:13 EDT
I have seen this as well.  

Here is the output of the iajc ant task:

     [iajc] trouble in: 
     [iajc]  class com.ihg.dec.framework.commons.utils.cow.AspectJBugTestCase$EntrySet extends java.util.AbstractSet implements java.util.Set:
     [iajc]   private java.util.Set wrapped [Signature(Ljava/util/Set<Ljava/util/Map$Entry<TK;Lcom/ihg/dec/framework/commons/utils/cow/AspectJBugTestCase$Value<TV;>;>;>;)]
     [iajc]   final com.ihg.dec.framework.commons.utils.cow.AspectJBugTestCase this$0
     [iajc]   public void <init>(com.ihg.dec.framework.commons.utils.cow.AspectJBugTestCase, java.util.Set):
     [iajc]                     ALOAD_0     // Lcom/ihg/dec/framework/commons/utils/cow/AspectJBugTestCase$EntrySet; this   (line 92)
     [iajc]                     ALOAD_1
     [iajc]                     PUTFIELD com.ihg.dec.framework.commons.utils.cow.AspectJBugTestCase$EntrySet.this$0 Lcom/ihg/dec/framework/commons/utils/cow/AspectJBugTestCase;
     [iajc]                     ALOAD_0     // Lcom/ihg/dec/framework/commons/utils/cow/AspectJBugTestCase$EntrySet; this
     [iajc]                     INVOKESPECIAL java.util.AbstractSet.<init> ()V
     [iajc]     constructor-execution(void com.ihg.dec.framework.commons.utils.cow.AspectJBugTestCase$EntrySet.<init>(com.ihg.dec.framework.commons.utils.cow.AspectJBugTestCase, java.util.Set))
     [iajc]     |               ALOAD_0     // Lcom/ihg/dec/framework/commons/utils/cow/AspectJBugTestCase$EntrySet; this   (line 93)
     [iajc]     |               ALOAD_2     // Ljava/util/Set; wrapped
     [iajc]     |               PUTFIELD com.ihg.dec.framework.commons.utils.cow.AspectJBugTestCase$EntrySet.wrapped Ljava/util/Set;
     [iajc]     |               RETURN   (line 94)
     [iajc]     constructor-execution(void com.ihg.dec.framework.commons.utils.cow.AspectJBugTestCase$EntrySet.<init>(com.ihg.dec.framework.commons.utils.cow.AspectJBugTestCase, java.util.Set))
     [iajc]   end public void <init>(com.ihg.dec.framework.commons.utils.cow.AspectJBugTestCase, java.util.Set)

     [iajc]   public java.util.Iterator iterator():
     [iajc]     method-execution(java.util.Iterator com.ihg.dec.framework.commons.utils.cow.AspectJBugTestCase$EntrySet.iterator())
     [iajc]     |               NEW com.ihg.dec.framework.commons.utils.cow.AspectJBugTestCase$EntrySetIterator   (line 99)
     [iajc]     |               DUP
     [iajc]     |               ALOAD_0     // Lcom/ihg/dec/framework/commons/utils/cow/AspectJBugTestCase$EntrySet; this
     [iajc]     |               GETFIELD com.ihg.dec.framework.commons.utils.cow.AspectJBugTestCase$EntrySet.this$0 Lcom/ihg/dec/framework/commons/utils/cow/AspectJBugTestCase;
     [iajc]     |               ALOAD_0     // Lcom/ihg/dec/framework/commons/utils/cow/AspectJBugTestCase$EntrySet; this
     [iajc]     |               GETFIELD com.ihg.dec.framework.commons.utils.cow.AspectJBugTestCase$EntrySet.wrapped Ljava/util/Set;
     [iajc]     | method-call(java.util.Iterator java.util.Set.iterator())
     [iajc]     | |             INVOKEINTERFACE java.util.Set.iterator ()Ljava/util/Iterator;
     [iajc]     | method-call(java.util.Iterator java.util.Set.iterator())
     [iajc]     |               INVOKESPECIAL com.ihg.dec.framework.commons.utils.cow.AspectJBugTestCase$EntrySetIterator.<init> (Lcom/ihg/dec/framework/commons/utils/cow/AspectJBugTestCase;Ljava/util/Iterator;)V
     [iajc]     |               ARETURN
     [iajc]     method-execution(java.util.Iterator com.ihg.dec.framework.commons.utils.cow.AspectJBugTestCase$EntrySet.iterator())
     [iajc]   end public java.util.Iterator iterator()

     [iajc]   public int size():
     [iajc]     method-execution(int com.ihg.dec.framework.commons.utils.cow.AspectJBugTestCase$EntrySet.size())
     [iajc]     |               ALOAD_0     // Lcom/ihg/dec/framework/commons/utils/cow/AspectJBugTestCase$EntrySet; this   (line 105)
     [iajc]     |               GETFIELD com.ihg.dec.framework.commons.utils.cow.AspectJBugTestCase$EntrySet.wrapped Ljava/util/Set;
     [iajc]     | method-call(int java.util.Set.size())
     [iajc]     | |             INVOKEINTERFACE java.util.Set.size ()I
     [iajc]     | method-call(int java.util.Set.size())
     [iajc]     |               IRETURN
     [iajc]     method-execution(int com.ihg.dec.framework.commons.utils.cow.AspectJBugTestCase$EntrySet.size())
     [iajc]   end public int size()

     [iajc] end  class com.ihg.dec.framework.commons.utils.cow.AspectJBugTestCase$EntrySet

     [iajc]     
     [iajc] Exception thrown from AspectJ 1.5.3

     [iajc] This might be logged as a bug already -- find current bugs at
     [iajc]   http://bugs.eclipse.org/bugs/buglist.cgi?product=AspectJ&component=Compiler

     [iajc] Bugs for exceptions thrown have titles File:line from the top stack, 
     [iajc] e.g., "SomeFile.java:243"

     [iajc] If you don't find the exception below in a bug, please add a new bug
     [iajc] at http://bugs.eclipse.org/bugs/enter_bug.cgi?product=AspectJ
     [iajc] To make the bug a priority, please include a test program
     [iajc] that can reproduce this exception.
     [iajc] Wrong number of type parameters supplied

     [iajc] when weaving type com.ihg.dec.framework.commons.utils.cow.AspectJBugTestCase$EntrySet
     [iajc] when weaving classes 
     [iajc] when weaving 
     [iajc] when batch building BuildConfig[null] #Files=16
     [iajc] Wrong number of type parameters supplied
     [iajc] java.lang.IllegalStateException: Wrong number of type parameters supplied
     [iajc]     at org.aspectj.weaver.ResolvedMemberImpl.parameterizedWith(ResolvedMemberImpl.java:616)
     [iajc]     at org.aspectj.weaver.ResolvedMemberImpl.parameterizedWith(ResolvedMemberImpl.java:597)
     [iajc]     at org.aspectj.weaver.ReferenceType.getDeclaredMethods(ReferenceType.java:512)
     [iajc]     at org.aspectj.weaver.bcel.BcelClassWeaver.checkForOverride(BcelClassWeaver.java:638)
     [iajc]     at org.aspectj.weaver.bcel.BcelClassWeaver.calculateAnyRequiredBridgeMethods(BcelClassWeaver.java:720)
     [iajc]     at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1615)
     [iajc]     at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump(BcelWeaver.java:1563)
     [iajc]     at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify(BcelWeaver.java:1341)
     [iajc]     at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1161)
     [iajc]     at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.weaveQueuedEntries(AjPipeliningCompilerAdapter.java:455)
     [iajc]     at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.queueForWeaving(AjPipeliningCompilerAdapter.java:392)
     [iajc]     at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.afterProcessing(AjPipeliningCompilerAdapter.java:380)
     [iajc]     at org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$after$org_aspectj_ajdt_internal_compiler_CompilerAdapter$5$6b855184(CompilerAdapter.aj:98)
     [iajc]     at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:533)
     [iajc]     at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:329)
     [iajc]     at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:906)
     [iajc]     at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuildManager.java:260)
     [iajc]     at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:176)
     [iajc]     at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:112)
     [iajc]     at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:60)
     [iajc]     at org.aspectj.tools.ajc.Main.run(Main.java:378)
     [iajc]     at org.aspectj.tools.ajc.Main.runMain(Main.java:253)
     [iajc]     at org.aspectj.tools.ajc.Main.main(Main.java:88)

     [iajc] Aug 6, 2007 7:30:26 PM org.aspectj.weaver.tools.Jdk14Trace info
     [iajc] INFO: Dumping to D:\Documents and Settings\psimerd\workspace\iris-web\.\ajcore.20070806.193026.708.txt

     [iajc] 1 fail|abort

Here is the class that got the error:

package com.ihg.dec.framework.commons.utils.cow;

import java.util.AbstractSet;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.Map.Entry;

public class AspectJBugTestCase
{
  class Value<V>
  {
    private V value;

    public Value( V value )
    {
      this.value = value;
    }

    public V getValue()
    {
      return value;
    }

    public void setValue( V value )
    {
      this.value = value;
    }
  }

  class EntrySetEntry<K, V>
    implements Entry<K, V>
  {
    private Entry<K, Value<V>> wrapped;

    public EntrySetEntry( Entry<K, Value<V>> wrapped )
    {
      this.wrapped = wrapped;
    }

    public K getKey()
    {
      return wrapped.getKey();
    }

    public V getValue()
    {
      return wrapped.getValue().getValue();
    }

    public V setValue( V value )
    {
      Value<V> old = wrapped.setValue( new Value<V>( value ) );
      return old == null ? null : old.getValue();
    }

  }

  class EntrySetIterator<K, V>
    implements Iterator<Entry<K, V>>
  {
    private Iterator<Entry<K, Value<V>>> wrapped;

    public EntrySetIterator( Iterator<Entry<K, Value<V>>> wrapped )
    {
      this.wrapped = wrapped;
    }

    public boolean hasNext()
    {
      return wrapped.hasNext();
    }

    public Entry<K, V> next()
    {
      return new EntrySetEntry<K, V>( wrapped.next() );
    }

    public void remove()
    {
      throw new UnsupportedOperationException( "Not implemented." );
    }
  }

  class EntrySet<K, V>
    extends AbstractSet<Entry<K, V>>
    implements Set<Entry<K, V>>
  {
    private Set<Entry<K, Value<V>>> wrapped;

    public EntrySet( Set<Entry<K, Value<V>>> wrapped )
    {
      this.wrapped = wrapped;
    }

    @Override
    public Iterator<Entry<K, V>> iterator()
    {
      return new EntrySetIterator<K, V>( wrapped.iterator() );
    }

    @Override
    public int size()
    {
      return wrapped.size();
    }
  }

  public void testIt()
  {
    new EntrySet<String, String>( new HashSet<Entry<String, Value<String>>>() );
  }
}

If I rearrange the EntrySet delcaration so that it extends AbstractSet with a non parameterized type like so:

package com.ihg.dec.framework.commons.utils.cow;

import java.util.AbstractSet;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.Map.Entry;

public class AspectJBugTestCase
{
  class Value<V>
  {
    private V value;

    public Value( V value )
    {
      this.value = value;
    }

    public V getValue()
    {
      return value;
    }

    public void setValue( V value )
    {
      this.value = value;
    }
  }

  class EntrySetEntry<K, V>
    implements Entry<K, V>
  {
    private Entry<K, Value<V>> wrapped;

    public EntrySetEntry( Entry<K, Value<V>> wrapped )
    {
      this.wrapped = wrapped;
    }

    public K getKey()
    {
      return wrapped.getKey();
    }

    public V getValue()
    {
      return wrapped.getValue().getValue();
    }

    public V setValue( V value )
    {
      Value<V> old = wrapped.setValue( new Value<V>( value ) );
      return old == null ? null : old.getValue();
    }

  }

  class EntrySetIterator<K, V, E extends Entry<K,V>>
    implements Iterator<E>
  {
    private Iterator<Entry<K, Value<V>>> wrapped;

    public EntrySetIterator( Iterator<Entry<K, Value<V>>> wrapped )
    {
      this.wrapped = wrapped;
    }

    public boolean hasNext()
    {
      return wrapped.hasNext();
    }

    @SuppressWarnings("unchecked")
    public E next()
    {
      return (E)new EntrySetEntry<K, V>( wrapped.next() );
    }

    public void remove()
    {
      throw new UnsupportedOperationException( "Not implemented." );
    }
  }

  class EntrySet<K, V, E extends Entry<K,V>>
    extends AbstractSet<E>
    implements Set<E>
  {
    private Set<Entry<K, Value<V>>> wrapped;

    public EntrySet( Set<Entry<K, Value<V>>> wrapped )
    {
      this.wrapped = wrapped;
    }

    @Override
    public Iterator<E> iterator()
    {
      return new EntrySetIterator<K, V, E>( wrapped.iterator() );
    }

    @Override
    public int size()
    {
      return wrapped.size();
    }
  }

  public void testIt()
  {
    new EntrySet<String, String, Entry<String,String>>( new HashSet<Entry<String, Value<String>>>() );
  }
}

Error goes away.
Comment 2 Dana P'Simer CLA 2007-08-06 19:42:48 EDT
I would like to add that since this prevents perfectly valid Java from compiling, the severity aught to be something higher than "normal"
Comment 3 Andrew Clement CLA 2007-10-26 06:54:01 EDT
several bugs are similar to this, but this one includes testcode (hurray!) - thanks for that.
Comment 4 Andrew Clement CLA 2007-10-29 13:08:26 EDT
I'm trying to recreate using the example code in comment 1 but it just seems to compile for me.  That is using either AspectJ1.5.3 or the latest dev builds.  Dana - I don't suppose you are still working with this code are you?  Can you let me know what operating system and jvm you are using?
Comment 5 Andrew Clement CLA 2007-11-08 11:10:20 EST
Finally, I managed to recreate this - I had to include an aspect alongside the testcode supplied in comment #1.  The aspect was

aspect X {
  declare parents: *.E* implements java.io.Serializable;
}

I needed this to ensure we would drive the bridge method building logic that is shown in the stacktrace included in this bug report (as that appeared to lead to the crash).  After showing it failing with AspectJ1.5.3, I then tested it with the latest drivers and it works fine.  Because the signature I can see at the top of the crash in comment #1 includes inner types I suspected it might be related to bug 175039 where we made a mistake processing signatures containing inner types.  And when I remove the fix for 175039 (just one line) from the latest copy of the code, it starts to fail exactly as reported here.  So I believe this was another symptom of the same problem reported in 175039.
Comment 6 Andrew Clement CLA 2007-11-08 11:13:12 EST
*** Bug 177215 has been marked as a duplicate of this bug. ***