Bug 28978 - RuntimeException: Unhandled kind of new on explicit constructor call
Summary: RuntimeException: Unhandled kind of new on explicit constructor call
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Jim Hugunin CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-01-03 13:35 EST by Robert Wenner CLA
Modified: 2003-01-07 16:11 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Wenner CLA 2003-01-03 13:35:04 EST
I am using AspectJ 1.1b1 on Linux version 2.4.18-4GB (root@Pentium.suse.de) (gcc
version 2.95.3 20010315 (SuSE)) #1 Wed Mar 27 13:57:05 UTC 2002 with java
version "1.4.0_01".

Using:

ajc -Xlint
-warn:constructorName,packageDefaultMethod,deprecation,maskedCatchBlocks,unusedLocals,unusedImports,syntheticAccess,-classpath
 .:aspectj1.1/lib/aspectjrt.jar CrashAspectJ.java

I get this output / stack trace:

trouble in:
public class CrashAspectJ extends java.lang.Object:
  public void <init>():
                    ALOAD_0     // CrashAspectJ this   (line 1)
                    INVOKESPECIAL java.lang.Object.<init> ()V
    constructor-execution(void CrashAspectJ.<init>())
    |               RETURN
    constructor-execution(void CrashAspectJ.<init>())
  end public void <init>()

  public static void main(String[]):
    method-execution(void CrashAspectJ.main(java.lang.String[]))
    |               NEW CrashAspectJ   (line 3)
    | constructor-call(void CrashAspectJ.<init>())
    | |             INVOKESPECIAL CrashAspectJ.<init> ()V
    | constructor-call(void CrashAspectJ.<init>())
    |               RETURN   (line 4)
    method-execution(void CrashAspectJ.main(java.lang.String[]))
  end public static void main(String[])

  public void testCrashMe():
    method-execution(void CrashAspectJ.testCrashMe())
    |               NEW Cloned   (line 7)
    | constructor-call(void Cloned.<init>())
    | |             INVOKESPECIAL Cloned.<init> ()V
    | constructor-call(void Cloned.<init>())
    |               RETURN   (line 8)
    method-execution(void CrashAspectJ.testCrashMe())
  end public void testCrashMe()
end public class CrashAspectJ
Exception thrown from AspectJ 1.1b1

Please email to us as follows:
       to: jitterbug@aspectj.org
  subject: top stack trace File:line, e.g., "SomeFile.java:243"
  message: copy the entire stack trace.

Your message can also request follow-up or provide a workaround.
To make the bug a priority, please include a test program.

You may search for duplicate bugs (i.e., known workarounds):

http://aspectj.org/bugs
http://aspectj.org/bugs/incoming?expression=SomeFile.java:243

Unhandled kind of new
Unhandled kind of new
java.lang.RuntimeException: Unhandled kind of new
        at org.aspectj.weaver.bcel.BcelShadow.deleteNewAndDup(BcelShadow.java:164)
        at org.aspectj.weaver.bcel.BcelShadow.prepareSelf0(BcelShadow.java:121)
        at org.aspectj.weaver.Shadow.implement(Shadow.java:211)
        at
org.aspectj.weaver.bcel.BcelClassWeaver.implement(BcelClassWeaver.java:245)
        at
org.aspectj.weaver.bcel.BcelClassWeaver.matchAndImplement(BcelClassWeaver.java:154)
        at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:120)
        at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:261)
        at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:229)
        at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.weaveAndGenerateClassFiles(AjBuildManager.java:371)
        at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:127)
        at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:75)
        at org.aspectj.tools.ajc.Main.run(Main.java:144)
        at org.aspectj.tools.ajc.Main.runMain(Main.java:94)
        at org.aspectj.tools.ajc.Main.main(Main.java:55)


This program should reproduce the problem:

public class CrashAspectJ {
    public static void main(String args[]) {
        new CrashAspectJ();
    }

    public void testCrashMe() {
        new Cloned();
    }
}

class Cloned implements Cloneable {
}

aspect ClonableContract {
    after(Cloneable newObj) throws NoSuchMethodException:
    this(newObj) && call(Cloneable+.new(..)) {
        System.out.println("Clonable check for " + newObj);
    }
}

Workaround: The program does not crash if I assign to a variable instead of
calling the constructor and not assigning the created object, i.e. if I write
the above method as:

    public void testCrashMe() {
        Cloned c = new Cloned();
    }

I wrote it without the local variable to get rid of the warning for an unused
local variable. The program should just print a message for the constructor of
something implementing Cloneable.
Comment 1 Robert Wenner CLA 2003-01-06 14:01:32 EST
The problem does not occur with AspectJ1.1b2.
Comment 2 Jim Hugunin CLA 2003-01-07 16:11:55 EST
fixed in 1.1beta2