You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Marcus Deluigi <md...@student.ethz.ch> on 2006/08/23 14:13:37 UTC

Javaflow: Ant-Task Bug?

Hi

I have another issue with java flow:
I am using a class called "Config" within a javaflow-thread.
On running the javaflow transformation task, I get the following  
exception:

/Users/mdeluigi/SourceCode/build.xml:114:  
org.apache.bcel.verifier.exc.AssertionViolatedException: INTERNAL  
ERROR: Missing class: java.lang.ClassNotFoundException: Exception  
while looking for class edu.ethz.cs.smp.database.Config:  
java.io.IOException: Couldn't find: edu/ethz/cs/smp/database/ 
Config.class

The class file is right there. The exception is only with this class.  
If I uncomment the usage, everything works fine.

Is it a bug or did I miss something?

Greetings
Marcus

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: Javaflow: Ant-Task Bug?

Posted by Marcus Deluigi <md...@student.ethz.ch>.
>
> Does "ASM based instrumentation" mean the Continuation Class Loader?
> That one works fine:
> ---
>         try {
>         	File dir = new File(System.getProperty("user.dir"));
>         	URL url = dir.toURL();
> 		ClassLoader cl = new ContinuationClassLoader( new URL[]{ url },
> 		Foo.class.getClassLoader()); // parent class loader
> 		Class cls = cl.loadClass("TestThread");
> 		System.out.println("Successfully loaded");
> 		TestThread bar = (TestThread) cls.newInstance();
> 		Continuation.startWith( bar );
>         }
>         catch (Exception e) {
>             System.out.println(e);
>         }
> ---
Update: I just tested the suspend() method (forgot to do that before):
It seems as if the class gets instantiated, but the byte code doesn't  
get modified.
I can't call the suspend() method within the Thread.
("stack corruption. Is class ... instrumented for javaflow?")

I'm following exactly the Tutorial. Do I miss something?

Greetings,
Marcus

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: Re: Javaflow: Ant-Task Bug?

Posted by Torsten Curdt <tc...@apache.org>.
> > Looks like for some reason you have the wrong version of ASM in
> > your classpath?!
>
> Do you know which ASM version worked?

The one that's being used to compile it ;-) ...it's in the lib directory.

Maybe print out your classpath on startup.

cheers
--
Torsten

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: Javaflow: Ant-Task Bug?

Posted by Marcus Deluigi <md...@student.ethz.ch>.
On Aug 24, 2006, at 2:55 PM, Torsten Curdt wrote:

>> For the task:
>> I tried asm 2.2.3 and asm 3.0 RC1, but I always get this exception:
>> java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init> 
>> (ZZ)V
>>
>> I can't make any sense out of it.
>
> Looks like for some reason you have the wrong version of ASM in  
> your classpath?!

Do you know which ASM version worked?


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: Re: Javaflow: Ant-Task Bug?

Posted by Torsten Curdt <tc...@apache.org>.
> For the task:
> I tried asm 2.2.3 and asm 3.0 RC1, but I always get this exception:
> java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(ZZ)V
>
> I can't make any sense out of it.

Looks like for some reason you have the wrong version of ASM in your classpath?!

> For me, it seems as it's an issue of the JVM: I am using Java 1.5 and
> the previous example is using Java Generics.
> Could that be cause of the problem?

Could be the case ...but unlikely - I am also using 1.5

> I could not find any comment in the official documentation (neither
> bcel nor asm) but from what I read from the mailing lists,
> it seems as if both frameworks don't work with Java 1.5 byte code.

1.5 byte code is not much different from 1.4 because generics are
not implemented on the byte code level. So in theory this should not
harm the instrumentation. But there are still a few things differenent.
Proper support for 1.5 has only been added to BCEL trunk just recently.

Pretty sure ASM does fully support 1.5 and (at least trunk) even 1.6.

> > .could please file all these information into a jira issue?
> Of course. Even if this is a Java version issue?

It would be great if you could compile your testcase without the generics
and target to 1.4 and then report back. But yes, please open an issue and
add all information to it.

cheers
--
Torsten

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: Javaflow: Ant-Task Bug?

Posted by Marcus Deluigi <md...@student.ethz.ch>.
>> Does "ASM based instrumentation" mean the Continuation Class Loader?
>
> Nope ...at the moment the BCEL instrumentation is used by default.

I see.

For the task:
I tried asm 2.2.3 and asm 3.0 RC1, but I always get this exception:
java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(ZZ)V

I can't make any sense out of it.
For me, it seems as it's an issue of the JVM: I am using Java 1.5 and  
the previous example is using Java Generics.
Could that be cause of the problem?
I could not find any comment in the official documentation (neither  
bcel nor asm) but from what I read from the mailing lists,
it seems as if both frameworks don't work with Java 1.5 byte code.

>> That one works fine:
>
> That's weird ..
As I wrote in the update, I think I do something wrong: The loaded  
class does not seem to be instrumented.
But I can't figure out what's missing.

