Forrest Sondahl | 8 Feb 2006 02:38
Picon

Resource problems with JavaWrapper?

I'm working on a fairly large project, that has a fully developed UI, etc.
I'm trying to integrate bytecode authoring capabilities into it, but I
run into the following problem.

When I run the program with BCEL's JavaWrapper, I get this error on
Windows machines, using Java version "1.5.0_06-b05" :

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
       at com.sun.java.swing.SwingUtilities2.drawTextAntialiased(SwingUtilities2.java:134)
       at com.sun.java.swing.SwingUtilities2.drawString(SwingUtilities2.java:397)
...

On Java 1.4.2, I get this error:

java.lang.reflect.InvocationTargetException
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.apache.bcel.util.JavaWrapper.runMain(JavaWrapper.java:127)
       at org.apache.bcel.util.JavaWrapper.main(JavaWrapper.java:149)
Caused by: java.lang.UnsatisfiedLinkError: getTextResourceByInt
       at com.sun.java.swing.plaf.windows.XPStyle.getTextResourceByInt(Native
Method)
...

It runs fine on Mac machines though.

I believe the errors are related to resources failing to load.  Has
(Continue reading)

roopa kannan | 23 Feb 2006 01:52
Picon

Fetching IF operands

Hi,

I have this requirement of fetching the operands of the IfInstruction from
the class file,
I am looking for help on how to proceed to fetch the operand values of
IfInstructions
I could find how many operands the IfInstruction consumes
using the consumestack method
but i want to find the actual operands
can anyone guide me how to proceed

Thankyou very much
Dave Brosius | 23 Feb 2006 06:29
Picon
Favicon

Re: Fetching IF operands

From the MethodGen, you can get an InstructionList, from which you can get a 
list of Instructions.
Once you've found the Instruction that represents the if statement you want,
cast it to an IfInstruction

From there you can get the target offset (the operand)

----- Original Message ----- 
From: "roopa kannan" <roopakannan <at> gmail.com>
To: <bcel-user <at> jakarta.apache.org>
Sent: Wednesday, February 22, 2006 7:52 PM
Subject: Fetching IF operands

Hi,

I have this requirement of fetching the operands of the IfInstruction from
the class file,
I am looking for help on how to proceed to fetch the operand values of
IfInstructions
I could find how many operands the IfInstruction consumes
using the consumestack method
but i want to find the actual operands
can anyone guide me how to proceed

Thankyou very much
email_ricevute_da-bcel | 23 Feb 2006 18:53
Picon
Favicon

problems with the Repository

Hello.
I have same problems with the Repository of bcel.
I would like to load a class received by command line
to change its bytecode.
Actually my project load correctly the class files if
they are in the same directory of my program, but I
got a NullPointerException if I try to load a class in
another directory.

My source code is the following:
...
if(!new File(classFileName+".class").isFile())   
  System.out.println("The file doesn't exists");
