a colleague pointed me the other day to BCEL which , as best I can tell from his explanation and a quick read, a way to modify at run time the byte code. My first thought was that it sounded dangerous, and my second thought was that it sounded cool. Then I gave it some more thought and I recalled the codinghorror post on monkey-patchin...
I'm playing around with BCEL. I'm not using it to generate bytecode, but instead I'm trying to inspect the structure of existing compiled classes.
I need to be able to point to an arbitrary .class file anywhere on my hard drive and load a JavaClass object based on that. Ideally I'd like to avoid having to add the given class to my cla...
I would like to initialize static fields in the static initializer of a class; and this in bcel. I haven't found a way to do so however... any hints?
I need something like:
// Field descriptor #8 [I
private static int[] a;
static {};
0 bipush 10
2 multianewarray int[] [9]
6 putstatic Output.a : int[] [11]
9 ret...
I installed findbugs into my ant lib directory and added the following code into my main ANT script:
<target name="findbugs" depends="init">
<findbugs home="C:\\findbugs\\" output="html outputFile="C:\\findbugs\\out.html" jvmargs="-Xms512M">
<sourcePath path="${messageaggregator.src}" />
<class location="${messageag...
I'm working on a simple build script that should get some constants from a java class file and use them as the version numbers in my file names. I use Eclipse and its own Ant, but put bcel-5.2.jar in my libs folder and into the classpath for the Ant call.
<target name="generate_version" depends="compile">
<loadproperties srcfile="${dir...
Given a line number, the code file, as well as the compiled class file if necessary, what is the most elegant way to get the signature of the surrounding method (if the line number is even in a method)?
Things to keep in mind:
the line might not even be in a method
the line might be in a method of an inner or anonymous class
While...
I am currently instrumenting bytecode using BCEL. In the BCEL API, the two instructions types LOOKUPSWITCH and TABLESWITCH (package org.apache.bcel.generic) are implementing interface StackProducer. I know that these two instructions pop the operand stack (i.e. consume it) and do not produce anything on the stack, so how come they implem...
I'm trying to switch the class loader at runtime:
public class Test {
public static void main(String[] args) throws Exception {
final InjectingClassLoader classLoader = new InjectingClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
Thread thread = new Thread("test") {
publi...
Hi,
I am trying to analyse a Maven project with Findbugs, as follows:
mvn org.codehaus.mojo:findbugs-maven-plugin:2.3.1:findbugs
The build is successfull, but there is no trace of the analysis reports and I also get the following output:
[INFO] [findbugs:findbugs {execution: default-cli}]
[INFO] Locale is en
[java] BCEL class compa...