You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-dev@jakarta.apache.org by tc...@apache.org on 2006/03/15 12:33:43 UTC
svn commit: r386056 [2/28] - in /jakarta/bcel/trunk: examples/
examples/Mini/ src/java/org/apache/bcel/
src/java/org/apache/bcel/classfile/ src/java/org/apache/bcel/generic/
src/java/org/apache/bcel/util/ src/java/org/apache/bcel/verifier/
src/java/org...
Modified: jakarta/bcel/trunk/examples/Mini/MiniParserTokenManager.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/examples/Mini/MiniParserTokenManager.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/examples/Mini/MiniParserTokenManager.java (original)
+++ jakarta/bcel/trunk/examples/Mini/MiniParserTokenManager.java Wed Mar 15 03:31:56 2006
@@ -39,16 +39,16 @@
}
static private final int jjMoveNfa_1(int startState, int curPos)
{
- int[] nextStates;
int startsAt = 0;
jjnewStateCnt = 3;
int i = 1;
jjstateSet[0] = startState;
- int j, kind = 0x7fffffff;
+ int kind = 0x7fffffff;
for (;;)
{
- if (++jjround == 0x7fffffff)
- ReInitRounds();
+ if (++jjround == 0x7fffffff) {
+ ReInitRounds();
+ }
if (curChar < 64)
{
long l = 1L << curChar;
@@ -59,19 +59,23 @@
case 0:
if ((0x2400L & l) != 0L)
{
- if (kind > 7)
+ if (kind > 7) {
kind = 7;
+ }
}
- if (curChar == 13)
- jjstateSet[jjnewStateCnt++] = 1;
+ if (curChar == 13) {
+ jjstateSet[jjnewStateCnt++] = 1;
+ }
break;
case 1:
- if (curChar == 10 && kind > 7)
- kind = 7;
+ if (curChar == 10 && kind > 7) {
+ kind = 7;
+ }
break;
case 2:
- if (curChar == 13)
- jjstateSet[jjnewStateCnt++] = 1;
+ if (curChar == 13) {
+ jjstateSet[jjnewStateCnt++] = 1;
+ }
break;
default : break;
}
@@ -79,7 +83,6 @@
}
else if (curChar < 128)
{
- long l = 1L << (curChar & 077);
do
{
switch(jjstateSet[--i])
@@ -90,8 +93,6 @@
}
else
{
- int i2 = (curChar & 0xff) >> 6;
- long l2 = 1L << (curChar & 077);
do
{
switch(jjstateSet[--i])
@@ -107,8 +108,9 @@
kind = 0x7fffffff;
}
++curPos;
- if ((i = jjnewStateCnt) == (startsAt = 3 - (jjnewStateCnt = startsAt)))
- return curPos;
+ if ((i = jjnewStateCnt) == (startsAt = 3 - (jjnewStateCnt = startsAt))) {
+ return curPos;
+ }
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) { return curPos; }
}
@@ -125,8 +127,9 @@
}
return -1;
case 1:
- if ((active0 & 0x400a400L) != 0L)
+ if ((active0 & 0x400a400L) != 0L) {
return 1;
+ }
if ((active0 & 0x3003805a00L) != 0L)
{
jjmatchedKind = 40;
@@ -135,8 +138,9 @@
}
return -1;
case 2:
- if ((active0 & 0x2004200L) != 0L)
+ if ((active0 & 0x2004200L) != 0L) {
return 1;
+ }
if ((active0 & 0x3001801800L) != 0L)
{
jjmatchedKind = 40;
@@ -151,8 +155,9 @@
jjmatchedPos = 3;
return 1;
}
- if ((active0 & 0x1001001800L) != 0L)
+ if ((active0 & 0x1001001800L) != 0L) {
return 1;
+ }
return -1;
default :
return -1;
@@ -241,42 +246,48 @@
switch(curChar)
{
case 45:
- if ((active0 & 0x40L) != 0L)
+ if ((active0 & 0x40L) != 0L) {
return jjStopAtPos(1, 6);
+ }
break;
case 61:
- if ((active0 & 0x40000L) != 0L)
+ if ((active0 & 0x40000L) != 0L) {
return jjStopAtPos(1, 18);
- else if ((active0 & 0x80000L) != 0L)
+ } else if ((active0 & 0x80000L) != 0L) {
return jjStopAtPos(1, 19);
- else if ((active0 & 0x100000L) != 0L)
+ } else if ((active0 & 0x100000L) != 0L) {
return jjStopAtPos(1, 20);
- else if ((active0 & 0x200000L) != 0L)
+ } else if ((active0 & 0x200000L) != 0L) {
return jjStopAtPos(1, 21);
+ }
break;
case 65:
return jjMoveStringLiteralDfa2_0(active0, 0x800000L);
case 69:
return jjMoveStringLiteralDfa2_0(active0, 0x1000004000L);
case 70:
- if ((active0 & 0x400L) != 0L)
+ if ((active0 & 0x400L) != 0L) {
return jjStartNfaWithStates_0(1, 10, 1);
+ }
break;
case 72:
return jjMoveStringLiteralDfa2_0(active0, 0x800L);
case 73:
- if ((active0 & 0x2000L) != 0L)
+ if ((active0 & 0x2000L) != 0L) {
return jjStartNfaWithStates_0(1, 13, 1);
+ }
break;
case 76:
return jjMoveStringLiteralDfa2_0(active0, 0x1000L);
case 78:
- if ((active0 & 0x8000L) != 0L)
+ if ((active0 & 0x8000L) != 0L) {
return jjStartNfaWithStates_0(1, 15, 1);
+ }
return jjMoveStringLiteralDfa2_0(active0, 0x2000000L);
case 82:
- if ((active0 & 0x4000000L) != 0L)
+ if ((active0 & 0x4000000L) != 0L) {
return jjStartNfaWithStates_0(1, 26, 1);
+ }
return jjMoveStringLiteralDfa2_0(active0, 0x2001000000L);
case 85:
return jjMoveStringLiteralDfa2_0(active0, 0x200L);
@@ -287,8 +298,9 @@
}
static private final int jjMoveStringLiteralDfa2_0(long old0, long active0)
{
- if (((active0 &= old0)) == 0L)
- return jjStartNfa_0(0, old0);
+ if (((active0 &= old0)) == 0L) {
+ return jjStartNfa_0(0, old0);
+}
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(1, active0);
@@ -299,8 +311,9 @@
case 65:
return jjMoveStringLiteralDfa3_0(active0, 0x1000000000L);
case 68:
- if ((active0 & 0x2000000L) != 0L)
+ if ((active0 & 0x2000000L) != 0L) {
return jjStartNfaWithStates_0(2, 25, 1);
+ }
break;
case 69:
return jjMoveStringLiteralDfa3_0(active0, 0x800L);
@@ -309,14 +322,16 @@
case 76:
return jjMoveStringLiteralDfa3_0(active0, 0x800000L);
case 78:
- if ((active0 & 0x200L) != 0L)
+ if ((active0 & 0x200L) != 0L) {
return jjStartNfaWithStates_0(2, 9, 1);
+ }
break;
case 83:
return jjMoveStringLiteralDfa3_0(active0, 0x1000L);
case 84:
- if ((active0 & 0x4000L) != 0L)
+ if ((active0 & 0x4000L) != 0L) {
return jjStartNfaWithStates_0(2, 14, 1);
+ }
break;
case 85:
return jjMoveStringLiteralDfa3_0(active0, 0x1000000L);
@@ -327,8 +342,9 @@
}
static private final int jjMoveStringLiteralDfa3_0(long old0, long active0)
{
- if (((active0 &= old0)) == 0L)
- return jjStartNfa_0(1, old0);
+ if (((active0 &= old0)) == 0L) {
+ return jjStartNfa_0(1, old0);
+}
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(2, active0);
@@ -337,18 +353,21 @@
switch(curChar)
{
case 68:
- if ((active0 & 0x1000000000L) != 0L)
+ if ((active0 & 0x1000000000L) != 0L) {
return jjStartNfaWithStates_0(3, 36, 1);
+ }
break;
case 69:
- if ((active0 & 0x1000L) != 0L)
+ if ((active0 & 0x1000L) != 0L) {
return jjStartNfaWithStates_0(3, 12, 1);
- else if ((active0 & 0x1000000L) != 0L)
+ } else if ((active0 & 0x1000000L) != 0L) {
return jjStartNfaWithStates_0(3, 24, 1);
+ }
break;
case 78:
- if ((active0 & 0x800L) != 0L)
+ if ((active0 & 0x800L) != 0L) {
return jjStartNfaWithStates_0(3, 11, 1);
+ }
break;
case 83:
return jjMoveStringLiteralDfa4_0(active0, 0x800000L);
@@ -361,8 +380,9 @@
}
static private final int jjMoveStringLiteralDfa4_0(long old0, long active0)
{
- if (((active0 &= old0)) == 0L)
- return jjStartNfa_0(2, old0);
+ if (((active0 &= old0)) == 0L) {
+ return jjStartNfa_0(2, old0);
+}
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(3, active0);
@@ -371,10 +391,11 @@
switch(curChar)
{
case 69:
- if ((active0 & 0x800000L) != 0L)
+ if ((active0 & 0x800000L) != 0L) {
return jjStartNfaWithStates_0(4, 23, 1);
- else if ((active0 & 0x2000000000L) != 0L)
+ } else if ((active0 & 0x2000000000L) != 0L) {
return jjStartNfaWithStates_0(4, 37, 1);
+ }
break;
default :
break;
@@ -386,16 +407,16 @@
};
static private final int jjMoveNfa_0(int startState, int curPos)
{
- int[] nextStates;
int startsAt = 0;
jjnewStateCnt = 6;
int i = 1;
jjstateSet[0] = startState;
- int j, kind = 0x7fffffff;
+ int kind = 0x7fffffff;
for (;;)
{
- if (++jjround == 0x7fffffff)
- ReInitRounds();
+ if (++jjround == 0x7fffffff) {
+ ReInitRounds();
+ }
if (curChar < 64)
{
long l = 1L << curChar;
@@ -406,38 +427,47 @@
case 0:
if ((0x3ff000000000000L & l) != 0L)
{
- if (kind > 41)
+ if (kind > 41) {
kind = 41;
+ }
jjCheckNAdd(2);
}
- else if (curChar == 34)
- jjCheckNAddTwoStates(4, 5);
+ else if (curChar == 34) {
+ jjCheckNAddTwoStates(4, 5);
+ }
break;
case 1:
- if ((0x3ff000000000000L & l) == 0L)
- break;
- if (kind > 40)
- kind = 40;
+ if ((0x3ff000000000000L & l) == 0L) {
+ break;
+ }
+ if (kind > 40) {
+ kind = 40;
+ }
jjstateSet[jjnewStateCnt++] = 1;
break;
case 2:
- if ((0x3ff000000000000L & l) == 0L)
- break;
- if (kind > 41)
- kind = 41;
+ if ((0x3ff000000000000L & l) == 0L) {
+ break;
+ }
+ if (kind > 41) {
+ kind = 41;
+ }
jjCheckNAdd(2);
break;
case 3:
- if (curChar == 34)
- jjCheckNAddTwoStates(4, 5);
+ if (curChar == 34) {
+ jjCheckNAddTwoStates(4, 5);
+ }
break;
case 4:
- if ((0xfffffffbffffdbffL & l) != 0L)
- jjCheckNAddTwoStates(4, 5);
+ if ((0xfffffffbffffdbffL & l) != 0L) {
+ jjCheckNAddTwoStates(4, 5);
+ }
break;
case 5:
- if (curChar == 34 && kind > 42)
- kind = 42;
+ if (curChar == 34 && kind > 42) {
+ kind = 42;
+ }
break;
default : break;
}
@@ -451,17 +481,21 @@
switch(jjstateSet[--i])
{
case 0:
- if ((0x7fffffe07fffffeL & l) == 0L)
- break;
- if (kind > 40)
- kind = 40;
+ if ((0x7fffffe07fffffeL & l) == 0L) {
+ break;
+ }
+ if (kind > 40) {
+ kind = 40;
+ }
jjCheckNAdd(1);
break;
case 1:
- if ((0x7fffffe87fffffeL & l) == 0L)
- break;
- if (kind > 40)
- kind = 40;
+ if ((0x7fffffe87fffffeL & l) == 0L) {
+ break;
+ }
+ if (kind > 40) {
+ kind = 40;
+ }
jjCheckNAdd(1);
break;
case 4:
@@ -480,8 +514,9 @@
switch(jjstateSet[--i])
{
case 4:
- if ((jjbitVec0[i2] & l2) != 0L)
- jjAddStates(0, 1);
+ if ((jjbitVec0[i2] & l2) != 0L) {
+ jjAddStates(0, 1);
+ }
break;
default : break;
}
@@ -494,8 +529,9 @@
kind = 0x7fffffff;
}
++curPos;
- if ((i = jjnewStateCnt) == (startsAt = 6 - (jjnewStateCnt = startsAt)))
- return curPos;
+ if ((i = jjnewStateCnt) == (startsAt = 6 - (jjnewStateCnt = startsAt))) {
+ return curPos;
+ }
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) { return curPos; }
}
@@ -539,8 +575,9 @@
static protected char curChar;
public MiniParserTokenManager(ASCII_CharStream stream)
{
- if (input_stream != null)
- throw new TokenMgrError("ERROR: Second call to constructor of static lexer. You must use ReInit() to initialize the static variables.", TokenMgrError.STATIC_LEXER_ERROR);
+ if (input_stream != null) {
+ throw new TokenMgrError("ERROR: Second call to constructor of static lexer. You must use ReInit() to initialize the static variables.", TokenMgrError.STATIC_LEXER_ERROR);
+}
input_stream = stream;
}
public MiniParserTokenManager(ASCII_CharStream stream, int lexState)
@@ -559,8 +596,9 @@
{
int i;
jjround = 0x80000001;
- for (i = 6; i-- > 0;)
- jjrounds[i] = 0x80000000;
+ for (i = 6; i-- > 0;) {
+ jjrounds[i] = 0x80000000;
+}
}
static public void ReInit(ASCII_CharStream stream, int lexState)
{
@@ -569,10 +607,11 @@
}
static public void SwitchTo(int lexState)
{
- if (lexState >= 2 || lexState < 0)
- throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
- else
- curLexState = lexState;
+ if (lexState >= 2 || lexState < 0) {
+ throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
+} else {
+ curLexState = lexState;
+}
}
static private final Token jjFillToken()
@@ -597,7 +636,6 @@
public static final Token getNextToken()
{
- int kind;
Token specialToken = null;
Token matchedToken;
int curPos = 0;
@@ -625,8 +663,9 @@
{
case 0:
try { input_stream.backup(0);
- while (curChar <= 32 && (0x100003600L & (1L << curChar)) != 0L)
- curChar = input_stream.BeginToken();
+ while (curChar <= 32 && (0x100003600L & (1L << curChar)) != 0L) {
+ curChar = input_stream.BeginToken();
+ }
}
catch (java.io.IOException e1) { continue EOFLoop; }
jjmatchedKind = 0x7fffffff;
@@ -645,14 +684,16 @@
}
if (jjmatchedKind != 0x7fffffff)
{
- if (jjmatchedPos + 1 < curPos)
- input_stream.backup(curPos - jjmatchedPos - 1);
+ if (jjmatchedPos + 1 < curPos) {
+ input_stream.backup(curPos - jjmatchedPos - 1);
+ }
if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
{
matchedToken = jjFillToken();
matchedToken.specialToken = specialToken;
- if (jjnewLexState[jjmatchedKind] != -1)
- curLexState = jjnewLexState[jjmatchedKind];
+ if (jjnewLexState[jjmatchedKind] != -1) {
+ curLexState = jjnewLexState[jjmatchedKind];
+ }
return matchedToken;
}
else if ((jjtoSkip[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
@@ -660,24 +701,26 @@
if ((jjtoSpecial[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
{
matchedToken = jjFillToken();
- if (specialToken == null)
- specialToken = matchedToken;
- else
+ if (specialToken == null) {
+ specialToken = matchedToken;
+ } else
{
matchedToken.specialToken = specialToken;
specialToken = (specialToken.next = matchedToken);
}
SkipLexicalActions(matchedToken);
- }
- else
- SkipLexicalActions(null);
- if (jjnewLexState[jjmatchedKind] != -1)
- curLexState = jjnewLexState[jjmatchedKind];
+ } else {
+ SkipLexicalActions(null);
+ }
+ if (jjnewLexState[jjmatchedKind] != -1) {
+ curLexState = jjnewLexState[jjmatchedKind];
+ }
continue EOFLoop;
}
jjimageLen += jjmatchedPos + 1;
- if (jjnewLexState[jjmatchedKind] != -1)
+ if (jjnewLexState[jjmatchedKind] != -1) {
curLexState = jjnewLexState[jjmatchedKind];
+ }
curPos = 0;
jjmatchedKind = 0x7fffffff;
try {
@@ -697,9 +740,9 @@
if (curChar == '\n' || curChar == '\r') {
error_line++;
error_column = 0;
+ } else {
+ error_column++;
}
- else
- error_column++;
}
if (!EOFSeen) {
input_stream.backup(1);
Modified: jakarta/bcel/trunk/examples/Mini/ParseException.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/examples/Mini/ParseException.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/examples/Mini/ParseException.java (original)
+++ jakarta/bcel/trunk/examples/Mini/ParseException.java Wed Mar 15 03:31:56 2006
@@ -115,7 +115,9 @@
String retval = "Encountered \"";
Token tok = currentToken.next;
for (int i = 0; i < maxSize; i++) {
- if (i != 0) retval += " ";
+ if (i != 0) {
+ retval += " ";
+ }
if (tok.kind == 0) {
retval += tokenImage[0];
break;
Modified: jakarta/bcel/trunk/examples/Mini/Variable.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/examples/Mini/Variable.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/examples/Mini/Variable.java (original)
+++ jakarta/bcel/trunk/examples/Mini/Variable.java Wed Mar 15 03:31:56 2006
@@ -29,10 +29,11 @@
}
public String toString() {
- if(!reserved)
- return var_name + " declared at line " + line + ", column " + column;
- else
- return var_name + " <reserved key word>";
+ if(!reserved) {
+ return var_name + " declared at line " + line + ", column " + column;
+ } else {
+ return var_name + " <reserved key word>";
+ }
}
public ASTIdent getName() { return name; }
Modified: jakarta/bcel/trunk/examples/Peephole.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/examples/Peephole.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/examples/Peephole.java (original)
+++ jakarta/bcel/trunk/examples/Peephole.java Wed Mar 15 03:31:56 2006
@@ -31,8 +31,9 @@
clazz.getClassName(), cp);
Method stripped = removeNOPs(mg);
- if(stripped != null) // Any NOPs stripped?
- methods[i] = stripped; // Overwrite with stripped method
+ if(stripped != null) {
+ methods[i] = stripped; // Overwrite with stripped method
+ }
}
}
@@ -57,8 +58,9 @@
/* Some nasty Java compilers may add NOP at end of method.
*/
- if((next = last.getNext()) == null)
- break;
+ if((next = last.getNext()) == null) {
+ break;
+ }
count += match.length;
@@ -72,8 +74,9 @@
for(int i=0; i < targets.length; i++) {
InstructionTargeter[] targeters = targets[i].getTargeters();
- for(int j=0; j < targeters.length; j++)
- targeters[j].updateTarget(targets[i], next);
+ for(int j=0; j < targeters.length; j++) {
+ targeters[j].updateTarget(targets[i], next);
+ }
}
}
}
Modified: jakarta/bcel/trunk/examples/ProxyCreator.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/examples/ProxyCreator.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/examples/ProxyCreator.java (original)
+++ jakarta/bcel/trunk/examples/ProxyCreator.java Wed Mar 15 03:31:56 2006
@@ -106,8 +106,9 @@
System.out.println("Done. Now calling actionPerformed()");
a.actionPerformed(new ActionEvent(a, ActionEvent.ACTION_PERFORMED, "hello"));
- } else
- System.err.println("Call me with java org.apache.bcel.util.JavaWrapper ProxyCreator");
+ } else {
+ System.err.println("Call me with java org.apache.bcel.util.JavaWrapper ProxyCreator");
+ }
}
}
Modified: jakarta/bcel/trunk/examples/helloify.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/examples/helloify.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/examples/helloify.java (original)
+++ jakarta/bcel/trunk/examples/helloify.java Wed Mar 15 03:31:56 2006
@@ -49,8 +49,9 @@
*/
Method[] methods = java_class.getMethods();
- for(int j=0; j < methods.length; j++) // Directly use array
- methods[j] = helloifyMethod(methods[j]);
+ for(int j=0; j < methods.length; j++) {
+ methods[j] = helloifyMethod(methods[j]);
+ }
/* Finally dump it back to a file.
*/
@@ -82,8 +83,9 @@
String name = m.getName();
// Sanity check
- if(m.isNative() || m.isAbstract() || (code == null))
- return m;
+ if(m.isNative() || m.isAbstract() || (code == null)) {
+ return m;
+ }
/* Create instruction list to be inserted at method start.
*/
@@ -106,13 +108,15 @@
break;
}
}
- } else
- il.insert(ihs[0], patch);
+ } else {
+ il.insert(ihs[0], patch);
+ }
/* Stack size must be at least 2, since the println method takes 2 argument.
*/
- if(code.getMaxStack() < 2)
- mg.setMaxStack(2);
+ if(code.getMaxStack() < 2) {
+ mg.setMaxStack(2);
+ }
m = mg.getMethod();
Modified: jakarta/bcel/trunk/examples/id.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/examples/id.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/examples/id.java (original)
+++ jakarta/bcel/trunk/examples/id.java Wed Mar 15 03:31:56 2006
@@ -27,8 +27,9 @@
public static void main(String[] argv) throws Exception {
JavaClass clazz = null;
- if((clazz = Repository.lookupClass(argv[0])) == null)
- clazz = new ClassParser(argv[0]).parse(); // May throw IOException
+ if((clazz = Repository.lookupClass(argv[0])) == null) {
+ clazz = new ClassParser(argv[0]).parse(); // May throw IOException
+ }
ClassGen cg = new ClassGen(clazz);
Modified: jakarta/bcel/trunk/examples/listclass.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/examples/listclass.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/examples/listclass.java (original)
+++ jakarta/bcel/trunk/examples/listclass.java Wed Mar 15 03:31:56 2006
@@ -74,21 +74,21 @@
*/
for(int i=0; i < argv.length; i++) {
if(argv[i].charAt(0) == '-') { // command line switch
- if(argv[i].equals("-constants"))
- constants=true;
- else if(argv[i].equals("-code"))
- code=true;
- else if(argv[i].equals("-brief"))
- verbose=false;
- else if(argv[i].equals("-dependencies"))
- classdep=true;
- else if(argv[i].equals("-nocontents"))
- nocontents=true;
- else if(argv[i].equals("-recurse"))
- recurse=true;
- else if(argv[i].equals("-exclude"))
- exclude=true;
- else if(argv[i].equals("-help")) {
+ if(argv[i].equals("-constants")) {
+ constants=true;
+ } else if(argv[i].equals("-code")) {
+ code=true;
+ } else if(argv[i].equals("-brief")) {
+ verbose=false;
+ } else if(argv[i].equals("-dependencies")) {
+ classdep=true;
+ } else if(argv[i].equals("-nocontents")) {
+ nocontents=true;
+ } else if(argv[i].equals("-recurse")) {
+ recurse=true;
+ } else if(argv[i].equals("-exclude")) {
+ exclude=true;
+ } else if(argv[i].equals("-help")) {
System.out.println( "Usage: java listclass [-constants] [-code] [-brief] " +
"[-dependencies] [-nocontents] [-recurse] class... " +
"[-exclude <list>]\n" +
@@ -101,19 +101,21 @@
"-exclude <list> Do not list classes beginning with " +
"strings in <list>" );
System.exit( 0 );
- } else
- System.err.println("Unknown switch " + argv[i] + " ignored.");
+ } else {
+ System.err.println("Unknown switch " + argv[i] + " ignored.");
+ }
} else { // add file name to list
- if(exclude)
- exclude_name.addElement(argv[i]);
- else
- file_name.addElement(argv[i]);
+ if(exclude) {
+ exclude_name.addElement(argv[i]);
+ } else {
+ file_name.addElement(argv[i]);
+ }
}
}
- if(file_name.size() == 0)
- System.err.println("list: No input files specified");
- else {
+ if(file_name.size() == 0) {
+ System.err.println("list: No input files specified");
+ } else {
listclass listClass = new listclass(code, constants, verbose, classdep,
nocontents, recurse, exclude_name);
@@ -144,12 +146,15 @@
try {
JavaClass java_class;
- if((listedClasses.get(name) != null) || name.startsWith("["))
+ if((listedClasses.get(name) != null) || name.startsWith("[")) {
return;
+ }
- for(int idx = 0; idx < exclude_name.size(); idx++)
- if(name.startsWith((String) exclude_name.elementAt(idx)))
- return;
+ for(int idx = 0; idx < exclude_name.size(); idx++) {
+ if(name.startsWith((String) exclude_name.elementAt(idx))) {
+ return;
+ }
+ }
if(name.endsWith(".class")) {
java_class = new ClassParser(name).parse(); // May throw IOException
@@ -157,27 +162,32 @@
java_class = Repository.lookupClass(name);
}
- if(nocontents)
+ if(nocontents) {
System.out.println(java_class.getClassName());
- else
+ } else {
System.out.println(java_class); // Dump the contents
+ }
- if(constants) // Dump the constant pool ?
- System.out.println(java_class.getConstantPool());
+ if(constants) {
+ System.out.println(java_class.getConstantPool());
+ }
- if(code) // Dump the method code ?
+ if(code) {
printCode(java_class.getMethods(), verbose);
+ }
- if(classdep)
+ if(classdep) {
printClassDependencies(java_class.getConstantPool());
+ }
listedClasses.put(name, name);
if(recurse) {
String[] dependencies = getClassDependencies(java_class.getConstantPool());
- for(int idx = 0; idx < dependencies.length; idx++)
- list(dependencies[idx]);
+ for(int idx = 0; idx < dependencies.length; idx++) {
+ list(dependencies[idx]);
+ }
}
} catch(IOException e) {
System.out.println("Error loading class " + name + " (" + e.getMessage() + ")");
@@ -193,8 +203,9 @@
public static void printClassDependencies(ConstantPool pool) {
String[] names = getClassDependencies(pool);
System.out.println("Dependencies:");
- for(int idx = 0; idx < names.length; idx++)
- System.out.println("\t" + names[idx]);
+ for(int idx = 0; idx < names.length; idx++) {
+ System.out.println("\t" + names[idx]);
+ }
}
public static String[] getClassDependencies(ConstantPool pool) {
@@ -209,8 +220,9 @@
buf.setLength(0);
buf.append(c1.getBytes());
for(int n = 0; n < buf.length(); n++) {
- if(buf.charAt(n) == '/')
+ if(buf.charAt(n) == '/') {
buf.setCharAt(n, '.');
+ }
}
tempArray[size++] = buf.toString();
@@ -230,8 +242,9 @@
System.out.println(methods[i]);
Code code = methods[i].getCode();
- if(code != null)
- System.out.println(code.toString(verbose));
+ if(code != null) {
+ System.out.println(code.toString(verbose));
+ }
}
}
}
Modified: jakarta/bcel/trunk/examples/maxstack.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/examples/maxstack.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/examples/maxstack.java (original)
+++ jakarta/bcel/trunk/examples/maxstack.java Wed Mar 15 03:31:56 2006
@@ -19,8 +19,9 @@
String class_name = argv[i];
JavaClass java_class = Repository.lookupClass(class_name);
- if(java_class == null) // Look for .class file?
- java_class = new ClassParser(class_name).parse();
+ if(java_class == null) {
+ java_class = new ClassParser(class_name).parse();
+ }
ConstantPoolGen cp = new ConstantPoolGen(java_class.getConstantPool());
Method[] methods = java_class.getMethods();
@@ -42,17 +43,19 @@
System.out.println(m);
- if(computed_stack == compiled_stack)
- System.out.println("Stack ok(" + computed_stack + ")");
- else
- System.out.println("\nCompiled stack size " + compiled_stack +
- " computed size " + computed_stack);
+ if(computed_stack == compiled_stack) {
+ System.out.println("Stack ok(" + computed_stack + ")");
+ } else {
+ System.out.println("\nCompiled stack size " + compiled_stack +
+ " computed size " + computed_stack);
+ }
- if(computed_locals == compiled_locals)
- System.out.println("Locals ok(" + computed_locals + ")");
- else
- System.out.println("\nCompiled locals " + compiled_locals +
- " computed size " + computed_locals);
+ if(computed_locals == compiled_locals) {
+ System.out.println("Locals ok(" + computed_locals + ")");
+ } else {
+ System.out.println("\nCompiled locals " + compiled_locals +
+ " computed size " + computed_locals);
+ }
}
}
}
Modified: jakarta/bcel/trunk/examples/patchclass.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/examples/patchclass.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/examples/patchclass.java (original)
+++ jakarta/bcel/trunk/examples/patchclass.java Wed Mar 15 03:31:56 2006
@@ -25,8 +25,9 @@
}
try {
- for(int i=2; i < argv.length; i++)
- file_name[files++] = argv[i];
+ for(int i=2; i < argv.length; i++) {
+ file_name[files++] = argv[i];
+ }
for(int i=0; i < files; i++) {
parser = new ClassParser(file_name[i]);
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/ExceptionConstants.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/ExceptionConstants.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/ExceptionConstants.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/ExceptionConstants.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel;
-
/**
* Exception constants.
*
@@ -24,63 +23,54 @@
* @author E. Haase
*/
public interface ExceptionConstants {
- /** The mother of all exceptions
- */
- public static final Class THROWABLE = Throwable.class;
-
- /** Super class of any run-time exception
- */
- public static final Class RUNTIME_EXCEPTION = RuntimeException.class;
-
- /** Super class of any linking exception (aka Linkage Error)
- */
- public static final Class LINKING_EXCEPTION = LinkageError.class;
-
- /** Linking Exceptions
- */
- public static final Class CLASS_CIRCULARITY_ERROR = ClassCircularityError.class;
- public static final Class CLASS_FORMAT_ERROR = ClassFormatError.class;
- public static final Class EXCEPTION_IN_INITIALIZER_ERROR = ExceptionInInitializerError.class;
- public static final Class INCOMPATIBLE_CLASS_CHANGE_ERROR = IncompatibleClassChangeError.class;
- public static final Class ABSTRACT_METHOD_ERROR = AbstractMethodError.class;
- public static final Class ILLEGAL_ACCESS_ERROR = IllegalAccessError.class;
- public static final Class INSTANTIATION_ERROR = InstantiationError.class;
- public static final Class NO_SUCH_FIELD_ERROR = NoSuchFieldError.class;
- public static final Class NO_SUCH_METHOD_ERROR = NoSuchMethodError.class;
- public static final Class NO_CLASS_DEF_FOUND_ERROR = NoClassDefFoundError.class;
- public static final Class UNSATISFIED_LINK_ERROR = UnsatisfiedLinkError.class;
- public static final Class VERIFY_ERROR = VerifyError.class;
-
- /* UnsupportedClassVersionError is new in JDK 1.2 */
- //public static final Class UnsupportedClassVersionError = UnsupportedClassVersionError.class;
-
- /** Run-Time Exceptions
- */
- public static final Class NULL_POINTER_EXCEPTION = NullPointerException.class;
- public static final Class ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION = ArrayIndexOutOfBoundsException.class;
- public static final Class ARITHMETIC_EXCEPTION = ArithmeticException.class;
- public static final Class NEGATIVE_ARRAY_SIZE_EXCEPTION = NegativeArraySizeException.class;
- public static final Class CLASS_CAST_EXCEPTION = ClassCastException.class;
- public static final Class ILLEGAL_MONITOR_STATE = IllegalMonitorStateException.class;
-
- /** Pre-defined exception arrays according to chapters 5.1-5.4 of the Java Virtual
- * Machine Specification
- */
- public static final Class[] EXCS_CLASS_AND_INTERFACE_RESOLUTION = {
- NO_CLASS_DEF_FOUND_ERROR, CLASS_FORMAT_ERROR, VERIFY_ERROR, ABSTRACT_METHOD_ERROR,
- EXCEPTION_IN_INITIALIZER_ERROR, ILLEGAL_ACCESS_ERROR
- }; // Chapter 5.1
-
- public static final Class[] EXCS_FIELD_AND_METHOD_RESOLUTION = {
- NO_SUCH_FIELD_ERROR, ILLEGAL_ACCESS_ERROR, NO_SUCH_METHOD_ERROR
- }; // Chapter 5.2
-
- public static final Class[] EXCS_INTERFACE_METHOD_RESOLUTION = new Class[0]; // Chapter 5.3 (as below)
- public static final Class[] EXCS_STRING_RESOLUTION = new Class[0];
- // Chapter 5.4 (no errors but the ones that _always_ could happen! How stupid.)
-
- public static final Class[] EXCS_ARRAY_EXCEPTION = {
- NULL_POINTER_EXCEPTION, ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION
- };
+ /** The mother of all exceptions
+ */
+ public static final Class THROWABLE = Throwable.class;
+ /** Super class of any run-time exception
+ */
+ public static final Class RUNTIME_EXCEPTION = RuntimeException.class;
+ /** Super class of any linking exception (aka Linkage Error)
+ */
+ public static final Class LINKING_EXCEPTION = LinkageError.class;
+ /** Linking Exceptions
+ */
+ public static final Class CLASS_CIRCULARITY_ERROR = ClassCircularityError.class;
+ public static final Class CLASS_FORMAT_ERROR = ClassFormatError.class;
+ public static final Class EXCEPTION_IN_INITIALIZER_ERROR = ExceptionInInitializerError.class;
+ public static final Class INCOMPATIBLE_CLASS_CHANGE_ERROR = IncompatibleClassChangeError.class;
+ public static final Class ABSTRACT_METHOD_ERROR = AbstractMethodError.class;
+ public static final Class ILLEGAL_ACCESS_ERROR = IllegalAccessError.class;
+ public static final Class INSTANTIATION_ERROR = InstantiationError.class;
+ public static final Class NO_SUCH_FIELD_ERROR = NoSuchFieldError.class;
+ public static final Class NO_SUCH_METHOD_ERROR = NoSuchMethodError.class;
+ public static final Class NO_CLASS_DEF_FOUND_ERROR = NoClassDefFoundError.class;
+ public static final Class UNSATISFIED_LINK_ERROR = UnsatisfiedLinkError.class;
+ public static final Class VERIFY_ERROR = VerifyError.class;
+ /* UnsupportedClassVersionError is new in JDK 1.2 */
+ //public static final Class UnsupportedClassVersionError = UnsupportedClassVersionError.class;
+ /** Run-Time Exceptions
+ */
+ public static final Class NULL_POINTER_EXCEPTION = NullPointerException.class;
+ public static final Class ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION = ArrayIndexOutOfBoundsException.class;
+ public static final Class ARITHMETIC_EXCEPTION = ArithmeticException.class;
+ public static final Class NEGATIVE_ARRAY_SIZE_EXCEPTION = NegativeArraySizeException.class;
+ public static final Class CLASS_CAST_EXCEPTION = ClassCastException.class;
+ public static final Class ILLEGAL_MONITOR_STATE = IllegalMonitorStateException.class;
+ /** Pre-defined exception arrays according to chapters 5.1-5.4 of the Java Virtual
+ * Machine Specification
+ */
+ public static final Class[] EXCS_CLASS_AND_INTERFACE_RESOLUTION = {
+ NO_CLASS_DEF_FOUND_ERROR, CLASS_FORMAT_ERROR, VERIFY_ERROR, ABSTRACT_METHOD_ERROR,
+ EXCEPTION_IN_INITIALIZER_ERROR, ILLEGAL_ACCESS_ERROR
+ }; // Chapter 5.1
+ public static final Class[] EXCS_FIELD_AND_METHOD_RESOLUTION = {
+ NO_SUCH_FIELD_ERROR, ILLEGAL_ACCESS_ERROR, NO_SUCH_METHOD_ERROR
+ }; // Chapter 5.2
+ public static final Class[] EXCS_INTERFACE_METHOD_RESOLUTION = new Class[0]; // Chapter 5.3 (as below)
+ public static final Class[] EXCS_STRING_RESOLUTION = new Class[0];
+ // Chapter 5.4 (no errors but the ones that _always_ could happen! How stupid.)
+ public static final Class[] EXCS_ARRAY_EXCEPTION = {
+ NULL_POINTER_EXCEPTION, ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION
+ };
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/Repository.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/Repository.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/Repository.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/Repository.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel;
-
import java.io.IOException;
import org.apache.bcel.classfile.JavaClass;
import org.apache.bcel.util.ClassPath;
@@ -34,215 +33,229 @@
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
*/
public abstract class Repository {
- private static org.apache.bcel.util.Repository _repository =
- SyntheticRepository.getInstance();
- /** @return currently used repository instance
- */
- public static org.apache.bcel.util.Repository getRepository() {
- return _repository;
- }
-
- /** Set repository instance to be used for class loading
- */
- public static void setRepository(org.apache.bcel.util.Repository rep) {
- _repository = rep;
- }
-
- /** Lookup class somewhere found on your CLASSPATH, or whereever the
- * repository instance looks for it.
- *
- * @return class object for given fully qualified class name
- * @throws ClassNotFoundException if the class could not be found or
- * parsed correctly
- */
- public static JavaClass lookupClass(String class_name)
- throws ClassNotFoundException {
-
- return _repository.loadClass(class_name);
- }
-
- /**
- * Try to find class source using the internal repository instance.
- * @see Class
- * @return JavaClass object for given runtime class
- * @throws ClassNotFoundException if the class could not be found or
- * parsed correctly
- */
- public static JavaClass lookupClass(Class clazz)
- throws ClassNotFoundException {
- return _repository.loadClass(clazz);
- }
-
- /**
- * @return class file object for given Java class by looking on the
- * system class path; returns null if the class file can't be
- * found
- */
- public static ClassPath.ClassFile lookupClassFile(String class_name) {
- try {
- ClassPath path = _repository.getClassPath();
-
- if(path == null)
- return null;
- return path.getClassFile(class_name);
-
- } catch(IOException e) { return null; }
- }
-
- /** Clear the repository.
- */
- public static void clearCache() {
- _repository.clear();
- }
-
- /**
- * Add clazz to repository if there isn't an equally named class already in there.
- *
- * @return old entry in repository
- */
- public static JavaClass addClass(JavaClass clazz) {
- JavaClass old = _repository.findClass(clazz.getClassName());
- _repository.storeClass(clazz);
- return old;
- }
-
- /**
- * Remove class with given (fully qualified) name from repository.
- */
- public static void removeClass(String clazz) {
- _repository.removeClass(_repository.findClass(clazz));
- }
-
- /**
- * Remove given class from repository.
- */
- public static void removeClass(JavaClass clazz) {
- _repository.removeClass(clazz);
- }
-
- /**
- * @return list of super classes of clazz in ascending order, i.e.,
- * Object is always the last element
- * @throws ClassNotFoundException if any of the superclasses can't be found
- */
- public static JavaClass[] getSuperClasses(JavaClass clazz)
- throws ClassNotFoundException {
- return clazz.getSuperClasses();
- }
-
- /**
- * @return list of super classes of clazz in ascending order, i.e.,
- * Object is always the last element.
- * @throws ClassNotFoundException if the named class or any of its
- * superclasses can't be found
- */
- public static JavaClass[] getSuperClasses(String class_name)
- throws ClassNotFoundException {
- JavaClass jc = lookupClass(class_name);
- return getSuperClasses(jc);
- }
-
- /**
- * @return all interfaces implemented by class and its super
- * classes and the interfaces that those interfaces extend, and so on.
- * (Some people call this a transitive hull).
- * @throws ClassNotFoundException if any of the class's
- * superclasses or superinterfaces can't be found
- */
- public static JavaClass[] getInterfaces(JavaClass clazz)
- throws ClassNotFoundException {
- return clazz.getAllInterfaces();
- }
-
- /**
- * @return all interfaces implemented by class and its super
- * classes and the interfaces that extend those interfaces, and so on
- * @throws ClassNotFoundException if the named class can't be found,
- * or if any of its superclasses or superinterfaces can't be found
- */
- public static JavaClass[] getInterfaces(String class_name)
- throws ClassNotFoundException {
- return getInterfaces(lookupClass(class_name));
- }
-
- /**
- * Equivalent to runtime "instanceof" operator.
- * @return true, if clazz is an instance of super_class
- * @throws ClassNotFoundException if any superclasses or superinterfaces
- * of clazz can't be found
- */
- public static boolean instanceOf(JavaClass clazz, JavaClass super_class)
- throws ClassNotFoundException {
- return clazz.instanceOf(super_class);
- }
-
- /**
- * @return true, if clazz is an instance of super_class
- * @throws ClassNotFoundException if either clazz or super_class
- * can't be found
- */
- public static boolean instanceOf(String clazz, String super_class)
- throws ClassNotFoundException {
- return instanceOf(lookupClass(clazz), lookupClass(super_class));
- }
-
- /**
- * @return true, if clazz is an instance of super_class
- * @throws ClassNotFoundException if super_class can't be found
- */
- public static boolean instanceOf(JavaClass clazz, String super_class)
- throws ClassNotFoundException {
- return instanceOf(clazz, lookupClass(super_class));
- }
-
- /**
- * @return true, if clazz is an instance of super_class
- * @throws ClassNotFoundException if clazz can't be found
- */
- public static boolean instanceOf(String clazz, JavaClass super_class)
- throws ClassNotFoundException {
- return instanceOf(lookupClass(clazz), super_class);
- }
-
- /**
- * @return true, if clazz is an implementation of interface inter
- * @throws ClassNotFoundException if any superclasses or superinterfaces
- * of clazz can't be found
- */
- public static boolean implementationOf(JavaClass clazz, JavaClass inter)
- throws ClassNotFoundException {
- return clazz.implementationOf(inter);
- }
-
- /**
- * @return true, if clazz is an implementation of interface inter
- * @throws ClassNotFoundException if clazz, inter, or any superclasses
- * or superinterfaces of clazz can't be found
- */
- public static boolean implementationOf(String clazz, String inter)
- throws ClassNotFoundException {
- return implementationOf(lookupClass(clazz), lookupClass(inter));
- }
-
- /**
- * @return true, if clazz is an implementation of interface inter
- * @throws ClassNotFoundException if inter or any superclasses
- * or superinterfaces of clazz can't be found
- */
- public static boolean implementationOf(JavaClass clazz, String inter)
- throws ClassNotFoundException {
- return implementationOf(clazz, lookupClass(inter));
- }
-
- /**
- * @return true, if clazz is an implementation of interface inter
- * @throws ClassNotFoundException if clazz or any superclasses or
- * superinterfaces of clazz can't be found
- */
- public static boolean implementationOf(String clazz, JavaClass inter)
- throws ClassNotFoundException {
- return implementationOf(lookupClass(clazz), inter);
- }
-}
+ private static org.apache.bcel.util.Repository _repository = SyntheticRepository.getInstance();
+
+ /** @return currently used repository instance
+ */
+ public static org.apache.bcel.util.Repository getRepository() {
+ return _repository;
+ }
+
+
+ /** Set repository instance to be used for class loading
+ */
+ public static void setRepository( org.apache.bcel.util.Repository rep ) {
+ _repository = rep;
+ }
+
+
+ /** Lookup class somewhere found on your CLASSPATH, or whereever the
+ * repository instance looks for it.
+ *
+ * @return class object for given fully qualified class name
+ * @throws ClassNotFoundException if the class could not be found or
+ * parsed correctly
+ */
+ public static JavaClass lookupClass( String class_name ) throws ClassNotFoundException {
+ return _repository.loadClass(class_name);
+ }
+
+
+ /**
+ * Try to find class source using the internal repository instance.
+ * @see Class
+ * @return JavaClass object for given runtime class
+ * @throws ClassNotFoundException if the class could not be found or
+ * parsed correctly
+ */
+ public static JavaClass lookupClass( Class clazz ) throws ClassNotFoundException {
+ return _repository.loadClass(clazz);
+ }
+
+
+ /**
+ * @return class file object for given Java class by looking on the
+ * system class path; returns null if the class file can't be
+ * found
+ */
+ public static ClassPath.ClassFile lookupClassFile( String class_name ) {
+ try {
+ ClassPath path = _repository.getClassPath();
+ if (path == null) {
+ return null;
+ }
+ return path.getClassFile(class_name);
+ } catch (IOException e) {
+ return null;
+ }
+ }
+
+
+ /** Clear the repository.
+ */
+ public static void clearCache() {
+ _repository.clear();
+ }
+
+
+ /**
+ * Add clazz to repository if there isn't an equally named class already in there.
+ *
+ * @return old entry in repository
+ */
+ public static JavaClass addClass( JavaClass clazz ) {
+ JavaClass old = _repository.findClass(clazz.getClassName());
+ _repository.storeClass(clazz);
+ return old;
+ }
+
+
+ /**
+ * Remove class with given (fully qualified) name from repository.
+ */
+ public static void removeClass( String clazz ) {
+ _repository.removeClass(_repository.findClass(clazz));
+ }
+
+
+ /**
+ * Remove given class from repository.
+ */
+ public static void removeClass( JavaClass clazz ) {
+ _repository.removeClass(clazz);
+ }
+
+
+ /**
+ * @return list of super classes of clazz in ascending order, i.e.,
+ * Object is always the last element
+ * @throws ClassNotFoundException if any of the superclasses can't be found
+ */
+ public static JavaClass[] getSuperClasses( JavaClass clazz ) throws ClassNotFoundException {
+ return clazz.getSuperClasses();
+ }
+
+
+ /**
+ * @return list of super classes of clazz in ascending order, i.e.,
+ * Object is always the last element.
+ * @throws ClassNotFoundException if the named class or any of its
+ * superclasses can't be found
+ */
+ public static JavaClass[] getSuperClasses( String class_name ) throws ClassNotFoundException {
+ JavaClass jc = lookupClass(class_name);
+ return getSuperClasses(jc);
+ }
+
+
+ /**
+ * @return all interfaces implemented by class and its super
+ * classes and the interfaces that those interfaces extend, and so on.
+ * (Some people call this a transitive hull).
+ * @throws ClassNotFoundException if any of the class's
+ * superclasses or superinterfaces can't be found
+ */
+ public static JavaClass[] getInterfaces( JavaClass clazz ) throws ClassNotFoundException {
+ return clazz.getAllInterfaces();
+ }
+
+
+ /**
+ * @return all interfaces implemented by class and its super
+ * classes and the interfaces that extend those interfaces, and so on
+ * @throws ClassNotFoundException if the named class can't be found,
+ * or if any of its superclasses or superinterfaces can't be found
+ */
+ public static JavaClass[] getInterfaces( String class_name ) throws ClassNotFoundException {
+ return getInterfaces(lookupClass(class_name));
+ }
+
+
+ /**
+ * Equivalent to runtime "instanceof" operator.
+ * @return true, if clazz is an instance of super_class
+ * @throws ClassNotFoundException if any superclasses or superinterfaces
+ * of clazz can't be found
+ */
+ public static boolean instanceOf( JavaClass clazz, JavaClass super_class )
+ throws ClassNotFoundException {
+ return clazz.instanceOf(super_class);
+ }
+
+
+ /**
+ * @return true, if clazz is an instance of super_class
+ * @throws ClassNotFoundException if either clazz or super_class
+ * can't be found
+ */
+ public static boolean instanceOf( String clazz, String super_class )
+ throws ClassNotFoundException {
+ return instanceOf(lookupClass(clazz), lookupClass(super_class));
+ }
+
+
+ /**
+ * @return true, if clazz is an instance of super_class
+ * @throws ClassNotFoundException if super_class can't be found
+ */
+ public static boolean instanceOf( JavaClass clazz, String super_class )
+ throws ClassNotFoundException {
+ return instanceOf(clazz, lookupClass(super_class));
+ }
+
+
+ /**
+ * @return true, if clazz is an instance of super_class
+ * @throws ClassNotFoundException if clazz can't be found
+ */
+ public static boolean instanceOf( String clazz, JavaClass super_class )
+ throws ClassNotFoundException {
+ return instanceOf(lookupClass(clazz), super_class);
+ }
+
+
+ /**
+ * @return true, if clazz is an implementation of interface inter
+ * @throws ClassNotFoundException if any superclasses or superinterfaces
+ * of clazz can't be found
+ */
+ public static boolean implementationOf( JavaClass clazz, JavaClass inter )
+ throws ClassNotFoundException {
+ return clazz.implementationOf(inter);
+ }
+
+
+ /**
+ * @return true, if clazz is an implementation of interface inter
+ * @throws ClassNotFoundException if clazz, inter, or any superclasses
+ * or superinterfaces of clazz can't be found
+ */
+ public static boolean implementationOf( String clazz, String inter )
+ throws ClassNotFoundException {
+ return implementationOf(lookupClass(clazz), lookupClass(inter));
+ }
+
+
+ /**
+ * @return true, if clazz is an implementation of interface inter
+ * @throws ClassNotFoundException if inter or any superclasses
+ * or superinterfaces of clazz can't be found
+ */
+ public static boolean implementationOf( JavaClass clazz, String inter )
+ throws ClassNotFoundException {
+ return implementationOf(clazz, lookupClass(inter));
+ }
+
+
+ /**
+ * @return true, if clazz is an implementation of interface inter
+ * @throws ClassNotFoundException if clazz or any superclasses or
+ * superinterfaces of clazz can't be found
+ */
+ public static boolean implementationOf( String clazz, JavaClass inter )
+ throws ClassNotFoundException {
+ return implementationOf(lookupClass(clazz), inter);
+ }
+}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/AccessFlags.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/AccessFlags.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/AccessFlags.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/AccessFlags.java Wed Mar 15 03:31:56 2006
@@ -26,123 +26,213 @@
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
*/
public abstract class AccessFlags implements java.io.Serializable {
- protected int access_flags;
-
- public AccessFlags() {}
-
- /**
- * @param a inital access flags
- */
- public AccessFlags(int a) {
- access_flags = a;
- }
-
- /**
- * @return Access flags of the object aka. "modifiers".
- */
- public final int getAccessFlags() { return access_flags; }
-
- /**
- * @return Access flags of the object aka. "modifiers".
- */
- public final int getModifiers() { return access_flags; }
-
- /** Set access flags aka "modifiers".
- * @param access_flags Access flags of the object.
- */
- public final void setAccessFlags(int access_flags) {
- this.access_flags = access_flags;
- }
-
- /** Set access flags aka "modifiers".
- * @param access_flags Access flags of the object.
- */
- public final void setModifiers(int access_flags) {
- setAccessFlags(access_flags);
- }
-
- private final void setFlag(int flag, boolean set) {
- if((access_flags & flag) != 0) { // Flag is set already
- if(!set) // Delete flag ?
- access_flags ^= flag;
- } else { // Flag not set
- if(set) // Set flag ?
- access_flags |= flag;
- }
- }
-
- public final void isPublic(boolean flag) { setFlag(Constants.ACC_PUBLIC, flag); }
- public final boolean isPublic() {
- return (access_flags & Constants.ACC_PUBLIC) != 0;
- }
-
- public final void isPrivate(boolean flag) { setFlag(Constants.ACC_PRIVATE, flag); }
- public final boolean isPrivate() {
- return (access_flags & Constants.ACC_PRIVATE) != 0;
- }
-
- public final void isProtected(boolean flag) { setFlag(Constants.ACC_PROTECTED, flag); }
- public final boolean isProtected() {
- return (access_flags & Constants.ACC_PROTECTED) != 0;
- }
-
- public final void isStatic(boolean flag) { setFlag(Constants.ACC_STATIC, flag); }
- public final boolean isStatic() {
- return (access_flags & Constants.ACC_STATIC) != 0;
- }
-
- public final void isFinal(boolean flag) { setFlag(Constants.ACC_FINAL, flag); }
- public final boolean isFinal() {
- return (access_flags & Constants.ACC_FINAL) != 0;
- }
-
- public final void isSynchronized(boolean flag) { setFlag(Constants.ACC_SYNCHRONIZED, flag); }
- public final boolean isSynchronized() {
- return (access_flags & Constants.ACC_SYNCHRONIZED) != 0;
- }
-
- public final void isVolatile(boolean flag) { setFlag(Constants.ACC_VOLATILE, flag); }
- public final boolean isVolatile() {
- return (access_flags & Constants.ACC_VOLATILE) != 0;
- }
-
- public final void isTransient(boolean flag) { setFlag(Constants.ACC_TRANSIENT, flag); }
- public final boolean isTransient() {
- return (access_flags & Constants.ACC_TRANSIENT) != 0;
- }
-
- public final void isNative(boolean flag) { setFlag(Constants.ACC_NATIVE, flag); }
- public final boolean isNative() {
- return (access_flags & Constants.ACC_NATIVE) != 0;
- }
-
- public final void isInterface(boolean flag) { setFlag(Constants.ACC_INTERFACE, flag); }
- public final boolean isInterface() {
- return (access_flags & Constants.ACC_INTERFACE) != 0;
- }
-
- public final void isAbstract(boolean flag) { setFlag(Constants.ACC_ABSTRACT, flag); }
- public final boolean isAbstract() {
- return (access_flags & Constants.ACC_ABSTRACT) != 0;
- }
-
- public final void isStrictfp(boolean flag) { setFlag(Constants.ACC_STRICT, flag); }
- public final boolean isStrictfp() {
- return (access_flags & Constants.ACC_STRICT) != 0;
- }
-
- public final void isSynthetic(boolean flag) { setFlag(Constants.ACC_SYNTHETIC, flag); }
- public final boolean isSynthetic() {
- return (access_flags & Constants.ACC_SYNTHETIC) != 0;
- }
-
- public final void isAnnotation(boolean flag) { setFlag(Constants.ACC_ANNOTATION, flag); }
- public final boolean isAnnotation() {
- return (access_flags & Constants.ACC_ANNOTATION) != 0;
- }
-
- public final void isEnum(boolean flag) { setFlag(Constants.ACC_ENUM, flag); }
- public final boolean isEnum() {
- return (access_flags & Constants.ACC_ENUM) != 0;
- }
+
+ protected int access_flags;
+
+
+ public AccessFlags() {
+ }
+
+
+ /**
+ * @param a inital access flags
+ */
+ public AccessFlags(int a) {
+ access_flags = a;
+ }
+
+
+ /**
+ * @return Access flags of the object aka. "modifiers".
+ */
+ public final int getAccessFlags() {
+ return access_flags;
+ }
+
+
+ /**
+ * @return Access flags of the object aka. "modifiers".
+ */
+ public final int getModifiers() {
+ return access_flags;
+ }
+
+
+ /** Set access flags aka "modifiers".
+ * @param access_flags Access flags of the object.
+ */
+ public final void setAccessFlags( int access_flags ) {
+ this.access_flags = access_flags;
+ }
+
+
+ /** Set access flags aka "modifiers".
+ * @param access_flags Access flags of the object.
+ */
+ public final void setModifiers( int access_flags ) {
+ setAccessFlags(access_flags);
+ }
+
+
+ private final void setFlag( int flag, boolean set ) {
+ if ((access_flags & flag) != 0) { // Flag is set already
+ if (!set) {
+ access_flags ^= flag;
+ }
+ } else { // Flag not set
+ if (set) {
+ access_flags |= flag;
+ }
+ }
+ }
+
+
+ public final void isPublic( boolean flag ) {
+ setFlag(Constants.ACC_PUBLIC, flag);
+ }
+
+
+ public final boolean isPublic() {
+ return (access_flags & Constants.ACC_PUBLIC) != 0;
+ }
+
+
+ public final void isPrivate( boolean flag ) {
+ setFlag(Constants.ACC_PRIVATE, flag);
+ }
+
+
+ public final boolean isPrivate() {
+ return (access_flags & Constants.ACC_PRIVATE) != 0;
+ }
+
+
+ public final void isProtected( boolean flag ) {
+ setFlag(Constants.ACC_PROTECTED, flag);
+ }
+
+
+ public final boolean isProtected() {
+ return (access_flags & Constants.ACC_PROTECTED) != 0;
+ }
+
+
+ public final void isStatic( boolean flag ) {
+ setFlag(Constants.ACC_STATIC, flag);
+ }
+
+
+ public final boolean isStatic() {
+ return (access_flags & Constants.ACC_STATIC) != 0;
+ }
+
+
+ public final void isFinal( boolean flag ) {
+ setFlag(Constants.ACC_FINAL, flag);
+ }
+
+
+ public final boolean isFinal() {
+ return (access_flags & Constants.ACC_FINAL) != 0;
+ }
+
+
+ public final void isSynchronized( boolean flag ) {
+ setFlag(Constants.ACC_SYNCHRONIZED, flag);
+ }
+
+
+ public final boolean isSynchronized() {
+ return (access_flags & Constants.ACC_SYNCHRONIZED) != 0;
+ }
+
+
+ public final void isVolatile( boolean flag ) {
+ setFlag(Constants.ACC_VOLATILE, flag);
+ }
+
+
+ public final boolean isVolatile() {
+ return (access_flags & Constants.ACC_VOLATILE) != 0;
+ }
+
+
+ public final void isTransient( boolean flag ) {
+ setFlag(Constants.ACC_TRANSIENT, flag);
+ }
+
+
+ public final boolean isTransient() {
+ return (access_flags & Constants.ACC_TRANSIENT) != 0;
+ }
+
+
+ public final void isNative( boolean flag ) {
+ setFlag(Constants.ACC_NATIVE, flag);
+ }
+
+
+ public final boolean isNative() {
+ return (access_flags & Constants.ACC_NATIVE) != 0;
+ }
+
+
+ public final void isInterface( boolean flag ) {
+ setFlag(Constants.ACC_INTERFACE, flag);
+ }
+
+
+ public final boolean isInterface() {
+ return (access_flags & Constants.ACC_INTERFACE) != 0;
+ }
+
+
+ public final void isAbstract( boolean flag ) {
+ setFlag(Constants.ACC_ABSTRACT, flag);
+ }
+
+
+ public final boolean isAbstract() {
+ return (access_flags & Constants.ACC_ABSTRACT) != 0;
+ }
+
+
+ public final void isStrictfp( boolean flag ) {
+ setFlag(Constants.ACC_STRICT, flag);
+ }
+
+
+ public final boolean isStrictfp() {
+ return (access_flags & Constants.ACC_STRICT) != 0;
+ }
+
+
+ public final void isSynthetic( boolean flag ) {
+ setFlag(Constants.ACC_SYNTHETIC, flag);
+ }
+
+
+ public final boolean isSynthetic() {
+ return (access_flags & Constants.ACC_SYNTHETIC) != 0;
+ }
+
+
+ public final void isAnnotation( boolean flag ) {
+ setFlag(Constants.ACC_ANNOTATION, flag);
+ }
+
+
+ public final boolean isAnnotation() {
+ return (access_flags & Constants.ACC_ANNOTATION) != 0;
+ }
+
+
+ public final void isEnum( boolean flag ) {
+ setFlag(Constants.ACC_ENUM, flag);
+ }
+
+
+ public final boolean isEnum() {
+ return (access_flags & Constants.ACC_ENUM) != 0;
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/AnnotationDefault.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/AnnotationDefault.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/AnnotationDefault.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/AnnotationDefault.java Wed Mar 15 03:31:56 2006
@@ -27,59 +27,61 @@
*/
public abstract class AnnotationDefault extends Attribute {
- ElementValue default_value;
+ ElementValue default_value;
- /**
- * @param annotation_type the subclass type of the annotation
- * @param name_index Index pointing to the name <em>Code</em>
- * @param length Content length in bytes
- * @param file Input stream
- * @param constant_pool Array of constants
- */
- AnnotationDefault(byte annotation_type, int name_index, int length, DataInputStream file,
- ConstantPool constant_pool) throws IOException
- {
- this(annotation_type, name_index, length, (ElementValue) null, constant_pool);
- default_value = new ElementValue(file, constant_pool);
- }
-
- /**
- * @param annotation_type the subclass type of the annotation
- * @param name_index Index pointing to the name <em>Code</em>
- * @param length Content length in bytes
- * @param defaultValue the annotation's default value
- * @param constant_pool Array of constants
- */
- public AnnotationDefault(byte annotation_type, int name_index, int length, ElementValue defaultValue, ConstantPool constant_pool)
- {
- super(annotation_type, name_index, length, constant_pool);
- setDefaultValue(defaultValue);
- }
-
- /**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept(Visitor v) {
-// v.visitAnnotationDefault(this);
- }
-
- /**
- * @param defaultValue the default value of this methodinfo's annotation
- */
- public final void setDefaultValue(ElementValue defaultValue)
- {
- default_value = defaultValue;
- }
-
- /**
- * @return the default value
- */
- public final ElementValue getDefaultValue()
- {
- return default_value;
- }
+
+ /**
+ * @param annotation_type the subclass type of the annotation
+ * @param name_index Index pointing to the name <em>Code</em>
+ * @param length Content length in bytes
+ * @param file Input stream
+ * @param constant_pool Array of constants
+ */
+ AnnotationDefault(byte annotation_type, int name_index, int length, DataInputStream file,
+ ConstantPool constant_pool) throws IOException {
+ this(annotation_type, name_index, length, (ElementValue) null, constant_pool);
+ default_value = new ElementValue(file, constant_pool);
+ }
+
+
+ /**
+ * @param annotation_type the subclass type of the annotation
+ * @param name_index Index pointing to the name <em>Code</em>
+ * @param length Content length in bytes
+ * @param defaultValue the annotation's default value
+ * @param constant_pool Array of constants
+ */
+ public AnnotationDefault(byte annotation_type, int name_index, int length,
+ ElementValue defaultValue, ConstantPool constant_pool) {
+ super(annotation_type, name_index, length, constant_pool);
+ setDefaultValue(defaultValue);
+ }
+
+
+ /**
+ * Called by objects that are traversing the nodes of the tree implicitely
+ * defined by the contents of a Java class. I.e., the hierarchy of methods,
+ * fields, attributes, etc. spawns a tree of objects.
+ *
+ * @param v Visitor object
+ */
+ public void accept( Visitor v ) {
+ // v.visitAnnotationDefault(this);
+ }
+
+
+ /**
+ * @param defaultValue the default value of this methodinfo's annotation
+ */
+ public final void setDefaultValue( ElementValue defaultValue ) {
+ default_value = defaultValue;
+ }
+
+
+ /**
+ * @return the default value
+ */
+ public final ElementValue getDefaultValue() {
+ return default_value;
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/AnnotationEntry.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/AnnotationEntry.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/AnnotationEntry.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/AnnotationEntry.java Wed Mar 15 03:31:56 2006
@@ -20,65 +20,70 @@
import java.io.IOException;
import org.apache.bcel.Constants;
-
/**
* represents one annotation in the annotation table
*
* @version $Id: AnnotationEntry
* @author <A HREF="mailto:dbrosius@qis.net">D. Brosius</A>
*/
-public class AnnotationEntry implements Node, Constants
-{
- private int type_index;
- private int num_element_value_pairs;
- private ElementValuePair[] element_value_pairs;
- private ConstantPool constant_pool;
-
- /**
- * Construct object from file stream.
- * @param file Input stream
- * @throws IOException
- */
- AnnotationEntry(DataInputStream file, ConstantPool constant_pool)
- throws IOException
- {
- type_index = (file.readUnsignedShort());
- num_element_value_pairs = (file.readUnsignedShort());
-
- element_value_pairs = new ElementValuePair[num_element_value_pairs];
- for(int i=0; i < num_element_value_pairs; i++)
- element_value_pairs[i] = new ElementValuePair(file, constant_pool);
- this.constant_pool = constant_pool;
- }
-
- /**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept(Visitor v) {
-// v.visitAnnotationEntry(this);
- }
-
- /**
- * @return the annotation type name
- */
- public String getAnnotationType() {
- ConstantUtf8 c;
-
- c = (ConstantUtf8)constant_pool.getConstant(type_index, CONSTANT_Utf8);
- return c.getBytes();
- }
-
- /**
- * @return the number of element value pairs in this annotation entry
- */
- public final int getNumElementValuePairs() { return num_element_value_pairs; }
-
- /**
- * @return the element value pairs in this annotation entry
- */
- public ElementValuePair[] getElementValuePairs() { return element_value_pairs; }
+public class AnnotationEntry implements Node, Constants {
+
+ private int type_index;
+ private int num_element_value_pairs;
+ private ElementValuePair[] element_value_pairs;
+ private ConstantPool constant_pool;
+
+
+ /**
+ * Construct object from file stream.
+ * @param file Input stream
+ * @throws IOException
+ */
+ AnnotationEntry(DataInputStream file, ConstantPool constant_pool) throws IOException {
+ type_index = (file.readUnsignedShort());
+ num_element_value_pairs = (file.readUnsignedShort());
+ element_value_pairs = new ElementValuePair[num_element_value_pairs];
+ for (int i = 0; i < num_element_value_pairs; i++) {
+ element_value_pairs[i] = new ElementValuePair(file, constant_pool);
+ }
+ this.constant_pool = constant_pool;
+ }
+
+
+ /**
+ * Called by objects that are traversing the nodes of the tree implicitely
+ * defined by the contents of a Java class. I.e., the hierarchy of methods,
+ * fields, attributes, etc. spawns a tree of objects.
+ *
+ * @param v Visitor object
+ */
+ public void accept( Visitor v ) {
+ // v.visitAnnotationEntry(this);
+ }
+
+
+ /**
+ * @return the annotation type name
+ */
+ public String getAnnotationType() {
+ ConstantUtf8 c;
+ c = (ConstantUtf8) constant_pool.getConstant(type_index, CONSTANT_Utf8);
+ return c.getBytes();
+ }
+
+
+ /**
+ * @return the number of element value pairs in this annotation entry
+ */
+ public final int getNumElementValuePairs() {
+ return num_element_value_pairs;
+ }
+
+
+ /**
+ * @return the element value pairs in this annotation entry
+ */
+ public ElementValuePair[] getElementValuePairs() {
+ return element_value_pairs;
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/Annotations.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/Annotations.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/Annotations.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/Annotations.java Wed Mar 15 03:31:56 2006
@@ -27,80 +27,83 @@
*/
public abstract class Annotations extends Attribute {
- private int annotation_table_length;
- private AnnotationEntry[] annotation_table; // Table of annotations
+ private int annotation_table_length;
+ private AnnotationEntry[] annotation_table; // Table of annotations
- /**
- * @param annotation_type the subclass type of the annotation
- * @param name_index Index pointing to the name <em>Code</em>
- * @param length Content length in bytes
- * @param file Input stream
- * @param constant_pool Array of constants
- */
- Annotations(byte annotation_type, int name_index, int length, DataInputStream file,
- ConstantPool constant_pool) throws IOException
- {
- this(annotation_type, name_index, length, (AnnotationEntry[]) null, constant_pool);
-
- annotation_table_length = (file.readUnsignedShort());
- annotation_table = new AnnotationEntry[annotation_table_length];
-
- for(int i=0; i < annotation_table_length; i++)
- annotation_table[i] = new AnnotationEntry(file, constant_pool);
- }
-
- /**
- * @param annotation_type the subclass type of the annotation
- * @param name_index Index pointing to the name <em>Code</em>
- * @param length Content length in bytes
- * @param annotation_table the actual annotations
- * @param constant_pool Array of constants
- */
- public Annotations(byte annotation_type, int name_index, int length, AnnotationEntry[] annotation_table, ConstantPool constant_pool)
- {
- super(annotation_type, name_index, length, constant_pool);
- setAnnotationTable(annotation_table);
-
- }
-
- /**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept(Visitor v) {
-// v.visitAnnotation(this);
- }
-
- /**
- * @param annotation_table the entries to set in this annotation
- */
- public final void setAnnotationTable(AnnotationEntry[] annotation_table)
- {
- this.annotation_table = annotation_table;
- annotation_table_length = (annotation_table == null)? 0 :
- annotation_table.length;
- }
-
- /**
- * @return the annotation entry table
- */
- public final AnnotationEntry[] getAnnotationTable()
- {
- return annotation_table;
- }
-
- /**
- * returns the array of annotation entries in this annotation
- */
- public AnnotationEntry[] getAnnotationEntries() {
- return annotation_table;
- }
-
- /**
- * @return the number of annotation entries in this annotation
- */
- public final int getNumAnnotations() { return annotation_table_length; }
+
+ /**
+ * @param annotation_type the subclass type of the annotation
+ * @param name_index Index pointing to the name <em>Code</em>
+ * @param length Content length in bytes
+ * @param file Input stream
+ * @param constant_pool Array of constants
+ */
+ Annotations(byte annotation_type, int name_index, int length, DataInputStream file,
+ ConstantPool constant_pool) throws IOException {
+ this(annotation_type, name_index, length, (AnnotationEntry[]) null, constant_pool);
+ annotation_table_length = (file.readUnsignedShort());
+ annotation_table = new AnnotationEntry[annotation_table_length];
+ for (int i = 0; i < annotation_table_length; i++) {
+ annotation_table[i] = new AnnotationEntry(file, constant_pool);
+ }
+ }
+
+
+ /**
+ * @param annotation_type the subclass type of the annotation
+ * @param name_index Index pointing to the name <em>Code</em>
+ * @param length Content length in bytes
+ * @param annotation_table the actual annotations
+ * @param constant_pool Array of constants
+ */
+ public Annotations(byte annotation_type, int name_index, int length,
+ AnnotationEntry[] annotation_table, ConstantPool constant_pool) {
+ super(annotation_type, name_index, length, constant_pool);
+ setAnnotationTable(annotation_table);
+ }
+
+
+ /**
+ * Called by objects that are traversing the nodes of the tree implicitely
+ * defined by the contents of a Java class. I.e., the hierarchy of methods,
+ * fields, attributes, etc. spawns a tree of objects.
+ *
+ * @param v Visitor object
+ */
+ public void accept( Visitor v ) {
+ // v.visitAnnotation(this);
+ }
+
+
+ /**
+ * @param annotation_table the entries to set in this annotation
+ */
+ public final void setAnnotationTable( AnnotationEntry[] annotation_table ) {
+ this.annotation_table = annotation_table;
+ annotation_table_length = (annotation_table == null) ? 0 : annotation_table.length;
+ }
+
+
+ /**
+ * @return the annotation entry table
+ */
+ public final AnnotationEntry[] getAnnotationTable() {
+ return annotation_table;
+ }
+
+
+ /**
+ * returns the array of annotation entries in this annotation
+ */
+ public AnnotationEntry[] getAnnotationEntries() {
+ return annotation_table;
+ }
+
+
+ /**
+ * @return the number of annotation entries in this annotation
+ */
+ public final int getNumAnnotations() {
+ return annotation_table_length;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-dev-help@jakarta.apache.org