Markus Dahm | 3 Jun 2002 16:30
Picon
Favicon

Reflection/Beans

Hi,

I started a new thread in the developers list about the to be developed
Reflection API, that may be of interest for some of you too.

Cheers
	Markus

P.S. Yes, the archive works now.
Pasch, Thomas (ACTGRO | 12 Jun 2002 16:39
Picon
Favicon

VerifyError after modifing a Class

Hello,

after using:

        ClassGen classGen = new ClassGen(jclass_);
        ConstantPoolGen poolGen = new
ConstantPoolGen(jclass_.getConstantPool());
        InstructionFactory instr = new InstructionFactory(classGen,
poolGen);

        classGen.addEmptyConstructor(Constants.ACC_PUBLIC);
        classGen.setClassName(name);

        JavaClass modifiedClass = classGen.getJavaClass();
        modifiedClass.dump(out);

and loading the class I encounter the following VerifyError:

java.lang.VerifyError: (class:
de/berlios/serijc/core/ReflectLinkHelper_modified, method: getLinkedTypesOld
signature: ()Ljava/util/List;) Incompatible type for getting or setting
field
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:1613)
        at java.lang.Class.getDeclaredMethods(Class.java:1102)
        at
de.berlios.serijc.test.TestReflectLinkHelper.test2(TestReflectLinkHelper.jav
a:121)
        at
