Apache Commons logo Commons BCEL
Apache Commons BCEL ™
  • Last Published: 09 Oct 2025
  • |
  • Version: 6.11.0

FAQ

Q: How can I ... with BCEL?
A: Take a look at org.apache.bcel.util.BCELifier, it takes a given class and converts it to a BCEL program (in Java, of course). It will show you how certain code is generated using BCEL.

Q: Is the BCEL thread-safe?
A: BCEL was (deliberately) not designed for thread safety. See "Concurrent Programming in Java", by Doug Lea, for an excellent reference on how to build thread-safe wrappers and more.

Q: Can I use BCEL in a commercial product?
A: Yes, this is covered by the Apache License, if you add a note about the original author and where to find the sources, i.e., https://commons.apache.org/bcel/

Q: (Typically for users of Xalan (XSLTC)) I'm getting

ClassGenException: Branch target offset too large for short

when compiling large files.

A: The answer lies in internal limitations of the JVM, branch instruction like goto can not address offsets larger than a short integer, i.e. offsets >= 32767.
The solution is to split the branch into in intermediate hops, which the XSLTC obviously doesn't take care off. (In fact you could replace gotos with the goto_w instruction, but this wouldn't help in the other cases).

Q: Can I create or modify classes dynamically with BCEL?
A: BCEL contains useful classes in the util package, namely ClassLoader and JavaWrapper. Take a look at the ProxyCreator example.

Q: I get a verification error, what can I do?
A: Use the JustIce verifier that comes together with BCEL to get more detailed information:

java org.apache.bcel.verifier.Verifier <your class>

Copyright © 2004-2025 The Apache Software Foundation. All Rights Reserved.

Apache Commons, Apache Commons BCEL, Apache, the Apache logo, and the Apache Commons project logos are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.

AltStyle によって変換されたページ (->オリジナル) /