> .could please file all these information into a jira issue?
Of course. Even if this is a Java version issue?

Greetings
Marcus

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: Re: Javaflow: Ant-Task Bug?

Posted by Torsten Curdt <tc...@apache.org>.
> Does "ASM based instrumentation" mean the Continuation Class Loader?

Nope ...at the moment the BCEL instrumentation is used by default.

>From the ant-task source:

   /**
     * Sets the transformer to use.
     *
     * <p>
     * This option is unpublished, because in a long run we'll
     * likely to just focus on one transformer and get rid
     * of the other (and this option will be removed then.)
     *
     * @param name
     *      either "BCEL" or "ASM". Case insensitive.
     */
    public void setMode(String name) {
        name = name.toLowerCase();
        if(name.equals("bcel"))
            transformer = new BcelClassTransformer();
        else
        if(name.equals("asm"))
            transformer = new AsmClassTransformer();
        else
            throw new BuildException("Unrecognized mode: "+name);
    }


So

<javaflow srcdir="${src.dir}" dstDir="${src.dir}/.." mode="asm">
  <include name="**/TestThread.class" />
</javaflow>


> That one works fine:

That's weird ...could please file all these information into a jira issue?

cheers
--
Torsten

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: Javaflow: Ant-Task Bug?

Posted by Marcus Deluigi <md...@student.ethz.ch>.
On Aug 23, 2006, at 2:56 PM, Torsten Curdt wrote:

>> On running the javaflow transformation task, I get the following
>> exception:
>>
>> /Users/mdeluigi/SourceCode/build.xml:114:
>> org.apache.bcel.verifier.exc.AssertionViolatedException: INTERNAL
>> ERROR: Missing class: java.lang.ClassNotFoundException: Exception
>> while looking for class edu.ethz.cs.smp.database.Config:
>> java.io.IOException: Couldn't find: edu/ethz/cs/smp/database/
>> Config.class
>>
>> The class file is right there. The exception is only with this class.
>> If I uncomment the usage, everything works fine.
>>
>> Is it a bug or did I miss something?
>
> Sounds like a BCEL bug ...can you please provide a testcase?
here it is:
----------8<----------
package edu.ethz.cs.smp.jobcontrol;

import java.util.Set;
import java.util.TreeSet;

class Foo {
     public Set<Object> getSecurities() throws Exception {
         return new TreeSet<Object>();
     }
}



public class TestThread implements Runnable {

     public void run () {
         try {
             Foo foo = new Foo();
             Set<Object> securities = foo.getSecurities();
         }
         catch (Exception e) {

         }
	System.out.println("Finished");
     }
}
---------->8----------

The Ant Task is as follows:
-----
		<javaflow srcdir="${src.dir}" dstDir="${src.dir}/..">
			<include name="**/TestThread.class" />
		</javaflow>
-----

And the exception:
BUILD FAILED
/Users/mdeluigi/SourceCode/build.xml:115:  
org.apache.bcel.verifier.exc.AssertionViolatedException: INTERNAL  
ERROR: Missing class: java.lang.ClassNotFoundException: Exception  
while looking for class edu.ethz.cs.smp.jobcontrol.Foo:  
java.io.IOException: Couldn't find: edu/ethz/cs/smp/jobcontrol/Foo.class

The exception is _not_ thrown if either the try .. except block is  
missing _or_ the "securities" collection is initialized within the run 
() method.


Does "ASM based instrumentation" mean the Continuation Class Loader?
That one works fine:
---
         try {
         	File dir = new File(System.getProperty("user.dir"));
         	URL url = dir.toURL();
		ClassLoader cl = new ContinuationClassLoader( new URL[]{ url },
		Foo.class.getClassLoader()); // parent class loader
		Class cls = cl.loadClass("TestThread");
		System.out.println("Successfully loaded");
		TestThread bar = (TestThread) cls.newInstance();
		Continuation.startWith( bar );
         }
         catch (Exception e) {
             System.out.println(e);
         }
---


Greetings
Marcus



> ...or at least the original class file. Without the other classes
> it might be hard to track down though.
>
> Did you try the ASM based instrumentation?
>
> cheers
> --
> Torsten
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: Javaflow: Ant-Task Bug?

Posted by Torsten Curdt <tc...@apache.org>.
> On running the javaflow transformation task, I get the following
> exception:
>
> /Users/mdeluigi/SourceCode/build.xml:114:
> org.apache.bcel.verifier.exc.AssertionViolatedException: INTERNAL
> ERROR: Missing class: java.lang.ClassNotFoundException: Exception
> while looking for class edu.ethz.cs.smp.database.Config:
> java.io.IOException: Couldn't find: edu/ethz/cs/smp/database/
> Config.class
>
> The class file is right there. The exception is only with this class.
> If I uncomment the usage, everything works fine.
>
> Is it a bug or did I miss something?

Sounds like a BCEL bug ...can you please provide a testcase?
...or at least the original class file. Without the other classes
it might be hard to track down though.

Did you try the ASM based instrumentation?

cheers
--
Torsten

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org