de.berlios.serijc.test.TestReflectLinkHelper.doIt(TestReflectLinkHelper.java
(Continue reading)

markus.dahm | 12 Jun 2002 18:20
Picon
Favicon

Re: VerifyError after modifing a Class

Hi,

>         ConstantPoolGen poolGen = new
> ConstantPoolGen(jclass_.getConstantPool());

should read

ConstantPoolGen poolGen = classGen.getConstantPool();

alternatively you could use setConstantPool() on classGen,
otherwise the cp has nothing to do with the modified
class.

Cheers
  Markus 
--
berlin.de - meine stadt im netz. Jetzt eigene eMail-adresse  <at> berlin.de sichern!
http://webmail.berlin.de
Pasch, Thomas (ACTGRO | 13 Jun 2002 09:27
Picon
Favicon

AW: VerifyError after modifing a Class

Dear Markus,

thank you for support. The error though, is still there. It 
seem to depend on whether there are (more) methods
after the (static) main.

I attached a class to test the problem with.

Kind regards,

Thomas

/*
 * BcelVerifyError.java
 */

import org.apache.bcel.*;
import org.apache.bcel.classfile.*;
import org.apache.bcel.generic.*;
import org.apache.bcel.util.*;

public class BcelVerifyError {

    private Object trash2;

    private BcelVerifyError(int dummy) {
    }

    private int getDummy() {
        return 1;
(Continue reading)

Abel Wang | 18 Jun 2002 05:24

JavaClass to Class

Hi BCEL users, I've been playing around with BCEL for a while now and was
wondering if there's any way for me to go from a java.lang.Class object into
a JavaClass object, and the other way around too.

Basically, I'm trying to dynamically change some class files that are being
loaded by a vendor specific class loader (one that doesn't get the class
from the system's class path).  Since the .class files are not in the class
path, I was wondering if I could create a JavaClass object from the
java.lang.Class object directly.

Thanks,

--Abel
Juozas Baliuka | 18 Jun 2002 08:16
Picon

Re: JavaClass to Class

try to find resource by class name:

clazz.getClassLoader().getResourceAsStream(clazz.getName().replace('.','/')
+ ".class");

> Hi BCEL users, I've been playing around with BCEL for a while now and was
> wondering if there's any way for me to go from a java.lang.Class object
into
> a JavaClass object, and the other way around too.
>
> Basically, I'm trying to dynamically change some class files that are
being
> loaded by a vendor specific class loader (one that doesn't get the class
> from the system's class path).  Since the .class files are not in the
class
> path, I was wondering if I could create a JavaClass object from the
> java.lang.Class object directly.
>
> Thanks,
>
> --Abel
>
>
> --
> To unsubscribe, e-mail:
<mailto:bcel-user-unsubscribe <at> jakarta.apache.org>
> For additional commands, e-mail:
<mailto:bcel-user-help <at> jakarta.apache.org>
>
(Continue reading)

Anthony La Forge | 19 Jun 2002 02:08
Picon
Favicon

Retrieving References of Methods in Methods

I'm having a little bit of a problem finding a means to parse out the method
references of a given function.  Basically I'm attempting to do the
following:

1.) Search for a method in the main class that takes a specific parameter
(e.g. boolean Process(Workflow workflow) )(No Problem here)

2.) Upon finding that method, introspect it, and look for function calls to
objects on its parameters list.  In my case it's a "Workflow" object and I'm
looking for workflow.get(String) and workflow.set(String, Object) command.
(This is basically so I can generate a set of pre-conditions and
post-conditions for a workitem).

For #2 I've tried just about every API call I could think of, but none of
them proved fruitful, including Code which looked fairly promising but ended
up delivering nothing better than a string containing a trace of the byte
code (albeit the specific byte code for the string, which in something I
cannot say about the constantPool).

At anyrate, does anyone have an idea how I could perform this operation
using BCEL?  Any ideas would be greatly appreciated.

Regards,

Anthony
Peter Lundin | 19 Jun 2002 10:50
Picon
Favicon

BCELifier

Hi,

I am using the BCELifier to get started with BCEL and it is really great. However I have problem with finally
and synchronized statements like the ones below. I get a NullPointerException which I suspect is due to
the handling of the Any Exception?
Is there a workaound or a patch available?

static void test0() {
        System.out.println("enter test0");
        try {
            System.out.println("doing something test0");
        } finally {
            System.out.println("exit test0");
        }
    }

    static void test1() {
        Object obj = new Object();
        synchronized (obj) {
            System.out.println("doing something test1");
        }
    }

Exception in thread "main" java.lang.NullPointerException
        at org.apache.bcel.util.BCELifier.printType(BCELifier.java:262)
        at org.apache.bcel.util.BCELFactory.updateExceptionHandlers(BCELFactory.java:340)
        at org.apache.bcel.util.BCELFactory.start(BCELFactory.java:108)
        at org.apache.bcel.util.BCELifier.visitMethod(BCELifier.java:213)
        at org.apache.bcel.classfile.Method.accept(Method.java:115)
        at org.apache.bcel.util.BCELifier.visitJavaClass(BCELifier.java:143)
(Continue reading)

markus.dahm | 22 Jun 2002 14:40
Picon
Favicon

Re: JavaClass to Class


> 
> Von: "Abel Wang" <abelw <at> nvisionsoftware.net>
> Datum: 2002/06/18 Di AM 05:24:06 GMT+02:00
> An: "BCEL Users List" <bcel-user <at> jakarta.apache.org>
> Betreff: JavaClass to Class
> 
> Hi BCEL users, I've been playing around with BCEL for a while now and was
> wondering if there's any way for me to go from a java.lang.Class object into
> a JavaClass object, and the other way around too.

The "other way around" would be to load the class
via a class loader.

> Basically, I'm trying to dynamically change some class files that are being
> loaded by a vendor specific class loader (one that doesn't get the class
> from the system's class path).  Since the .class files are not in the class
> path, I was wondering if I could create a JavaClass object from the
> java.lang.Class object directly.

You can load the class file corresponding to the
given class, see the corresponding method in the
Repository.

Cheers
  markus

--
berlin.de - meine stadt im netz. Jetzt eigene eMail-adresse  <at> berlin.de sichern!
http://webmail.berlin.de

++++++++++++++++++++++++++++++++++++++++++++++++
7 CITIES SUMMER
(Continue reading)

markus.dahm | 22 Jun 2002 14:42
Picon
Favicon

AW: BCELifier


> Hi,
> 
> I am using the BCELifier to get started with BCEL and it is really great. However I have problem with finally
and synchronized statements like the ones below. I get a NullPointerException which I suspect is due to
the handling of the Any Exception?
> Is there a workaound or a patch available?

I'll take a look at it as soon I get back from my 
vacation :-)

Cheers
  Markus

> 
> static void test0() {
>         System.out.println("enter test0");
>         try {
>             System.out.println("doing something test0");
>         } finally {
>             System.out.println("exit test0");
>         }
>     }
> 
>     static void test1() {
>         Object obj = new Object();
>         synchronized (obj) {
>             System.out.println("doing something test1");
>         }
>     }
(Continue reading)


Gmane