else {
  JavaClass clazz =
Repository.lookupClass(classFileName);
  Method[] methods = clazz.getMethods();
...

If, for example, classFileName == prova\Prova, I'm
sure that the file exists for the if clause, but the
command lookupClass fail the load and return null.

Someone can help me?

Thanks.

---------------------------------
Debendetti Emanuele
sanremo.too.it
(Continue reading)

roopa kannan | 25 Feb 2006 20:48
Picon

Fetching If operands

Hi dbrosius,

Thanks a lot for your reply,
By fetching if operands I meant fetching operands of the IF instruction in
the java source file not the class file, guess i worded it wrong.
Basically i want to get the operands of the load instructions, so i can look
up the local variable table for the name of the variable.
Any help in this regard would be highly appreciated.

Thank you very much
Roopa
Dave Brosius | 25 Feb 2006 20:51
Picon
Favicon

Re: Fetching If operands

well, practically speaking you can only fetch constants that are on the 
stack, and/or the static types of those items. You can look for LDCs for 
instance before the if statements, and look at those values.

----- Original Message ----- 
From: "roopa kannan" <roopakannan <at> gmail.com>
To: <bcel-user <at> jakarta.apache.org>
Sent: Saturday, February 25, 2006 2:48 PM
Subject: Fetching If operands

Hi dbrosius,

Thanks a lot for your reply,
By fetching if operands I meant fetching operands of the IF instruction in
the java source file not the class file, guess i worded it wrong.
Basically i want to get the operands of the load instructions, so i can look
up the local variable table for the name of the variable.
Any help in this regard would be highly appreciated.

Thank you very much
Roopa
Dave Brosius | 26 Feb 2006 08:18
Picon
Favicon

Re: problems with the Repository

don't use backslashes to specify class package names.

you should be able to use package syntax

prova.Prova

or

internal format syntax

prova/Prova

----- Original Message ----- 
From: <email_ricevute_da-bcel <at> yahoo.it>
To: "BCEL Users List" <bcel-user <at> jakarta.apache.org>
Sent: Thursday, February 23, 2006 12:53 PM
Subject: problems with the Repository

> Hello.
> I have same problems with the Repository of bcel.
> I would like to load a class received by command line
> to change its bytecode.
> Actually my project load correctly the class files if
> they are in the same directory of my program, but I
> got a NullPointerException if I try to load a class in
> another directory.
> 
> My source code is the following:
> ...
> if(!new File(classFileName+".class").isFile())   
(Continue reading)

Pico Florin | 2 Mar 2006 16:21
Picon
Favicon

Get InnerClass and AnonymousClass fusing BCEL API

Hi!
    I'm new in BCEL. I've just tested your API and I want to ask you this:
  1.how can I obtain the Inner Classes and Anonymous as JavaClass class  in order to treat them like this(i.e.
to see what are their fields,  methods etc). To be more specific, I want to have the same  functionality like
the method getDeclaredClasses() from the  java.lang.Class. Is this possible with your API?
  2. It is possible with  your API to obtain the anonymous class  defined in a code like this(the method
mentioned above  getDeclaredClasses doesn't report it)

  public static void main(String[] args) {
          javax.swing.SwingUtilities.invokeLater(new Runnable() {
              public void run() {
                  createAndShowGUI();
              }
          });
     }

  Thank you in advance,
       Florin

  
		
---------------------------------
Yahoo! Messenger  NEW - crystal clear PC to PC calling worldwide with voicemail 
Pico Florin | 3 Mar 2006 10:14
Picon
Favicon

Get imported packages using BCEL

Hi!
    It is possible to use BCEL API to obtain the imported packages(classes) from a java binary code? 
   Thank you in advance,
          Florin

		
---------------------------------
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre.
Dave Brosius | 3 Mar 2006 13:48
Picon
Favicon

Re: Get imported packages using BCEL

Not directly. You can look at all the instructions and look for 
INVOKEVIRTUAL, INVOKESTATIC, INVOKESPECIAL, INVOKEINTERFACE, and find all of 
the classes specified. And from that assume the list of imports, You would 
have to do the same
for imports for member variables, as well. The problem idea falls apart for 
imports for of classes to access static final variables. In this case
the variable is directly accessed from the importing class, without 
reference to the class where the variable is defined.

So, the answer is no you can't, and what you can get isn't pleasant.

I'm not sure
----- Original Message ----- 
From: "Pico Florin" <picoflorin <at> yahoo.co.uk>
To: <bcel-user <at> jakarta.apache.org>
Sent: Friday, March 03, 2006 4:14 AM
Subject: Get imported packages using BCEL

> Hi!
>    It is possible to use BCEL API to obtain the imported packages(classes) 
> from a java binary code?
>   Thank you in advance,
>          Florin
>
>
> ---------------------------------
> To help you stay safe and secure online, we've developed the all new 
> Yahoo! Security Centre. 

Gmane