• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<?xml version="1.0"?>
2<!--
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10    *
11    *   http://www.apache.org/licenses/LICENSE-2.0
12    *
13    * Unless required by applicable law or agreed to in writing,
14    * software distributed under the License is distributed on an
15    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16    * KIND, either express or implied.  See the License for the
17    * specific language governing permissions and limitations
18    * under the License.
19-->
20
21<document>
22
23  <properties>
24    <title>BCEL FAQ</title>
25  </properties>
26
27  <body>
28
29  <section name="FAQ">
30    <p>
31      <b>Q: </b>How can I ... with BCEL?
32      <br/>
33      <b>A: </b>Take a look at
34      <tt>org.apache.bcel.util.BCELifier</tt>, it takes a given class
35      and converts it to a BCEL program (in Java, of course). It will
36      show you how certain code is generated using BCEL.
37    </p>
38
39    <p>
40      <b>Q: </b> Is the BCEL thread-safe?
41      <br/>
42      <b>A: </b>BCEL was (deliberately) not designed for thread
43      safety. See <a href="http://java.sun.com/docs/books/cp/">
44      "Concurrent Programming in Java"</a>, by Doug Lea,
45      for an excellent reference on how to build thread-safe wrappers.
46    </p>
47
48    <p>
49      <b>Q: </b> Can I use BCEL in a commercial product?
50      <br/>
51      <b>A: </b> Yes, this is covered by the <a
52      href="http://www.apache.org/licenses/">Apache License</a>, if you add a note about the original
53      author and where to find the sources, i.e.,
54      <a href="http://commons.apache.org/bcel/">http://commons.apache.org/bcel/</a>
55    </p>
56
57    <p>
58      <b>Q: </b> (Typically for users of Xalan (XSLTC)) I'm getting
59      <pre>
60      ClassGenException: Branch target offset too large for short
61      </pre>
62      when compiling large files.
63      <br/>
64
65      <b>A: </b> The answer lies in internal limitations of the JVM,
66      branch instruction like goto can not address offsets larger than
67      a short integer, i.e. offsets >= 32767.<br/>
68      The solution is to split the branch into in intermediate hops,
69      which the XSLTC obviously doesn't take care off.
70      (In fact you could replace gotos with the goto_w instruction,
71      but this wouldn't help in the other cases).
72    </p>
73
74    <p>
75      <b>Q:</b> Can I create or modify classes dynamically with BCEL?
76      <br/>
77      <b>A:</b> BCEL contains useful classes in the
78      <tt>util</tt> package, namely <tt>ClassLoader</tt> and
79       <tt>JavaWrapper</tt>. Take a look at the <tt> ProxyCreator</tt> example.
80    </p>
81
82    <p>
83      <b>Q:</b> I get a verification error, what can I do?
84      <br/>
85      <b>A:</b> Use the JustIce verifier that comes together with BCEL
86      to get more detailed information:
87       <pre>
88       java org.apache.bcel.verifier.Verifier &lt;your class&gt;</pre>
89    </p>
90
91    </section>
92<!--
93    <p>
94      <b>Q: </b>
95      <br/>
96      <b>A: </b>
97    </p>
98-->
99</body>
100</document>
101