aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.cvsignore3
-rw-r--r--README62
-rw-r--r--README.JustIce40
-rw-r--r--TODO.JustIce35
-rw-r--r--build.xml157
-rw-r--r--docs/Faculty.java28
-rw-r--r--docs/HelloWorld.java16
-rw-r--r--docs/Peephole.java82
-rw-r--r--docs/appendix.tex193
-rw-r--r--docs/bool.java24
-rw-r--r--docs/classfile.mdl2134
-rw-r--r--docs/diagrams.tex19
-rw-r--r--docs/eps/classfile.eps378
-rw-r--r--docs/eps/classfile.fig173
-rw-r--r--docs/eps/classgen.eps499
-rw-r--r--docs/eps/classgen.fig302
-rw-r--r--docs/eps/classloader.eps160
-rw-r--r--docs/eps/classloader.fig47
-rw-r--r--docs/eps/constantpool.eps399
-rw-r--r--docs/eps/constantpool.fig211
-rw-r--r--docs/eps/diagram.fig351
-rw-r--r--docs/eps/il.eps513
-rw-r--r--docs/eps/il.fig225
-rw-r--r--docs/eps/instructions.eps445
-rw-r--r--docs/eps/instructions.fig245
-rw-r--r--docs/eps/javaclass.eps525
-rw-r--r--docs/eps/javaclass.fig353
-rw-r--r--docs/eps/jvm.eps218
-rw-r--r--docs/eps/jvm.fig62
-rw-r--r--docs/generic.mdl2860
-rw-r--r--docs/manual.bib185
-rw-r--r--docs/manual.ps4988
-rw-r--r--docs/manual.tex1079
-rw-r--r--docs/opt24
-rw-r--r--docs/unopt24
-rw-r--r--examples/HelloWorldBuilder.java157
-rw-r--r--examples/JasminVisitor.java281
-rw-r--r--examples/Mini/ASCII_CharStream.java381
-rw-r--r--examples/Mini/ASTExpr.java292
-rw-r--r--examples/Mini/ASTFactor.java37
-rw-r--r--examples/Mini/ASTFunAppl.java221
-rw-r--r--examples/Mini/ASTFunDecl.java395
-rw-r--r--examples/Mini/ASTIdent.java118
-rw-r--r--examples/Mini/ASTIfExpr.java156
-rw-r--r--examples/Mini/ASTInteger.java73
-rw-r--r--examples/Mini/ASTLetExpr.java159
-rw-r--r--examples/Mini/ASTProgram.java301
-rw-r--r--examples/Mini/ASTTerm.java37
-rw-r--r--examples/Mini/EnvEntry.java13
-rw-r--r--examples/Mini/Environment.java184
-rw-r--r--examples/Mini/Function.java63
-rw-r--r--examples/Mini/JJTMiniParserState.java123
-rw-r--r--examples/Mini/Mini.bnf75
-rw-r--r--examples/Mini/Mini.jj576
-rw-r--r--examples/Mini/Mini.jjt293
-rw-r--r--examples/Mini/MiniC.java154
-rw-r--r--examples/Mini/MiniParser$JJCallsbin0 -> 363 bytes
-rw-r--r--examples/Mini/MiniParser.java991
-rw-r--r--examples/Mini/MiniParserConstants.java85
-rw-r--r--examples/Mini/MiniParserTokenManager.java721
-rw-r--r--examples/Mini/MiniParserTreeConstants.java33
-rw-r--r--examples/Mini/Node.java35
-rw-r--r--examples/Mini/ParseException.java191
-rw-r--r--examples/Mini/README54
-rw-r--r--examples/Mini/SimpleNode.java81
-rw-r--r--examples/Mini/Token.java81
-rw-r--r--examples/Mini/TokenMgrError.java133
-rw-r--r--examples/Mini/Variable.java50
-rw-r--r--examples/Mini/fac.mini10
-rw-r--r--examples/Mini/fib.mini11
-rw-r--r--examples/Mini/max.mini21
-rw-r--r--examples/Package.java243
-rw-r--r--examples/Peephole.java88
-rw-r--r--examples/ProxyCreator.java105
-rw-r--r--examples/helloify.java109
-rw-r--r--examples/id.java47
-rw-r--r--examples/listclass.java225
-rw-r--r--examples/maxstack.java61
-rw-r--r--examples/patchclass.java90
-rw-r--r--lib/CCK.jarbin0 -> 473400 bytes
-rw-r--r--lib/Regex.jarbin0 -> 29871 bytes
-rw-r--r--src/java/org/apache/bcel/Constants.java768
-rw-r--r--src/java/org/apache/bcel/ExceptionConstants.java123
-rw-r--r--src/java/org/apache/bcel/Repository.java295
-rw-r--r--src/java/org/apache/bcel/classfile/AccessFlags.java159
-rw-r--r--src/java/org/apache/bcel/classfile/Attribute.java274
-rw-r--r--src/java/org/apache/bcel/classfile/ClassParser.java329
-rw-r--r--src/java/org/apache/bcel/classfile/Code.java373
-rw-r--r--src/java/org/apache/bcel/classfile/CodeException.java227
-rw-r--r--src/java/org/apache/bcel/classfile/Constant.java148
-rw-r--r--src/java/org/apache/bcel/classfile/ConstantCP.java154
-rw-r--r--src/java/org/apache/bcel/classfile/ConstantClass.java153
-rw-r--r--src/java/org/apache/bcel/classfile/ConstantDouble.java142
-rw-r--r--src/java/org/apache/bcel/classfile/ConstantFieldref.java104
-rw-r--r--src/java/org/apache/bcel/classfile/ConstantFloat.java141
-rw-r--r--src/java/org/apache/bcel/classfile/ConstantInteger.java148
-rw-r--r--src/java/org/apache/bcel/classfile/ConstantInterfaceMethodref.java104
-rw-r--r--src/java/org/apache/bcel/classfile/ConstantLong.java139
-rw-r--r--src/java/org/apache/bcel/classfile/ConstantMethodref.java104
-rw-r--r--src/java/org/apache/bcel/classfile/ConstantNameAndType.java171
-rw-r--r--src/java/org/apache/bcel/classfile/ConstantObject.java69
-rw-r--r--src/java/org/apache/bcel/classfile/ConstantPool.java369
-rw-r--r--src/java/org/apache/bcel/classfile/ConstantString.java147
-rw-r--r--src/java/org/apache/bcel/classfile/ConstantUtf8.java143
-rw-r--r--src/java/org/apache/bcel/classfile/ConstantValue.java204
-rw-r--r--src/java/org/apache/bcel/classfile/Deprecated.java170
-rw-r--r--src/java/org/apache/bcel/classfile/DescendingVisitor.java351
-rw-r--r--src/java/org/apache/bcel/classfile/EmptyVisitor.java104
-rw-r--r--src/java/org/apache/bcel/classfile/ExceptionTable.java202
-rw-r--r--src/java/org/apache/bcel/classfile/Field.java157
-rw-r--r--src/java/org/apache/bcel/classfile/FieldOrMethod.java223
-rw-r--r--src/java/org/apache/bcel/classfile/InnerClass.java221
-rw-r--r--src/java/org/apache/bcel/classfile/InnerClasses.java181
-rw-r--r--src/java/org/apache/bcel/classfile/JavaClass.java611
-rw-r--r--src/java/org/apache/bcel/classfile/LineNumber.java164
-rw-r--r--src/java/org/apache/bcel/classfile/LineNumberTable.java234
-rw-r--r--src/java/org/apache/bcel/classfile/LocalVariable.java257
-rw-r--r--src/java/org/apache/bcel/classfile/LocalVariableTable.java196
-rw-r--r--src/java/org/apache/bcel/classfile/Method.java216
-rw-r--r--src/java/org/apache/bcel/classfile/Node.java65
-rw-r--r--src/java/org/apache/bcel/classfile/PMGClass.java189
-rw-r--r--src/java/org/apache/bcel/classfile/Signature.java295
-rw-r--r--src/java/org/apache/bcel/classfile/SourceFile.java165
-rw-r--r--src/java/org/apache/bcel/classfile/StackMap.java185
-rw-r--r--src/java/org/apache/bcel/classfile/StackMapEntry.java209
-rw-r--r--src/java/org/apache/bcel/classfile/StackMapType.java172
-rw-r--r--src/java/org/apache/bcel/classfile/Synthetic.java171
-rw-r--r--src/java/org/apache/bcel/classfile/Unknown.java205
-rw-r--r--src/java/org/apache/bcel/classfile/Utility.java1355
-rw-r--r--src/java/org/apache/bcel/classfile/Visitor.java100
-rw-r--r--src/java/org/apache/bcel/classfile/lic53
-rw-r--r--src/java/org/apache/bcel/classfile/package.html14
-rw-r--r--src/java/org/apache/bcel/generic/AALOAD.java87
-rw-r--r--src/java/org/apache/bcel/generic/AASTORE.java87
-rw-r--r--src/java/org/apache/bcel/generic/ACONST_NULL.java94
-rw-r--r--src/java/org/apache/bcel/generic/ALOAD.java92
-rw-r--r--src/java/org/apache/bcel/generic/ANEWARRAY.java114
-rw-r--r--src/java/org/apache/bcel/generic/ARETURN.java88
-rw-r--r--src/java/org/apache/bcel/generic/ARRAYLENGTH.java92
-rw-r--r--src/java/org/apache/bcel/generic/ASTORE.java92
-rw-r--r--src/java/org/apache/bcel/generic/ATHROW.java92
-rw-r--r--src/java/org/apache/bcel/generic/AllocationInstruction.java64
-rw-r--r--src/java/org/apache/bcel/generic/ArithmeticInstruction.java106
-rw-r--r--src/java/org/apache/bcel/generic/ArrayInstruction.java106
-rw-r--r--src/java/org/apache/bcel/generic/ArrayType.java156
-rw-r--r--src/java/org/apache/bcel/generic/BALOAD.java87
-rw-r--r--src/java/org/apache/bcel/generic/BASTORE.java87
-rw-r--r--src/java/org/apache/bcel/generic/BIPUSH.java132
-rw-r--r--src/java/org/apache/bcel/generic/BREAKPOINT.java80
-rw-r--r--src/java/org/apache/bcel/generic/BasicType.java101
-rw-r--r--src/java/org/apache/bcel/generic/BranchHandle.java151
-rw-r--r--src/java/org/apache/bcel/generic/BranchInstruction.java246
-rw-r--r--src/java/org/apache/bcel/generic/CALOAD.java87
-rw-r--r--src/java/org/apache/bcel/generic/CASTORE.java87
-rw-r--r--src/java/org/apache/bcel/generic/CHECKCAST.java117
-rw-r--r--src/java/org/apache/bcel/generic/CPInstruction.java166
-rw-r--r--src/java/org/apache/bcel/generic/ClassGen.java434
-rw-r--r--src/java/org/apache/bcel/generic/ClassGenException.java68
-rw-r--r--src/java/org/apache/bcel/generic/ClassObserver.java67
-rw-r--r--src/java/org/apache/bcel/generic/CodeExceptionGen.java201
-rw-r--r--src/java/org/apache/bcel/generic/CompoundInstruction.java76
-rw-r--r--src/java/org/apache/bcel/generic/ConstantPoolGen.java782
-rw-r--r--src/java/org/apache/bcel/generic/ConstantPushInstruction.java70
-rw-r--r--src/java/org/apache/bcel/generic/ConversionInstruction.java102
-rw-r--r--src/java/org/apache/bcel/generic/D2F.java87
-rw-r--r--src/java/org/apache/bcel/generic/D2I.java87
-rw-r--r--src/java/org/apache/bcel/generic/D2L.java87
-rw-r--r--src/java/org/apache/bcel/generic/DADD.java88
-rw-r--r--src/java/org/apache/bcel/generic/DALOAD.java87
-rw-r--r--src/java/org/apache/bcel/generic/DASTORE.java87
-rw-r--r--src/java/org/apache/bcel/generic/DCMPG.java93
-rw-r--r--src/java/org/apache/bcel/generic/DCMPL.java92
-rw-r--r--src/java/org/apache/bcel/generic/DCONST.java112
-rw-r--r--src/java/org/apache/bcel/generic/DDIV.java88
-rw-r--r--src/java/org/apache/bcel/generic/DLOAD.java92
-rw-r--r--src/java/org/apache/bcel/generic/DMUL.java88
-rw-r--r--src/java/org/apache/bcel/generic/DNEG.java85
-rw-r--r--src/java/org/apache/bcel/generic/DREM.java88
-rw-r--r--src/java/org/apache/bcel/generic/DRETURN.java87
-rw-r--r--src/java/org/apache/bcel/generic/DSTORE.java92
-rw-r--r--src/java/org/apache/bcel/generic/DSUB.java88
-rw-r--r--src/java/org/apache/bcel/generic/DUP.java84
-rw-r--r--src/java/org/apache/bcel/generic/DUP2.java84
-rw-r--r--src/java/org/apache/bcel/generic/DUP2_X1.java82
-rw-r--r--src/java/org/apache/bcel/generic/DUP2_X2.java82
-rw-r--r--src/java/org/apache/bcel/generic/DUP_X1.java82
-rw-r--r--src/java/org/apache/bcel/generic/DUP_X2.java82
-rw-r--r--src/java/org/apache/bcel/generic/EmptyVisitor.java244
-rw-r--r--src/java/org/apache/bcel/generic/ExceptionThrower.java79
-rw-r--r--src/java/org/apache/bcel/generic/F2D.java87
-rw-r--r--src/java/org/apache/bcel/generic/F2I.java87
-rw-r--r--src/java/org/apache/bcel/generic/F2L.java87
-rw-r--r--src/java/org/apache/bcel/generic/FADD.java87
-rw-r--r--src/java/org/apache/bcel/generic/FALOAD.java87
-rw-r--r--src/java/org/apache/bcel/generic/FASTORE.java87
-rw-r--r--src/java/org/apache/bcel/generic/FCMPG.java91
-rw-r--r--src/java/org/apache/bcel/generic/FCMPL.java91
-rw-r--r--src/java/org/apache/bcel/generic/FCONST.java114
-rw-r--r--src/java/org/apache/bcel/generic/FDIV.java87
-rw-r--r--src/java/org/apache/bcel/generic/FLOAD.java92
-rw-r--r--src/java/org/apache/bcel/generic/FMUL.java87
-rw-r--r--src/java/org/apache/bcel/generic/FNEG.java85
-rw-r--r--src/java/org/apache/bcel/generic/FREM.java87
-rw-r--r--src/java/org/apache/bcel/generic/FRETURN.java87
-rw-r--r--src/java/org/apache/bcel/generic/FSTORE.java92
-rw-r--r--src/java/org/apache/bcel/generic/FSUB.java87
-rw-r--r--src/java/org/apache/bcel/generic/FieldGen.java310
-rw-r--r--src/java/org/apache/bcel/generic/FieldGenOrMethodGen.java129
-rw-r--r--src/java/org/apache/bcel/generic/FieldInstruction.java116
-rw-r--r--src/java/org/apache/bcel/generic/FieldObserver.java67
-rw-r--r--src/java/org/apache/bcel/generic/FieldOrMethod.java117
-rw-r--r--src/java/org/apache/bcel/generic/GETFIELD.java117
-rw-r--r--src/java/org/apache/bcel/generic/GETSTATIC.java113
-rw-r--r--src/java/org/apache/bcel/generic/GOTO.java122
-rw-r--r--src/java/org/apache/bcel/generic/GOTO_W.java110
-rw-r--r--src/java/org/apache/bcel/generic/GotoInstruction.java75
-rw-r--r--src/java/org/apache/bcel/generic/I2B.java87
-rw-r--r--src/java/org/apache/bcel/generic/I2C.java87
-rw-r--r--src/java/org/apache/bcel/generic/I2D.java87
-rw-r--r--src/java/org/apache/bcel/generic/I2F.java87
-rw-r--r--src/java/org/apache/bcel/generic/I2L.java87
-rw-r--r--src/java/org/apache/bcel/generic/I2S.java85
-rw-r--r--src/java/org/apache/bcel/generic/IADD.java87
-rw-r--r--src/java/org/apache/bcel/generic/IALOAD.java88
-rw-r--r--src/java/org/apache/bcel/generic/IAND.java85
-rw-r--r--src/java/org/apache/bcel/generic/IASTORE.java88
-rw-r--r--src/java/org/apache/bcel/generic/ICONST.java110
-rw-r--r--src/java/org/apache/bcel/generic/IDIV.java94
-rw-r--r--src/java/org/apache/bcel/generic/IFEQ.java98
-rw-r--r--src/java/org/apache/bcel/generic/IFGE.java98
-rw-r--r--src/java/org/apache/bcel/generic/IFGT.java98
-rw-r--r--src/java/org/apache/bcel/generic/IFLE.java98
-rw-r--r--src/java/org/apache/bcel/generic/IFLT.java98
-rw-r--r--src/java/org/apache/bcel/generic/IFNE.java98
-rw-r--r--src/java/org/apache/bcel/generic/IFNONNULL.java97
-rw-r--r--src/java/org/apache/bcel/generic/IFNULL.java98
-rw-r--r--src/java/org/apache/bcel/generic/IF_ACMPEQ.java97
-rw-r--r--src/java/org/apache/bcel/generic/IF_ACMPNE.java98
-rw-r--r--src/java/org/apache/bcel/generic/IF_ICMPEQ.java98
-rw-r--r--src/java/org/apache/bcel/generic/IF_ICMPGE.java98
-rw-r--r--src/java/org/apache/bcel/generic/IF_ICMPGT.java98
-rw-r--r--src/java/org/apache/bcel/generic/IF_ICMPLE.java98
-rw-r--r--src/java/org/apache/bcel/generic/IF_ICMPLT.java98
-rw-r--r--src/java/org/apache/bcel/generic/IF_ICMPNE.java98
-rw-r--r--src/java/org/apache/bcel/generic/IINC.java179
-rw-r--r--src/java/org/apache/bcel/generic/ILOAD.java92
-rw-r--r--src/java/org/apache/bcel/generic/IMPDEP1.java80
-rw-r--r--src/java/org/apache/bcel/generic/IMPDEP2.java80
-rw-r--r--src/java/org/apache/bcel/generic/IMUL.java87
-rw-r--r--src/java/org/apache/bcel/generic/INEG.java85
-rw-r--r--src/java/org/apache/bcel/generic/INSTANCEOF.java106
-rw-r--r--src/java/org/apache/bcel/generic/INVOKEINTERFACE.java163
-rw-r--r--src/java/org/apache/bcel/generic/INVOKESPECIAL.java113
-rw-r--r--src/java/org/apache/bcel/generic/INVOKESTATIC.java110
-rw-r--r--src/java/org/apache/bcel/generic/INVOKEVIRTUAL.java112
-rw-r--r--src/java/org/apache/bcel/generic/IOR.java85
-rw-r--r--src/java/org/apache/bcel/generic/IREM.java94
-rw-r--r--src/java/org/apache/bcel/generic/IRETURN.java87
-rw-r--r--src/java/org/apache/bcel/generic/ISHL.java85
-rw-r--r--src/java/org/apache/bcel/generic/ISHR.java85
-rw-r--r--src/java/org/apache/bcel/generic/ISTORE.java92
-rw-r--r--src/java/org/apache/bcel/generic/ISUB.java87
-rw-r--r--src/java/org/apache/bcel/generic/IUSHR.java85
-rw-r--r--src/java/org/apache/bcel/generic/IXOR.java85
-rw-r--r--src/java/org/apache/bcel/generic/IfInstruction.java82
-rw-r--r--src/java/org/apache/bcel/generic/IndexedInstruction.java68
-rw-r--r--src/java/org/apache/bcel/generic/Instruction.java276
-rw-r--r--src/java/org/apache/bcel/generic/InstructionConstants.java326
-rw-r--r--src/java/org/apache/bcel/generic/InstructionFactory.java593
-rw-r--r--src/java/org/apache/bcel/generic/InstructionHandle.java284
-rw-r--r--src/java/org/apache/bcel/generic/InstructionList.java1287
-rw-r--r--src/java/org/apache/bcel/generic/InstructionListObserver.java67
-rw-r--r--src/java/org/apache/bcel/generic/InstructionTargeter.java70
-rw-r--r--src/java/org/apache/bcel/generic/InvokeInstruction.java146
-rw-r--r--src/java/org/apache/bcel/generic/JSR.java119
-rw-r--r--src/java/org/apache/bcel/generic/JSR_W.java110
-rw-r--r--src/java/org/apache/bcel/generic/JsrInstruction.java116
-rw-r--r--src/java/org/apache/bcel/generic/L2D.java85
-rw-r--r--src/java/org/apache/bcel/generic/L2F.java85
-rw-r--r--src/java/org/apache/bcel/generic/L2I.java85
-rw-r--r--src/java/org/apache/bcel/generic/LADD.java86
-rw-r--r--src/java/org/apache/bcel/generic/LALOAD.java87
-rw-r--r--src/java/org/apache/bcel/generic/LAND.java86
-rw-r--r--src/java/org/apache/bcel/generic/LASTORE.java87
-rw-r--r--src/java/org/apache/bcel/generic/LCMP.java82
-rw-r--r--src/java/org/apache/bcel/generic/LCONST.java112
-rw-r--r--src/java/org/apache/bcel/generic/LDC.java172
-rw-r--r--src/java/org/apache/bcel/generic/LDC2_W.java116
-rw-r--r--src/java/org/apache/bcel/generic/LDC_W.java87
-rw-r--r--src/java/org/apache/bcel/generic/LDIV.java91
-rw-r--r--src/java/org/apache/bcel/generic/LLOAD.java89
-rw-r--r--src/java/org/apache/bcel/generic/LMUL.java86
-rw-r--r--src/java/org/apache/bcel/generic/LNEG.java85
-rw-r--r--src/java/org/apache/bcel/generic/LOOKUPSWITCH.java133
-rw-r--r--src/java/org/apache/bcel/generic/LOR.java85
-rw-r--r--src/java/org/apache/bcel/generic/LREM.java88
-rw-r--r--src/java/org/apache/bcel/generic/LRETURN.java85
-rw-r--r--src/java/org/apache/bcel/generic/LSHL.java85
-rw-r--r--src/java/org/apache/bcel/generic/LSHR.java85
-rw-r--r--src/java/org/apache/bcel/generic/LSTORE.java89
-rw-r--r--src/java/org/apache/bcel/generic/LSUB.java86
-rw-r--r--src/java/org/apache/bcel/generic/LUSHR.java85
-rw-r--r--src/java/org/apache/bcel/generic/LXOR.java85
-rw-r--r--src/java/org/apache/bcel/generic/LineNumberGen.java130
-rw-r--r--src/java/org/apache/bcel/generic/LoadClass.java86
-rw-r--r--src/java/org/apache/bcel/generic/LoadInstruction.java101
-rw-r--r--src/java/org/apache/bcel/generic/LocalVariableGen.java191
-rw-r--r--src/java/org/apache/bcel/generic/LocalVariableInstruction.java227
-rw-r--r--src/java/org/apache/bcel/generic/MONITORENTER.java88
-rw-r--r--src/java/org/apache/bcel/generic/MONITOREXIT.java88
-rw-r--r--src/java/org/apache/bcel/generic/MULTIANEWARRAY.java172
-rw-r--r--src/java/org/apache/bcel/generic/MethodGen.java938
-rw-r--r--src/java/org/apache/bcel/generic/MethodObserver.java67
-rw-r--r--src/java/org/apache/bcel/generic/NEW.java111
-rw-r--r--src/java/org/apache/bcel/generic/NEWARRAY.java141
-rw-r--r--src/java/org/apache/bcel/generic/NOP.java80
-rw-r--r--src/java/org/apache/bcel/generic/NamedAndTyped.java71
-rw-r--r--src/java/org/apache/bcel/generic/ObjectType.java136
-rw-r--r--src/java/org/apache/bcel/generic/POP.java85
-rw-r--r--src/java/org/apache/bcel/generic/POP2.java85
-rw-r--r--src/java/org/apache/bcel/generic/PUSH.java196
-rw-r--r--src/java/org/apache/bcel/generic/PUTFIELD.java114
-rw-r--r--src/java/org/apache/bcel/generic/PUTSTATIC.java114
-rw-r--r--src/java/org/apache/bcel/generic/PopInstruction.java68
-rw-r--r--src/java/org/apache/bcel/generic/PushInstruction.java73
-rw-r--r--src/java/org/apache/bcel/generic/RET.java161
-rw-r--r--src/java/org/apache/bcel/generic/RETURN.java85
-rw-r--r--src/java/org/apache/bcel/generic/ReferenceType.java258
-rw-r--r--src/java/org/apache/bcel/generic/ReturnInstruction.java104
-rw-r--r--src/java/org/apache/bcel/generic/ReturnaddressType.java102
-rw-r--r--src/java/org/apache/bcel/generic/SALOAD.java85
-rw-r--r--src/java/org/apache/bcel/generic/SASTORE.java85
-rw-r--r--src/java/org/apache/bcel/generic/SIPUSH.java129
-rw-r--r--src/java/org/apache/bcel/generic/SWAP.java84
-rw-r--r--src/java/org/apache/bcel/generic/SWITCH.java183
-rw-r--r--src/java/org/apache/bcel/generic/Select.java256
-rw-r--r--src/java/org/apache/bcel/generic/StackConsumer.java68
-rw-r--r--src/java/org/apache/bcel/generic/StackInstruction.java83
-rw-r--r--src/java/org/apache/bcel/generic/StackProducer.java69
-rw-r--r--src/java/org/apache/bcel/generic/StoreInstruction.java102
-rw-r--r--src/java/org/apache/bcel/generic/TABLESWITCH.java147
-rw-r--r--src/java/org/apache/bcel/generic/TargetLostException.java100
-rw-r--r--src/java/org/apache/bcel/generic/Type.java232
-rw-r--r--src/java/org/apache/bcel/generic/TypedInstruction.java67
-rw-r--r--src/java/org/apache/bcel/generic/UnconditionalBranch.java67
-rw-r--r--src/java/org/apache/bcel/generic/VariableLengthInstruction.java70
-rw-r--r--src/java/org/apache/bcel/generic/Visitor.java247
-rw-r--r--src/java/org/apache/bcel/generic/package.html16
-rw-r--r--src/java/org/apache/bcel/package.html17
-rw-r--r--src/java/org/apache/bcel/util/AttributeHTML.java256
-rw-r--r--src/java/org/apache/bcel/util/ByteSequence.java82
-rw-r--r--src/java/org/apache/bcel/util/Class2HTML.java262
-rw-r--r--src/java/org/apache/bcel/util/ClassLoader.java200
-rw-r--r--src/java/org/apache/bcel/util/ClassPath.java322
-rw-r--r--src/java/org/apache/bcel/util/ClassQueue.java78
-rw-r--r--src/java/org/apache/bcel/util/ClassStack.java73
-rw-r--r--src/java/org/apache/bcel/util/ClassVector.java79
-rw-r--r--src/java/org/apache/bcel/util/CodeHTML.java618
-rw-r--r--src/java/org/apache/bcel/util/ConstantHTML.java262
-rw-r--r--src/java/org/apache/bcel/util/InstructionFinder.java440
-rw-r--r--src/java/org/apache/bcel/util/JavaWrapper.java152
-rw-r--r--src/java/org/apache/bcel/util/MethodHTML.java199
-rw-r--r--src/java/org/apache/bcel/util/package.html25
-rw-r--r--src/java/org/apache/bcel/verifier/GraphicalVerifier.java109
-rw-r--r--src/java/org/apache/bcel/verifier/NativeVerifier.java116
-rw-r--r--src/java/org/apache/bcel/verifier/PassVerifier.java143
-rw-r--r--src/java/org/apache/bcel/verifier/TransitiveHull.java138
-rw-r--r--src/java/org/apache/bcel/verifier/VerificationResult.java138
-rw-r--r--src/java/org/apache/bcel/verifier/Verifier.java283
-rw-r--r--src/java/org/apache/bcel/verifier/VerifierAppFrame.java390
-rw-r--r--src/java/org/apache/bcel/verifier/VerifierFactory.java142
-rw-r--r--src/java/org/apache/bcel/verifier/VerifierFactoryListModel.java107
-rw-r--r--src/java/org/apache/bcel/verifier/VerifierFactoryObserver.java76
-rw-r--r--src/java/org/apache/bcel/verifier/VerifyDialog.java559
-rw-r--r--src/java/org/apache/bcel/verifier/exc/AssertionViolatedException.java115
-rw-r--r--src/java/org/apache/bcel/verifier/exc/ClassConstraintException.java83
-rw-r--r--src/java/org/apache/bcel/verifier/exc/CodeConstraintException.java77
-rw-r--r--src/java/org/apache/bcel/verifier/exc/InvalidMethodException.java71
-rw-r--r--src/java/org/apache/bcel/verifier/exc/LinkingConstraintException.java74
-rw-r--r--src/java/org/apache/bcel/verifier/exc/LoadingException.java82
-rw-r--r--src/java/org/apache/bcel/verifier/exc/LocalVariableInfoInconsistentException.java81
-rw-r--r--src/java/org/apache/bcel/verifier/exc/StaticCodeConstraintException.java71
-rw-r--r--src/java/org/apache/bcel/verifier/exc/StaticCodeInstructionConstraintException.java74
-rw-r--r--src/java/org/apache/bcel/verifier/exc/StaticCodeInstructionOperandConstraintException.java74
-rw-r--r--src/java/org/apache/bcel/verifier/exc/StructuralCodeConstraintException.java82
-rw-r--r--src/java/org/apache/bcel/verifier/exc/Utility.java76
-rw-r--r--src/java/org/apache/bcel/verifier/exc/VerificationException.java82
-rw-r--r--src/java/org/apache/bcel/verifier/exc/VerifierConstraintViolatedException.java107
-rw-r--r--src/java/org/apache/bcel/verifier/exc/package.html24
-rw-r--r--src/java/org/apache/bcel/verifier/package.html25
-rw-r--r--src/java/org/apache/bcel/verifier/statics/DOUBLE_Upper.java79
-rw-r--r--src/java/org/apache/bcel/verifier/statics/IntList.java85
-rw-r--r--src/java/org/apache/bcel/verifier/statics/LONG_Upper.java79
-rw-r--r--src/java/org/apache/bcel/verifier/statics/LocalVariableInfo.java145
-rw-r--r--src/java/org/apache/bcel/verifier/statics/LocalVariablesInfo.java113
-rw-r--r--src/java/org/apache/bcel/verifier/statics/Pass1Verifier.java214
-rw-r--r--src/java/org/apache/bcel/verifier/statics/Pass2Verifier.java1334
-rw-r--r--src/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java1070
-rw-r--r--src/java/org/apache/bcel/verifier/statics/StringRepresentation.java202
-rw-r--r--src/java/org/apache/bcel/verifier/statics/package.html26
-rw-r--r--src/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java466
-rw-r--r--src/java/org/apache/bcel/verifier/structurals/ExceptionHandler.java93
-rw-r--r--src/java/org/apache/bcel/verifier/structurals/ExceptionHandlers.java107
-rw-r--r--src/java/org/apache/bcel/verifier/structurals/ExecutionVisitor.java1126
-rw-r--r--src/java/org/apache/bcel/verifier/structurals/Frame.java153
-rw-r--r--src/java/org/apache/bcel/verifier/structurals/GenericArray.java66
-rw-r--r--src/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java2652
-rw-r--r--src/java/org/apache/bcel/verifier/structurals/InstructionContext.java141
-rw-r--r--src/java/org/apache/bcel/verifier/structurals/LocalVariables.java229
-rw-r--r--src/java/org/apache/bcel/verifier/structurals/OperandStack.java275
-rw-r--r--src/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java366
-rw-r--r--src/java/org/apache/bcel/verifier/structurals/Subroutine.java126
-rw-r--r--src/java/org/apache/bcel/verifier/structurals/Subroutines.java668
-rw-r--r--src/java/org/apache/bcel/verifier/structurals/UninitializedObjectType.java97
-rw-r--r--src/java/org/apache/bcel/verifier/structurals/package.html27
415 files changed, 78788 insertions, 0 deletions
diff --git a/.cvsignore b/.cvsignore
new file mode 100644
index 00000000..534d47ab
--- /dev/null
+++ b/.cvsignore
@@ -0,0 +1,3 @@
+bin
+velocity.log
+*~
diff --git a/README b/README
new file mode 100644
index 00000000..2b754740
--- /dev/null
+++ b/README
@@ -0,0 +1,62 @@
+********** A lot to do here ... ********************
+
+I took the chance to make some changes when moving to Apache. In particular:
+
+* The package names have changed, just rename the prefix
+ de.fub.bytecode -> org.apache.bcel
+* All deprecated classes and methods have been removed (e.g.,
+ Instruction.getTag() == getOpcode())
+* The FindPattern class has been removed in favor of
+ org.apache.bcel.util.InstructionFinder which offers an improved API
+* The Regex package from Jakarta is used instead of GNU regexp
+* BCEL now relies on JDK1.2 classes, collection classes in particular, this
+ may even speed up BCEL a bit since no more synchronization locks are used
+* BCEL is compiled using ANT instead of make
+
+However, for 99% of the users they will just have to rename the
+packages and it will work.
+
+
+There are also some new parts of BCEL, which have been distributed as
+separate packages before:
+
+BCEL Manual
+-----------
+
+The BCEL manual (the former Technical report) is added to the distribution.
+
+
+Class Construction Kit (CCK)
+----------------------------
+
+The sources can be obtained upon request, however they've been developed
+with IBM's VisualAge, thus they're hard to read at best. You can request
+and Visual Age repository file as well. CCK has been developed by
+Markus Dahm (markus.dahm@berlin.de)
+
+You can run CCK with java -jar lib/CCK.jar
+
+JustIce verifier
+----------------
+
+The JustIce bytecode verifier has been developed by Enver Haase
+(enver@convergence.de) and is now an integral part of BCEL.
+
+Mini
+----
+
+The Mini programming language is now distributed together with BCEL.
+
+
+New versions
+------------
+
+ http://jakarta.apache.org/bcel/
+
+Author
+------
+
+The BCEL is copyright (2001) Markus Dahm. Send bug reports and
+suggestions to markus.dahm@berlin.de (Markus Dahm), please tell me
+also if you find this tool helpful and in what kind of projects you
+use it.
diff --git a/README.JustIce b/README.JustIce
new file mode 100644
index 00000000..de6c4423
--- /dev/null
+++ b/README.JustIce
@@ -0,0 +1,40 @@
+
+--------------------------------
+RUNNING A CONSOLE-BASED VERIFIER
+--------------------------------
+
+A command like
+
+ java org.apache.bcel.verifier.Verifier fully.qualified.class.Name
+
+lets JustIce work standalone.
+
+
+If you get a "java.lang.OutOfMemoryError", you should increase the
+maximum Java heap space. A command like
+
+ java -Xmx1887436800 org.apache.bcel.verifier.Verifier f.q.c.Name
+
+will usually resolve the problem. The value above is suitable for
+big server machines; if your machine starts swapping to disk, try
+to lower the value.
+
+
+---------------------------------
+RUNNING A GRAPHICS-BASED VERIFIER
+---------------------------------
+
+If you prefer a graphical application, you should use a command like
+
+ java org.apache.bcel.verifier.GraphicalVerifier
+
+to launch one. Again, you may have to resolve a memory issue depending
+on the classes to verify.
+
+
+------------------
+CONTACT THE AUTHOR
+------------------
+
+If you do something useful with JustIce, I'd like to hear about it!
+Enver Haase <ehaase@inf.fu-berlin.de>
diff --git a/TODO.JustIce b/TODO.JustIce
new file mode 100644
index 00000000..a60343ee
--- /dev/null
+++ b/TODO.JustIce
@@ -0,0 +1,35 @@
+
+$Id$
+
+"TODO" list for JustIce, the Java Class File Verifier by Enver Haase.
+
+- JustIce uses object generalization during pass 3b, as supposed by
+Sun. However, there are better methods such as the idea proposed by
+Staerk et al.: using sets of object types.
+
+- There are a few bugs concerning access rights of referenced method
+and probably fields. The tests for access rights that Sun defines
+should happen in pass four (which JustIce performs during pass 3a) are
+unintentionally omitted. This also happened to Sun and IBM with some
+of their version 1.3 JVMs. Thanks Markus Dahm.
+
+- There are bugs because of an ambiguity in the Java Virtual Machine
+Specification, Second Edition. These have to do with inheritance: A
+method invocation like MyObject::equals(Object) is considered illegal,
+if MyObject has no overriding definition of equals(Object). Sun
+clarified this issue via electronic mail: the invocation is legal,
+because MyObject inherits the member function equals(Object) from
+Object::equals(Object). The search algorithms don't seem to be trivial
+because interfaces can not only specify methods, but also declare
+fields. Also, access modifiers have to be honoured (see above).
+
+- It is not verified if classes that propose they would implement an
+interface _really_ implement all the methods.
+
+- The InstructionContext.getSuccessors() method may return the same
+successor more than one time. For performance reasons the ControlFlow-
+Graph.InstructionContextImpl class should return an array where the
+successors are pairwise disjoint. It should also be cached so that we
+don't have to do this calculation every time.
+
+***End of File***
diff --git a/build.xml b/build.xml
new file mode 100644
index 00000000..8b03bcbd
--- /dev/null
+++ b/build.xml
@@ -0,0 +1,157 @@
+<?xml version="1.0"?>
+
+<!--
+ Build file for BCEL
+ $Id$
+
+Notes:
+ This is a build file for use with the Jakarta Ant build tool.
+
+Prerequisites:
+
+ jakarta-ant from http://jakarta.apache.org/ant/index.html
+
+Build Instructions:
+ To build, run
+
+ ant <target>
+
+ in the directory where this file is located with the target you want.
+
+Available targets:
+
+ - compile -> compile source classes and places result in "classes" directory
+ - jar -> Create file "lib/bcel.jar"
+ - test<x> -> Run example number x
+ - test -> Run all examples
+ - mini -> Run Mini compiler and test results
+ - docs -> Build documentation from TeX sources
+ - apidocs -> Build API documentation (javadoc) in "docs/api"
+-->
+
+<project default="jar" basedir=".">
+ <target name="init">
+ <property name="name" value="bcel"/>
+ <property name="packages" value="org.apache.bcel.*"/>
+ <property name="src.dir" value="${basedir}/src/java"/>
+ <property name="build.dir" value="${basedir}/bin"/>
+ <property name="examples.dir" value="${basedir}/examples"/>
+ <property name="mini.dir" value="${examples.dir}/Mini"/>
+ <property name="docs.dir" value="${basedir}/docs"/>
+ <property name="apidocs.dir" value="${docs.dir}/api"/>
+ <property name="build.dest" value="${build.dir}/classes"/>
+ <property name="lib.dir" value="${basedir}/lib"/>
+ <property name="class.path" value="${lib.dir}/Regex.jar:${build.dir}"/>
+
+ <!-- Use jikes compiler, if you don't have it comment out the next lines -->
+ <!-- property name="build.compiler.emacs" value="true"/ -->
+ <!-- property name="build.compiler" value="jikes"/ -->
+ </target>
+
+ <!-- Compile the sources -->
+ <target name="compile" depends="init">
+ <mkdir dir="${build.dest}"/>
+ <javac srcdir="${src.dir}" destdir="${build.dest}" classpath="${class.path}" debug="true"/>
+ </target>
+
+ <!-- Jar the library -->
+ <target name="jar" depends="compile">
+ <jar jarfile="${build.dir}/${name}.jar"
+ basedir="${build.dest}"
+ includes="org/**"
+ />
+ </target>
+
+ <!-- Compile the examples -->
+ <target name="examples" depends="compile">
+ <javac srcdir="${examples.dir}" destdir="${build.dir}" classpath="${class.path}" />
+ </target>
+
+ <target name="docs" depends="init">
+ <exec dir="${docs.dir}" executable="latex"> <arg line="manual.tex"/> </exec>
+ <exec dir="${docs.dir}" executable="bibtex"> <arg line="manual"/> </exec>
+ <exec dir="${docs.dir}" executable="latex"> <arg line="manual.tex"/> </exec>
+ <exec dir="${docs.dir}" executable="latex"> <arg line="manual.tex"/> </exec>
+ <exec dir="${docs.dir}" executable="dvips"> <arg line="manual.dvi"/> </exec>
+ </target>
+
+ <!-- Creates the API documentation -->
+ <target name="apidoc" depends="init">
+ <mkdir dir="${apidocs.dir}"/>
+ <javadoc packagenames="${packages}"
+ sourcepath="${src.dir}"
+ destdir="${apidocs.dir}"
+ author="true"
+ version="true"
+ use="true"
+ windowtitle="${name} API"
+ doctitle="${name}"
+ />
+ </target>
+
+ <target name="test1" depends="examples">
+ <echo message="Display class file contents"/>
+
+ <java classname="listclass" classpath="${class.path}">
+ <arg value="-code"/>
+ <arg value="java.lang.String"/>
+ </java>
+ </target>
+
+ <target name="test2" depends="examples">
+ <echo message="Decompile class file to Jasmin format"/>
+
+ <java classname="JasminVisitor" classpath="${class.path}">
+ <arg value="java.lang.String"/>
+ </java>
+ </target>
+
+ <target name="test3" depends="examples">
+ <echo message="Create Hello World class from scratch"/>
+ <java classname="HelloWorldBuilder" classpath="${class.path}"/>
+
+ <echo message="Running Hello World"/>
+ <java classname="HelloWorld" classpath="."/>
+ </target>
+
+ <target name="test4" depends="examples">
+ <echo message="Run fancy classloader example"/>
+
+ <java classname="org.apache.bcel.util.JavaWrapper" fork="true"
+ classpath="${class.path}">
+ <arg value="ProxyCreator"/>
+ </java>
+ </target>
+
+ <target name="test" depends="test1,test2,test3,test4"/>
+
+ <target name="mini" depends="examples">
+ <echo message="Run Mini compiler"/>
+
+ <java classname="Mini.MiniC" classpath="${class.path}" fork="true" dir="${mini.dir}">
+ <arg value="fac.mini"/>
+ <arg value="fib.mini"/>
+ <arg value="max.mini"/>
+ </java>
+
+ <echo message="Faculty"/>
+ <java classname="fac" classpath="${mini.dir}" />
+ <echo message="Fibonacci"/>
+ <java classname="fib" classpath="${mini.dir}" />
+ <echo message="Maximum of numbers"/>
+ <java classname="max" classpath="${mini.dir}" />
+ </target>
+
+ <!-- Clean everything up -->
+ <target name="clean" depends="init">
+ <delete dir="${build.dir}"/>
+ <delete>
+ <fileset dir="${docs.dir}"
+ includes="manual.blg,manual.bbl,manual.dvi,manual.log"/>
+ <fileset dir="${docs.dir}" includes="**/*.aux"/>
+ <fileset dir="${basedir}" includes="**/*~"/>
+ </delete>
+
+ </target>
+
+</project>
diff --git a/docs/Faculty.java b/docs/Faculty.java
new file mode 100644
index 00000000..c8e7d956
--- /dev/null
+++ b/docs/Faculty.java
@@ -0,0 +1,28 @@
+import java.io.*;
+
+public class Faculty {
+ private static BufferedReader in = new BufferedReader(new
+ InputStreamReader(System.in));
+
+ public static final int fac(int n) {
+ return(n == 0)? 1 : n * fac(n - 1);
+ }
+
+ public static final int readInt() {
+ int n = 4711;
+
+ try {
+ System.out.print("Please enter a number> ");
+ n = Integer.parseInt(in.readLine());
+ }
+ catch(IOException e1) { System.err.println(e1); }
+ catch(NumberFormatException e2) { System.err.println(e2); }
+
+ return n;
+ }
+
+ public static void main(String[] args) {
+ int n = readInt();
+ System.out.println("Faculty of " + n + " is " + fac(n));
+ }
+}
diff --git a/docs/HelloWorld.java b/docs/HelloWorld.java
new file mode 100644
index 00000000..1630e21f
--- /dev/null
+++ b/docs/HelloWorld.java
@@ -0,0 +1,16 @@
+import java.io.*;
+
+public class HelloWorld {
+ public static void main(String[] argv) {
+ BufferedReader in = new BufferedReader(new
+ InputStreamReader(System.in));
+ String name = null;
+
+ try {
+ System.out.print("Please enter your name> ");
+ name = in.readLine();
+ } catch(IOException e) { return; }
+
+ System.out.println("Hello, " + name);
+ }
+}
diff --git a/docs/Peephole.java b/docs/Peephole.java
new file mode 100644
index 00000000..c8806aed
--- /dev/null
+++ b/docs/Peephole.java
@@ -0,0 +1,82 @@
+import java.io.*;
+
+import java.util.Iterator;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.generic.*;
+import org.apache.bcel.Repository;
+import org.apache.bcel.util.InstructionFinder;
+
+public class Peephole {
+ public static void main(String[] argv) {
+ try {
+ /* Load the class from CLASSPATH.
+ */
+ JavaClass clazz = Repository.lookupClass(argv[0]);
+ Method[] methods = clazz.getMethods();
+ ConstantPoolGen cp = new ConstantPoolGen(clazz.getConstantPool());
+
+ for(int i=0; i < methods.length; i++) {
+ if(!(methods[i].isAbstract() || methods[i].isNative())) {
+ MethodGen mg = new MethodGen(methods[i],
+ clazz.getClassName(), cp);
+ Method stripped = removeNOPs(mg);
+
+ if(stripped != null) // Any NOPs stripped?
+ methods[i] = stripped; // Overwrite with stripped method
+ }
+ }
+
+ /* Dump the class to <class name>_.class
+ */
+ clazz.setConstantPool(cp.getFinalConstantPool());
+ clazz.dump(clazz.getClassName() + "_.class");
+ } catch(Exception e) { e.printStackTrace(); }
+ }
+
+ private static final Method removeNOPs(MethodGen mg) {
+ InstructionList il = mg.getInstructionList();
+ InstructionFinder f = new InstructionFinder(il);
+ String pat = "NOP+"; // Find at least one NOP
+ InstructionHandle next = null;
+ int count = 0;
+
+ for(Iterator i = f.search(pat); i.hasNext(); ) {
+ InstructionHandle[] match = (InstructionHandle[])e.next();
+ InstructionHandle first = match[0];
+ InstructionHandle last = match[match.length - 1];
+
+ /* Some nasty Java compilers may add NOP at end of method.
+ */
+ if((next = last.getNext()) == null)
+ break;
+
+ count += match.length;
+
+ /* Delete NOPs and redirect any references to them to the following
+ * (non-nop) instruction.
+ */
+ try {
+ il.delete(first, last);
+ } catch(TargetLostException e) {
+ InstructionHandle[] targets = e.getTargets();
+ 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);
+ }
+ }
+ }
+
+ Method m = null;
+
+ if(count > 0) {
+ System.out.println("Removed " + count + " NOP instructions from method " +
+ mg.getName());
+ m = mg.getMethod();
+ }
+
+ il.dispose(); // Reuse instruction handles
+ return m;
+ }
+}
diff --git a/docs/appendix.tex b/docs/appendix.tex
new file mode 100644
index 00000000..26cfc74b
--- /dev/null
+++ b/docs/appendix.tex
@@ -0,0 +1,193 @@
+\section{Code examples for the BCEL API}\label{sec:apicg}
+
+\subsection{HelloWorldBuilder.java}
+The following Java program reads a name from the standard input and
+prints a friendly ``Hello''. Since the \texttt{readLine()} method may
+throw an \texttt{IOException} it is enclosed by a \texttt{try-catch} block.
+
+{\small \verbatimtabinput{HelloWorld.java}\label{sec:hello}}
+
+\subsection{HelloWorldBuilder.java}
+
+We will sketch here how the above Java class can be created from the
+scratch using the \jc API. For ease of reading we will
+use textual signatures and not create them dynamically. For example,
+the signature
+
+\begin{verbatim}
+ "(Ljava/lang/String;)Ljava/lang/StringBuffer;"
+\end{verbatim}
+
+would actually be created with
+
+\begin{verbatim}
+ Type.getMethodSignature(Type.STRINGBUFFER, new Type[] { Type.STRING });
+\end{verbatim}
+
+\subsubsection{Initialization:}
+
+First we create an empty class and an instruction list:
+
+{\small\begin{verbatim}
+ ClassGen cg = new ClassGen("HelloWorld", "java.lang.Object",
+ "<generated>", ACC_PUBLIC | ACC_SUPER,
+ null);
+ ConstantPoolGen cp = cg.getConstantPool(); // cg creates constant pool
+ InstructionList il = new InstructionList();
+\end{verbatim}}
+
+We then create the main method, supplying the method's name and the
+symbolic type signature encoded with \texttt{Type} objects.
+
+{\small\begin{verbatim}
+ MethodGen mg = new MethodGen(ACC_STATIC | ACC_PUBLIC,// access flags
+ Type.VOID, // return type
+ new Type[] { // argument types
+ new ArrayType(Type.STRING, 1) },
+ new String[] { "argv" }, // arg names
+ "main", "HelloWorld", // method, class
+ il, cp);
+ InstructionFactory factory = new InstructionFactory(cg);
+\end{verbatim}}
+
+We define some often use types:
+
+{\small\begin{verbatim}
+ ObjectType i_stream = new ObjectType("java.io.InputStream");
+ ObjectType p_stream = new ObjectType("java.io.PrintStream");
+\end{verbatim}}
+
+\subsubsection{Create variables \texttt{in} and \texttt{name}:}
+
+We call the constructors, i.e. execute
+\texttt{BufferedReader(Input\-Stream\-Reader(System.in))}. The reference
+to the \texttt{BufferedReader} object stays on top of the stack and is
+stored in the newly allocated \texttt{in} variable.
+
+{\small\begin{verbatim}
+ il.append(factory.createNew("java.io.BufferedReader"));
+ il.append(InstructionConstants.DUP); // Use predefined constant
+ il.append(factory.createNew("java.io.InputStreamReader"));
+ il.append(InstructionConstants.DUP);
+ il.append(factory.createFieldAccess("java.lang.System", "in", i_stream,
+ Constants.GETSTATIC));
+ il.append(factory.createInvoke("java.io.InputStreamReader", "<init>",
+ Type.VOID, new Type[] { i_stream },
+ Constants.INVOKESPECIAL));
+ il.append(factory.createInvoke("java.io.BufferedReader", "<init>", Type.VOID,
+ new Type[] {new ObjectType("java.io.Reader")},
+ Constants.INVOKESPECIAL));
+
+ LocalVariableGen lg =
+ mg.addLocalVariable("in",
+ new ObjectType("java.io.BufferedReader"), null, null);
+ int in = lg.getIndex();
+ lg.setStart(il.append(new ASTORE(in))); // `i' valid from here
+\end{verbatim}}
+
+Create local variable \texttt{name} and initialize it to \texttt{null}.
+
+{\small\begin{verbatim}
+ lg = mg.addLocalVariable("name", Type.STRING, null, null);
+ int name = lg.getIndex();
+ il.append(InstructionConstants.ACONST_NULL);
+ lg.setStart(il.append(new ASTORE(name))); // `name' valid from here
+\end{verbatim}}
+
+\subsubsection{Create try-catch block}
+
+We remember the start of the block, read a line from the standard
+input and store it into the variable \texttt{name}.
+
+{\small\begin{verbatim}
+ InstructionHandle try_start =
+ il.append(factory.createFieldAccess("java.lang.System", "out", p_stream,
+ Constants.GETSTATIC));
+
+ il.append(new PUSH(cp, "Please enter your name> "));
+ il.append(factory.createInvoke("java.io.PrintStream", "print", Type.VOID,
+ new Type[] { Type.STRING },
+ Constants.INVOKEVIRTUAL));
+ il.append(new ALOAD(in));
+ il.append(factory.createInvoke("java.io.BufferedReader", "readLine",
+ Type.STRING, Type.NO_ARGS,
+ Constants.INVOKEVIRTUAL));
+ il.append(new ASTORE(name));
+\end{verbatim}}
+
+Upon normal execution we jump behind exception handler, the target
+address is not known yet.
+
+{\small\begin{verbatim}
+ GOTO g = new GOTO(null);
+ InstructionHandle try_end = il.append(g);
+\end{verbatim}}
+
+We add the exception handler which simply returns from the method.
+
+{\small\begin{verbatim}
+ InstructionHandle handler = il.append(InstructionConstants.RETURN);
+ mg.addExceptionHandler(try_start, try_end, handler, "java.io.IOException");
+\end{verbatim}}
+
+``Normal'' code continues, now we can set the branch target of the GOTO.
+
+{\small\begin{verbatim}
+ InstructionHandle ih =
+ il.append(factory.createFieldAccess("java.lang.System", "out", p_stream,
+ Constants.GETSTATIC));
+ g.setTarget(ih);
+\end{verbatim}}
+
+\subsubsection{Printing "Hello"}
+
+String concatenation compiles to \texttt{StringBuffer} operations.
+
+{\small\begin{verbatim}
+ il.append(factory.createNew(Type.STRINGBUFFER));
+ il.append(InstructionConstants.DUP);
+ il.append(new PUSH(cp, "Hello, "));
+ il.append(factory.createInvoke("java.lang.StringBuffer", "<init>",
+ Type.VOID, new Type[] { Type.STRING },
+ Constants.INVOKESPECIAL));
+ il.append(new ALOAD(name));
+ il.append(factory.createInvoke("java.lang.StringBuffer", "append",
+ Type.STRINGBUFFER, new Type[] { Type.STRING },
+ Constants.INVOKEVIRTUAL));
+ il.append(factory.createInvoke("java.lang.StringBuffer", "toString",
+ Type.STRING, Type.NO_ARGS,
+ Constants.INVOKEVIRTUAL));
+
+ il.append(factory.createInvoke("java.io.PrintStream", "println",
+ Type.VOID, new Type[] { Type.STRING },
+ Constants.INVOKEVIRTUAL));
+ il.append(InstructionConstants.RETURN);
+\end{verbatim}}
+
+\subsubsection{Finalization}
+
+Finally, we have to set the stack size, which normally would be
+computed on the fly and add a default constructor method to the class,
+which is empty in this case.
+
+{\small\begin{verbatim}
+ mg.setMaxStack(5);
+ cg.addMethod(mg.getMethod());
+ il.dispose(); // Allow instruction handles to be reused
+ cg.addEmptyConstructor(ACC_PUBLIC);
+\end{verbatim}}
+
+Last but not least we dump the \texttt{JavaClass} object to a file.
+
+{\small\begin{verbatim}
+ try {
+ cg.getJavaClass().dump("HelloWorld.class");
+ } catch(java.io.IOException e) { System.err.println(e); }
+\end{verbatim}}
+
+\subsection{Peephole.java}
+
+This class implements a simple peephole optimizer that removes any NOP
+instructions from the given class.
+
+{\small\verbatimtabinput{Peephole.java}}\label{sec:nop}
diff --git a/docs/bool.java b/docs/bool.java
new file mode 100644
index 00000000..cf517ea0
--- /dev/null
+++ b/docs/bool.java
@@ -0,0 +1,24 @@
+ InstructionList il = new InstructionList();
+ ...
+ CodeConstraint constraint = new CodeConstraint() {
+ public boolean checkCode(InstructionHandle[] match) {
+ IfInstruction if1 = (IfInstruction)match[0].getInstruction();
+ GOTO g = (GOTO)match[2].getInstruction();
+ return (if1.getTarget() == match[3]) &&
+ (g.getTarget() == match[4]);
+ }
+ };
+ FindPattern f = new FindPattern(il);
+ String pat = "`IfInstruction'`ICONST_0'`GOTO'`ICONST_1'" +
+ "`NOP'(`IFEQ'|`IFNE')";
+ InstructionHandle[] match;
+ for(InstructionHandle ih = f.search(pat, constraint);
+ ih != null; ih = f.search(pat, match[0], constraint)) {
+ match = f.getMatch(); // Constraint already checked
+ ...
+ match[0].setTarget(match[5].getTarget()); // Update target
+ ...
+ try {
+ il.delete(match[1], match[5]);
+ } catch(TargetLostException e) { ... }
+ }
diff --git a/docs/classfile.mdl b/docs/classfile.mdl
new file mode 100644
index 00000000..8035b380
--- /dev/null
+++ b/docs/classfile.mdl
@@ -0,0 +1,2134 @@
+
+(object Petal
+ version 42
+ _written "Rose 4.5.8054a"
+ charSet 0)
+
+(object Design "Logical View"
+ is_unit TRUE
+ is_loaded TRUE
+ defaults (object defaults
+ rightMargin 0.000000
+ leftMargin 0.000000
+ topMargin 0.000000
+ bottomMargin 0.000000
+ pageOverlap 0.000000
+ clipIconLabels TRUE
+ autoResize TRUE
+ snapToGrid TRUE
+ gridX 16
+ gridY 16
+ defaultFont (object Font
+ size 10
+ face "Arial"
+ bold FALSE
+ italics FALSE
+ underline FALSE
+ strike FALSE
+ color 0
+ default_color TRUE)
+ showMessageNum 1
+ showClassOfObject TRUE
+ notation "Unified")
+ root_usecase_package (object Class_Category "Use Case View"
+ quid "36597149004C"
+ exportControl "Public"
+ global TRUE
+ logical_models (list unit_reference_list)
+ logical_presentations (list unit_reference_list
+ (object UseCaseDiagram "Main"
+ quid "3659714A03A0"
+ title "Main"
+ zoom 100
+ max_height 28350
+ max_width 21600
+ origin_x 0
+ origin_y 0
+ items (list diagram_item_list))))
+ root_category (object Class_Category "Logical View"
+ quid "36597149004B"
+ exportControl "Public"
+ global TRUE
+ subsystem "Component View"
+ quidu "365971490054"
+ logical_models (list unit_reference_list
+ (object Class "JavaClass"
+ quid "3659716E02C4"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "3783415D015E"
+ supplier "Logical View::AccessFlags"
+ quidu "3783404E0032"))
+ operations (list Operations
+ (object Operation "getInterfaceNames"
+ quid "365973DC00DE"
+ result "String[]"
+ concurrency "Sequential"
+ opExportControl "Public"
+ uid 0)
+ (object Operation "getSuperclassName"
+ quid "365974050213"
+ result "String"
+ concurrency "Sequential"
+ opExportControl "Public"
+ uid 0)))
+ (object Class "Field"
+ quid "3659719C025C"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "378340240028"
+ supplier "Logical View::FieldOrMethod"
+ quidu "37833DF6035A")))
+ (object Class "Method"
+ quid "365971AB002D"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "3783403702BA"
+ supplier "Logical View::FieldOrMethod"
+ quidu "37833DF6035A")))
+ (object Class "Attribute"
+ quid "365974430259")
+ (object Class "Code"
+ quid "3659744C02AC"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "36597457033E"
+ stereotype "Method attribute"
+ supplier "Logical View::Attribute"
+ quidu "365974430259"))
+ operations (list Operations
+ (object Operation "getCode"
+ quid "365977B9022A"
+ result "byte[]"
+ concurrency "Sequential"
+ opExportControl "Public"
+ uid 0))
+ class_attributes (list class_attribute_list
+ (object ClassAttribute "max_stack"
+ quid "3659775703CE"
+ type "int")
+ (object ClassAttribute "max_locals"
+ quid "36597761015C"
+ type "int")
+ (object ClassAttribute "exception_handlers"
+ quid "3659837E02EB")))
+ (object Class "LineNumberTable"
+ quid "365974D401FD"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "3659752A01B0"
+ stereotype "Code attribute"
+ supplier "Logical View::Attribute"
+ quidu "365974430259")))
+ (object Class "LocalVariableTable"
+ quid "365974E4034A"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "365975320072"
+ stereotype "Code attribute"
+ supplier "Logical View::Attribute"
+ quidu "365974430259")))
+ (object Class "SourceFile"
+ quid "365974F201D8"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "3659753B002E"
+ stereotype "Class attribute"
+ supplier "Logical View::Attribute"
+ quidu "365974430259")))
+ (object Class "InnerClasses"
+ quid "3659751A0398"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "3659756B010A"
+ stereotype "Class attribute"
+ supplier "Logical View::Attribute"
+ quidu "365974430259")))
+ (object Class "ConstantPool"
+ quid "365976440134"
+ operations (list Operations
+ (object Operation "getConstant"
+ quid "365987690117"
+ result "Constant"
+ concurrency "Sequential"
+ opExportControl "Public"
+ uid 0)))
+ (object Class "Constant"
+ quid "3659764E01CE")
+ (object Class "ConstantCP"
+ quid "365976530348"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "36597AFA0160"
+ supplier "Logical View::Constant"
+ quidu "3659764E01CE")))
+ (object Class "ExceptionTable"
+ quid "365976ED0187"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "3659781D03A1"
+ stereotype "Method attribute"
+ supplier "Logical View::Attribute"
+ quidu "365974430259")))
+ (object Class "ConstantInterfaceMethodref"
+ quid "36597B2E03DC"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "365A9E870042"
+ supplier "Logical View::ConstantCP"
+ quidu "365976530348")))
+ (object Class "ConstantMethodref"
+ quid "36597B3F01C3"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "365A9E8D0091"
+ supplier "Logical View::ConstantCP"
+ quidu "365976530348")))
+ (object Class "ConstantFieldref"
+ quid "36597B460340"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "365A9E84020B"
+ supplier "Logical View::ConstantCP"
+ quidu "365976530348")))
+ (object Class "Deprecated"
+ quid "36597C6901C2"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "36597CC90075"
+ stereotype "Method attribute"
+ supplier "Logical View::Attribute"
+ quidu "365974430259")))
+ (object Class "Unknown"
+ quid "36597C7100E7"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "36597CB500BD"
+ supplier "Logical View::Attribute"
+ quidu "365974430259")))
+ (object Class "Synthetic"
+ quid "36597C7B00CD"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "36597CAF01A4"
+ stereotype "Class attribute"
+ supplier "Logical View::Attribute"
+ quidu "365974430259")))
+ (object Class "ConstantValue"
+ quid "36597D720032"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "36597D8000D3"
+ stereotype "Field attribute"
+ supplier "Logical View::Attribute"
+ quidu "365974430259")))
+ (object Class_Utility "ClassParser"
+ quid "365982D0039F"
+ used_nodes (list uses_relationship_list
+ (object Uses_Relationship
+ quid "365982F50013"
+ stereotype "creates"
+ supplier "Logical View::JavaClass"
+ quidu "3659716E02C4"))
+ operations (list Operations
+ (object Operation "parse"
+ quid "36598B7B03D2"
+ result "JavaClass"
+ concurrency "Sequential"
+ opExportControl "Public"
+ uid 0)))
+ (object Class "Visitor"
+ quid "3659848103DE"
+ stereotype "Interface")
+ (object Class "ConstantString"
+ quid "365A9EE901C0"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "365A9F9D0010"
+ supplier "Logical View::Constant"
+ quidu "3659764E01CE")))
+ (object Class "ConstantClass"
+ quid "365A9EFB005D"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "365A9F8A00C7"
+ supplier "Logical View::Constant"
+ quidu "3659764E01CE")))
+ (object Class "ConstantInteger"
+ quid "365A9F020374"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "365AA0090278"
+ supplier "Logical View::Constant"
+ quidu "3659764E01CE")))
+ (object Class "ConstantDouble"
+ quid "365A9F0902C0"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "365A9FA002A9"
+ supplier "Logical View::Constant"
+ quidu "3659764E01CE")))
+ (object Class "ConstantFloat"
+ quid "365A9F1003E3"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "365A9FA302D6"
+ supplier "Logical View::Constant"
+ quidu "3659764E01CE")))
+ (object Class "ConstantLong"
+ quid "365A9F3F0228"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "365A9FAB016F"
+ supplier "Logical View::Constant"
+ quidu "3659764E01CE")))
+ (object Class "ConstantUnicode"
+ quid "365A9F4E01CF"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "365A9FA80110"
+ supplier "Logical View::Constant"
+ quidu "3659764E01CE")))
+ (object Class "ConstantNameAndType"
+ quid "365A9F5B00A1"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "365A9FAE01FF"
+ supplier "Logical View::Constant"
+ quidu "3659764E01CE")))
+ (object Class "ConstantUtf8"
+ quid "365A9F7400A7"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "365A9FB1031C"
+ supplier "Logical View::Constant"
+ quidu "3659764E01CE")))
+ (object Class "FieldOrMethod"
+ quid "37833DF6035A"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "3783415403D2"
+ supplier "Logical View::AccessFlags"
+ quidu "3783404E0032"))
+ operations (list Operations
+ (object Operation "getName"
+ quid "37833E050063"
+ result "String"
+ concurrency "Sequential"
+ opExportControl "Public"
+ uid 0))
+ abstract TRUE)
+ (object Class "AccessFlags"
+ quid "3783404E0032"
+ operations (list Operations
+ (object Operation "isPublic"
+ quid "3783405602D2"
+ result "boolean"
+ concurrency "Sequential"
+ opExportControl "Public"
+ uid 0))
+ abstract TRUE)
+ (object Association "$UNNAMED$0"
+ quid "3659721C01B6"
+ roles (list role_list
+ (object Role "$UNNAMED$1"
+ quid "3659721C03DD"
+ supplier "Logical View::JavaClass"
+ quidu "3659716E02C4"
+ client_cardinality (value cardinality "1")
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$2"
+ quid "3659721D0009"
+ supplier "Logical View::Method"
+ quidu "365971AB002D"
+ client_cardinality (value cardinality "n")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$3"
+ quid "36597228027C"
+ roles (list role_list
+ (object Role "$UNNAMED$4"
+ quid "365972290129"
+ supplier "Logical View::JavaClass"
+ quidu "3659716E02C4"
+ client_cardinality (value cardinality "1")
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$5"
+ quid "36597229013D"
+ supplier "Logical View::Field"
+ quidu "3659719C025C"
+ client_cardinality (value cardinality "n")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$6"
+ quid "3659760E010E"
+ roles (list role_list
+ (object Role "$UNNAMED$7"
+ quid "36597610005D"
+ supplier "Logical View::JavaClass"
+ quidu "3659716E02C4"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$8"
+ quid "365976100071"
+ supplier "Logical View::Attribute"
+ quidu "365974430259"
+ client_cardinality (value cardinality "n")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$9"
+ quid "365979BF00B3"
+ roles (list role_list
+ (object Role "$UNNAMED$10"
+ quid "365979C0001E"
+ supplier "Logical View::Method"
+ quidu "365971AB002D"
+ client_cardinality (value cardinality "1")
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$11"
+ quid "365979C00028"
+ supplier "Logical View::Code"
+ quidu "3659744C02AC"
+ client_cardinality (value cardinality "0..1")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$12"
+ quid "365979F60198"
+ roles (list role_list
+ (object Role "$UNNAMED$13"
+ quid "365979F803B8"
+ supplier "Logical View::Method"
+ quidu "365971AB002D"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$14"
+ quid "365979F803B9"
+ supplier "Logical View::ExceptionTable"
+ quidu "365976ED0187"
+ client_cardinality (value cardinality "0..1")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$15"
+ quid "36597A20015D"
+ roles (list role_list
+ (object Role "$UNNAMED$16"
+ quid "36597A2101E0"
+ supplier "Logical View::Code"
+ quidu "3659744C02AC"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$17"
+ quid "36597A2101EA"
+ supplier "Logical View::LineNumberTable"
+ quidu "365974D401FD"
+ client_cardinality (value cardinality "1")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$18"
+ quid "36597A2A0233"
+ roles (list role_list
+ (object Role "$UNNAMED$19"
+ quid "36597A2B0203"
+ supplier "Logical View::Code"
+ quidu "3659744C02AC"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$20"
+ quid "36597A2B020D"
+ supplier "Logical View::LocalVariableTable"
+ quidu "365974E4034A"
+ client_cardinality (value cardinality "1")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$21"
+ quid "36597A4703BB"
+ roles (list role_list
+ (object Role "$UNNAMED$22"
+ quid "36597A49001B"
+ supplier "Logical View::JavaClass"
+ quidu "3659716E02C4"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$23"
+ quid "36597A49002F"
+ supplier "Logical View::InnerClasses"
+ quidu "3659751A0398"
+ client_cardinality (value cardinality "0..1")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$24"
+ quid "36597A54005D"
+ roles (list role_list
+ (object Role "$UNNAMED$25"
+ quid "36597A5403CE"
+ supplier "Logical View::JavaClass"
+ quidu "3659716E02C4"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$26"
+ quid "36597A5403E2"
+ supplier "Logical View::SourceFile"
+ quidu "365974F201D8"
+ client_cardinality (value cardinality "1")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$27"
+ quid "36597ADA000F"
+ roles (list role_list
+ (object Role "$UNNAMED$28"
+ quid "36597ADA0327"
+ supplier "Logical View::ConstantPool"
+ quidu "365976440134"
+ client_cardinality (value cardinality "1")
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$29"
+ quid "36597ADA0331"
+ supplier "Logical View::Constant"
+ quidu "3659764E01CE"
+ client_cardinality (value cardinality "n")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$30"
+ quid "36597D490047"
+ roles (list role_list
+ (object Role "$UNNAMED$31"
+ quid "36597D4903B9"
+ supplier "Logical View::JavaClass"
+ quidu "3659716E02C4"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$32"
+ quid "36597D4903C3"
+ supplier "Logical View::Attribute"
+ quidu "365974430259"
+ client_cardinality (value cardinality "n")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$33"
+ quid "36597D8E01EB"
+ roles (list role_list
+ (object Role "$UNNAMED$34"
+ quid "36597D8F0124"
+ supplier "Logical View::Field"
+ quidu "3659719C025C"
+ client_cardinality (value cardinality "1")
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$35"
+ quid "36597D8F012E"
+ supplier "Logical View::Attribute"
+ quidu "365974430259"
+ client_cardinality (value cardinality "n")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$36"
+ quid "36597D930315"
+ roles (list role_list
+ (object Role "$UNNAMED$37"
+ quid "36597D9500B5"
+ supplier "Logical View::Method"
+ quidu "365971AB002D"
+ client_cardinality (value cardinality "1")
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$38"
+ quid "36597D9500BF"
+ supplier "Logical View::Attribute"
+ quidu "365974430259"
+ client_cardinality (value cardinality "n")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$39"
+ quid "36597F6600FA"
+ roles (list role_list
+ (object Role "$UNNAMED$40"
+ quid "36597F680070"
+ supplier "Logical View::JavaClass"
+ quidu "3659716E02C4"
+ client_cardinality (value cardinality "1")
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$41"
+ quid "36597F68007A"
+ supplier "Logical View::Attribute"
+ quidu "365974430259"
+ client_cardinality (value cardinality "n")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$42"
+ quid "36598570008E"
+ roles (list role_list
+ (object Role "$UNNAMED$43"
+ quid "365985700265"
+ supplier "Logical View::JavaClass"
+ quidu "3659716E02C4"
+ client_cardinality (value cardinality "1")
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$44"
+ quid "36598570026F"
+ supplier "Logical View::ConstantPool"
+ quidu "365976440134"
+ client_cardinality (value cardinality "1")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$45"
+ quid "365985A101F7"
+ roles (list role_list
+ (object Role "$UNNAMED$46"
+ quid "365985A10392"
+ supplier "Logical View::JavaClass"
+ quidu "3659716E02C4"
+ is_navigable TRUE)
+ (object Role "$UNNAMED$47"
+ quid "365985A1039C"
+ supplier "Logical View::ConstantPool"
+ quidu "365976440134"
+ is_navigable TRUE))))
+ logical_presentations (list unit_reference_list
+ (object ClassDiagram "Java class"
+ quid "3659714A03C7"
+ title "Java class"
+ zoom 90
+ max_height 28350
+ max_width 21600
+ origin_x 0
+ origin_y 414
+ items (list diagram_item_list
+ (object ClassView "Class" "Logical View::ExceptionTable" @1
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1104, 1920)
+ label (object ItemLabel
+ Parent_View @1
+ location (949, 1869)
+ fill_color 13434879
+ nlines 1
+ max_width 310
+ justify 0
+ label "ExceptionTable")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365976ED0187"
+ width 328
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::LineNumberTable" @2
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2144, 1936)
+ label (object ItemLabel
+ Parent_View @2
+ location (1970, 1885)
+ fill_color 13434879
+ nlines 1
+ max_width 348
+ justify 0
+ label "LineNumberTable")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365974D401FD"
+ width 366
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::Code" @3
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1584, 2032)
+ label (object ItemLabel
+ Parent_View @3
+ location (1382, 1876)
+ fill_color 13434879
+ nlines 1
+ max_width 404
+ justify 0
+ label "Code")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659744C02AC"
+ compartment (object Compartment
+ Parent_View @3
+ location (1382, 1931)
+ icon_style "Icon"
+ fill_color 13434879
+ anchor 2
+ nlines 5
+ max_width 409)
+ width 422
+ height 336
+ annotation 8
+ autoResize TRUE)
+ (object AssociationViewNew "$UNNAMED$15" @4
+ location (1877, 1981)
+ stereotype TRUE
+ line_color 3342489
+ quidu "36597A20015D"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$16" @5
+ Parent_View @4
+ location (197, 877)
+ stereotype TRUE
+ line_color 3342489
+ quidu "36597A2101E0"
+ client @4
+ supplier @3
+ line_style 0)
+ (object RoleView "$UNNAMED$17" @6
+ Parent_View @4
+ location (197, 877)
+ stereotype TRUE
+ line_color 3342489
+ quidu "36597A2101EA"
+ client @4
+ supplier @2
+ line_style 0
+ label (object SegLabel @7
+ Parent_View @6
+ location (1943, 1915)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "1"
+ pctDist 0.900000
+ height 54
+ orientation 0))))
+ (object ClassView "Class" "Logical View::LocalVariableTable" @8
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2496, 2144)
+ label (object ItemLabel
+ Parent_View @8
+ location (2311, 2093)
+ fill_color 13434879
+ nlines 1
+ max_width 370
+ justify 0
+ label "LocalVariableTable")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365974E4034A"
+ width 388
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object AssociationViewNew "$UNNAMED$18" @9
+ location (2048, 2088)
+ stereotype TRUE
+ line_color 3342489
+ quidu "36597A2A0233"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$19" @10
+ Parent_View @9
+ location (-183, 852)
+ stereotype TRUE
+ line_color 3342489
+ quidu "36597A2B0203"
+ client @9
+ supplier @3
+ line_style 0)
+ (object RoleView "$UNNAMED$20" @11
+ Parent_View @9
+ location (-183, 852)
+ stereotype TRUE
+ line_color 3342489
+ quidu "36597A2B020D"
+ client @9
+ supplier @8
+ line_style 0
+ label (object SegLabel @12
+ Parent_View @11
+ location (2269, 2170)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "1"
+ pctDist 0.900000
+ height 54
+ orientation 1))))
+ (object ClassView "Class" "Logical View::InnerClasses" @13
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2224, 1552)
+ label (object ItemLabel
+ Parent_View @13
+ location (2088, 1501)
+ fill_color 13434879
+ nlines 1
+ max_width 272
+ justify 0
+ label "InnerClasses")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659751A0398"
+ width 290
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::SourceFile" @14
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2576, 1552)
+ label (object ItemLabel
+ Parent_View @14
+ location (2461, 1501)
+ fill_color 13434879
+ nlines 1
+ max_width 230
+ justify 0
+ label "SourceFile")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365974F201D8"
+ width 248
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::Deprecated" @15
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (720, 1920)
+ label (object ItemLabel
+ Parent_View @15
+ location (602, 1869)
+ fill_color 13434879
+ nlines 1
+ max_width 236
+ justify 0
+ label "Deprecated")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "36597C6901C2"
+ width 254
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::Unknown" @16
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2816, 1936)
+ label (object ItemLabel
+ Parent_View @16
+ location (2717, 1885)
+ fill_color 13434879
+ nlines 1
+ max_width 198
+ justify 0
+ label "Unknown")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "36597C7100E7"
+ width 216
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::Synthetic" @17
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2896, 1552)
+ label (object ItemLabel
+ Parent_View @17
+ location (2791, 1501)
+ fill_color 13434879
+ nlines 1
+ max_width 210
+ justify 0
+ label "Synthetic")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "36597C7B00CD"
+ width 228
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::ConstantValue" @18
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (848, 1552)
+ label (object ItemLabel
+ Parent_View @18
+ location (697, 1501)
+ fill_color 13434879
+ nlines 1
+ max_width 302
+ justify 0
+ label "ConstantValue")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "36597D720032"
+ width 320
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "ClassUtility" "Logical View::ClassParser" @19
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (784, 912)
+ label (object ItemLabel
+ Parent_View @19
+ location (657, 839)
+ fill_color 13434879
+ nlines 1
+ max_width 254
+ justify 0
+ label "ClassParser")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365982D0039F"
+ compartment (object Compartment
+ Parent_View @19
+ location (657, 894)
+ icon_style "Icon"
+ fill_color 16777215
+ anchor 2
+ nlines 2
+ max_width 148)
+ width 272
+ height 168
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::Attribute" @20
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1648, 1536)
+ label (object ItemLabel
+ Parent_View @20
+ location (1552, 1484)
+ fill_color 13434879
+ nlines 1
+ max_width 192
+ justify 0
+ label "Attribute")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365974430259"
+ width 210
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object InheritTreeView "" @21
+ location (1620, 1691)
+ line_color 3342489
+ fill_color 13434879
+ supplier @20
+ vertices (list Points
+ (1620, 1691)
+ (1620, 1599)))
+ (object InheritView "" @22
+ stereotype (object SegLabel @23
+ Parent_View @22
+ location (1625, 1778)
+ anchor 10
+ anchor_loc 1
+ nlines 1
+ max_width 450
+ justify 0
+ label "<<Method attribute>>"
+ pctDist 0.505747
+ height 52
+ orientation 1)
+ line_color 3342489
+ quidu "36597457033E"
+ client @3
+ supplier @20
+ line_style 3
+ origin_attachment (1573, 1864)
+ terminal_attachment (1573, 1691)
+ drawSupplier @21)
+ (object InheritView "" @24
+ stereotype (object SegLabel @25
+ Parent_View @24
+ location (2121, 1847)
+ anchor 10
+ anchor_loc 1
+ nlines 1
+ max_width 450
+ justify 0
+ label "<<Code attribute>>"
+ pctDist 0.143488
+ height 3
+ orientation 1)
+ line_color 3342489
+ quidu "3659752A01B0"
+ client @2
+ supplier @20
+ line_style 3
+ origin_attachment (2118, 1873)
+ terminal_attachment (2118, 1691)
+ drawSupplier @21)
+ (object InheritView "" @26
+ stereotype (object SegLabel @27
+ Parent_View @26
+ location (2579, 1653)
+ anchor 10
+ anchor_loc 1
+ nlines 1
+ max_width 450
+ justify 0
+ label "<<Class attribute>>"
+ pctDist 0.497717
+ height 13
+ orientation 0)
+ line_color 3342489
+ quidu "3659753B002E"
+ client @14
+ supplier @20
+ line_style 3
+ origin_attachment (2566, 1615)
+ terminal_attachment (2566, 1691)
+ drawSupplier @21)
+ (object InheritView "" @28
+ stereotype (object SegLabel @29
+ Parent_View @28
+ location (1145, 1774)
+ anchor 10
+ anchor_loc 1
+ nlines 1
+ max_width 450
+ justify 0
+ label "<<Method attribute>>"
+ pctDist 0.497006
+ height 34
+ orientation 1)
+ line_color 3342489
+ quidu "3659781D03A1"
+ client @1
+ supplier @20
+ line_style 3
+ origin_attachment (1111, 1857)
+ terminal_attachment (1111, 1691)
+ drawSupplier @21)
+ (object InheritView "" @30
+ stereotype TRUE
+ line_color 3342489
+ quidu "36597CB500BD"
+ client @16
+ supplier @20
+ line_style 3
+ origin_attachment (2819, 1873)
+ terminal_attachment (2819, 1691)
+ drawSupplier @21)
+ (object InheritView "" @31
+ stereotype (object SegLabel @32
+ Parent_View @31
+ location (732, 1774)
+ anchor 10
+ anchor_loc 1
+ nlines 1
+ max_width 450
+ justify 0
+ label "<<Method attribute>>"
+ pctDist 0.497006
+ height 34
+ orientation 1)
+ line_color 3342489
+ quidu "36597CC90075"
+ client @15
+ supplier @20
+ line_style 3
+ origin_attachment (698, 1857)
+ terminal_attachment (698, 1691)
+ drawSupplier @21)
+ (object ClassView "Class" "Logical View::Method" @33
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2064, 1408)
+ label (object ItemLabel
+ Parent_View @33
+ location (1983, 1362)
+ fill_color 13434879
+ nlines 1
+ max_width 162
+ justify 0
+ label "Method")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365971AB002D"
+ height 114
+ annotation 8
+ autoResize TRUE)
+ (object AssociationViewNew "$UNNAMED$36" @34
+ location (1863, 1469)
+ stereotype TRUE
+ line_color 3342489
+ quidu "36597D930315"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$37" @35
+ Parent_View @34
+ location (-57, 797)
+ stereotype TRUE
+ line_color 3342489
+ quidu "36597D9500B5"
+ client @34
+ supplier @33
+ line_style 0
+ label (object SegLabel @36
+ Parent_View @35
+ location (1978, 1491)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "1"
+ pctDist 0.900000
+ height 54
+ orientation 1))
+ (object RoleView "$UNNAMED$38" @37
+ Parent_View @34
+ location (-57, 797)
+ stereotype TRUE
+ line_color 3342489
+ quidu "36597D9500BF"
+ client @34
+ supplier @20
+ line_style 0
+ label (object SegLabel @38
+ Parent_View @37
+ location (1781, 1551)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "*"
+ pctDist 0.900000
+ height 54
+ orientation 0))))
+ (object ClassView "Class" "Logical View::Field" @39
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1232, 1408)
+ label (object ItemLabel
+ Parent_View @39
+ location (1151, 1362)
+ fill_color 13434879
+ nlines 1
+ max_width 162
+ justify 0
+ label "Field")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659719C025C"
+ height 114
+ annotation 8
+ autoResize TRUE)
+ (object AssociationViewNew "$UNNAMED$33" @40
+ location (1432, 1469)
+ stereotype TRUE
+ line_color 3342489
+ quidu "36597D8E01EB"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$34" @41
+ Parent_View @40
+ location (-488, 797)
+ stereotype TRUE
+ line_color 3342489
+ quidu "36597D8F0124"
+ client @40
+ supplier @39
+ line_style 0
+ label (object SegLabel @42
+ Parent_View @41
+ location (1319, 1491)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "1"
+ pctDist 0.900000
+ height 54
+ orientation 0))
+ (object RoleView "$UNNAMED$35" @43
+ Parent_View @40
+ location (-488, 797)
+ stereotype TRUE
+ line_color 3342489
+ quidu "36597D8F012E"
+ client @40
+ supplier @20
+ line_style 0
+ label (object SegLabel @44
+ Parent_View @43
+ location (1546, 1448)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "*"
+ pctDist 0.900000
+ height 54
+ orientation 0))))
+ (object ClassView "Class" "Logical View::ConstantPool" @45
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2448, 1152)
+ label (object ItemLabel
+ Parent_View @45
+ location (2300, 1070)
+ fill_color 13434879
+ nlines 1
+ max_width 296
+ justify 0
+ label "ConstantPool")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365976440134"
+ compartment (object Compartment
+ Parent_View @45
+ location (2300, 1125)
+ icon_style "Icon"
+ fill_color 16777215
+ anchor 2
+ nlines 2
+ max_width 303)
+ width 314
+ height 186
+ annotation 8
+ autoResize TRUE)
+ (object InheritView "" @46
+ stereotype (object SegLabel @47
+ Parent_View @46
+ location (2476, 2035)
+ anchor 10
+ anchor_loc 1
+ nlines 1
+ max_width 450
+ justify 0
+ label "<<Code attribute>>"
+ pctDist 0.118199
+ height 4
+ orientation 1)
+ line_color 3342489
+ quidu "365975320072"
+ client @8
+ supplier @20
+ line_style 3
+ origin_attachment (2472, 2081)
+ terminal_attachment (2472, 1691)
+ drawSupplier @21)
+ (object InheritView "" @48
+ stereotype (object SegLabel @49
+ Parent_View @48
+ location (2206, 1653)
+ anchor 10
+ anchor_loc 1
+ nlines 1
+ max_width 450
+ justify 0
+ label "<<Class attribute>>"
+ pctDist 0.497717
+ height 7
+ orientation 1)
+ line_color 3342489
+ quidu "3659756B010A"
+ client @13
+ supplier @20
+ line_style 3
+ origin_attachment (2212, 1615)
+ terminal_attachment (2212, 1691)
+ drawSupplier @21)
+ (object InheritView "" @50
+ label (object ItemLabel
+ Parent_View @50
+ location (2892, 1653)
+ anchor_loc 1
+ nlines 1
+ max_width 264
+ justify 0
+ label "")
+ stereotype (object SegLabel @51
+ Parent_View @50
+ location (2902, 1653)
+ anchor 10
+ anchor_loc 1
+ nlines 1
+ max_width 450
+ justify 0
+ label "<<Class attribute>>"
+ pctDist 0.497717
+ height 10
+ orientation 0)
+ line_color 3342489
+ quidu "36597CAF01A4"
+ client @17
+ supplier @20
+ line_style 3
+ origin_attachment (2892, 1615)
+ terminal_attachment (2892, 1691)
+ drawSupplier @21)
+ (object InheritView "" @52
+ stereotype (object SegLabel @53
+ Parent_View @52
+ location (871, 1651)
+ anchor 10
+ anchor_loc 1
+ nlines 1
+ max_width 450
+ justify 0
+ label "<<Field attribute>>"
+ pctDist 0.480000
+ height 27
+ orientation 0)
+ line_color 3342489
+ quidu "36597D8000D3"
+ client @18
+ supplier @20
+ line_style 3
+ origin_attachment (844, 1615)
+ terminal_attachment (844, 1691)
+ drawSupplier @21)
+ (object ClassView "Class" "Logical View::FieldOrMethod" @54
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1648, 1200)
+ font (object Font
+ italics TRUE)
+ label (object ItemLabel
+ Parent_View @54
+ location (1502, 1127)
+ fill_color 13434879
+ nlines 1
+ max_width 292
+ justify 0
+ label "FieldOrMethod")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "37833DF6035A"
+ compartment (object Compartment
+ Parent_View @54
+ location (1502, 1182)
+ font (object Font
+ italics TRUE)
+ icon_style "Icon"
+ fill_color 13434879
+ anchor 2
+ nlines 2
+ max_width 208)
+ width 310
+ height 168
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::AccessFlags" @55
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (896, 1200)
+ font (object Font
+ italics TRUE)
+ label (object ItemLabel
+ Parent_View @55
+ location (762, 1127)
+ fill_color 13434879
+ nlines 1
+ max_width 268
+ justify 0
+ label "AccessFlags")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3783404E0032"
+ compartment (object Compartment
+ Parent_View @55
+ location (762, 1182)
+ font (object Font
+ italics TRUE)
+ icon_style "Icon"
+ fill_color 13434879
+ anchor 2
+ nlines 2
+ max_width 192)
+ width 286
+ height 168
+ annotation 8
+ autoResize TRUE)
+ (object InheritView "" @56
+ stereotype TRUE
+ line_color 3342489
+ quidu "3783415403D2"
+ client @54
+ supplier @55
+ line_style 0)
+ (object InheritTreeView "" @57
+ location (1635, 1379)
+ line_color 3342489
+ fill_color 13434879
+ supplier @54
+ vertices (list Points
+ (1635, 1379)
+ (1635, 1284)))
+ (object InheritView "" @58
+ stereotype TRUE
+ line_color 3342489
+ quidu "3783403702BA"
+ client @33
+ supplier @54
+ line_style 3
+ origin_attachment (1979, 1358)
+ terminal_attachment (1979, 1379)
+ drawSupplier @57)
+ (object InheritView "" @59
+ stereotype TRUE
+ line_color 3342489
+ quidu "378340240028"
+ client @39
+ supplier @54
+ line_style 3
+ origin_attachment (1312, 1410)
+ terminal_attachment (1312, 1379)
+ drawSupplier @57)
+ (object ClassView "Class" "Logical View::JavaClass" @60
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1648, 912)
+ label (object ItemLabel
+ Parent_View @60
+ location (1446, 816)
+ fill_color 13434879
+ nlines 1
+ max_width 404
+ justify 0
+ label "JavaClass")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659716E02C4"
+ compartment (object Compartment
+ Parent_View @60
+ location (1446, 871)
+ icon_style "Icon"
+ fill_color 13434879
+ anchor 2
+ nlines 3
+ max_width 450)
+ width 422
+ height 214
+ annotation 8
+ autoResize TRUE)
+ (object AssociationViewNew "$UNNAMED$0" @61
+ location (1876, 1184)
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659721C01B6"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$1" @62
+ Parent_View @61
+ location (1508, 768)
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659721C03DD"
+ client @61
+ supplier @60
+ line_style 0
+ label (object SegLabel @63
+ Parent_View @62
+ location (1712, 1071)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "1"
+ pctDist 0.900000
+ height 54
+ orientation 0))
+ (object RoleView "$UNNAMED$2" @64
+ Parent_View @61
+ location (1508, 768)
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659721D0009"
+ client @61
+ supplier @33
+ line_style 0
+ label (object SegLabel @65
+ Parent_View @64
+ location (2042, 1299)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "*"
+ pctDist 0.900000
+ height 54
+ orientation 0))))
+ (object UsesView "" @66
+ label (object ItemLabel
+ Parent_View @66
+ location (1178, 912)
+ anchor_loc 1
+ nlines 1
+ max_width 60
+ justify 0
+ label "")
+ stereotype (object SegLabel @67
+ Parent_View @66
+ location (1228, 869)
+ anchor 10
+ anchor_loc 1
+ nlines 1
+ max_width 450
+ justify 0
+ label "<<creates>>"
+ pctDist 0.598000
+ height 44
+ orientation 0)
+ line_color 3342489
+ quidu "365982F50013"
+ client @19
+ supplier @60
+ line_style 0)
+ (object AssociationViewNew "$UNNAMED$45" @68
+ location (2074, 1039)
+ stereotype TRUE
+ line_color 3342489
+ quidu "365985A101F7"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$46" @69
+ Parent_View @68
+ location (-278, 847)
+ stereotype TRUE
+ line_color 3342489
+ quidu "365985A10392"
+ client @68
+ supplier @60
+ line_style 0)
+ (object RoleView "$UNNAMED$47" @70
+ Parent_View @68
+ location (-278, 847)
+ stereotype TRUE
+ line_color 3342489
+ quidu "365985A1039C"
+ client @68
+ supplier @45
+ line_style 0)))
+ (object InheritView "" @71
+ stereotype TRUE
+ line_color 3342489
+ quidu "3783415D015E"
+ client @60
+ supplier @55
+ line_style 0)
+ (object AssociationViewNew "$UNNAMED$3" @72
+ location (1418, 1184)
+ stereotype TRUE
+ line_color 3342489
+ quidu "36597228027C"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$4" @73
+ Parent_View @72
+ location (426, 400)
+ stereotype TRUE
+ line_color 3342489
+ quidu "365972290129"
+ client @72
+ supplier @60
+ line_style 0
+ label (object SegLabel @74
+ Parent_View @73
+ location (1583, 1071)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "1"
+ pctDist 0.900000
+ height 54
+ orientation 1))
+ (object RoleView "$UNNAMED$5" @75
+ Parent_View @72
+ location (426, 400)
+ stereotype TRUE
+ line_color 3342489
+ quidu "36597229013D"
+ client @72
+ supplier @39
+ line_style 0
+ label (object SegLabel @76
+ Parent_View @75
+ location (1334, 1368)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "*"
+ pctDist 0.900000
+ height 54
+ orientation 0))))))
+ (object ClassDiagram "Constant pool"
+ quid "36597BC201E0"
+ title "Constant pool"
+ zoom 100
+ max_height 28350
+ max_width 21600
+ origin_x 995
+ origin_y 0
+ items (list diagram_item_list
+ (object ClassView "Class" "Logical View::ConstantCP" @77
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2192, 800)
+ label (object ItemLabel
+ Parent_View @77
+ location (2065, 751)
+ fill_color 13434879
+ nlines 1
+ max_width 254
+ justify 0
+ label "ConstantCP")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365976530348"
+ width 272
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::ConstantInterfaceMethodref" @78
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2160, 1104)
+ label (object ItemLabel
+ Parent_View @78
+ location (1894, 1055)
+ fill_color 13434879
+ nlines 1
+ max_width 532
+ justify 0
+ label "ConstantInterfaceMethodref")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "36597B2E03DC"
+ width 550
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::ConstantMethodref" @79
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2688, 1104)
+ label (object ItemLabel
+ Parent_View @79
+ location (2504, 1055)
+ fill_color 13434879
+ nlines 1
+ max_width 368
+ justify 0
+ label "ConstantMethodref")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "36597B3F01C3"
+ width 386
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::ConstantFieldref" @80
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1648, 1104)
+ label (object ItemLabel
+ Parent_View @80
+ location (1484, 1055)
+ fill_color 13434879
+ nlines 1
+ max_width 328
+ justify 0
+ label "ConstantFieldref")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "36597B460340"
+ width 346
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::ConstantPool" @81
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2368, 176)
+ label (object ItemLabel
+ Parent_View @81
+ location (2220, 97)
+ fill_color 13434879
+ nlines 1
+ max_width 296
+ justify 0
+ label "ConstantPool")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365976440134"
+ width 314
+ height 186
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::Constant" @82
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2368, 448)
+ label (object ItemLabel
+ Parent_View @82
+ location (2270, 399)
+ fill_color 13434879
+ nlines 1
+ max_width 196
+ justify 0
+ label "Constant")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659764E01CE"
+ width 214
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object AssociationViewNew "$UNNAMED$27" @83
+ location (2368, 326)
+ stereotype TRUE
+ line_color 3342489
+ quidu "36597ADA000F"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$28" @84
+ Parent_View @83
+ location (1968, -2298)
+ stereotype TRUE
+ line_color 3342489
+ quidu "36597ADA0327"
+ client @83
+ supplier @81
+ line_style 0
+ label (object SegLabel @85
+ Parent_View @84
+ location (2422, 276)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "1"
+ pctDist 0.900000
+ height 54
+ orientation 1))
+ (object RoleView "$UNNAMED$29" @86
+ Parent_View @83
+ location (1968, -2298)
+ stereotype TRUE
+ line_color 3342489
+ quidu "36597ADA0331"
+ client @83
+ supplier @82
+ line_style 0
+ label (object SegLabel @87
+ Parent_View @86
+ location (2422, 378)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "*"
+ pctDist 0.900000
+ height 54
+ orientation 0))))
+ (object InheritTreeView "" @88
+ location (2181, 956)
+ line_color 3342489
+ fill_color 13434879
+ supplier @77
+ vertices (list Points
+ (2181, 956)
+ (2181, 863)))
+ (object InheritView "" @89
+ stereotype TRUE
+ line_color 3342489
+ quidu "365A9E84020B"
+ client @80
+ supplier @77
+ line_style 3
+ origin_attachment (1640, 1041)
+ terminal_attachment (1640, 956)
+ drawSupplier @88)
+ (object ClassView "Class" "Logical View::ConstantString" @90
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2704, 800)
+ label (object ItemLabel
+ Parent_View @90
+ location (2552, 751)
+ fill_color 13434879
+ nlines 1
+ max_width 304
+ justify 0
+ label "ConstantString")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365A9EE901C0"
+ width 322
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::ConstantClass" @91
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1360, 800)
+ label (object ItemLabel
+ Parent_View @91
+ location (1208, 751)
+ fill_color 13434879
+ nlines 1
+ max_width 304
+ justify 0
+ label "ConstantClass")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365A9EFB005D"
+ width 322
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::ConstantInteger" @92
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1968, 432)
+ label (object ItemLabel
+ Parent_View @92
+ location (1812, 383)
+ fill_color 13434879
+ nlines 1
+ max_width 312
+ justify 0
+ label "ConstantInteger")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365A9F020374"
+ width 330
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::ConstantDouble" @93
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1568, 432)
+ label (object ItemLabel
+ Parent_View @93
+ location (1406, 383)
+ fill_color 13434879
+ nlines 1
+ max_width 324
+ justify 0
+ label "ConstantDouble")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365A9F0902C0"
+ width 342
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::ConstantFloat" @94
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1760, 800)
+ label (object ItemLabel
+ Parent_View @94
+ location (1617, 751)
+ fill_color 13434879
+ nlines 1
+ max_width 286
+ justify 0
+ label "ConstantFloat")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365A9F1003E3"
+ width 304
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::ConstantLong" @95
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1184, 432)
+ label (object ItemLabel
+ Parent_View @95
+ location (1041, 383)
+ fill_color 13434879
+ nlines 1
+ max_width 286
+ justify 0
+ label "ConstantLong")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365A9F3F0228"
+ width 304
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::ConstantUnicode" @96
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (3136, 800)
+ label (object ItemLabel
+ Parent_View @96
+ location (2964, 751)
+ fill_color 13434879
+ nlines 1
+ max_width 344
+ justify 0
+ label "ConstantUnicode")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365A9F4E01CF"
+ width 362
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::ConstantNameAndType" @97
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2848, 432)
+ label (object ItemLabel
+ Parent_View @97
+ location (2620, 383)
+ fill_color 13434879
+ nlines 1
+ max_width 456
+ justify 0
+ label "ConstantNameAndType")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365A9F5B00A1"
+ width 474
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::ConstantUtf8" @98
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (3312, 432)
+ label (object ItemLabel
+ Parent_View @98
+ location (3178, 383)
+ fill_color 13434879
+ nlines 1
+ max_width 268
+ justify 0
+ label "ConstantUtf8")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365A9F7400A7"
+ width 286
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object InheritTreeView "" @99
+ location (2374, 625)
+ line_color 3342489
+ fill_color 13434879
+ supplier @82
+ vertices (list Points
+ (2374, 625)
+ (2374, 511)))
+ (object InheritView "" @100
+ stereotype TRUE
+ line_color 3342489
+ quidu "365A9F8A00C7"
+ client @91
+ supplier @82
+ line_style 3
+ origin_attachment (1362, 737)
+ terminal_attachment (1362, 625)
+ drawSupplier @99)
+ (object InheritView "" @101
+ stereotype TRUE
+ line_color 3342489
+ quidu "365A9F9D0010"
+ client @90
+ supplier @82
+ line_style 3
+ origin_attachment (2698, 737)
+ terminal_attachment (2698, 625)
+ drawSupplier @99)
+ (object InheritView "" @102
+ stereotype TRUE
+ line_color 3342489
+ quidu "365A9FA002A9"
+ client @93
+ supplier @82
+ line_style 3
+ origin_attachment (1559, 495)
+ terminal_attachment (1559, 625)
+ drawSupplier @99)
+ (object InheritView "" @103
+ stereotype TRUE
+ line_color 3342489
+ quidu "365A9FA80110"
+ client @96
+ supplier @82
+ line_style 3
+ origin_attachment (3133, 737)
+ terminal_attachment (3133, 625)
+ drawSupplier @99)
+ (object InheritView "" @104
+ stereotype TRUE
+ line_color 3342489
+ quidu "365A9FAB016F"
+ client @95
+ supplier @82
+ line_style 3
+ origin_attachment (1181, 495)
+ terminal_attachment (1181, 625)
+ drawSupplier @99)
+ (object InheritView "" @105
+ stereotype TRUE
+ line_color 3342489
+ quidu "365A9FB1031C"
+ client @98
+ supplier @82
+ line_style 3
+ origin_attachment (3312, 495)
+ terminal_attachment (3312, 625)
+ drawSupplier @99)
+ (object InheritView "" @106
+ stereotype TRUE
+ line_color 3342489
+ quidu "36597AFA0160"
+ client @77
+ supplier @82
+ line_style 3
+ origin_attachment (2190, 737)
+ terminal_attachment (2190, 625)
+ drawSupplier @99)
+ (object InheritView "" @107
+ stereotype TRUE
+ line_color 3342489
+ quidu "365AA0090278"
+ client @92
+ supplier @82
+ line_style 3
+ origin_attachment (1950, 495)
+ terminal_attachment (1950, 625)
+ drawSupplier @99)
+ (object InheritView "" @108
+ stereotype TRUE
+ line_color 3342489
+ quidu "365A9FA302D6"
+ client @94
+ supplier @82
+ line_style 3
+ origin_attachment (1753, 737)
+ terminal_attachment (1753, 625)
+ drawSupplier @99)
+ (object InheritView "" @109
+ stereotype TRUE
+ line_color 3342489
+ quidu "365A9FAE01FF"
+ client @97
+ supplier @82
+ line_style 3
+ origin_attachment (2812, 495)
+ terminal_attachment (2812, 625)
+ drawSupplier @99)
+ (object InheritView "" @110
+ stereotype TRUE
+ line_color 3342489
+ quidu "365A9E870042"
+ client @78
+ supplier @77
+ line_style 3
+ origin_attachment (2143, 1041)
+ terminal_attachment (2143, 956)
+ drawSupplier @88)
+ (object InheritView "" @111
+ stereotype TRUE
+ line_color 3342489
+ quidu "365A9E8D0091"
+ client @79
+ supplier @77
+ line_style 3
+ origin_attachment (2668, 1041)
+ terminal_attachment (2668, 956)
+ drawSupplier @88)))))
+ root_subsystem (object SubSystem "Component View"
+ quid "365971490054"
+ physical_models (list unit_reference_list)
+ physical_presentations (list unit_reference_list
+ (object Module_Diagram "Main"
+ quid "3659714A039F"
+ title "Main"
+ zoom 100
+ max_height 28350
+ max_width 21600
+ origin_x 0
+ origin_y 0
+ items (list diagram_item_list))))
+ process_structure (object Processes
+ quid "365971490055"
+ ProcsNDevs (list
+ (object Process_Diagram "Deployment View"
+ quid "36597149005E"
+ title "Deployment View"
+ zoom 100
+ max_height 28350
+ max_width 21600
+ origin_x 0
+ origin_y 0
+ items (list diagram_item_list))))
+ properties (object Properties
+ quid "365971490056"))
diff --git a/docs/diagrams.tex b/docs/diagrams.tex
new file mode 100644
index 00000000..454b7242
--- /dev/null
+++ b/docs/diagrams.tex
@@ -0,0 +1,19 @@
+
+\begin{figure}[htbp]
+ \begin{center}
+ \leavevmode
+ \epsfysize0.93\textheight
+ \epsfbox{eps/constantpool.eps}
+ \caption{UML diagram for the ConstantPool API}\label{fig:umlcp}
+ \end{center}
+\end{figure}
+
+\begin{figure}[ht]
+ \begin{center}
+ \leavevmode
+ \epsfysize0.93\textheight
+ \epsfbox{eps/instructions.eps}
+ \caption{UML diagram for the Instruction API}\label{fig:umlinstr}
+ \end{center}
+\end{figure}
+
diff --git a/docs/eps/classfile.eps b/docs/eps/classfile.eps
new file mode 100644
index 00000000..5896e457
--- /dev/null
+++ b/docs/eps/classfile.eps
@@ -0,0 +1,378 @@
+%!PS-Adobe-2.0 EPSF-2.0
+%%Title: classfile.eps
+%%Creator: fig2dev Version 3.2 Patchlevel 1
+%%CreationDate: Mon Nov 30 16:01:26 1998
+%%For: dahm@che (Markus Dahm,,,,,)
+%%Orientation: Portrait
+%%BoundingBox: 0 0 520 460
+%%Pages: 0
+%%BeginSetup
+%%EndSetup
+%%Magnification: 1.0000
+%%EndComments
+/$F2psDict 200 dict def
+$F2psDict begin
+$F2psDict /mtrx matrix put
+/col-1 {0 setgray} bind def
+/col0 {0.000 0.000 0.000 srgb} bind def
+/col1 {0.000 0.000 1.000 srgb} bind def
+/col2 {0.000 1.000 0.000 srgb} bind def
+/col3 {0.000 1.000 1.000 srgb} bind def
+/col4 {1.000 0.000 0.000 srgb} bind def
+/col5 {1.000 0.000 1.000 srgb} bind def
+/col6 {1.000 1.000 0.000 srgb} bind def
+/col7 {1.000 1.000 1.000 srgb} bind def
+/col8 {0.000 0.000 0.560 srgb} bind def
+/col9 {0.000 0.000 0.690 srgb} bind def
+/col10 {0.000 0.000 0.820 srgb} bind def
+/col11 {0.530 0.810 1.000 srgb} bind def
+/col12 {0.000 0.560 0.000 srgb} bind def
+/col13 {0.000 0.690 0.000 srgb} bind def
+/col14 {0.000 0.820 0.000 srgb} bind def
+/col15 {0.000 0.560 0.560 srgb} bind def
+/col16 {0.000 0.690 0.690 srgb} bind def
+/col17 {0.000 0.820 0.820 srgb} bind def
+/col18 {0.560 0.000 0.000 srgb} bind def
+/col19 {0.690 0.000 0.000 srgb} bind def
+/col20 {0.820 0.000 0.000 srgb} bind def
+/col21 {0.560 0.000 0.560 srgb} bind def
+/col22 {0.690 0.000 0.690 srgb} bind def
+/col23 {0.820 0.000 0.820 srgb} bind def
+/col24 {0.500 0.190 0.000 srgb} bind def
+/col25 {0.630 0.250 0.000 srgb} bind def
+/col26 {0.750 0.380 0.000 srgb} bind def
+/col27 {1.000 0.500 0.500 srgb} bind def
+/col28 {1.000 0.630 0.630 srgb} bind def
+/col29 {1.000 0.750 0.750 srgb} bind def
+/col30 {1.000 0.880 0.880 srgb} bind def
+/col31 {1.000 0.840 0.000 srgb} bind def
+
+end
+save
+-17.0 540.0 translate
+1 -1 scale
+
+/cp {closepath} bind def
+/ef {eofill} bind def
+/gr {grestore} bind def
+/gs {gsave} bind def
+/sa {save} bind def
+/rs {restore} bind def
+/l {lineto} bind def
+/m {moveto} bind def
+/rm {rmoveto} bind def
+/n {newpath} bind def
+/s {stroke} bind def
+/sh {show} bind def
+/slc {setlinecap} bind def
+/slj {setlinejoin} bind def
+/slw {setlinewidth} bind def
+/srgb {setrgbcolor} bind def
+/rot {rotate} bind def
+/sc {scale} bind def
+/sd {setdash} bind def
+/ff {findfont} bind def
+/sf {setfont} bind def
+/scf {scalefont} bind def
+/sw {stringwidth} bind def
+/tr {translate} bind def
+/tnt {dup dup currentrgbcolor
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
+ bind def
+/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
+ 4 -2 roll mul srgb} bind def
+/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
+/$F2psEnd {$F2psEnteredState restore end} def
+%%EndProlog
+
+$F2psBegin
+10 setmiterlimit
+n -1000 10000 m -1000 -1000 l 9937 -1000 l 9937 10000 l cp clip
+ 0.06000 0.06000 sc
+% Polyline
+7.500 slw
+n 2999 6599 m 2400 6599 l 2400 6749 l 2999 6749 l cp gs col0 s gr
+% Polyline
+n 2400 6749 m 2999 6749 l 2999 6899 l 2400 6899 l cp gs col0 s gr
+% Polyline
+n 2999 6899 m 2400 6899 l 2400 7049 l 2999 7049 l cp gs col0 s gr
+% Polyline
+n 2400 7049 m 2999 7049 l 2999 7200 l 2400 7200 l cp gs col0 s gr
+% Polyline
+n 2400 7200 m 2999 7200 l 2999 7349 l 2400 7349 l cp gs col0 s gr
+% Polyline
+30.000 slw
+ [15 45] 45 sd
+n 2699 7424 m 2699 7724 l gs col0 s gr [] 0 sd
+% Polyline
+7.500 slw
+n 299 6449 m 3299 6449 l 3299 7949 l 299 7949 l cp gs col0 s gr
+/Helvetica-Bold ff 210.00 scf sf
+599 6824 m
+gs 1 -1 sc (Methods) col0 sh gr
+% Polyline
+n 2999 5099 m 2400 5099 l 2400 5249 l 2999 5249 l cp gs col0 s gr
+% Polyline
+n 2400 5249 m 2999 5249 l 2999 5399 l 2400 5399 l cp gs col0 s gr
+% Polyline
+n 2999 5399 m 2400 5399 l 2400 5549 l 2999 5549 l cp gs col0 s gr
+% Polyline
+n 2400 5549 m 2999 5549 l 2999 5699 l 2400 5699 l cp gs col0 s gr
+% Polyline
+n 2400 5699 m 2999 5699 l 2999 5849 l 2400 5849 l cp gs col0 s gr
+% Polyline
+30.000 slw
+ [15 45] 45 sd
+n 2699 5924 m 2699 6224 l gs col0 s gr [] 0 sd
+% Polyline
+7.500 slw
+n 299 4949 m 3299 4949 l 3299 6449 l 299 6449 l cp gs col0 s gr
+/Helvetica-Bold ff 210.00 scf sf
+599 5399 m
+gs 1 -1 sc (Fields) col0 sh gr
+% Polyline
+n 299 4199 m 3299 4199 l 3299 4949 l 299 4949 l cp gs col0 s gr
+/Helvetica-Bold ff 210.00 scf sf
+599 4649 m
+gs 1 -1 sc (Implemented interfaces) col0 sh gr
+% Polyline
+n 299 3449 m 3299 3449 l 3299 4199 l 299 4199 l cp gs col0 s gr
+/Helvetica-Bold ff 210.00 scf sf
+599 3899 m
+gs 1 -1 sc (Access rights) col0 sh gr
+% Polyline
+n 299 1349 m 3299 1349 l 3299 2099 l 299 2099 l cp gs col0 s gr
+/Helvetica-Bold ff 210.00 scf sf
+599 1799 m
+gs 1 -1 sc (Header) col0 sh gr
+% Polyline
+n 2999 2249 m 2400 2249 l 2400 2400 l 2999 2400 l cp gs col0 s gr
+% Polyline
+n 2400 2400 m 2999 2400 l 2999 2549 l 2400 2549 l cp gs col0 s gr
+% Polyline
+n 2999 2549 m 2400 2549 l 2400 2699 l 2999 2699 l cp gs col0 s gr
+% Polyline
+n 2400 2699 m 2999 2699 l 2999 2849 l 2400 2849 l cp gs col0 s gr
+% Polyline
+n 2400 2849 m 2999 2849 l 2999 2999 l 2400 2999 l cp gs col0 s gr
+% Polyline
+30.000 slw
+ [15 45] 45 sd
+n 2699 3074 m 2699 3374 l gs col0 s gr [] 0 sd
+% Polyline
+7.500 slw
+n 299 2099 m 3299 2099 l 3299 3449 l 299 3449 l cp gs col0 s gr
+/Helvetica-Bold ff 210.00 scf sf
+599 2549 m
+gs 1 -1 sc (Constant pool) col0 sh gr
+% Polyline
+n 299 7949 m 3299 7949 l 3299 8699 l 299 8699 l cp gs col0 s gr
+/Helvetica-Bold ff 210.00 scf sf
+599 8400 m
+gs 1 -1 sc (Class attributes) col0 sh gr
+% Polyline
+n 4800 2999 m 7499 2999 l 7499 4349 l 4800 4349 l cp gs col0 s gr
+/Helvetica-Bold ff 210.00 scf sf
+5099 3299 m
+gs 1 -1 sc (ConstantFieldref) col0 sh gr
+/Helvetica ff 210.00 scf sf
+5099 3600 m
+gs 1 -1 sc ("aVariable") col0 sh gr
+/Helvetica ff 210.00 scf sf
+5099 3884 m
+gs 1 -1 sc ("[Ljava/lang/Object;") col0 sh gr
+/Helvetica ff 210.00 scf sf
+5099 4199 m
+gs 1 -1 sc ("HelloWorld") col0 sh gr
+% Polyline
+n 5024 2624 m 7124 2624 l 7124 2924 l 5024 2924 l cp gs col0 s gr
+/Helvetica ff 210.00 scf sf
+5099 2849 m
+gs 1 -1 sc ("java/io/PrintStream") col0 sh gr
+% Polyline
+n 4800 1649 m 7499 1649 l 7499 2999 l 4800 2999 l cp gs col0 s gr
+/Helvetica-Bold ff 210.00 scf sf
+5099 1949 m
+gs 1 -1 sc (ConstantMethodRef) col0 sh gr
+/Helvetica ff 210.00 scf sf
+5099 2249 m
+gs 1 -1 sc ("println") col0 sh gr
+/Helvetica ff 210.00 scf sf
+5099 2534 m
+gs 1 -1 sc ("\(Ljava/lang/String;\)V") col0 sh gr
+% Polyline
+n 4800 4349 m 7499 4349 l 7499 5099 l 4800 5099 l cp gs col0 s gr
+/Helvetica-Bold ff 210.00 scf sf
+5099 4649 m
+gs 1 -1 sc (ConstantClass) col0 sh gr
+/Helvetica ff 210.00 scf sf
+5099 4949 m
+gs 1 -1 sc ("java/io/PrintStream") col0 sh gr
+% Polyline
+n 4080 6500 m 3975 6500 3975 7770 105 arcto 4 {pop} repeat
+ 3975 7875 8820 7875 105 arcto 4 {pop} repeat
+ 8925 7875 8925 6605 105 arcto 4 {pop} repeat
+ 8925 6500 4080 6500 105 arcto 4 {pop} repeat
+ cp gs 0.00 setgray ef gr gs col0 s gr
+% Polyline
+n 3855 6725 m 3750 6725 3750 7995 105 arcto 4 {pop} repeat
+ 3750 8100 8595 8100 105 arcto 4 {pop} repeat
+ 8700 8100 8700 6830 105 arcto 4 {pop} repeat
+ 8700 6725 3855 6725 105 arcto 4 {pop} repeat
+ cp gs col7 1.00 shd ef gr gs col0 s gr
+% Polyline
+30.000 slw
+ [15 45] 45 sd
+n 6150 7800 m 6150 7950 l gs col0 s gr [] 0 sd
+% Polyline
+7.500 slw
+n 5550 7200 m 7200 7200 l 7200 7425 l 5550 7425 l cp gs col0 s gr
+% Polyline
+n 5550 7500 m 8625 7500 l 8625 7725 l 5550 7725 l cp gs col0 s gr
+/Courier-Bold ff 180.00 scf sf
+4050 7050 m
+gs 1 -1 sc (getstatic java.lang.System.out) col0 sh gr
+/Courier-Bold ff 180.00 scf sf
+4050 7650 m
+gs 1 -1 sc (invokevirtual java.io.PrintStream.println) col0 sh gr
+/Courier-Bold ff 180.00 scf sf
+4050 7350 m
+gs 1 -1 sc (ldc "Hello, world") col0 sh gr
+% Polyline
+ [15 45] 45 sd
+n 2400 2249 m 4800 1649 l gs col0 s gr [] 0 sd
+% Polyline
+ [15 45] 45 sd
+n 2400 2849 m 4800 5849 l gs col0 s gr [] 0 sd
+% Polyline
+gs clippath
+4693 3661 m 4800 3600 l 4734 3705 l 4832 3611 l 4790 3568 l cp
+clip
+n 2999 5324 m 4800 3600 l gs col0 s gr gr
+
+% arrowhead
+n 4693 3661 m 4800 3600 l 4734 3705 l 4713 3683 l 4693 3661 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+3669 7107 m 3750 7200 l 3635 7156 l 3745 7233 l 3779 7184 l cp
+clip
+n 2999 6674 m 3750 7200 l gs col0 s gr gr
+
+% arrowhead
+n 3669 7107 m 3750 7200 l 3635 7156 l 3652 7131 l 3669 7107 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+n 5099 1649 m 5099 1349 l 7799 1349 l 7799 5549 l 7499 5549 l 7499 1649 l
+ 5099 1649 l cp gs 0.00 setgray ef gr gs col0 s gr
+% Polyline
+ [15 45] 45 sd
+n 2999 2849 m 4800 4049 l gs col0 s gr [] 0 sd
+% Polyline
+ [15 45] 45 sd
+n 2999 2249 m 4800 2024 l gs col0 s gr [] 0 sd
+% Polyline
+gs clippath
+7609 2533 m 7500 2475 l 7624 2475 l 7493 2442 l 7478 2500 l cp
+clip
+n 7800 2550 m 7500 2475 l gs col7 s gr gr
+
+% arrowhead
+n 7609 2533 m 7500 2475 l 7624 2475 l 7616 2504 l 7609 2533 l cp gs col7 1.00 shd ef gr col7 s
+% Polyline
+n 4800 5099 m 7499 5099 l 7499 5849 l 4800 5849 l cp gs col0 s gr
+% Polyline
+n 7800 7500 m 7801 7499 l 7804 7496 l 7809 7491 l 7816 7483 l 7826 7472 l
+ 7840 7457 l 7856 7440 l 7875 7419 l 7897 7395 l 7921 7368 l
+ 7946 7340 l 7973 7310 l 7999 7279 l 8026 7247 l 8052 7216 l
+ 8078 7184 l 8102 7152 l 8125 7121 l 8147 7090 l 8167 7059 l
+ 8186 7029 l 8203 6998 l 8220 6966 l 8235 6934 l 8250 6900 l
+ 8261 6873 l 8272 6845 l 8282 6816 l 8292 6786 l 8303 6756 l
+ 8313 6724 l 8323 6692 l 8333 6659 l 8343 6626 l 8353 6592 l
+ 8363 6557 l 8373 6522 l 8382 6487 l 8392 6451 l 8402 6415 l
+ 8412 6379 l 8421 6342 l 8431 6305 l 8440 6268 l 8449 6231 l
+ 8458 6194 l 8467 6157 l 8476 6120 l 8484 6082 l 8492 6045 l
+ 8500 6007 l 8508 5969 l 8515 5932 l 8522 5894 l 8528 5856 l
+ 8535 5817 l 8540 5778 l 8545 5739 l 8550 5700 l 8554 5664 l
+ 8557 5628 l 8560 5591 l 8563 5554 l 8565 5517 l 8567 5479 l
+ 8568 5440 l 8570 5401 l 8571 5362 l 8572 5322 l 8572 5281 l
+ 8573 5241 l 8573 5200 l 8573 5159 l 8573 5117 l 8573 5076 l
+ 8572 5034 l 8572 4992 l 8571 4950 l 8570 4908 l 8570 4866 l
+ 8569 4824 l 8568 4783 l 8567 4741 l 8566 4700 l 8565 4659 l
+ 8564 4619 l 8563 4578 l 8562 4538 l 8561 4499 l 8560 4460 l
+ 8559 4421 l 8558 4383 l 8557 4346 l 8555 4309 l 8554 4272 l
+ 8552 4236 l 8550 4200 l 8548 4161 l 8545 4121 l 8542 4083 l
+ 8540 4044 l 8537 4006 l 8534 3968 l 8531 3930 l 8528 3892 l
+ 8526 3854 l 8523 3815 l 8520 3777 l 8517 3739 l 8515 3702 l
+ 8512 3664 l 8509 3626 l 8506 3588 l 8503 3551 l 8500 3514 l
+ 8497 3477 l 8493 3440 l 8490 3404 l 8486 3368 l 8481 3333 l
+ 8477 3298 l 8471 3264 l 8466 3231 l 8460 3199 l 8453 3167 l
+ 8446 3136 l 8438 3107 l 8430 3078 l 8421 3051 l 8411 3025 l
+ 8400 3000 l 8385 2969 l 8368 2941 l 8349 2913 l 8328 2887 l
+ 8305 2862 l 8279 2838 l 8251 2814 l 8220 2790 l 8187 2767 l
+ 8153 2744 l 8117 2721 l 8080 2699 l 8043 2678 l 8006 2657 l
+ 7970 2638 l 7937 2620 l 7907 2604 l 7879 2590 l 7856 2578 l
+ 7837 2568 l 7823 2561 l 7812 2556 l 7805 2553 l 7802 2551 l
+ 7800 2550 l gs col0 s gr
+% Polyline
+gs clippath
+4723 4703 m 4800 4800 l 4687 4750 l 4794 4833 l 4830 4785 l cp
+clip
+n 5025 2775 m 5024 2776 l 5020 2779 l 5015 2784 l 5006 2792 l 4993 2804 l
+ 4977 2818 l 4957 2836 l 4934 2857 l 4908 2881 l 4879 2907 l
+ 4849 2935 l 4818 2964 l 4786 2994 l 4754 3023 l 4723 3053 l
+ 4693 3082 l 4664 3110 l 4637 3137 l 4612 3163 l 4589 3188 l
+ 4568 3212 l 4549 3235 l 4531 3257 l 4515 3278 l 4500 3300 l
+ 4485 3324 l 4471 3347 l 4457 3371 l 4444 3396 l 4432 3420 l
+ 4419 3445 l 4408 3470 l 4396 3495 l 4385 3520 l 4374 3546 l
+ 4363 3571 l 4352 3596 l 4342 3622 l 4332 3647 l 4323 3673 l
+ 4314 3698 l 4306 3724 l 4299 3749 l 4292 3775 l 4286 3800 l
+ 4281 3825 l 4278 3850 l 4276 3875 l 4275 3900 l 4276 3925 l
+ 4278 3950 l 4282 3975 l 4287 4001 l 4293 4027 l 4301 4053 l
+ 4309 4080 l 4319 4106 l 4329 4133 l 4340 4160 l 4351 4187 l
+ 4363 4214 l 4375 4241 l 4387 4268 l 4399 4294 l 4411 4320 l
+ 4423 4345 l 4434 4370 l 4446 4394 l 4457 4417 l 4468 4439 l
+ 4478 4460 l 4489 4481 l 4500 4500 l 4513 4522 l 4528 4543 l
+ 4543 4563 l 4559 4583 l 4578 4603 l 4597 4623 l 4618 4643 l
+ 4640 4664 l 4663 4685 l 4686 4705 l 4709 4724 l 4730 4742 l
+ 4749 4758 l 4765 4772 l 4778 4783 l 4800 4800 l gs col0 s gr gr
+
+% arrowhead
+n 4723 4703 m 4800 4800 l 4687 4750 l 4705 4727 l 4723 4703 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+7591 5782 m 7499 5699 l 7619 5728 l 7500 5665 l 7472 5719 l cp
+clip
+n 7200 7275 m 7203 7274 l 7208 7271 l 7219 7265 l 7235 7257 l 7256 7246 l
+ 7282 7233 l 7312 7217 l 7346 7200 l 7381 7182 l 7417 7163 l
+ 7453 7144 l 7487 7126 l 7520 7109 l 7551 7092 l 7580 7076 l
+ 7607 7061 l 7631 7048 l 7654 7034 l 7676 7022 l 7696 7010 l
+ 7714 6998 l 7733 6986 l 7750 6975 l 7770 6961 l 7790 6947 l
+ 7810 6933 l 7829 6918 l 7847 6903 l 7866 6887 l 7883 6871 l
+ 7901 6855 l 7917 6837 l 7933 6820 l 7947 6802 l 7961 6784 l
+ 7973 6766 l 7984 6748 l 7994 6729 l 8003 6711 l 8010 6693 l
+ 8016 6675 l 8021 6656 l 8025 6638 l 8028 6618 l 8030 6598 l
+ 8031 6578 l 8031 6556 l 8030 6534 l 8029 6511 l 8026 6487 l
+ 8023 6462 l 8019 6438 l 8015 6412 l 8009 6387 l 8004 6362 l
+ 7997 6338 l 7991 6314 l 7984 6291 l 7977 6269 l 7971 6247 l
+ 7964 6226 l 7957 6207 l 7950 6187 l 7942 6167 l 7934 6146 l
+ 7926 6126 l 7918 6106 l 7909 6086 l 7900 6066 l 7891 6046 l
+ 7881 6027 l 7871 6008 l 7861 5990 l 7850 5972 l 7840 5956 l
+ 7829 5940 l 7818 5925 l 7807 5911 l 7797 5898 l 7785 5886 l
+ 7774 5874 l 7762 5863 l 7750 5852 l 7737 5841 l 7722 5830 l
+ 7707 5819 l 7689 5807 l 7670 5795 l 7648 5782 l 7625 5769 l
+ 7602 5755 l 7578 5742 l 7555 5729 l 7535 5718 l 7499 5699 l gs col0 s gr gr
+
+% arrowhead
+n 7591 5782 m 7499 5699 l 7619 5728 l 7605 5755 l 7591 5782 l cp gs 0.00 setgray ef gr col0 s
+/Helvetica ff 210.00 scf sf
+975 9000 m
+gs 1 -1 sc (HelloWorld.class) col0 sh gr
+/Helvetica ff 210.00 scf sf
+5099 5699 m
+gs 1 -1 sc ("Hello, world") col0 sh gr
+/Helvetica-Bold ff 210.00 scf sf
+5099 5399 m
+gs 1 -1 sc (ConstantString) col0 sh gr
+$F2psEnd
+rs
diff --git a/docs/eps/classfile.fig b/docs/eps/classfile.fig
new file mode 100644
index 00000000..e52815ce
--- /dev/null
+++ b/docs/eps/classfile.fig
@@ -0,0 +1,173 @@
+#FIG 3.2
+Portrait
+Center
+Inches
+A4
+100.00
+Single
+-2
+1200 2
+6 299 1349 3299 8699
+6 299 1349 3299 7949
+6 299 6449 3299 7949
+6 2400 6599 2999 7799
+6 2400 6599 2999 7349
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 2999 6599 2400 6599 2400 6749 2999 6749 2999 6599
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 2400 6749 2999 6749 2999 6899 2400 6899 2400 6749
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 2999 6899 2400 6899 2400 7049 2999 7049 2999 6899
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 2400 7049 2999 7049 2999 7200 2400 7200 2400 7049
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 2400 7200 2999 7200 2999 7349 2400 7349 2400 7200
+-6
+2 1 2 3 0 7 100 0 -1 3.000 0 0 -1 0 0 2
+ 2699 7424 2699 7724
+-6
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 299 6449 3299 6449 3299 7949 299 7949 299 6449
+4 0 0 100 0 18 14 0.0000 4 165 900 599 6824 Methods\001
+-6
+6 299 4949 3299 6449
+6 2400 5099 2999 6299
+6 2400 5099 2999 5849
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 2999 5099 2400 5099 2400 5249 2999 5249 2999 5099
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 2400 5249 2999 5249 2999 5399 2400 5399 2400 5249
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 2999 5399 2400 5399 2400 5549 2999 5549 2999 5399
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 2400 5549 2999 5549 2999 5699 2400 5699 2400 5549
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 2400 5699 2999 5699 2999 5849 2400 5849 2400 5699
+-6
+2 1 2 3 0 7 100 0 -1 3.000 0 0 -1 0 0 2
+ 2699 5924 2699 6224
+-6
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 299 4949 3299 4949 3299 6449 299 6449 299 4949
+4 0 0 100 0 18 14 0.0000 4 165 630 599 5399 Fields\001
+-6
+6 299 4199 3299 4949
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 299 4199 3299 4199 3299 4949 299 4949 299 4199
+4 0 0 100 0 18 14 0.0000 4 210 2400 599 4649 Implemented interfaces\001
+-6
+6 299 3449 3299 4199
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 299 3449 3299 3449 3299 4199 299 4199 299 3449
+4 0 0 100 0 18 14 0.0000 4 210 1410 599 3899 Access rights\001
+-6
+6 299 1349 3299 2099
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 299 1349 3299 1349 3299 2099 299 2099 299 1349
+4 0 0 100 0 18 14 0.0000 4 165 720 599 1799 Header\001
+-6
+6 2400 2249 2999 3449
+6 2400 2249 2999 2999
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 2999 2249 2400 2249 2400 2400 2999 2400 2999 2249
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 2400 2400 2999 2400 2999 2549 2400 2549 2400 2400
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 2999 2549 2400 2549 2400 2699 2999 2699 2999 2549
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 2400 2699 2999 2699 2999 2849 2400 2849 2400 2699
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 2400 2849 2999 2849 2999 2999 2400 2999 2400 2849
+-6
+2 1 2 3 0 7 100 0 -1 3.000 0 0 -1 0 0 2
+ 2699 3074 2699 3374
+-6
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 299 2099 3299 2099 3299 3449 299 3449 299 2099
+4 0 0 100 0 18 14 0.0000 4 210 1470 599 2549 Constant pool\001
+-6
+6 299 7949 3299 8699
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 299 7949 3299 7949 3299 8699 299 8699 299 7949
+4 0 0 100 0 18 14 0.0000 4 165 1620 599 8400 Class attributes\001
+-6
+-6
+6 4800 2999 7499 4349
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 4800 2999 7499 2999 7499 4349 4800 4349 4800 2999
+4 0 0 100 0 18 14 0.0000 4 165 1725 5099 3299 ConstantFieldref\001
+4 0 0 100 0 16 14 0.0000 4 165 1050 5099 3600 "aVariable"\001
+4 0 0 100 0 16 14 0.0000 4 210 1920 5099 3884 "[Ljava/lang/Object;"\001
+4 0 0 100 0 16 14 0.0000 4 165 1185 5099 4199 "HelloWorld"\001
+-6
+6 4800 1649 7499 2999
+6 5024 2624 7124 2924
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 5024 2624 7124 2624 7124 2924 5024 2924 5024 2624
+4 0 0 100 0 16 14 0.0000 4 210 1950 5099 2849 "java/io/PrintStream"\001
+-6
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 4800 1649 7499 1649 7499 2999 4800 2999 4800 1649
+4 0 0 100 0 18 14 0.0000 4 165 2070 5099 1949 ConstantMethodRef\001
+4 0 0 100 0 16 14 0.0000 4 210 735 5099 2249 "println"\001
+4 0 0 100 0 16 14 0.0000 4 210 2085 5099 2534 "(Ljava/lang/String;)V"\001
+-6
+6 4800 4349 7499 5099
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 4800 4349 7499 4349 7499 5099 4800 5099 4800 4349
+4 0 0 100 0 18 14 0.0000 4 165 1515 5099 4649 ConstantClass\001
+4 0 0 100 0 16 14 0.0000 4 210 1950 5099 4949 "java/io/PrintStream"\001
+-6
+6 3750 6450 8925 8100
+2 4 0 1 0 0 100 0 20 0.000 0 0 7 0 0 5
+ 8925 7875 3975 7875 3975 6500 8925 6500 8925 7875
+2 4 0 1 0 7 100 0 20 0.000 0 0 7 0 0 5
+ 8700 8100 3750 8100 3750 6725 8700 6725 8700 8100
+-6
+6 4050 6900 8625 8025
+2 1 2 3 0 7 100 0 -1 3.000 0 0 -1 0 0 2
+ 6150 7800 6150 7950
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 5550 7200 7200 7200 7200 7425 5550 7425 5550 7200
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 5550 7500 8625 7500 8625 7725 5550 7725 5550 7500
+4 0 0 100 0 14 12 0.0000 4 180 3570 4050 7050 getstatic java.lang.System.out\001
+4 0 0 100 0 14 12 0.0000 4 180 4305 4050 7650 invokevirtual java.io.PrintStream.println\001
+4 0 0 100 0 14 12 0.0000 4 150 2940 4050 7350 ldc "Hello, world"\001
+-6
+2 1 2 1 0 7 100 0 -1 3.000 0 0 -1 0 0 2
+ 2400 2249 4800 1649
+2 1 2 1 0 7 100 0 -1 3.000 0 0 -1 0 0 2
+ 2400 2849 4800 5849
+2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
+ 1 1 1.00 60.00 120.00
+ 2999 5324 4800 3600
+2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
+ 1 1 1.00 60.00 120.00
+ 2999 6674 3750 7200
+2 1 0 1 0 0 100 0 20 0.000 0 0 -1 0 0 7
+ 5099 1649 5099 1349 7799 1349 7799 5549 7499 5549 7499 1649
+ 5099 1649
+2 1 2 1 0 7 100 0 -1 3.000 0 0 -1 0 0 2
+ 2999 2849 4800 4049
+2 1 2 1 0 7 100 0 -1 3.000 0 0 -1 0 0 2
+ 2999 2249 4800 2024
+2 1 0 1 7 7 100 0 -1 0.000 0 0 -1 1 0 2
+ 1 1 1.00 60.00 120.00
+ 7800 2550 7500 2475
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 4800 5099 7499 5099 7499 5849 4800 5849 4800 5099
+3 2 0 1 0 7 100 0 -1 0.000 0 0 0 6
+ 7800 7500 8250 6900 8550 5700 8550 4200 8400 3000 7800 2550
+ 0.000 -1.000 -1.000 -1.000 -1.000 0.000
+3 2 0 1 0 7 100 0 -1 0.000 0 1 0 5
+ 1 1 1.00 60.00 120.00
+ 5025 2775 4500 3300 4275 3900 4500 4500 4800 4800
+ 0.000 -1.000 -1.000 -1.000 0.000
+3 0 0 1 0 7 100 0 -1 0.000 0 1 0 6
+ 1 1 1.00 60.00 120.00
+ 7200 7275 7800 6975 8100 6675 7950 6150 7799 5849 7499 5699
+ 0.000 1.000 1.000 1.000 1.000 0.000
+4 0 0 100 0 16 14 0.0000 4 165 1575 975 9000 HelloWorld.class\001
+4 0 0 100 0 16 14 0.0000 4 195 1260 5099 5699 "Hello, world"\001
+4 0 0 100 0 18 14 0.0000 4 210 1560 5099 5399 ConstantString\001
diff --git a/docs/eps/classgen.eps b/docs/eps/classgen.eps
new file mode 100644
index 00000000..4d7052b1
--- /dev/null
+++ b/docs/eps/classgen.eps
@@ -0,0 +1,499 @@
+%!PS-Adobe-3.0 EPSF-3.0
+%%Title: Rose Diagram(s)
+%%Creator: AdobePS5.dll Version 5.0
+%%CreationDate: 7/7/1999 17:42:13
+%%Pages: 1
+%%Orientation: Portrait
+%%PageOrder: Ascend
+%%DocumentNeededResources: (atend)
+%%DocumentSuppliedResources: (atend)
+%%DocumentData: Clean7Bit
+%%TargetDevice: (HP LaserJet 5Si) (2014.108) 1
+%%LanguageLevel: 2
+%%BoundingBox: 13 12 535 830
+%%EndComments
+%%BeginProcSet: epsffit 1 0
+gsave
+1249.738 -7.476 translate
+90 rotate
+1.623 1.623 scale
+%%EndProcSet
+
+
+%%BeginDefaults
+%%PageBoundingBox: 13 12 582 830
+%%EndDefaults
+
+%%BeginProlog
+%%BeginResource: file Pscript_WinNT_ErrorHandler 5.0 0
+/currentpacking where{pop/oldpack currentpacking def/setpacking where{pop false
+setpacking}if}if/$brkpage 64 dict def $brkpage begin/prnt{dup type/stringtype
+ne{=string cvs}if dup length 6 mul/tx exch def/ty 10 def currentpoint/toy exch
+def/tox exch def 1 setgray newpath tox toy 2 sub moveto 0 ty rlineto tx 0
+rlineto 0 ty neg rlineto closepath fill tox toy moveto 0 setgray show}bind def
+/nl{currentpoint exch pop lmargin exch moveto 0 -10 rmoveto}def/=={/cp 0 def
+typeprint nl}def/typeprint{dup type exec}readonly def/lmargin 72 def/rmargin 72
+def/tprint{dup length cp add rmargin gt{nl/cp 0 def}if dup length cp add/cp
+exch def prnt}readonly def/cvsprint{=string cvs tprint( )tprint}readonly def
+/integertype{cvsprint}readonly def/realtype{cvsprint}readonly def/booleantype
+{cvsprint}readonly def/operatortype{(--)tprint =string cvs tprint(-- )tprint}
+readonly def/marktype{pop(-mark- )tprint}readonly def/dicttype{pop
+(-dictionary- )tprint}readonly def/nulltype{pop(-null- )tprint}readonly def
+/filetype{pop(-filestream- )tprint}readonly def/savetype{pop(-savelevel- )
+tprint}readonly def/fonttype{pop(-fontid- )tprint}readonly def/nametype{dup
+xcheck not{(/)tprint}if cvsprint}readonly def/stringtype{dup rcheck{(\()tprint
+tprint(\))tprint}{pop(-string- )tprint}ifelse}readonly def/arraytype{dup rcheck
+{dup xcheck{({)tprint{typeprint}forall(})tprint}{([)tprint{typeprint}forall(])
+tprint}ifelse}{pop(-array- )tprint}ifelse}readonly def/packedarraytype{dup
+rcheck{dup xcheck{({)tprint{typeprint}forall(})tprint}{([)tprint{typeprint}
+forall(])tprint}ifelse}{pop(-packedarray- )tprint}ifelse}readonly def/courier
+/Courier findfont 10 scalefont def end errordict/handleerror{systemdict begin
+$error begin $brkpage begin newerror{/newerror false store vmstatus pop pop 0
+ne{grestoreall}if showpage initgraphics courier setfont lmargin 720 moveto
+(ERROR: )prnt errorname prnt nl(OFFENDING COMMAND: )prnt/command load prnt
+$error/ostack known{nl nl(STACK:)prnt nl nl $error/ostack get aload length{==}
+repeat}if systemdict/showpage get exec(%%[ Error: )print errorname =print
+(; OffendingCommand: )print/command load =print( ]%%)= flush}if end end end}dup
+0 systemdict put dup 4 $brkpage put bind readonly put/currentpacking where{pop
+/setpacking where{pop oldpack setpacking}if}if
+%%EndResource
+userdict /Pscript_WinNT_Incr 230 dict dup begin put
+%%BeginResource: file Pscript_FatalError 5.0 0
+/FatalErrorIf{{initgraphics findfont exch scalefont setfont counttomark 3 div
+cvi{moveto show}repeat showpage quit}{cleartomark}ifelse}bind def
+%%EndResource
+/VM?{vmstatus exch sub exch pop gt{[
+(This job requires more memory than is available in this printer.)100 500
+(Try one or more of the following, and then print again:)100 485
+(For the output format, choose Optimize For Portability.)115 470
+(In the Device Settings page, make sure the Available PostScript Memory is accurate.)
+115 455(Reduce the number of fonts in the document.)115 440
+(Print the document in parts.)115 425 12/Times-Roman showpage
+(%%[ PrinterError: Low Printer VM ]%%)= true FatalErrorIf}if}bind def
+%%BeginResource: file Pscript_Win_Basic 5.0 0
+/d/def load def/,/load load d/~/exch , d/?/ifelse , d/!/pop , d/`/begin , d/^
+/index , d/@/dup , d/+/translate , d/$/roll , d/U/userdict , d/M/moveto , d/-
+/rlineto , d/&/currentdict , d/:/gsave , d/;/grestore , d/F/false , d/T/true ,
+d/N/newpath , d/E/end , d/Ac/arc , d/An/arcn , d/A/ashow , d/D/awidthshow , d/C
+/closepath , d/V/div , d/O/eofill , d/L/fill , d/I/lineto , d/-c/curveto , d/-M
+/rmoveto , d/+S/scale , d/Ji/setfont , d/Lc/setlinecap , d/Lj/setlinejoin , d
+/Lw/setlinewidth , d/Lm/setmiterlimit , d/sd/setdash , d/S/show , d/LH/showpage
+, d/K/stroke , d/W/widthshow , d/R/rotate , d/P/eoclip , d/L2? false
+/languagelevel where{pop languagelevel 2 ge{pop true}if}if d L2?{/xS/xshow , d
+/yS/yshow , d/zS/xyshow , d}if/b{bind d}bind d/bd{bind d}bind d/xd{~ d}bd/ld{,
+d}bd/lw/Lw ld/lc/Lc ld/lj/Lj ld/sg/setgray ld/ADO_mxRot null d/self & d/OrgMx
+matrix currentmatrix d/reinitialize{: OrgMx setmatrix[/TextInit/GraphInit
+/UtilsInit counttomark{@ where{self eq}{F}?{cvx exec}{!}?}repeat cleartomark ;}
+b/initialize{`{/ADO_mxRot ~ d/TextInitialised? F d reinitialize E}{U
+/Pscript_Win_Data 230 dict @ ` put/ADO_mxRot ~ d/TextInitialised? F d
+reinitialize}?}b/terminate{!{& self eq{exit}{E}?}loop E}b/suspend/terminate , d
+/resume{` Pscript_Win_Data `}b/snap{transform 0.25 sub round 0.25 add ~ 0.25
+sub round 0.25 add ~ itransform}b/dsnap{dtransform round ~ round ~ idtransform}
+b<04>cvn{}d/rr{1 ^ 0 - 0 ~ - neg 0 - C}b/rp{4 2 $ M 1 ^ 0 - 0 ~ - neg 0 -}b
+/solid{[]0 sd}b/g{@ not{U/DefIf_save save put}if U/DefIf_bool 2 ^ put}b
+/DefIf_El{if U/DefIf_bool get not @{U/DefIf_save get restore}if}b/e{DefIf_El !}
+b/UDF{L2?{undefinefont}{!}?}b/UDR{L2?{undefineresource}{! !}?}b
+%%EndResource
+%%BeginResource: file Pscript_Win_Utils_L2 5.0 0
+/rf/rectfill , d/fx{1 1 dtransform @ 0 ge{1 sub 0.5}{1 add -0.5}? 3 -1 $ @ 0 ge
+{1 sub 0.5}{1 add -0.5}? 3 1 $ 4 1 $ idtransform 4 -2 $ idtransform}b/BZ{4 -2 $
+snap + +S fx rf}b/rs/rectstroke , d/rc/rectclip , d/UtilsInit{currentglobal{F
+setglobal}if}b/scol{! setcolor}b/colspA/DeviceGray d/colspABC/DeviceRGB d
+/colspRefresh{colspABC setcolorspace}b/SetColSpace{colspABC setcolorspace}b
+%%EndResource
+end
+%%EndProlog
+
+%%BeginSetup
+[ 1 0 0 1 0 0 ] false Pscript_WinNT_Incr dup /initialize get exec
+1 setlinecap 1 setlinejoin
+/mysetup [ 0.24 0 0 -0.24 13.43905 829.74047 ] def
+%%EndSetup
+
+%%Page: 1 1
+%%PageBoundingBox: 13 12 582 830
+%%EndPageComments
+%%BeginPageSetup
+/DeviceRGB dup setcolorspace /colspABC exch def mysetup concat colspRefresh
+%%EndPageSetup
+
+Pscript_WinNT_Incr begin
+%%BeginResource: file Pscript_Win_GdiObject 5.0 0
+/SavedCTM null d/CTMsave{/SavedCTM SavedCTM currentmatrix d}b/CTMrestore
+{SavedCTM setmatrix}b/mp null d/ADO_mxRot null d/GDIHMatrix null d
+/GDIHPatternDict 22 dict d GDIHPatternDict `/PatternType 1 d/PaintType 2 d/Reps
+L2?{1}{5}? d/XStep 8 Reps mul d/YStep XStep d/BBox[0 0 XStep YStep]d/TilingType
+1 d/PaintProc{` 1 Lw[]0 sd PaintData , exec E}b/FGnd null d/BGnd null d
+/HS_Horizontal{horiz}b/HS_Vertical{vert}b/HS_FDiagonal{fdiag}b/HS_BDiagonal
+{biag}b/HS_Cross{horiz vert}b/HS_DiagCross{fdiag biag}b/MaxXYStep XStep YStep
+gt{XStep}{YStep}? d/horiz{Reps{0 4 M XStep 0 - 0 8 +}repeat 0 -8 Reps mul + K}b
+/vert{Reps{4 0 M 0 YStep - 8 0 +}repeat 0 -8 Reps mul + K}b/biag{Reps{0 0 M
+MaxXYStep @ - 0 YStep neg M MaxXYStep @ - 0 8 +}repeat 0 -8 Reps mul + 0 YStep
+M 8 8 - K}b/fdiag{Reps{0 0 M MaxXYStep @ neg - 0 YStep M MaxXYStep @ neg - 0 8
++}repeat 0 -8 Reps mul + MaxXYStep @ M 8 -8 - K}b E/makehatch{4 -2 $/yOrg ~ d
+/xOrg ~ d GDIHPatternDict/PaintData 3 -1 $ put CTMsave GDIHMatrix setmatrix
+GDIHPatternDict matrix xOrg yOrg + mp CTMrestore ~ U ~ 2 ^ put}b/h0{/h0
+/HS_Horizontal makehatch}b/h1{/h1/HS_Vertical makehatch}b/h2{/h2/HS_FDiagonal
+makehatch}b/h3{/h3/HS_BDiagonal makehatch}b/h4{/h4/HS_Cross makehatch}b/h5{/h5
+/HS_DiagCross makehatch}b/GDIBWPatternDict 25 dict @ `/PatternType 1 d
+/PaintType L2?{1}{2}? d/RepsV L2?{1}{6}? d/RepsH L2?{1}{5}? d/BBox[0 0 RepsH 1]
+d/TilingType 1 d/XStep 1 d/YStep 1 d/Height 8 RepsV mul d/Width 8 d/mx[Width 0
+0 Height neg 0 Height]d/FGnd null d/BGnd null d/SetBGndFGnd L2?{{FGnd null ne
+{FGnd aload ! scol BBox aload ! 2 ^ sub ~ 3 ^ sub ~ rf}if BGnd null ne{BGnd
+aload ! scol}if}}{{}}? b/PaintProc{` SetBGndFGnd RepsH{Width Height F mx
+PaintData imagemask Width 0 +}repeat E}b E d/GDIBWPatternMx null d/pfprep{save
+8 1 $/PatternOfTheDay 8 1 $ GDIBWPatternDict `/yOrg ~ d/xOrg ~ d/PaintData ~ d
+/yExt ~ d/Width ~ d/FGnd ~ d/BGnd ~ d/Height yExt RepsV mul d/mx[Width 0 0
+Height 0 0]d E : GDIBWPatternDict ` Width Height E dsnap +S/GDIBWPatternMx
+matrix currentmatrix d ; CTMsave GDIBWPatternMx setmatrix GDIBWPatternDict @ `
+xOrg yOrg E matrix + mp CTMrestore ~ !}b/pfbf{/fEOFill ~ d pfprep hbf fEOFill
+{O}{L}? restore}b/GraphInit{GDIHMatrix null eq{/SavedCTM matrix d : ADO_mxRot
+concat 0 0 snap + : 0.48 @ GDIHPatternDict ` YStep mul ~ XStep mul ~ dsnap
+YStep V ~ XStep V ~ E +S/GDIHMatrix matrix currentmatrix readonly d ; : 0.24
+-0.24 +S GDIBWPatternDict ` Width Height E dsnap +S/GDIBWPatternMx matrix
+currentmatrix readonly d ; ;}if}b
+%%EndResource
+%%BeginResource: file Pscript_Win_GdiObject_L2 5.0 0
+/mp/makepattern , d/hbf{setpattern}b/hf{:/fEOFill ~ d ~ ! setpattern fEOFill{O}
+{L}? ;}b/pbf{: !/fEOFill ~ d GDIBWPatternDict `/yOrg ~ d/xOrg ~ d/PaintData ~ d
+/OutputBPP ~ d/Height ~ d/Width ~ d/PaintType 1 d/PatternType 1 d/TilingType 1
+d/BBox[0 0 Width Height]d/XStep Width d/YStep Height d/mx xOrg yOrg matrix + d
+20 dict @ `/ImageType 1 d/Width Width d/Height Height d/ImageMatrix mx d
+/BitsPerComponent 8 d OutputBPP 24 eq{/Decode[0 1 0 1 0 1]d}{OutputBPP 8 eq{
+/Decode[0 1]d}{/Decode[0 1 0 1 0 1 0 1]d}?}?/DataSource{PaintData}d E/ImageDict
+~ d/PaintProc{` ImageDict image E}b & mx makepattern setpattern E fEOFill{O}{L}
+? ;}b
+%%EndResource
+end reinitialize
+: N 234 594 236 124 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol 1 Lw N 470 593 M 233 593 I 233 718 I 470 718 I C
+K
+0 0 0 1 scol Pscript_WinNT_Incr begin
+%%BeginResource: file Pscript_Text 5.0 0
+/TextInit{TextInitialised? not{/Pscript_Windows_Font & d/TextInitialised? T d
+/fM[1 0 0 1 0 0]d/mFM matrix d/iMat[1 0 0.212557 1 0 0]d}if}b/copyfont{1 ^
+length add dict `{1 ^/FID ne{d}{! !}?}forall & E}b/EncodeDict 11 dict d/bullets
+{{/bullet}repeat}b/rF{3 copyfont @ ` ~ EncodeDict ~ get/Encoding ~ 3 ^/0 eq{&
+/CharStrings known{CharStrings/Eth known not{! EncodeDict/ANSIEncodingOld get}
+if}if}if d E}b/mF{@ 7 1 $ findfont ~{@/Encoding get @ StandardEncoding eq{! T}{
+{ISOLatin1Encoding}stopped{! F}{eq}?{T}{@ ` T 32 1 127{Encoding 1 ^ get
+StandardEncoding 3 -1 $ get eq and}for E}?}?}{F}?{1 ^ ~ rF}{0 copyfont}? 6 -2 $
+{T pd_AddEm87 ~ !}{! ~ !/pd_charset @ where{~ get 128 eq{@ FDV 2 copy get @
+length array copy put pd_CoverFCRange}if}{!}?}? 2 ^ ~ definefont fM 5 4 -1 $
+put fM 4 0 put fM makefont Pscript_Windows_Font 3 1 $ put}b/sLT{: Lw -M
+currentpoint snap M 0 - 0 Lc K ;}b/xUP null d/yUP null d/uW null d/xSP null d
+/ySP null d/sW null d/sSU{N/uW ~ d/yUP ~ d/xUP ~ d}b/sU{xUP yUP uW sLT}b/sST{N
+/sW ~ d/ySP ~ d/xSP ~ d}b/sT{xSP ySP sW sLT}b/sR{: + R 0 0 M}b/sRxy{: matrix
+astore concat 0 0 M}b/eR/; , d/AddOrigFP{{&/FontInfo known{&/FontInfo get
+length 6 add}{6}? dict `/WinPitchAndFamily ~ d/WinCharSet ~ d/OrigFontType ~ d
+/OrigFontStyle ~ d/OrigFontName ~ d & E/FontInfo ~ d}{! ! ! ! !}?}b/mFS
+{makefont Pscript_Windows_Font 3 1 $ put}b/mF42D{0 copyfont `/FontName ~ d 2
+copy ~ sub 1 add dict `/.notdef 0 d 2 copy 1 ~{@ 3 ^ sub Encoding ~ get ~ d}for
+& E/CharStrings ~ d ! ! & @ E/FontName get ~ definefont}bind d/mF42{15 dict ` @
+4 1 $/FontName ~ d/FontType 0 d/FMapType 2 d/FontMatrix[1 0 0 1 0 0]d 1 ^ 254
+add 255 idiv @ array/Encoding ~ d 0 1 3 -1 $ 1 sub{@ Encoding 3 1 $ put}for
+/FDepVector Encoding length array d/CharStrings 2 dict `/.notdef 0 d & E d 0 1
+Encoding length 1 sub{@ @ 10 lt{! FontName length 1 add string}{100 lt{FontName
+length 2 add string}{FontName length 3 add string}?}? @ 0 FontName @ length
+string cvs putinterval @ 3 -1 $ @ 4 1 $ 3 string cvs FontName length ~
+putinterval cvn 1 ^ 256 mul @ 255 add 3 -1 $ 4 ^ findfont mF42D FDepVector 3 1
+$ put}for & @ E/FontName get ~ definefont ! ! ! mF}b/UmF{L2?
+{Pscript_Windows_Font ~ undef}{!}?}b/UmF42{@ findfont/FDepVector get{/FontName
+get undefinefont}forall undefinefont}b
+%%EndResource
+end reinitialize
+Pscript_WinNT_Incr begin
+%%BeginResource: file Pscript_Encoding256 5.0 0
+/CharCol256Encoding[/.notdef/breve/caron/dotaccent/dotlessi/fi/fl/fraction
+/hungarumlaut/Lslash/lslash/minus/ogonek/ring/Zcaron/zcaron/.notdef/.notdef
+/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
+/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/exclam/quotedbl/numbersign
+/dollar/percent/ampersand/quotesingle/parenleft/parenright/asterisk/plus/comma
+/hyphen/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon
+/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S
+/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/asciicircum/underscore/grave
+/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright
+/asciitilde/.notdef/.notdef/.notdef/quotesinglbase/florin/quotedblbase/ellipsis
+/dagger/daggerdbl/circumflex/perthousand/Scaron/guilsinglleft/OE/.notdef
+/.notdef/.notdef/.notdef/quoteleft/quoteright/quotedblleft/quotedblright/bullet
+/endash/emdash/tilde/trademark/scaron/guilsinglright/oe/.notdef/.notdef
+/Ydieresis/.notdef/exclamdown/cent/sterling/currency/yen/brokenbar/section
+/dieresis/copyright/ordfeminine/guillemotleft/logicalnot/.notdef/registered
+/macron/degree/plusminus/twosuperior/threesuperior/acute/mu/paragraph
+/periodcentered/cedilla/onesuperior/ordmasculine/guillemotright/onequarter
+/onehalf/threequarters/questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis
+/Aring/AE/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute
+/Icircumflex/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
+/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls
+/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla/egrave/eacute
+/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis/eth/ntilde/ograve
+/oacute/ocircumflex/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex
+/udieresis/yacute/thorn/ydieresis]def EncodeDict/256 CharCol256Encoding put
+%%EndResource
+end reinitialize
+
+%%IncludeResource: font Helvetica
+F /F0 0 /256 T /Helvetica mF
+/F0S29 F0 [41 0 0 -41 0 0 ] mFS
+F0S29 Ji
+257 643 M (BasicType)[27 23 20 8 21 26 19 23 0]xS
+0.602 0 0.199 1 scol N 470 659 M 233 659 I 233 718 I 470 718 I C
+K
+N 470 682 M 233 682 I 233 718 I 470 718 I C
+K
+: N 252 292 360 184 rp C
+1 1 0.801 1 scol L ; N 612 291 M 251 291 I 251 476 I 612 476 I C
+K
+0 0 0 1 scol 326 341 M (ObjectType)[32 23 10 23 21 11 26 19 23 0]xS
+0.602 0 0.199 1 scol N 612 357 M 251 357 I 251 476 I 612 476 I C
+K
+N 612 380 M 251 380 I 251 476 I 612 476 I C
+K
+0 0 0 1 scol 310 448 M (getClassName\(\))[23 23 11 30 10 23 20 20 30 23 36 23 14 0]xS
+: N 699 292 362 184 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 1061 291 M 698 291 I 698 476 I 1061 476 I C
+K
+0 0 0 1 scol 786 341 M (ArrayType)[27 14 14 23 19 26 19 23 0]xS
+0.602 0 0.199 1 scol N 1061 357 M 698 357 I 698 476 I 1061 476 I C
+K
+N 1061 380 M 698 380 I 698 476 I 1061 476 I C
+K
+0 0 0 1 scol 757 448 M (getDimensions\(\))[23 23 11 30 8 36 23 23 20 8 23 23 20 14 0]xS
+: N 532 594 312 124 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 844 593 M 531 593 I 531 718 I 844 718 I C
+K
+0 0 0 1 scol 546 643 M (ReferenceType)[30 23 12 23 14 23 23 21 23 26 19 23 0]xS
+0.602 0 0.199 1 scol N 844 659 M 531 659 I 531 718 I 844 718 I C
+K
+N 844 682 M 531 682 I 531 718 I 844 718 I C
+K
+: N 1202 295 284 178 rp C
+1 1 0.801 1 scol L ; N 1486 294 M 1201 294 I 1201 473 I 1486 473 I C
+K
+0 0 0 1 scol
+%%IncludeResource: font Helvetica-Oblique
+F /F1 0 /256 T /Helvetica-Oblique mF
+/F1S29 F1 [41 0 0 -41 0 0 ] mFS
+F1S29 Ji
+1226 343 M (AccessFlags)[27 21 21 23 21 21 25 9 23 23 0]xS
+0.602 0 0.199 1 scol N 1486 360 M 1201 360 I 1201 473 I 1486 473 I C
+K
+N 1486 383 M 1201 383 I 1201 473 I 1486 473 I C
+K
+0 0 0 1 scol 1260 450 M (isPublic\(\))[9 21 27 23 23 9 9 21 14 0]xS
+0.602 0 0.199 1 scol N 1344 602 M 1344 474 I K
+N 1059 602 M 1634 602 I K
+N 1344 474 M 1366 534 I 1322 534 I C
+: 1 1 1 1 scol O ; K
+N 678 500 M 678 593 I K
+N 369 500 M 881 500 I K
+N 678 593 M 700 533 I 656 533 I C
+: 1 1 1 1 scol O ; K
+N 369 477 M 369 500 I K
+N 881 477 M 881 500 I K
+: N 919 683 306 234 rp C
+1 1 0.801 1 scol L ; N 1225 682 M 918 682 I 918 917 I 1225 917 I C
+K
+0 0 0 1 scol F0S29 Ji
+988 732 M (FieldGen)[25 8 23 10 23 32 23 0]xS
+0.602 0 0.199 1 scol N 1225 748 M 918 748 I 918 917 I 1225 917 I C
+K
+N 1225 771 M 918 771 I 918 917 I 1225 917 I C
+K
+0 0 0 1 scol 977 839 M (getField\(\))[23 23 11 25 8 23 10 23 14 0]xS
+977 886 M (setInitValue\(\))[20 23 11 10 23 8 11 27 23 10 23 23 14 0]xS
+0.602 0 0.199 1 scol N 1059 682 M 1059 602 I K
+: N 543 1283 386 122 rp C
+1 1 0.801 1 scol L ; N 929 1282 M 542 1282 I 542 1405 I 929 1405 I C
+K
+0 0 0 1 scol 571 1332 M (LocalVariableGen)[23 23 21 23 10 27 23 14 8 23 23 10 23 32 23 0]xS
+0.602 0 0.199 1 scol N 929 1348 M 542 1348 I 542 1405 I 929 1405 I C
+K
+N 929 1371 M 542 1371 I 542 1405 I 929 1405 I C
+K
+: N 538 1106 396 124 rp C
+1 1 0.801 1 scol L ; N 934 1105 M 537 1105 I 537 1230 I 934 1230 I C
+K
+0 0 0 1 scol 559 1155 M (CodeExceptionGen)[30 23 23 23 27 18 21 23 23 11 8 23 23 32 23 0]xS
+0.602 0 0.199 1 scol N 934 1171 M 537 1171 I 537 1230 I 934 1230 I C
+K
+N 934 1194 M 537 1194 I 537 1230 I 934 1230 I C
+K
+: N 351 836 322 184 rp C
+1 1 0.801 1 scol L ; N 673 835 M 350 835 I 350 1020 I 673 1020 I C
+K
+0 0 0 1 scol 466 885 M (Type)[26 19 23 0]xS
+0.602 0 0.199 1 scol N 673 901 M 350 901 I 350 1020 I 673 1020 I C
+K
+N 673 924 M 350 924 I 350 1020 I 673 1020 I C
+K
+0 0 0 1 scol 409 992 M (getSignature\(\))[23 23 11 27 8 23 23 23 11 23 14 23 14 0]xS
+0.602 0 0.199 1 scol N 512 745 M 512 835 I K
+N 347 745 M 669 745 I K
+N 512 835 M 534 775 I 490 775 I C
+: 1 1 1 1 scol O ; K
+N 795 862 M 674 889 I K
+N 795 862 M 917 833 I K
+N 347 719 M 347 745 I K
+N 669 719 M 669 745 I K
+: N 538 1457 364 126 rp C
+1 1 0.801 1 scol L ; N 902 1456 M 537 1456 I 537 1583 I 902 1583 I C
+K
+0 0 0 1 scol 561 1506 M (BranchInstruction)[27 14 23 23 21 23 10 23 20 11 14 23 21 11 8 23 0]xS
+0.602 0 0.199 1 scol N 902 1522 M 537 1522 I 537 1583 I 902 1583 I C
+K
+N 902 1545 M 537 1545 I 537 1583 I 902 1583 I C
+K
+: N 1157 1012 342 184 rp C
+1 1 0.801 1 scol L ; N 1499 1011 M 1156 1011 I 1156 1196 I 1499 1196 I C
+K
+0 0 0 1 scol 1221 1061 M (MethodGen)[33 23 11 23 23 23 32 23 0]xS
+0.602 0 0.199 1 scol N 1499 1077 M 1156 1077 I 1156 1196 I 1499 1196 I C
+K
+N 1499 1100 M 1156 1100 I 1156 1196 I 1499 1196 I C
+K
+0 0 0 1 scol 1215 1168 M (addException\(\))[23 23 23 27 18 21 23 23 11 8 23 23 14 0]xS
+0.602 0 0.199 1 scol N 1022 1227 M 1155 1172 I K
+N 1155 1172 M 1136 1196 I 1105 1193 I 1124 1168 I 1155 1172 I C
+: 1 1 1 1 scol O ; K
+N 1022 1227 M 886 1281 I K
+N 913 1302 16 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 913 1340 M (*)S
+N 913 1302 16 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 913 1340 M (*)S
+0.602 0 0.199 1 scol N 1045 1134 M 1155 1121 I K
+N 1155 1121 M 1130 1139 I 1101 1127 I 1126 1109 I 1155 1121 I C
+: 1 1 1 1 scol O ; K
+N 1045 1134 M 935 1145 I K
+N 934 1068 16 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 934 1106 M (*)S
+N 934 1068 16 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 934 1106 M (*)S
+0.602 0 0.199 1 scol N 914 1014 M 674 962 I K
+N 914 1014 M 1155 1066 I K
+N 1344 1011 M 1344 602 I K
+: N 1751 1012 306 184 rp C
+1 1 0.801 1 scol L ; N 2057 1011 M 1750 1011 I 1750 1196 I 2057 1196 I C
+K
+0 0 0 1 scol 1779 1061 M (InstructionList)[10 23 20 11 14 23 21 11 8 23 23 23 8 20 0]xS
+0.602 0 0.199 1 scol N 2057 1077 M 1750 1077 I 1750 1196 I 2057 1196 I C
+K
+N 2057 1100 M 1750 1100 I 1750 1196 I 2057 1196 I C
+K
+0 0 0 1 scol 1809 1168 M (append\(\))[23 23 23 23 23 23 14 0]xS
+0.602 0 0.199 1 scol N 1624 1104 M 1749 1104 I K
+N 1624 1104 M 1500 1104 I K
+: N 1201 1313 222 190 rp C
+1 1 0.801 1 scol L ; N 1423 1312 M 1200 1312 I 1200 1503 I 1423 1503 I C
+K
+0 0 0 1 scol 1219 1362 M (Instruction)[10 23 20 11 14 23 21 11 8 23 0]xS
+0.602 0 0.199 1 scol N 1423 1378 M 1200 1378 I 1200 1503 I 1423 1503 I C
+K
+N 1423 1495 M 1200 1495 I 1200 1503 I 1423 1503 I C
+K
+0 0 0 1 scol 1259 1422 M (tag)[11 23 0]xS
+1259 1469 M (length)[10 23 23 23 11 0]xS
+0.602 0 0.199 1 scol N 903 1485 M 1199 1429 I K
+N 1199 1429 M 1144 1462 I 1136 1418 I C
+: 1 1 1 1 scol O ; K
+: N 1722 1345 364 126 rp C
+1 1 0.801 1 scol L ; N 2086 1344 M 1721 1344 I 1721 1471 I 2086 1471 I C
+K
+0 0 0 1 scol 1744 1394 M (InstructionHandle)[10 23 20 11 14 23 21 11 8 23 23 30 23 23 23 10 0]xS
+0.602 0 0.199 1 scol N 2086 1410 M 1721 1410 I 1721 1471 I 2086 1471 I C
+K
+N 2086 1433 M 1721 1433 I 1721 1471 I 2086 1471 I C
+K
+N 1904 1270 M 1904 1197 I K
+N 1947 1181 23 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1947 1219 M (1)S
+0.602 0 0.199 1 scol N 1904 1197 M 1919 1224 I 1904 1251 I 1889 1224 I 1904 1197 I C
+: 1 1 1 1 scol O ; K
+N 1904 1270 M 1904 1343 I K
+N 1950 1313 16 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1950 1351 M (*)S
+N 1947 1181 23 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1947 1219 M (1)S
+N 1950 1313 16 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1950 1351 M (*)S
+0.602 0 0.199 1 scol N 1572 1408 M 1424 1408 I K
+N 1429 1439 23 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1429 1477 M (1)S
+0.602 0 0.199 1 scol N 1572 1408 M 1720 1408 I K
+N 1693 1439 23 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1693 1477 M (1)S
+N 1429 1439 23 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1429 1477 M (1)S
+N 1693 1439 23 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1693 1477 M (1)S
+: N 0 1224 384 240 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol : 0 1223 385 242 rc N 384 1223 M -1 1223 I -1 1464 I 384 1464 I C
+K
+; 0 0 0 1 scol 20 1323 M (InstructionTargeter)[10 23 20 11 14 23 21 11 8 23 23 26 23 14 23 23 11 23 0]xS
+0.602 0 0.199 1 scol : 0 1339 385 126 rc N 384 1339 M -1 1339 I -1 1464 I 384 1464 I C
+K
+; : 0 1362 385 103 rc N 384 1362 M -1 1362 I -1 1464 I 384 1464 I C
+K
+; 0 0 0 1 scol 58 1430 M (updateTarget\(\))[23 23 23 23 11 23 26 23 14 23 23 11 14 0]xS
+64 1273 M (<<Interface>>)[24 24 10 23 11 23 14 12 23 21 23 24 0]xS
+1 1 1 1 scol [ 72 24 ] 0 sd N 540 1231 M 385 1280 I K
+0 0 0 1 scol [ 72 24 ] 0 sd N 540 1231 M 385 1280 I K
+0.602 0 0.199 1 scol solid N 385 1280 M 449 1283 I 435 1241 I C
+: 1 1 1 1 scol O ; K
+1 1 1 1 scol [ 72 24 ] 0 sd N 541 1344 M 385 1344 I K
+0 0 0 1 scol [ 72 24 ] 0 sd N 541 1344 M 385 1344 I K
+0.602 0 0.199 1 scol solid N 385 1344 M 445 1366 I 445 1322 I C
+: 1 1 1 1 scol O ; K
+N 1043 1616 M 1903 1616 I K
+N 1903 1616 M 1903 1472 I K
+N 1949 1550 16 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1949 1588 M (*)S
+0.602 0 0.199 1 scol N 1043 1616 M 191 1616 I K
+N 191 1616 M 191 1465 I K
+N 237 1542 16 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 237 1580 M (*)S
+N 1949 1550 16 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1949 1588 M (*)S
+N 237 1542 16 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 237 1580 M (*)S
+N 1186 1556 221 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1186 1594 M (<<targets>>)[24 24 11 23 14 23 23 11 20 24 0]xS
+: N 1707 306 362 284 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 2069 305 M 1706 305 I 1706 590 I 2069 590 I C
+K
+0 0 0 1 scol 1725 355 M (ConstantPoolGen)[30 23 23 20 11 23 23 11 27 23 23 10 32 23 0]xS
+0.602 0 0.199 1 scol N 2069 371 M 1706 371 I 1706 590 I 2069 590 I C
+K
+N 2069 394 M 1706 394 I 1706 590 I 2069 590 I C
+K
+0 0 0 1 scol 1765 462 M (addClass\(\))[23 23 23 30 10 23 20 20 14 0]xS
+1765 509 M (addMethodRef\(\))[23 23 23 33 23 11 23 23 23 30 23 12 14 0]xS
+1765 556 M (addInteger\(\))[23 23 23 10 23 11 23 23 23 14 14 0]xS
+: N 1475 683 314 234 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 1789 682 M 1474 682 I 1474 917 I 1789 917 I C
+K
+0 0 0 1 scol 1541 732 M (ClassGen)[30 10 23 20 20 32 23 0]xS
+0.602 0 0.199 1 scol N 1789 748 M 1474 748 I 1474 917 I 1789 917 I C
+K
+N 1789 771 M 1474 771 I 1474 917 I 1789 917 I C
+K
+0 0 0 1 scol 1533 839 M (addInterface\(\))[23 23 23 10 23 11 23 14 12 23 21 23 14 0]xS
+1533 886 M (addMethod\(\))[23 23 23 33 23 11 23 23 23 14 0]xS
+0.602 0 0.199 1 scol N 1634 682 M 1634 602 I K
+N 1751 636 M 1782 591 I K
+N 1751 636 M 1717 681 I K
+1 1 1 1 scol [ 72 24 ] 0 sd N 536 1458 M 385 1408 I K
+0 0 0 1 scol [ 72 24 ] 0 sd N 536 1458 M 385 1408 I K
+0.602 0 0.199 1 scol solid N 385 1408 M 449 1406 I 435 1448 I C
+: 1 1 1 1 scol O ; K
+LH
+%%PageTrailer
+
+%%Trailer
+%%DocumentNeededResources:
+%%+ font Helvetica-Oblique
+%%+ font Helvetica
+%%DocumentSuppliedResources:
+Pscript_WinNT_Incr dup /terminate get exec
+%%EOF
+grestore
diff --git a/docs/eps/classgen.fig b/docs/eps/classgen.fig
new file mode 100644
index 00000000..0bb425ff
--- /dev/null
+++ b/docs/eps/classgen.fig
@@ -0,0 +1,302 @@
+#FIG 3.2
+Portrait
+Center
+Inches
+A4
+100.00
+Single
+-2
+1200 2
+0 32 #f9f9f9
+0 33 #303030
+6 165 2157 5761 10157
+2 1 0 0 32 32 998 0 20 4.000 0 0 0 0 0 4
+ 4717 10153 4717 8621 5673 8621 5673 10153
+2 1 0 1 33 33 997 0 -1 4.000 0 0 0 0 0 5
+ 4713 10157 4713 8617 5677 8617 5677 10157 4713 10157
+2 1 0 1 33 33 995 0 -1 4.000 0 0 0 0 0 5
+ 5177 10157 5177 8617 5677 8617 5677 10157 5177 10157
+2 1 0 1 33 33 994 0 -1 4.000 0 0 0 0 0 5
+ 5269 10157 5269 8617 5677 8617 5677 10157 5269 10157
+2 1 0 0 32 32 991 0 20 4.000 0 0 0 0 0 4
+ 2325 9277 2325 8345 2817 8345 2817 9277
+2 1 0 1 33 33 990 0 -1 4.000 0 0 0 0 0 5
+ 2321 9281 2321 8341 2821 8341 2821 9281 2321 9281
+2 1 0 1 33 33 988 0 -1 4.000 0 0 0 0 0 5
+ 2585 9281 2585 8341 2821 8341 2821 9281 2585 9281
+2 1 0 1 33 33 987 0 -1 4.000 0 0 0 0 0 5
+ 2677 9281 2677 8341 2821 8341 2821 9281 2677 9281
+2 1 0 0 32 32 986 0 20 4.000 0 0 0 0 0 4
+ 925 9721 925 8285 1657 8285 1657 9721
+2 1 0 1 33 33 985 0 -1 4.000 0 0 0 0 0 5
+ 921 9725 921 8281 1661 8281 1661 9725 921 9725
+2 1 0 1 33 33 983 0 -1 4.000 0 0 0 0 0 5
+ 1185 9725 1185 8281 1661 8281 1661 9725 1185 9725
+2 1 0 1 33 33 982 0 -1 4.000 0 0 0 0 0 5
+ 1277 9725 1277 8281 1661 8281 1661 9725 1277 9725
+2 1 0 0 32 32 980 0 20 4.000 0 0 0 0 0 4
+ 925 8061 925 6617 1657 6617 1657 8061
+2 1 0 1 33 33 979 0 -1 4.000 0 0 0 0 0 5
+ 921 8065 921 6613 1661 6613 1661 8065 921 8065
+2 1 0 1 33 33 977 0 -1 4.000 0 0 0 0 0 5
+ 1185 8065 1185 6613 1661 6613 1661 8065 1185 8065
+2 1 0 1 33 33 976 0 -1 4.000 0 0 0 0 0 5
+ 1277 8065 1277 6613 1661 6613 1661 8065 1277 8065
+2 1 0 0 32 32 974 0 20 4.000 0 0 0 0 0 4
+ 169 6461 169 4889 1901 4889 1901 6461
+2 1 0 1 33 33 973 0 -1 4.000 0 0 0 0 0 5
+ 165 6465 165 4885 1905 4885 1905 6465 165 6465
+2 1 0 1 33 33 971 0 -1 4.000 0 0 0 0 0 5
+ 429 6465 429 4885 1905 4885 1905 6465 429 6465
+2 1 0 1 33 33 970 0 -1 4.000 0 0 0 0 0 5
+ 521 6465 521 4885 1905 4885 1905 6465 521 6465
+2 1 0 0 32 32 963 0 20 4.000 0 0 0 0 0 4
+ 2325 8089 2325 6845 2817 6845 2817 8089
+2 1 0 1 33 33 962 0 -1 4.000 0 0 0 0 0 5
+ 2321 8093 2321 6841 2821 6841 2821 8093 2321 8093
+2 1 0 1 33 33 960 0 -1 4.000 0 0 0 0 0 5
+ 2585 8093 2585 6841 2821 6841 2821 8093 2585 8093
+2 1 0 1 33 33 959 0 -1 4.000 0 0 0 0 0 5
+ 2677 8093 2677 6841 2821 6841 2821 8093 2677 8093
+2 1 0 1 33 33 958 0 -1 4.000 0 0 0 0 0 2
+ 1953 7605 2321 7605
+2 1 0 1 33 33 957 0 -1 4.000 0 0 0 0 0 2
+ 1953 9229 1953 7329
+2 1 0 0 7 7 956 0 20 4.000 0 0 0 0 0 4
+ 2321 7605 2081 7517 2081 7693 2321 7605
+2 1 0 1 33 33 955 0 -1 4.000 0 0 0 0 0 4
+ 2321 7605 2081 7517 2081 7693 2321 7605
+2 1 0 1 33 33 954 0 -1 4.000 0 0 0 0 0 2
+ 1665 9229 1953 9229
+2 1 0 0 32 32 953 0 20 4.000 0 0 0 0 0 4
+ 5273 8045 5273 6505 5757 6505 5757 8045
+2 1 0 1 33 33 952 0 -1 4.000 0 0 0 0 0 5
+ 5269 8049 5269 6501 5761 6501 5761 8049 5269 8049
+2 1 0 1 33 33 950 0 -1 4.000 0 0 0 0 0 5
+ 5533 8049 5533 6501 5761 6501 5761 8049 5533 8049
+2 1 0 1 33 33 949 0 -1 4.000 0 0 0 0 0 5
+ 5625 8049 5625 6501 5761 6501 5761 8049 5625 8049
+2 1 1 1 7 7 948 0 -1 4.000 0 0 0 0 0 2
+ 5397 8053 5313 8613
+2 1 1 1 0 0 947 0 -1 4.000 0 0 0 0 0 2
+ 5397 8053 5313 8613
+2 1 0 0 7 7 946 0 20 4.000 0 0 0 0 0 4
+ 5313 8613 5261 8365 5437 8389 5313 8613
+2 1 0 1 33 33 945 0 -1 4.000 0 0 0 0 0 4
+ 5313 8613 5261 8365 5437 8389 5313 8613
+2 1 0 0 32 32 944 0 20 4.000 0 0 0 0 0 4
+ 4565 8065 4565 6485 5057 6485 5057 8065
+2 1 0 1 33 33 943 0 -1 4.000 0 0 0 0 0 5
+ 4561 8069 4561 6481 5061 6481 5061 8069 4561 8069
+2 1 0 1 33 33 941 0 -1 4.000 0 0 0 0 0 5
+ 4825 8069 4825 6481 5061 6481 5061 8069 4825 8069
+2 1 0 1 33 33 940 0 -1 4.000 0 0 0 0 0 5
+ 4917 8069 4917 6481 5061 6481 5061 8069 4917 8069
+2 1 1 1 7 7 939 0 -1 4.000 0 0 0 0 0 2
+ 4957 8073 5053 8613
+2 1 1 1 0 0 938 0 -1 4.000 0 0 0 0 0 2
+ 4957 8073 5053 8613
+2 1 0 0 7 7 937 0 20 4.000 0 0 0 0 0 4
+ 5053 8613 5097 8361 4921 8393 5053 8613
+2 1 0 1 33 33 936 0 -1 4.000 0 0 0 0 0 4
+ 5053 8613 5097 8361 4921 8393 5053 8613
+2 1 0 0 32 32 935 0 20 4.000 0 0 0 0 0 4
+ 4401 5873 4401 4325 5733 4325 5733 5873
+2 1 0 1 33 33 934 0 -1 4.000 0 0 0 0 0 5
+ 4397 5877 4397 4321 5737 4321 5737 5877 4397 5877
+2 1 0 1 33 33 932 0 -1 4.000 0 0 0 0 0 5
+ 4661 5877 4661 4321 5737 4321 5737 5877 4661 5877
+2 1 0 1 33 33 931 0 -1 4.000 0 0 0 0 0 5
+ 5129 5877 5129 4321 5737 4321 5737 5877 5129 5877
+2 1 0 1 33 33 926 0 -1 4.000 0 0 0 0 0 2
+ 5289 6189 5229 5881
+2 1 0 0 7 7 925 0 20 4.000 0 0 0 0 0 5
+ 5229 5881 5309 5977 5269 6093 5189 6001 5229 5881
+2 1 0 1 33 33 924 0 -1 4.000 0 0 0 0 0 5
+ 5229 5881 5309 5977 5269 6093 5189 6001 5229 5881
+2 1 0 1 33 33 923 0 -1 4.000 0 0 0 0 0 2
+ 5289 6189 5353 6497
+2 1 0 0 7 7 922 0 20 4.000 0 0 0 0 0 4
+ 5465 6453 5465 6389 5653 6389 5653 6453
+2 1 0 0 7 7 920 0 20 4.000 0 0 0 0 0 4
+ 5465 6453 5465 6389 5653 6389 5653 6453
+2 1 0 1 33 33 918 0 -1 4.000 0 0 0 0 0 2
+ 4941 6181 4977 5881
+2 1 0 0 7 7 917 0 20 4.000 0 0 0 0 0 5
+ 4977 5881 4905 5981 4953 6097 5025 5997 4977 5881
+2 1 0 1 33 33 916 0 -1 4.000 0 0 0 0 0 5
+ 4977 5881 4905 5981 4953 6097 5025 5997 4977 5881
+2 1 0 1 33 33 915 0 -1 4.000 0 0 0 0 0 2
+ 4941 6181 4905 6477
+2 1 0 0 7 7 914 0 20 4.000 0 0 0 0 0 4
+ 4605 6449 4605 6385 4793 6385 4793 6449
+2 1 0 0 7 7 912 0 20 4.000 0 0 0 0 0 4
+ 4605 6449 4605 6385 4793 6385 4793 6449
+2 1 0 0 32 32 910 0 20 4.000 0 0 0 0 0 4
+ 1465 3517 1465 2201 2397 2201 2397 3517
+2 1 0 1 33 33 909 0 -1 4.000 0 0 0 0 0 5
+ 1461 3521 1461 2197 2401 2197 2401 3521 1461 3521
+2 1 0 1 33 33 907 0 -1 4.000 0 0 0 0 0 5
+ 1725 3521 1725 2197 2401 2197 2401 3521 1725 3521
+2 1 0 1 33 33 906 0 -1 4.000 0 0 0 0 0 5
+ 1817 3521 1817 2197 2401 2197 2401 3521 1817 3521
+2 1 0 1 33 33 903 0 -1 4.000 0 0 0 0 0 2
+ 1501 4205 1717 3525
+2 1 0 0 7 7 902 0 20 4.000 0 0 0 0 0 5
+ 1717 3525 1629 3609 1653 3729 1741 3645 1717 3525
+2 1 0 1 33 33 901 0 -1 4.000 0 0 0 0 0 5
+ 1717 3525 1629 3609 1653 3729 1741 3645 1717 3525
+2 1 0 1 33 33 900 0 -1 4.000 0 0 0 0 0 2
+ 1501 4205 1289 4881
+2 1 0 0 7 7 899 0 20 4.000 0 0 0 0 0 4
+ 1429 4913 1429 4821 1617 4821 1617 4913
+2 1 0 0 7 7 897 0 20 4.000 0 0 0 0 0 4
+ 1429 4913 1429 4821 1617 4821 1617 4913
+2 1 0 1 33 33 895 0 -1 4.000 0 0 0 0 0 2
+ 3397 3913 2405 3201
+2 1 0 0 7 7 894 0 20 4.000 0 0 0 0 0 5
+ 2405 3201 2529 3217 2581 3325 2457 3313 2405 3201
+2 1 0 1 33 33 893 0 -1 4.000 0 0 0 0 0 5
+ 2405 3201 2529 3217 2581 3325 2457 3313 2405 3201
+2 1 0 1 33 33 892 0 -1 4.000 0 0 0 0 0 2
+ 3397 3913 4393 4621
+2 1 0 0 7 7 891 0 20 4.000 0 0 0 0 0 4
+ 4321 4405 4321 4341 4509 4341 4509 4405
+2 1 0 0 7 7 889 0 20 4.000 0 0 0 0 0 4
+ 4321 4405 4321 4341 4509 4341 4509 4405
+2 1 0 0 32 32 887 0 20 4.000 0 0 0 0 0 4
+ 3385 8813 3385 7529 4317 7529 4317 8813
+2 1 0 1 33 33 886 0 -1 4.000 0 0 0 0 0 5
+ 3381 8817 3381 7525 4321 7525 4321 8817 3381 8817
+2 1 0 1 33 33 884 0 -1 4.000 0 0 0 0 0 5
+ 3645 8817 3645 7525 4321 7525 4321 8817 3645 8817
+2 1 0 1 33 33 883 0 -1 4.000 0 0 0 0 0 5
+ 3737 8817 3737 7525 4321 7525 4321 8817 3737 8817
+2 1 0 1 33 33 880 0 -1 4.000 0 0 0 0 0 2
+ 2977 8181 3381 8181
+2 1 0 1 33 33 879 0 -1 4.000 0 0 0 0 0 2
+ 2977 8805 2977 7517
+2 1 0 0 7 7 878 0 20 4.000 0 0 0 0 0 4
+ 3381 8181 3141 8093 3141 8269 3381 8181
+2 1 0 1 33 33 877 0 -1 4.000 0 0 0 0 0 4
+ 3381 8181 3141 8093 3141 8269 3381 8181
+2 1 0 1 33 33 876 0 -1 4.000 0 0 0 0 0 2
+ 4429 6701 4105 7521
+2 1 0 1 33 33 875 0 -1 4.000 0 0 0 0 0 2
+ 4429 6701 4753 5881
+2 1 0 0 32 32 874 0 20 4.000 0 0 0 0 0 4
+ 2261 6321 2261 4773 3393 4773 3393 6321
+2 1 0 1 33 33 873 0 -1 4.000 0 0 0 0 0 5
+ 2257 6325 2257 4769 3397 4769 3397 6325 2257 6325
+2 1 0 1 33 33 871 0 -1 4.000 0 0 0 0 0 5
+ 2521 6325 2521 4769 3397 4769 3397 6325 2521 6325
+2 1 0 1 33 33 870 0 -1 4.000 0 0 0 0 0 5
+ 2801 6325 2801 4769 3397 4769 3397 6325 2801 6325
+2 1 0 1 33 33 866 0 -1 4.000 0 0 0 0 0 2
+ 2357 4145 2153 3525
+2 1 0 0 7 7 865 0 20 4.000 0 0 0 0 0 5
+ 2153 3525 2245 3609 2221 3729 2129 3645 2153 3525
+2 1 0 1 33 33 864 0 -1 4.000 0 0 0 0 0 5
+ 2153 3525 2245 3609 2221 3729 2129 3645 2153 3525
+2 1 0 1 33 33 863 0 -1 4.000 0 0 0 0 0 2
+ 2357 4145 2565 4765
+2 1 0 0 7 7 862 0 20 4.000 0 0 0 0 0 4
+ 2657 4665 2657 4601 2845 4601 2845 4665
+2 1 0 0 7 7 860 0 20 4.000 0 0 0 0 0 4
+ 2657 4665 2657 4601 2845 4601 2845 4665
+2 1 0 1 33 33 858 0 -1 4.000 0 0 0 0 0 2
+ 3365 6925 3593 7521
+2 1 0 1 33 33 857 0 -1 4.000 0 0 0 0 0 2
+ 3365 6925 3129 6329
+2 1 0 1 33 33 856 0 -1 4.000 0 0 0 0 0 2
+ 2825 8805 2977 8805
+2 1 0 1 33 33 855 0 -1 4.000 0 0 0 0 0 2
+ 2825 7517 2977 7517
+2 1 0 1 33 33 854 0 -1 4.000 0 0 0 0 0 2
+ 1665 7329 1953 7329
+2 1 0 0 32 32 853 0 20 4.000 0 0 0 0 0 4
+ 3413 3533 3413 2313 3905 2313 3905 3533
+2 1 0 1 33 33 852 0 -1 4.000 0 0 0 0 0 5
+ 3409 3537 3409 2309 3909 2309 3909 3537 3409 3537
+2 1 0 1 33 33 850 0 -1 4.000 0 0 0 0 0 5
+ 3673 3537 3673 2309 3909 2309 3909 3537 3673 3537
+2 1 0 1 33 33 849 0 -1 4.000 0 0 0 0 0 5
+ 3765 3537 3765 2309 3909 2309 3909 3537 3765 3537
+2 1 1 1 7 7 848 0 -1 4.000 0 0 0 0 0 2
+ 4561 4317 3913 3313
+2 1 1 1 0 0 847 0 -1 4.000 0 0 0 0 0 2
+ 4561 4317 3913 3313
+2 1 0 1 0 0 846 0 -1 4.000 0 0 0 0 0 2
+ 3913 3313 4045 3401
+2 1 0 1 0 0 845 0 -1 4.000 0 0 0 0 0 2
+ 3913 3313 3941 3465
+2 1 0 0 32 32 844 0 20 4.000 0 0 0 0 0 4
+ 4665 3685 4665 2161 5597 2161 5597 3685
+2 1 0 1 33 33 843 0 -1 4.000 0 0 0 0 0 5
+ 4661 3689 4661 2157 5601 2157 5601 3689 4661 3689
+2 1 0 1 33 33 841 0 -1 4.000 0 0 0 0 0 5
+ 4925 3689 4925 2157 5601 2157 5601 3689 4925 3689
+2 1 0 1 33 33 840 0 -1 4.000 0 0 0 0 0 5
+ 5393 3689 5393 2157 5601 2157 5601 3689 5393 3689
+2 1 0 1 33 33 837 0 -1 4.000 0 0 0 0 0 2
+ 4285 2921 3913 2921
+2 1 0 0 7 7 836 0 20 4.000 0 0 0 0 0 5
+ 3913 2921 4021 2861 4129 2921 4021 2981 3913 2921
+2 1 0 1 33 33 835 0 -1 4.000 0 0 0 0 0 5
+ 3913 2921 4021 2861 4129 2921 4021 2981 3913 2921
+2 1 0 1 33 33 834 0 -1 4.000 0 0 0 0 0 2
+ 4285 2921 4657 2921
+2 1 0 0 7 7 833 0 20 4.000 0 0 0 0 0 4
+ 4525 2737 4525 2673 4713 2673 4713 2737
+2 1 0 0 7 7 831 0 20 4.000 0 0 0 0 0 4
+ 4525 2737 4525 2673 4713 2673 4713 2737
+4 0 0 996 -1 16 10 1.5708 4 150 1305 5113 10073 InstructionTargeter\001
+4 0 0 993 -1 16 10 1.5708 4 150 1035 5541 9921 updateTarget()\001
+4 0 0 992 -1 16 10 1.5708 4 120 975 4913 9897 <<Interface>>\001
+4 0 0 989 -1 16 10 1.5708 4 150 720 2521 9189 BasicType\001
+4 0 0 984 -1 16 10 1.5708 4 150 795 1121 9425 ObjectType\001
+4 0 0 981 -1 16 10 1.5708 4 150 1095 1549 9489 getClassName()\001
+4 0 0 978 -1 16 10 1.5708 4 135 705 1121 7713 ArrayType\001
+4 0 0 975 -1 16 10 1.5708 4 150 1110 1549 7829 getDimensions()\001
+4 0 0 972 -1 16 10 1.5708 4 120 1245 365 6325 ConstantPoolGen\001
+4 0 0 969 -1 16 10 1.5708 4 150 1260 793 6229 getConstantPool()\001
+4 0 0 968 -1 16 10 1.5708 4 150 735 981 6229 addClass()\001
+4 0 0 967 -1 16 10 1.5708 4 150 765 1169 6229 addString()\001
+4 0 0 966 -1 16 10 1.5708 4 150 930 1357 6229 addFieldRef()\001
+4 0 0 965 -1 16 10 1.5708 4 150 1125 1545 6229 addMethodRef()\001
+4 0 0 964 -1 16 10 1.5708 4 150 855 1733 6229 addInteger()\001
+4 0 0 961 -1 16 10 1.5708 4 150 1065 2521 8033 ReferenceType\001
+4 0 0 951 -1 16 10 1.5708 4 120 1245 5469 7933 LocalVariableGen\001
+4 0 0 942 -1 16 10 1.5708 4 150 1365 4761 7981 CodeExceptionGen\001
+4 0 0 933 -1 16 10 1.5708 4 120 825 4597 5525 MethodGen\001
+4 0 0 930 -1 16 10 1.5708 4 150 1200 4837 5641 access_flags : int\001
+4 0 0 929 -1 16 10 1.5708 4 150 1065 5025 5641 max_locals : int\001
+4 0 0 928 -1 16 10 1.5708 4 150 840 5401 5641 getMethod()\001
+4 0 0 927 -1 16 10 1.5708 4 150 1050 5589 5641 addException()\001
+4 0 0 921 -1 16 10 1.5708 4 60 60 5617 6453 *\001
+4 0 0 919 -1 16 10 1.5708 4 60 60 5617 6453 *\001
+4 0 0 913 -1 16 10 1.5708 4 60 60 4757 6449 *\001
+4 0 0 911 -1 16 10 1.5708 4 60 60 4757 6449 *\001
+4 0 0 908 -1 16 10 1.5708 4 120 675 1661 3221 ClassGen\001
+4 0 0 905 -1 16 10 1.5708 4 150 1020 2089 3285 getJavaClass()\001
+4 0 0 904 -1 16 10 1.5708 4 150 975 2277 3285 addInterface()\001
+4 0 0 898 -1 16 10 1.5708 4 105 90 1581 4913 1\001
+4 0 0 896 -1 16 10 1.5708 4 105 90 1581 4913 1\001
+4 0 0 890 -1 16 10 1.5708 4 60 60 4473 4405 *\001
+4 0 0 888 -1 16 10 1.5708 4 60 60 4473 4405 *\001
+4 0 0 885 -1 16 10 1.5708 4 135 345 3581 8353 Type\001
+4 0 0 882 -1 16 10 1.5708 4 135 660 4009 8581 getType()\001
+4 0 0 881 -1 16 10 1.5708 4 150 990 4197 8581 getSignature()\001
+4 0 0 872 -1 16 10 1.5708 4 120 630 2457 5881 FieldGen\001
+4 0 0 869 -1 16 10 1.5708 4 150 1200 2697 6089 access_flags : int\001
+4 0 0 868 -1 16 10 1.5708 4 150 645 3073 6089 getField()\001
+4 0 0 867 -1 16 10 1.5708 4 150 915 3261 6089 setInitValue()\001
+4 0 0 861 -1 16 10 1.5708 4 60 60 2809 4665 *\001
+4 0 0 859 -1 16 10 1.5708 4 60 60 2809 4665 *\001
+4 0 0 851 -1 16 10 1.5708 4 120 960 3609 3421 InstructionList\001
+4 0 0 842 -1 16 10 1.5708 4 120 720 4861 3297 Instruction\001
+4 0 0 839 -1 16 10 1.5708 4 150 660 5101 3453 tag : byte\001
+4 0 0 838 -1 16 10 1.5708 4 150 1215 5289 3453 length, offset : int\001
+4 0 0 832 -1 16 10 1.5708 4 60 60 4677 2737 *\001
+4 0 0 830 -1 16 10 1.5708 4 60 60 4677 2737 *\001
+-6
diff --git a/docs/eps/classloader.eps b/docs/eps/classloader.eps
new file mode 100644
index 00000000..4c3a3f3f
--- /dev/null
+++ b/docs/eps/classloader.eps
@@ -0,0 +1,160 @@
+%!PS-Adobe-2.0 EPSF-2.0
+%%Title: classloader.eps
+%%Creator: fig2dev Version 3.2 Patchlevel 0-beta3
+%%CreationDate: Thu Mar 18 16:45:56 1999
+%%For: dahm@gromit (Markus Dahm)
+%%Orientation: Portrait
+%%BoundingBox: 0 0 683 144
+%%Pages: 0
+%%BeginSetup
+%%EndSetup
+%%Magnification: 1.0000
+%%EndComments
+/$F2psDict 200 dict def
+$F2psDict begin
+$F2psDict /mtrx matrix put
+/col-1 {0 setgray} bind def
+/col0 {0.000 0.000 0.000 srgb} bind def
+/col1 {0.000 0.000 1.000 srgb} bind def
+/col2 {0.000 1.000 0.000 srgb} bind def
+/col3 {0.000 1.000 1.000 srgb} bind def
+/col4 {1.000 0.000 0.000 srgb} bind def
+/col5 {1.000 0.000 1.000 srgb} bind def
+/col6 {1.000 1.000 0.000 srgb} bind def
+/col7 {1.000 1.000 1.000 srgb} bind def
+/col8 {0.000 0.000 0.560 srgb} bind def
+/col9 {0.000 0.000 0.690 srgb} bind def
+/col10 {0.000 0.000 0.820 srgb} bind def
+/col11 {0.530 0.810 1.000 srgb} bind def
+/col12 {0.000 0.560 0.000 srgb} bind def
+/col13 {0.000 0.690 0.000 srgb} bind def
+/col14 {0.000 0.820 0.000 srgb} bind def
+/col15 {0.000 0.560 0.560 srgb} bind def
+/col16 {0.000 0.690 0.690 srgb} bind def
+/col17 {0.000 0.820 0.820 srgb} bind def
+/col18 {0.560 0.000 0.000 srgb} bind def
+/col19 {0.690 0.000 0.000 srgb} bind def
+/col20 {0.820 0.000 0.000 srgb} bind def
+/col21 {0.560 0.000 0.560 srgb} bind def
+/col22 {0.690 0.000 0.690 srgb} bind def
+/col23 {0.820 0.000 0.820 srgb} bind def
+/col24 {0.500 0.190 0.000 srgb} bind def
+/col25 {0.630 0.250 0.000 srgb} bind def
+/col26 {0.750 0.380 0.000 srgb} bind def
+/col27 {1.000 0.500 0.500 srgb} bind def
+/col28 {1.000 0.630 0.630 srgb} bind def
+/col29 {1.000 0.750 0.750 srgb} bind def
+/col30 {1.000 0.880 0.880 srgb} bind def
+/col31 {1.000 0.840 0.000 srgb} bind def
+
+end
+save
+-55.0 171.0 translate
+1 -1 scale
+
+/cp {closepath} bind def
+/ef {eofill} bind def
+/gr {grestore} bind def
+/gs {gsave} bind def
+/sa {save} bind def
+/rs {restore} bind def
+/l {lineto} bind def
+/m {moveto} bind def
+/rm {rmoveto} bind def
+/n {newpath} bind def
+/s {stroke} bind def
+/sh {show} bind def
+/slc {setlinecap} bind def
+/slj {setlinejoin} bind def
+/slw {setlinewidth} bind def
+/srgb {setrgbcolor} bind def
+/rot {rotate} bind def
+/sc {scale} bind def
+/sd {setdash} bind def
+/ff {findfont} bind def
+/sf {setfont} bind def
+/scf {scalefont} bind def
+/sw {stringwidth} bind def
+/tr {translate} bind def
+/tnt {dup dup currentrgbcolor
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
+ bind def
+/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
+ 4 -2 roll mul srgb} bind def
+/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
+/$F2psEnd {$F2psEnteredState restore end} def
+%%EndProlog
+
+$F2psBegin
+10 setmiterlimit
+n -1000 3712 m -1000 -1000 l 12712 -1000 l 12712 3712 l cp clip
+ 0.06299 0.06299 sc
+% Polyline
+7.500 slw
+n 1005 450 m 900 450 900 1020 105 arcto 4 {pop} repeat
+ 900 1125 3045 1125 105 arcto 4 {pop} repeat
+ 3150 1125 3150 555 105 arcto 4 {pop} repeat
+ 3150 450 1005 450 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Helvetica ff 210.00 scf sf
+1350 900 m
+gs 1 -1 sc (Java class file) col0 sh gr
+% Polyline
+n 3600 450 m 5850 450 l 5850 1125 l 3600 1125 l cp gs col0 s gr
+/Helvetica ff 210.00 scf sf
+4140 855 m
+gs 1 -1 sc (Class loader) col0 sh gr
+% Polyline
+n 6750 450 m 9000 450 l 9000 1125 l 6750 1125 l cp gs col0 s gr
+/Helvetica ff 210.00 scf sf
+7020 855 m
+gs 1 -1 sc (Byte code verifier) col0 sh gr
+% Polyline
+n 9450 450 m 11700 450 l 11700 1125 l 9450 1125 l cp gs col0 s gr
+/Helvetica ff 210.00 scf sf
+9900 900 m
+gs 1 -1 sc (Interpreter/JIT) col0 sh gr
+% Polyline
+n 4950 1575 m 7875 1575 l 7875 2700 l 4950 2700 l cp gs col0 s gr
+/Helvetica ff 210.00 scf sf
+5175 2475 m
+gs 1 -1 sc (Byte code transformations) col0 sh gr
+/Courier-Bold ff 210.00 scf sf
+5850 2025 m
+gs 1 -1 sc (JavaClass) col0 sh gr
+% Polyline
+gs clippath
+3453 735 m 3573 765 l 3453 795 l 3615 795 l 3615 735 l cp
+clip
+n 3150 765 m 3600 765 l gs col0 s gr gr
+
+% arrowhead
+n 3453 735 m 3573 765 l 3453 795 l 3453 765 l 3453 735 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+9303 735 m 9423 765 l 9303 795 l 9465 795 l 9465 735 l cp
+clip
+n 9000 765 m 9450 765 l gs col0 s gr gr
+
+% arrowhead
+n 9303 735 m 9423 765 l 9303 795 l 9303 765 l 9303 735 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+6105 1428 m 6075 1548 l 6045 1428 l 6045 1590 l 6105 1590 l cp
+clip
+n 5850 765 m 6075 765 l 6075 1575 l gs col0 s gr gr
+
+% arrowhead
+n 6105 1428 m 6075 1548 l 6045 1428 l 6075 1428 l 6105 1428 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+6603 735 m 6723 765 l 6603 795 l 6765 795 l 6765 735 l cp
+clip
+n 6525 1575 m 6525 765 l 6750 765 l gs col0 s gr gr
+
+% arrowhead
+n 6603 735 m 6723 765 l 6603 795 l 6603 765 l 6603 735 l cp gs 0.00 setgray ef gr col0 s
+$F2psEnd
+rs
diff --git a/docs/eps/classloader.fig b/docs/eps/classloader.fig
new file mode 100644
index 00000000..729d7749
--- /dev/null
+++ b/docs/eps/classloader.fig
@@ -0,0 +1,47 @@
+#FIG 3.2
+Portrait
+Center
+Metric
+A4
+100.00
+Single
+-2
+1200 2
+6 900 450 3150 1125
+2 4 0 1 0 7 100 0 -1 0.000 0 0 7 0 0 5
+ 3150 1125 3150 450 900 450 900 1125 3150 1125
+4 0 0 100 0 16 14 0.0000 4 165 1380 1350 900 Java class file\001
+-6
+6 3600 450 5850 1125
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 3600 450 5850 450 5850 1125 3600 1125 3600 450
+4 0 0 100 0 16 14 0.0000 4 165 1215 4140 855 Class loader\001
+-6
+6 6750 450 9000 1125
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 6750 450 9000 450 9000 1125 6750 1125 6750 450
+4 0 0 100 0 16 14 0.0000 4 210 1665 7020 855 Byte code verifier\001
+-6
+6 9450 450 11700 1125
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 9450 450 11700 450 11700 1125 9450 1125 9450 450
+4 0 0 100 0 16 14 0.0000 4 210 1410 9900 900 Interpreter/JIT\001
+-6
+6 4950 1575 7875 2700
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 4950 1575 7875 1575 7875 2700 4950 2700 4950 1575
+4 0 0 100 0 16 14 0.0000 4 210 2505 5175 2475 Byte code transformations\001
+4 0 0 100 0 14 14 0.0000 4 150 1215 5850 2025 JavaClass\001
+-6
+2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 1 0 2
+ 1 1 1.00 60.00 120.00
+ 3150 765 3600 765
+2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 1 0 2
+ 1 1 1.00 60.00 120.00
+ 9000 765 9450 765
+2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 1 0 3
+ 1 1 1.00 60.00 120.00
+ 5850 765 6075 765 6075 1575
+2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 1 0 3
+ 1 1 1.00 60.00 120.00
+ 6525 1575 6525 765 6750 765
diff --git a/docs/eps/constantpool.eps b/docs/eps/constantpool.eps
new file mode 100644
index 00000000..4d3d5bd7
--- /dev/null
+++ b/docs/eps/constantpool.eps
@@ -0,0 +1,399 @@
+%!PS-Adobe-3.0 EPSF-3.0
+%%Title: Rose Diagram(s)
+%%Creator: AdobePS5.dll Version 5.0
+%%CreationDate: 7/7/1999 17:45:21
+%%Pages: 1
+%%Orientation: Portrait
+%%PageOrder: Ascend
+%%DocumentNeededResources: (atend)
+%%DocumentSuppliedResources: (atend)
+%%DocumentData: Clean7Bit
+%%TargetDevice: (HP LaserJet 5Si) (2014.108) 1
+%%LanguageLevel: 2
+%%BoundingBox: 13 12 383 830
+%%EndComments
+%%BeginProcSet: epsffit 1 0
+gsave
+1677.488 -356.303 translate
+90 rotate
+2.035 2.035 scale
+%%EndProcSet
+
+
+%%BeginDefaults
+%%PageBoundingBox: 13 12 582 830
+%%EndDefaults
+
+%%BeginProlog
+%%BeginResource: file Pscript_WinNT_ErrorHandler 5.0 0
+/currentpacking where{pop/oldpack currentpacking def/setpacking where{pop false
+setpacking}if}if/$brkpage 64 dict def $brkpage begin/prnt{dup type/stringtype
+ne{=string cvs}if dup length 6 mul/tx exch def/ty 10 def currentpoint/toy exch
+def/tox exch def 1 setgray newpath tox toy 2 sub moveto 0 ty rlineto tx 0
+rlineto 0 ty neg rlineto closepath fill tox toy moveto 0 setgray show}bind def
+/nl{currentpoint exch pop lmargin exch moveto 0 -10 rmoveto}def/=={/cp 0 def
+typeprint nl}def/typeprint{dup type exec}readonly def/lmargin 72 def/rmargin 72
+def/tprint{dup length cp add rmargin gt{nl/cp 0 def}if dup length cp add/cp
+exch def prnt}readonly def/cvsprint{=string cvs tprint( )tprint}readonly def
+/integertype{cvsprint}readonly def/realtype{cvsprint}readonly def/booleantype
+{cvsprint}readonly def/operatortype{(--)tprint =string cvs tprint(-- )tprint}
+readonly def/marktype{pop(-mark- )tprint}readonly def/dicttype{pop
+(-dictionary- )tprint}readonly def/nulltype{pop(-null- )tprint}readonly def
+/filetype{pop(-filestream- )tprint}readonly def/savetype{pop(-savelevel- )
+tprint}readonly def/fonttype{pop(-fontid- )tprint}readonly def/nametype{dup
+xcheck not{(/)tprint}if cvsprint}readonly def/stringtype{dup rcheck{(\()tprint
+tprint(\))tprint}{pop(-string- )tprint}ifelse}readonly def/arraytype{dup rcheck
+{dup xcheck{({)tprint{typeprint}forall(})tprint}{([)tprint{typeprint}forall(])
+tprint}ifelse}{pop(-array- )tprint}ifelse}readonly def/packedarraytype{dup
+rcheck{dup xcheck{({)tprint{typeprint}forall(})tprint}{([)tprint{typeprint}
+forall(])tprint}ifelse}{pop(-packedarray- )tprint}ifelse}readonly def/courier
+/Courier findfont 10 scalefont def end errordict/handleerror{systemdict begin
+$error begin $brkpage begin newerror{/newerror false store vmstatus pop pop 0
+ne{grestoreall}if showpage initgraphics courier setfont lmargin 720 moveto
+(ERROR: )prnt errorname prnt nl(OFFENDING COMMAND: )prnt/command load prnt
+$error/ostack known{nl nl(STACK:)prnt nl nl $error/ostack get aload length{==}
+repeat}if systemdict/showpage get exec(%%[ Error: )print errorname =print
+(; OffendingCommand: )print/command load =print( ]%%)= flush}if end end end}dup
+0 systemdict put dup 4 $brkpage put bind readonly put/currentpacking where{pop
+/setpacking where{pop oldpack setpacking}if}if
+%%EndResource
+userdict /Pscript_WinNT_Incr 230 dict dup begin put
+%%BeginResource: file Pscript_FatalError 5.0 0
+/FatalErrorIf{{initgraphics findfont exch scalefont setfont counttomark 3 div
+cvi{moveto show}repeat showpage quit}{cleartomark}ifelse}bind def
+%%EndResource
+/VM?{vmstatus exch sub exch pop gt{[
+(This job requires more memory than is available in this printer.)100 500
+(Try one or more of the following, and then print again:)100 485
+(For the output format, choose Optimize For Portability.)115 470
+(In the Device Settings page, make sure the Available PostScript Memory is accurate.)
+115 455(Reduce the number of fonts in the document.)115 440
+(Print the document in parts.)115 425 12/Times-Roman showpage
+(%%[ PrinterError: Low Printer VM ]%%)= true FatalErrorIf}if}bind def
+%%BeginResource: file Pscript_Win_Basic 5.0 0
+/d/def load def/,/load load d/~/exch , d/?/ifelse , d/!/pop , d/`/begin , d/^
+/index , d/@/dup , d/+/translate , d/$/roll , d/U/userdict , d/M/moveto , d/-
+/rlineto , d/&/currentdict , d/:/gsave , d/;/grestore , d/F/false , d/T/true ,
+d/N/newpath , d/E/end , d/Ac/arc , d/An/arcn , d/A/ashow , d/D/awidthshow , d/C
+/closepath , d/V/div , d/O/eofill , d/L/fill , d/I/lineto , d/-c/curveto , d/-M
+/rmoveto , d/+S/scale , d/Ji/setfont , d/Lc/setlinecap , d/Lj/setlinejoin , d
+/Lw/setlinewidth , d/Lm/setmiterlimit , d/sd/setdash , d/S/show , d/LH/showpage
+, d/K/stroke , d/W/widthshow , d/R/rotate , d/P/eoclip , d/L2? false
+/languagelevel where{pop languagelevel 2 ge{pop true}if}if d L2?{/xS/xshow , d
+/yS/yshow , d/zS/xyshow , d}if/b{bind d}bind d/bd{bind d}bind d/xd{~ d}bd/ld{,
+d}bd/lw/Lw ld/lc/Lc ld/lj/Lj ld/sg/setgray ld/ADO_mxRot null d/self & d/OrgMx
+matrix currentmatrix d/reinitialize{: OrgMx setmatrix[/TextInit/GraphInit
+/UtilsInit counttomark{@ where{self eq}{F}?{cvx exec}{!}?}repeat cleartomark ;}
+b/initialize{`{/ADO_mxRot ~ d/TextInitialised? F d reinitialize E}{U
+/Pscript_Win_Data 230 dict @ ` put/ADO_mxRot ~ d/TextInitialised? F d
+reinitialize}?}b/terminate{!{& self eq{exit}{E}?}loop E}b/suspend/terminate , d
+/resume{` Pscript_Win_Data `}b/snap{transform 0.25 sub round 0.25 add ~ 0.25
+sub round 0.25 add ~ itransform}b/dsnap{dtransform round ~ round ~ idtransform}
+b<04>cvn{}d/rr{1 ^ 0 - 0 ~ - neg 0 - C}b/rp{4 2 $ M 1 ^ 0 - 0 ~ - neg 0 -}b
+/solid{[]0 sd}b/g{@ not{U/DefIf_save save put}if U/DefIf_bool 2 ^ put}b
+/DefIf_El{if U/DefIf_bool get not @{U/DefIf_save get restore}if}b/e{DefIf_El !}
+b/UDF{L2?{undefinefont}{!}?}b/UDR{L2?{undefineresource}{! !}?}b
+%%EndResource
+%%BeginResource: file Pscript_Win_Utils_L2 5.0 0
+/rf/rectfill , d/fx{1 1 dtransform @ 0 ge{1 sub 0.5}{1 add -0.5}? 3 -1 $ @ 0 ge
+{1 sub 0.5}{1 add -0.5}? 3 1 $ 4 1 $ idtransform 4 -2 $ idtransform}b/BZ{4 -2 $
+snap + +S fx rf}b/rs/rectstroke , d/rc/rectclip , d/UtilsInit{currentglobal{F
+setglobal}if}b/scol{! setcolor}b/colspA/DeviceGray d/colspABC/DeviceRGB d
+/colspRefresh{colspABC setcolorspace}b/SetColSpace{colspABC setcolorspace}b
+%%EndResource
+end
+%%EndProlog
+
+%%BeginSetup
+[ 1 0 0 1 0 0 ] false Pscript_WinNT_Incr dup /initialize get exec
+1 setlinecap 1 setlinejoin
+/mysetup [ 0.24 0 0 -0.24 13.43905 829.74047 ] def
+%%EndSetup
+
+%%Page: 1 1
+%%PageBoundingBox: 13 12 582 830
+%%EndPageComments
+%%BeginPageSetup
+/DeviceRGB dup setcolorspace /colspABC exch def mysetup concat colspRefresh
+%%EndPageSetup
+
+Pscript_WinNT_Incr begin
+%%BeginResource: file Pscript_Win_GdiObject 5.0 0
+/SavedCTM null d/CTMsave{/SavedCTM SavedCTM currentmatrix d}b/CTMrestore
+{SavedCTM setmatrix}b/mp null d/ADO_mxRot null d/GDIHMatrix null d
+/GDIHPatternDict 22 dict d GDIHPatternDict `/PatternType 1 d/PaintType 2 d/Reps
+L2?{1}{5}? d/XStep 8 Reps mul d/YStep XStep d/BBox[0 0 XStep YStep]d/TilingType
+1 d/PaintProc{` 1 Lw[]0 sd PaintData , exec E}b/FGnd null d/BGnd null d
+/HS_Horizontal{horiz}b/HS_Vertical{vert}b/HS_FDiagonal{fdiag}b/HS_BDiagonal
+{biag}b/HS_Cross{horiz vert}b/HS_DiagCross{fdiag biag}b/MaxXYStep XStep YStep
+gt{XStep}{YStep}? d/horiz{Reps{0 4 M XStep 0 - 0 8 +}repeat 0 -8 Reps mul + K}b
+/vert{Reps{4 0 M 0 YStep - 8 0 +}repeat 0 -8 Reps mul + K}b/biag{Reps{0 0 M
+MaxXYStep @ - 0 YStep neg M MaxXYStep @ - 0 8 +}repeat 0 -8 Reps mul + 0 YStep
+M 8 8 - K}b/fdiag{Reps{0 0 M MaxXYStep @ neg - 0 YStep M MaxXYStep @ neg - 0 8
++}repeat 0 -8 Reps mul + MaxXYStep @ M 8 -8 - K}b E/makehatch{4 -2 $/yOrg ~ d
+/xOrg ~ d GDIHPatternDict/PaintData 3 -1 $ put CTMsave GDIHMatrix setmatrix
+GDIHPatternDict matrix xOrg yOrg + mp CTMrestore ~ U ~ 2 ^ put}b/h0{/h0
+/HS_Horizontal makehatch}b/h1{/h1/HS_Vertical makehatch}b/h2{/h2/HS_FDiagonal
+makehatch}b/h3{/h3/HS_BDiagonal makehatch}b/h4{/h4/HS_Cross makehatch}b/h5{/h5
+/HS_DiagCross makehatch}b/GDIBWPatternDict 25 dict @ `/PatternType 1 d
+/PaintType L2?{1}{2}? d/RepsV L2?{1}{6}? d/RepsH L2?{1}{5}? d/BBox[0 0 RepsH 1]
+d/TilingType 1 d/XStep 1 d/YStep 1 d/Height 8 RepsV mul d/Width 8 d/mx[Width 0
+0 Height neg 0 Height]d/FGnd null d/BGnd null d/SetBGndFGnd L2?{{FGnd null ne
+{FGnd aload ! scol BBox aload ! 2 ^ sub ~ 3 ^ sub ~ rf}if BGnd null ne{BGnd
+aload ! scol}if}}{{}}? b/PaintProc{` SetBGndFGnd RepsH{Width Height F mx
+PaintData imagemask Width 0 +}repeat E}b E d/GDIBWPatternMx null d/pfprep{save
+8 1 $/PatternOfTheDay 8 1 $ GDIBWPatternDict `/yOrg ~ d/xOrg ~ d/PaintData ~ d
+/yExt ~ d/Width ~ d/FGnd ~ d/BGnd ~ d/Height yExt RepsV mul d/mx[Width 0 0
+Height 0 0]d E : GDIBWPatternDict ` Width Height E dsnap +S/GDIBWPatternMx
+matrix currentmatrix d ; CTMsave GDIBWPatternMx setmatrix GDIBWPatternDict @ `
+xOrg yOrg E matrix + mp CTMrestore ~ !}b/pfbf{/fEOFill ~ d pfprep hbf fEOFill
+{O}{L}? restore}b/GraphInit{GDIHMatrix null eq{/SavedCTM matrix d : ADO_mxRot
+concat 0 0 snap + : 0.48 @ GDIHPatternDict ` YStep mul ~ XStep mul ~ dsnap
+YStep V ~ XStep V ~ E +S/GDIHMatrix matrix currentmatrix readonly d ; : 0.24
+-0.24 +S GDIBWPatternDict ` Width Height E dsnap +S/GDIBWPatternMx matrix
+currentmatrix readonly d ; ;}if}b
+%%EndResource
+%%BeginResource: file Pscript_Win_GdiObject_L2 5.0 0
+/mp/makepattern , d/hbf{setpattern}b/hf{:/fEOFill ~ d ~ ! setpattern fEOFill{O}
+{L}? ;}b/pbf{: !/fEOFill ~ d GDIBWPatternDict `/yOrg ~ d/xOrg ~ d/PaintData ~ d
+/OutputBPP ~ d/Height ~ d/Width ~ d/PaintType 1 d/PatternType 1 d/TilingType 1
+d/BBox[0 0 Width Height]d/XStep Width d/YStep Height d/mx xOrg yOrg matrix + d
+20 dict @ `/ImageType 1 d/Width Width d/Height Height d/ImageMatrix mx d
+/BitsPerComponent 8 d OutputBPP 24 eq{/Decode[0 1 0 1 0 1]d}{OutputBPP 8 eq{
+/Decode[0 1]d}{/Decode[0 1 0 1 0 1 0 1]d}?}?/DataSource{PaintData}d E/ImageDict
+~ d/PaintProc{` ImageDict image E}b & mx makepattern setpattern E fEOFill{O}{L}
+? ;}b
+%%EndResource
+end reinitialize
+: N 1409 506 185 84 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol 1 Lw N 1594 505 M 1408 505 I 1408 590 I 1594 590 I C
+K
+0 0 0 1 scol Pscript_WinNT_Incr begin
+%%BeginResource: file Pscript_Text 5.0 0
+/TextInit{TextInitialised? not{/Pscript_Windows_Font & d/TextInitialised? T d
+/fM[1 0 0 1 0 0]d/mFM matrix d/iMat[1 0 0.212557 1 0 0]d}if}b/copyfont{1 ^
+length add dict `{1 ^/FID ne{d}{! !}?}forall & E}b/EncodeDict 11 dict d/bullets
+{{/bullet}repeat}b/rF{3 copyfont @ ` ~ EncodeDict ~ get/Encoding ~ 3 ^/0 eq{&
+/CharStrings known{CharStrings/Eth known not{! EncodeDict/ANSIEncodingOld get}
+if}if}if d E}b/mF{@ 7 1 $ findfont ~{@/Encoding get @ StandardEncoding eq{! T}{
+{ISOLatin1Encoding}stopped{! F}{eq}?{T}{@ ` T 32 1 127{Encoding 1 ^ get
+StandardEncoding 3 -1 $ get eq and}for E}?}?}{F}?{1 ^ ~ rF}{0 copyfont}? 6 -2 $
+{T pd_AddEm87 ~ !}{! ~ !/pd_charset @ where{~ get 128 eq{@ FDV 2 copy get @
+length array copy put pd_CoverFCRange}if}{!}?}? 2 ^ ~ definefont fM 5 4 -1 $
+put fM 4 0 put fM makefont Pscript_Windows_Font 3 1 $ put}b/sLT{: Lw -M
+currentpoint snap M 0 - 0 Lc K ;}b/xUP null d/yUP null d/uW null d/xSP null d
+/ySP null d/sW null d/sSU{N/uW ~ d/yUP ~ d/xUP ~ d}b/sU{xUP yUP uW sLT}b/sST{N
+/sW ~ d/ySP ~ d/xSP ~ d}b/sT{xSP ySP sW sLT}b/sR{: + R 0 0 M}b/sRxy{: matrix
+astore concat 0 0 M}b/eR/; , d/AddOrigFP{{&/FontInfo known{&/FontInfo get
+length 6 add}{6}? dict `/WinPitchAndFamily ~ d/WinCharSet ~ d/OrigFontType ~ d
+/OrigFontStyle ~ d/OrigFontName ~ d & E/FontInfo ~ d}{! ! ! ! !}?}b/mFS
+{makefont Pscript_Windows_Font 3 1 $ put}b/mF42D{0 copyfont `/FontName ~ d 2
+copy ~ sub 1 add dict `/.notdef 0 d 2 copy 1 ~{@ 3 ^ sub Encoding ~ get ~ d}for
+& E/CharStrings ~ d ! ! & @ E/FontName get ~ definefont}bind d/mF42{15 dict ` @
+4 1 $/FontName ~ d/FontType 0 d/FMapType 2 d/FontMatrix[1 0 0 1 0 0]d 1 ^ 254
+add 255 idiv @ array/Encoding ~ d 0 1 3 -1 $ 1 sub{@ Encoding 3 1 $ put}for
+/FDepVector Encoding length array d/CharStrings 2 dict `/.notdef 0 d & E d 0 1
+Encoding length 1 sub{@ @ 10 lt{! FontName length 1 add string}{100 lt{FontName
+length 2 add string}{FontName length 3 add string}?}? @ 0 FontName @ length
+string cvs putinterval @ 3 -1 $ @ 4 1 $ 3 string cvs FontName length ~
+putinterval cvn 1 ^ 256 mul @ 255 add 3 -1 $ 4 ^ findfont mF42D FDepVector 3 1
+$ put}for & @ E/FontName get ~ definefont ! ! ! mF}b/UmF{L2?
+{Pscript_Windows_Font ~ undef}{!}?}b/UmF42{@ findfont/FDepVector get{/FontName
+get undefinefont}forall undefinefont}b
+%%EndResource
+end reinitialize
+Pscript_WinNT_Incr begin
+%%BeginResource: file Pscript_Encoding256 5.0 0
+/CharCol256Encoding[/.notdef/breve/caron/dotaccent/dotlessi/fi/fl/fraction
+/hungarumlaut/Lslash/lslash/minus/ogonek/ring/Zcaron/zcaron/.notdef/.notdef
+/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
+/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/exclam/quotedbl/numbersign
+/dollar/percent/ampersand/quotesingle/parenleft/parenright/asterisk/plus/comma
+/hyphen/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon
+/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S
+/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/asciicircum/underscore/grave
+/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright
+/asciitilde/.notdef/.notdef/.notdef/quotesinglbase/florin/quotedblbase/ellipsis
+/dagger/daggerdbl/circumflex/perthousand/Scaron/guilsinglleft/OE/.notdef
+/.notdef/.notdef/.notdef/quoteleft/quoteright/quotedblleft/quotedblright/bullet
+/endash/emdash/tilde/trademark/scaron/guilsinglright/oe/.notdef/.notdef
+/Ydieresis/.notdef/exclamdown/cent/sterling/currency/yen/brokenbar/section
+/dieresis/copyright/ordfeminine/guillemotleft/logicalnot/.notdef/registered
+/macron/degree/plusminus/twosuperior/threesuperior/acute/mu/paragraph
+/periodcentered/cedilla/onesuperior/ordmasculine/guillemotright/onequarter
+/onehalf/threequarters/questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis
+/Aring/AE/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute
+/Icircumflex/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
+/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls
+/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla/egrave/eacute
+/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis/eth/ntilde/ograve
+/oacute/ocircumflex/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex
+/udieresis/yacute/thorn/ydieresis]def EncodeDict/256 CharCol256Encoding put
+%%EndResource
+end reinitialize
+
+%%IncludeResource: font Helvetica
+F /F0 0 /256 T /Helvetica mF
+/F0S18 F0 [24.66 0 0 -24.66 0 0 ] mFS
+F0S18 Ji
+1433 537 M (ConstantCP)[18 14 14 13 7 14 14 7 18 0]xS
+0.602 0 0.199 1 scol N 1594 551 M 1408 551 I 1408 590 I 1594 590 I C
+K
+N 1594 565 M 1408 565 I 1408 590 I 1594 590 I C
+K
+: N 1292 714 375 85 rp C
+1 1 0.801 1 scol L ; N 1667 713 M 1291 713 I 1291 799 I 1667 799 I C
+K
+0 0 0 1 scol 1324 745 M (ConstantInterfaceMethodref)[18 14 14 13 7 14 14 7 6 14 7 14 8 7 14 13 14 21 14 7 14 14 14 8 14 0]xS
+0.602 0 0.199 1 scol N 1667 759 M 1291 759 I 1291 799 I 1667 799 I C
+K
+N 1667 773 M 1291 773 I 1291 799 I 1667 799 I C
+K
+: N 1710 714 262 85 rp C
+1 1 0.801 1 scol L ; N 1972 713 M 1709 713 I 1709 799 I 1972 799 I C
+K
+0 0 0 1 scol 1734 745 M (ConstantMethodref)[18 14 14 13 7 14 14 7 21 14 7 14 14 14 8 14 0]xS
+0.602 0 0.199 1 scol N 1972 759 M 1709 759 I 1709 799 I 1972 799 I C
+K
+N 1972 773 M 1709 773 I 1709 799 I 1972 799 I C
+K
+: N 1011 714 235 85 rp C
+1 1 0.801 1 scol L ; N 1246 713 M 1010 713 I 1010 799 I 1246 799 I C
+K
+0 0 0 1 scol 1036 745 M (ConstantFieldref)[18 14 14 13 7 14 14 7 15 6 14 6 14 8 14 0]xS
+0.602 0 0.199 1 scol N 1246 759 M 1010 759 I 1010 799 I 1246 799 I C
+K
+N 1246 773 M 1010 773 I 1010 799 I 1246 799 I C
+K
+: N 1516 58 213 125 rp C
+1 1 0.801 1 scol L ; N 1729 57 M 1515 57 I 1515 183 I 1729 183 I C
+K
+0 0 0 1 scol 1546 89 M (ConstantPool)[18 14 14 13 7 14 14 7 17 14 14 0]xS
+0.602 0 0.199 1 scol N 1729 103 M 1515 103 I 1515 183 I 1729 183 I C
+K
+N 1729 116 M 1515 116 I 1515 183 I 1729 183 I C
+K
+0 0 0 1 scol 1555 158 M (getConstant\(\))[14 14 7 18 14 14 13 7 14 14 7 8 0]xS
+: N 1550 265 144 84 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 1694 264 M 1549 264 I 1549 349 I 1694 349 I C
+K
+0 0 0 1 scol 1571 296 M (Constant)[18 14 14 13 7 14 14 0]xS
+0.602 0 0.199 1 scol N 1694 310 M 1549 310 I 1549 349 I 1694 349 I C
+K
+N 1694 323 M 1549 323 I 1549 349 I 1694 349 I C
+K
+N 1622 223 M 1622 184 I K
+N 1652 175 14 29 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1652 198 M (1)S
+0.602 0 0.199 1 scol N 1622 184 M 1632 203 I 1622 221 I 1612 203 I 1622 184 I C
+: 1 1 1 1 scol O ; K
+N 1622 223 M 1622 263 I K
+N 1654 245 11 28 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1654 268 M (*)S
+N 1652 175 14 29 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1652 198 M (1)S
+N 1654 245 11 28 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1654 268 M (*)S
+0.602 0 0.199 1 scol N 1494 655 M 1494 591 I K
+N 1123 655 M 1828 655 I K
+N 1494 591 M 1509 632 I 1479 632 I C
+: 1 1 1 1 scol O ; K
+N 1123 713 M 1123 655 I K
+: N 1743 506 219 84 rp C
+1 1 0.801 1 scol L ; N 1962 505 M 1742 505 I 1742 590 I 1962 590 I C
+K
+0 0 0 1 scol 1769 537 M (ConstantString)[18 14 14 13 7 14 14 7 17 7 8 6 14 0]xS
+0.602 0 0.199 1 scol N 1962 551 M 1742 551 I 1742 590 I 1962 590 I C
+K
+N 1962 565 M 1742 565 I 1742 590 I 1962 590 I C
+K
+: N 822 506 219 84 rp C
+1 1 0.801 1 scol L ; N 1041 505 M 821 505 I 821 590 I 1041 590 I C
+K
+0 0 0 1 scol 849 537 M (ConstantClass)[18 14 14 13 7 14 14 7 18 6 14 13 0]xS
+0.602 0 0.199 1 scol N 1041 551 M 821 551 I 821 590 I 1041 590 I C
+K
+N 1041 565 M 821 565 I 821 590 I 1041 590 I C
+K
+: N 1236 254 224 84 rp C
+1 1 0.801 1 scol L ; N 1460 253 M 1235 253 I 1235 338 I 1460 338 I C
+K
+0 0 0 1 scol 1259 285 M (ConstantInteger)[18 14 14 13 7 14 14 7 6 14 7 14 14 14 0]xS
+0.602 0 0.199 1 scol N 1460 299 M 1235 299 I 1235 338 I 1460 338 I C
+K
+N 1460 312 M 1235 312 I 1235 338 I 1460 338 I C
+K
+: N 958 254 232 84 rp C
+1 1 0.801 1 scol L ; N 1190 253 M 957 253 I 957 338 I 1190 338 I C
+K
+0 0 0 1 scol 984 285 M (ConstantDouble)[18 14 14 13 7 14 14 7 18 14 14 14 6 0]xS
+0.602 0 0.199 1 scol N 1190 299 M 957 299 I 957 338 I 1190 338 I C
+K
+N 1190 312 M 957 312 I 957 338 I 1190 338 I C
+K
+: N 1102 506 207 84 rp C
+1 1 0.801 1 scol L ; N 1309 505 M 1101 505 I 1101 590 I 1309 590 I C
+K
+0 0 0 1 scol 1127 537 M (ConstantFloat)[18 14 14 13 7 14 14 7 15 6 14 14 0]xS
+0.602 0 0.199 1 scol N 1309 551 M 1101 551 I 1101 590 I 1309 590 I C
+K
+N 1309 565 M 1101 565 I 1101 590 I 1309 590 I C
+K
+: N 708 254 206 84 rp C
+1 1 0.801 1 scol L ; N 914 253 M 707 253 I 707 338 I 914 338 I C
+K
+0 0 0 1 scol 732 285 M (ConstantLong)[18 14 14 13 7 14 14 7 14 14 14 0]xS
+0.602 0 0.199 1 scol N 914 299 M 707 299 I 707 338 I 914 338 I C
+K
+N 914 312 M 707 312 I 707 338 I 914 338 I C
+K
+: N 2025 506 246 84 rp C
+1 1 0.801 1 scol L ; N 2271 505 M 2024 505 I 2024 590 I 2271 590 I C
+K
+0 0 0 1 scol 2051 537 M (ConstantUnicode)[18 14 14 13 7 14 14 7 18 14 6 13 14 14 0]xS
+0.602 0 0.199 1 scol N 2271 545 M 2024 545 I 2024 590 I 2271 590 I C
+K
+N 2271 558 M 2024 558 I 2024 590 I 2271 590 I C
+K
+: N 1790 254 322 84 rp C
+1 1 0.801 1 scol L ; N 2112 253 M 1789 253 I 1789 338 I 2112 338 I C
+K
+0 0 0 1 scol 1817 285 M (ConstantNameAndType)[18 14 14 13 7 14 14 7 18 14 22 14 17 14 14 14 12 14 0]xS
+0.602 0 0.199 1 scol N 2112 299 M 1789 299 I 1789 338 I 2112 338 I C
+K
+N 2112 312 M 1789 312 I 1789 338 I 2112 338 I C
+K
+: N 2172 254 194 84 rp C
+1 1 0.801 1 scol L ; N 2366 253 M 2171 253 I 2171 338 I 2366 338 I C
+K
+0 0 0 1 scol 2195 285 M (ConstantUtf8)[18 14 14 13 7 14 14 7 18 7 7 0]xS
+0.602 0 0.199 1 scol N 2366 293 M 2171 293 I 2171 338 I 2366 338 I C
+K
+N 2366 306 M 2171 306 I 2171 338 I 2366 338 I C
+K
+N 1626 428 M 1626 350 I K
+N 809 428 M 2269 428 I K
+N 1626 350 M 1641 391 I 1611 391 I C
+: 1 1 1 1 scol O ; K
+N 933 505 M 933 428 I K
+N 1848 505 M 1848 428 I K
+N 1068 339 M 1068 428 I K
+N 2146 505 M 2146 428 I K
+N 809 339 M 809 428 I K
+N 2269 339 M 2269 428 I K
+N 1500 505 M 1500 428 I K
+N 1336 339 M 1336 428 I K
+N 1201 505 M 1201 428 I K
+N 1926 339 M 1926 428 I K
+N 1468 713 M 1468 655 I K
+N 1828 713 M 1828 655 I K
+LH
+%%PageTrailer
+
+%%Trailer
+%%DocumentNeededResources:
+%%+ font Helvetica
+%%DocumentSuppliedResources:
+Pscript_WinNT_Incr dup /terminate get exec
+%%EOF
+grestore
diff --git a/docs/eps/constantpool.fig b/docs/eps/constantpool.fig
new file mode 100644
index 00000000..1c7b738c
--- /dev/null
+++ b/docs/eps/constantpool.fig
@@ -0,0 +1,211 @@
+#FIG 3.2
+Portrait
+Center
+Inches
+A4
+100.00
+Single
+-2
+1200 2
+0 32 #f9f9f9
+0 33 #303030
+6 75 0 4500 9825
+2 1 0 0 32 32 998 0 20 4.000 0 0 0 0 0 4
+ 2747 5661 2747 4585 3239 4585 3239 5661
+2 1 0 1 33 33 997 0 -1 4.000 0 0 0 0 0 5
+ 2743 5665 2743 4581 3243 4581 3243 5665 2743 5665
+2 1 0 1 33 33 995 0 -1 4.000 0 0 0 0 0 5
+ 3015 5665 3015 4581 3243 4581 3243 5665 3015 5665
+2 1 0 1 33 33 994 0 -1 4.000 0 0 0 0 0 5
+ 3107 5665 3107 4581 3243 4581 3243 5665 3107 5665
+2 1 0 0 32 32 993 0 20 4.000 0 0 0 0 0 4
+ 3963 6345 3963 4157 4455 4157 4455 6345
+2 1 0 1 33 33 992 0 -1 4.000 0 0 0 0 0 5
+ 3959 6349 3959 4153 4459 4153 4459 6349 3959 6349
+2 1 0 1 33 33 990 0 -1 4.000 0 0 0 0 0 5
+ 4231 6349 4231 4153 4459 4153 4459 6349 4231 6349
+2 1 0 1 33 33 989 0 -1 4.000 0 0 0 0 0 5
+ 4323 6349 4323 4153 4459 4153 4459 6349 4323 6349
+2 1 0 0 32 32 988 0 20 4.000 0 0 0 0 0 4
+ 3963 3905 3963 2373 4455 2373 4455 3905
+2 1 0 1 33 33 987 0 -1 4.000 0 0 0 0 0 5
+ 3959 3909 3959 2369 4459 2369 4459 3909 3959 3909
+2 1 0 1 33 33 985 0 -1 4.000 0 0 0 0 0 5
+ 4231 3909 4231 2369 4459 2369 4459 3909 4231 3909
+2 1 0 1 33 33 984 0 -1 4.000 0 0 0 0 0 5
+ 4323 3909 4323 2369 4459 2369 4459 3909 4323 3909
+2 1 0 0 32 32 983 0 20 4.000 0 0 0 0 0 4
+ 3963 7985 3963 6613 4455 6613 4455 7985
+2 1 0 1 33 33 982 0 -1 4.000 0 0 0 0 0 5
+ 3959 7989 3959 6609 4459 6609 4459 7989 3959 7989
+2 1 0 1 33 33 980 0 -1 4.000 0 0 0 0 0 5
+ 4231 7989 4231 6609 4459 6609 4459 7989 4231 7989
+2 1 0 1 33 33 979 0 -1 4.000 0 0 0 0 0 5
+ 4323 7989 4323 6609 4459 6609 4459 7989 4323 7989
+2 1 0 0 32 32 978 0 20 4.000 0 0 0 0 0 4
+ 131 5041 131 3797 863 3797 863 5041
+2 1 0 1 33 33 977 0 -1 4.000 0 0 0 0 0 5
+ 127 5045 127 3793 867 3793 867 5045 127 5045
+2 1 0 1 33 33 975 0 -1 4.000 0 0 0 0 0 5
+ 399 5045 399 3793 867 3793 867 5045 399 5045
+2 1 0 1 33 33 974 0 -1 4.000 0 0 0 0 0 5
+ 491 5045 491 3793 867 3793 867 5045 491 5045
+2 1 0 0 32 32 972 0 20 4.000 0 0 0 0 0 4
+ 1339 4841 1339 3997 1831 3997 1831 4841
+2 1 0 1 33 33 971 0 -1 4.000 0 0 0 0 0 5
+ 1335 4845 1335 3993 1835 3993 1835 4845 1335 4845
+2 1 0 1 33 33 969 0 -1 4.000 0 0 0 0 0 5
+ 1607 4845 1607 3993 1835 3993 1835 4845 1607 4845
+2 1 0 1 33 33 968 0 -1 4.000 0 0 0 0 0 5
+ 1699 4845 1699 3993 1835 3993 1835 4845 1699 4845
+2 1 0 1 33 33 967 0 -1 4.000 0 0 0 0 0 2
+ 1099 4417 871 4417
+2 1 0 0 7 7 966 0 20 4.000 0 0 0 0 0 4
+ 807 4245 807 4153 995 4153 995 4245
+2 1 0 0 7 7 964 0 20 4.000 0 0 0 0 0 5
+ 871 4417 979 4357 1087 4417 979 4477 871 4417
+2 1 0 1 33 33 963 0 -1 4.000 0 0 0 0 0 5
+ 871 4417 979 4357 1087 4417 979 4477 871 4417
+2 1 0 1 33 33 962 0 -1 4.000 0 0 0 0 0 2
+ 1099 4417 1331 4417
+2 1 0 0 7 7 961 0 20 4.000 0 0 0 0 0 4
+ 1215 4233 1215 4169 1403 4169 1403 4233
+2 1 0 0 7 7 959 0 20 4.000 0 0 0 0 0 4
+ 807 4245 807 4153 995 4153 995 4245
+2 1 0 0 7 7 957 0 20 4.000 0 0 0 0 0 4
+ 1215 4233 1215 4169 1403 4169 1403 4233
+2 1 0 1 33 33 955 0 -1 4.000 0 0 0 0 0 2
+ 3619 5165 3247 5165
+2 1 0 1 33 33 954 0 -1 4.000 0 0 0 0 0 2
+ 3619 7329 3619 3217
+2 1 0 0 7 7 953 0 20 4.000 0 0 0 0 0 4
+ 3247 5165 3487 5077 3487 5253 3247 5165
+2 1 0 1 33 33 952 0 -1 4.000 0 0 0 0 0 4
+ 3247 5165 3487 5077 3487 5253 3247 5165
+2 1 0 1 33 33 951 0 -1 4.000 0 0 0 0 0 2
+ 3959 7329 3619 7329
+2 1 0 0 32 32 950 0 20 4.000 0 0 0 0 0 4
+ 2747 3713 2747 2437 3239 2437 3239 3713
+2 1 0 1 33 33 949 0 -1 4.000 0 0 0 0 0 5
+ 2743 3717 2743 2433 3243 2433 3243 3717 2743 3717
+2 1 0 1 33 33 947 0 -1 4.000 0 0 0 0 0 5
+ 3015 3717 3015 2433 3243 2433 3243 3717 3015 3717
+2 1 0 1 33 33 946 0 -1 4.000 0 0 0 0 0 5
+ 3107 3717 3107 2433 3243 2433 3243 3717 3107 3717
+2 1 0 0 32 32 945 0 20 4.000 0 0 0 0 0 4
+ 2747 9089 2747 7813 3239 7813 3239 9089
+2 1 0 1 33 33 944 0 -1 4.000 0 0 0 0 0 5
+ 2743 9093 2743 7809 3243 7809 3243 9093 2743 9093
+2 1 0 1 33 33 942 0 -1 4.000 0 0 0 0 0 5
+ 3015 9093 3015 7809 3243 7809 3243 9093 3015 9093
+2 1 0 1 33 33 941 0 -1 4.000 0 0 0 0 0 5
+ 3107 9093 3107 7809 3243 7809 3243 9093 3107 9093
+2 1 0 0 32 32 940 0 20 4.000 0 0 0 0 0 4
+ 1275 6673 1275 5365 1767 5365 1767 6673
+2 1 0 1 33 33 939 0 -1 4.000 0 0 0 0 0 5
+ 1271 6677 1271 5361 1771 5361 1771 6677 1271 6677
+2 1 0 1 33 33 937 0 -1 4.000 0 0 0 0 0 5
+ 1543 6677 1543 5361 1771 5361 1771 6677 1543 6677
+2 1 0 1 33 33 936 0 -1 4.000 0 0 0 0 0 5
+ 1635 6677 1635 5361 1771 5361 1771 6677 1635 6677
+2 1 0 0 32 32 935 0 20 4.000 0 0 0 0 0 4
+ 1275 8297 1275 6941 1767 6941 1767 8297
+2 1 0 1 33 33 934 0 -1 4.000 0 0 0 0 0 5
+ 1271 8301 1271 6937 1771 6937 1771 8301 1271 8301
+2 1 0 1 33 33 932 0 -1 4.000 0 0 0 0 0 5
+ 1543 8301 1543 6937 1771 6937 1771 8301 1543 8301
+2 1 0 1 33 33 931 0 -1 4.000 0 0 0 0 0 5
+ 1635 8301 1635 6937 1771 6937 1771 8301 1635 8301
+2 1 0 0 32 32 930 0 20 4.000 0 0 0 0 0 4
+ 2747 7453 2747 6249 3239 6249 3239 7453
+2 1 0 1 33 33 929 0 -1 4.000 0 0 0 0 0 5
+ 2743 7457 2743 6245 3243 6245 3243 7457 2743 7457
+2 1 0 1 33 33 927 0 -1 4.000 0 0 0 0 0 5
+ 3015 7457 3015 6245 3243 6245 3243 7457 3015 7457
+2 1 0 1 33 33 926 0 -1 4.000 0 0 0 0 0 5
+ 3107 7457 3107 6245 3243 6245 3243 7457 3107 7457
+2 1 0 0 32 32 925 0 20 4.000 0 0 0 0 0 4
+ 1275 9757 1275 8553 1767 8553 1767 9757
+2 1 0 1 33 33 924 0 -1 4.000 0 0 0 0 0 5
+ 1271 9761 1271 8549 1771 8549 1771 9761 1271 9761
+2 1 0 1 33 33 922 0 -1 4.000 0 0 0 0 0 5
+ 1543 9761 1543 8549 1771 8549 1771 9761 1543 9761
+2 1 0 1 33 33 921 0 -1 4.000 0 0 0 0 0 5
+ 1635 9761 1635 8549 1771 8549 1771 9761 1635 9761
+2 1 0 0 32 32 920 0 20 4.000 0 0 0 0 0 4
+ 2747 2065 2747 630 3239 630 3239 2065
+2 1 0 1 33 33 919 0 -1 4.000 0 0 0 0 0 5
+ 2743 2069 2743 626 3243 626 3243 2069 2743 2069
+2 1 0 1 33 33 917 0 -1 4.000 0 0 0 0 0 5
+ 3015 2069 3015 626 3243 626 3243 2069 3015 2069
+2 1 0 1 33 33 916 0 -1 4.000 0 0 0 0 0 5
+ 3107 2069 3107 626 3243 626 3243 2069 3107 2069
+2 1 0 0 32 32 915 0 20 4.000 0 0 0 0 0 4
+ 1275 3441 1275 1557 1767 1557 1767 3441
+2 1 0 1 33 33 914 0 -1 4.000 0 0 0 0 0 5
+ 1271 3445 1271 1553 1771 1553 1771 3445 1271 3445
+2 1 0 1 33 33 912 0 -1 4.000 0 0 0 0 0 5
+ 1543 3445 1543 1553 1771 1553 1771 3445 1543 3445
+2 1 0 1 33 33 911 0 -1 4.000 0 0 0 0 0 5
+ 1635 3445 1635 1553 1771 1553 1771 3445 1635 3445
+2 1 0 0 32 32 910 0 20 4.000 0 0 0 0 0 4
+ 1275 1209 1275 78 1767 78 1767 1209
+2 1 0 1 33 33 909 0 -1 4.000 0 0 0 0 0 5
+ 1271 1213 1271 74 1771 74 1771 1213 1271 1213
+2 1 0 1 33 33 907 0 -1 4.000 0 0 0 0 0 5
+ 1543 1213 1543 74 1771 74 1771 1213 1543 1213
+2 1 0 1 33 33 906 0 -1 4.000 0 0 0 0 0 5
+ 1635 1213 1635 74 1771 74 1771 1213 1635 1213
+2 1 0 1 33 33 905 0 -1 4.000 0 0 0 0 0 2
+ 2295 4393 1839 4393
+2 1 0 1 33 33 904 0 -1 4.000 0 0 0 0 0 2
+ 2295 9165 2295 642
+2 1 0 0 7 7 903 0 20 4.000 0 0 0 0 0 4
+ 1839 4393 2079 4305 2079 4481 1839 4393
+2 1 0 1 33 33 902 0 -1 4.000 0 0 0 0 0 4
+ 1839 4393 2079 4305 2079 4481 1839 4393
+2 1 0 1 33 33 901 0 -1 4.000 0 0 0 0 0 2
+ 2743 8441 2295 8441
+2 1 0 1 33 33 900 0 -1 4.000 0 0 0 0 0 2
+ 2743 3097 2295 3097
+2 1 0 1 33 33 899 0 -1 4.000 0 0 0 0 0 2
+ 1775 7653 2295 7653
+2 1 0 1 33 33 898 0 -1 4.000 0 0 0 0 0 2
+ 2743 1357 2295 1357
+2 1 0 1 33 33 897 0 -1 4.000 0 0 0 0 0 2
+ 1775 9165 2295 9165
+2 1 0 1 33 33 896 0 -1 4.000 0 0 0 0 0 2
+ 1775 642 2295 642
+2 1 0 1 33 33 895 0 -1 4.000 0 0 0 0 0 2
+ 2743 5129 2295 5129
+2 1 0 1 33 33 894 0 -1 4.000 0 0 0 0 0 2
+ 1775 6089 2295 6089
+2 1 0 1 33 33 893 0 -1 4.000 0 0 0 0 0 2
+ 2743 6877 2295 6877
+2 1 0 1 33 33 892 0 -1 4.000 0 0 0 0 0 2
+ 1775 2641 2295 2641
+2 1 0 1 33 33 891 0 -1 4.000 0 0 0 0 0 2
+ 3959 5317 3619 5317
+2 1 0 1 33 33 890 0 -1 4.000 0 0 0 0 0 2
+ 3959 3217 3619 3217
+4 0 0 996 -1 16 10 1.5708 4 105 840 2951 5565 ConstantCP\001
+4 0 0 991 -1 16 10 1.5708 4 120 1950 4167 6269 ConstantInterfaceMethodref\001
+4 0 0 986 -1 16 10 1.5708 4 120 1335 4167 3837 ConstantMethodref\001
+4 0 0 981 -1 16 10 1.5708 4 120 1140 4167 7901 ConstantFieldref\001
+4 0 0 976 -1 16 10 1.5708 4 120 945 335 4913 ConstantPool\001
+4 0 0 973 -1 16 10 1.5708 4 135 945 763 4809 getConstant()\001
+4 0 0 970 -1 16 10 1.5708 4 105 630 1543 4745 Constant\001
+4 0 0 965 -1 16 10 1.5708 4 105 90 959 4245 1\001
+4 0 0 960 -1 16 10 1.5708 4 60 60 1367 4233 *\001
+4 0 0 958 -1 16 10 1.5708 4 105 90 959 4245 1\001
+4 0 0 956 -1 16 10 1.5708 4 60 60 1367 4233 *\001
+4 0 0 948 -1 16 10 1.5708 4 150 1035 2951 3613 ConstantString\001
+4 0 0 943 -1 16 10 1.5708 4 120 1005 2951 8985 ConstantClass\001
+4 0 0 938 -1 16 10 1.5708 4 135 1125 1479 6601 ConstantInteger\001
+4 0 0 933 -1 16 10 1.5708 4 120 1125 1479 8209 ConstantDouble\001
+4 0 0 928 -1 16 10 1.5708 4 120 975 2951 7361 ConstantFloat\001
+4 0 0 923 -1 16 10 1.5708 4 135 990 1479 9665 ConstantLong\001
+4 0 0 918 -1 16 10 1.5708 4 120 1200 2951 1977 ConstantUnicode\001
+4 0 0 913 -1 16 10 1.5708 4 150 1665 1479 3377 ConstantNameAndType\001
+4 0 0 908 -1 16 10 1.5708 4 120 915 1479 1121 ConstantUtf8\001
+-6
diff --git a/docs/eps/diagram.fig b/docs/eps/diagram.fig
new file mode 100644
index 00000000..cc81536b
--- /dev/null
+++ b/docs/eps/diagram.fig
@@ -0,0 +1,351 @@
+#FIG 3.2
+Portrait
+Center
+Inches
+A4
+100.00
+Single
+-2
+1200 2
+0 32 #f9f9f9
+0 33 #303030
+0 34 #7e7e7e
+6 600 300 5925 10575
+2 1 0 0 32 32 998 0 20 4.000 0 0 0 0 0 4
+ 4527 8915 4527 7615 5019 7615 5019 8915
+2 1 0 1 33 33 997 0 -1 4.000 0 0 0 0 0 5
+ 4523 8919 4523 7611 5023 7611 5023 8919 4523 8919
+2 1 0 1 33 33 995 0 -1 4.000 0 0 0 0 0 5
+ 4763 8919 4763 7611 5023 7611 5023 8919 4763 8919
+2 1 0 1 33 33 994 0 -1 4.000 0 0 0 0 0 5
+ 4855 8919 4855 7611 5023 7611 5023 8919 4855 8919
+2 1 0 0 32 32 993 0 20 4.000 0 0 0 0 0 4
+ 4591 4831 4591 3379 5083 3379 5083 4831
+2 1 0 1 33 33 992 0 -1 4.000 0 0 0 0 0 5
+ 4587 4835 4587 3375 5087 3375 5087 4835 4587 4835
+2 1 0 1 33 33 990 0 -1 4.000 0 0 0 0 0 5
+ 4827 4835 4827 3375 5087 3375 5087 4835 4827 4835
+2 1 0 1 33 33 989 0 -1 4.000 0 0 0 0 0 5
+ 4919 4835 4919 3375 5087 3375 5087 4835 4919 4835
+2 1 0 0 32 32 988 0 20 4.000 0 0 0 0 0 4
+ 4555 7183 4555 5507 5887 5507 5887 7183
+2 1 0 1 33 33 987 0 -1 4.000 0 0 0 0 0 5
+ 4551 7187 4551 5503 5891 5503 5891 7187 4551 7187
+2 1 0 1 33 33 985 0 -1 4.000 0 0 0 0 0 5
+ 4791 7187 4791 5503 5891 5503 5891 7187 4791 7187
+2 1 0 1 33 33 984 0 -1 4.000 0 0 0 0 0 5
+ 5447 7187 5447 5503 5891 5503 5891 7187 5447 7187
+2 1 0 1 33 33 979 0 -1 4.000 0 0 0 0 0 2
+ 5019 5171 5075 5499
+2 1 0 0 7 7 978 0 20 4.000 0 0 0 0 0 5
+ 5075 5499 5115 5379 5039 5287 4995 5403 5075 5499
+2 1 0 1 33 33 977 0 -1 4.000 0 0 0 0 0 5
+ 5075 5499 5115 5379 5039 5287 4995 5403 5075 5499
+2 1 0 1 33 33 976 0 -1 4.000 0 0 0 0 0 2
+ 5019 5171 4963 4839
+2 1 0 0 7 7 975 0 20 4.000 0 0 0 0 0 4
+ 4667 4947 4667 4855 4855 4855 4855 4947
+2 1 0 0 7 7 973 0 20 4.000 0 0 0 0 0 4
+ 4667 4947 4667 4855 4855 4855 4855 4947
+2 1 0 0 32 32 971 0 20 4.000 0 0 0 0 0 4
+ 5423 3467 5423 1927 5915 1927 5915 3467
+2 1 0 1 33 33 970 0 -1 4.000 0 0 0 0 0 5
+ 5419 3471 5419 1923 5919 1923 5919 3471 5419 3471
+2 1 0 1 33 33 968 0 -1 4.000 0 0 0 0 0 5
+ 5659 3471 5659 1923 5919 1923 5919 3471 5659 3471
+2 1 0 1 33 33 967 0 -1 4.000 0 0 0 0 0 5
+ 5751 3471 5751 1923 5919 1923 5919 3471 5751 3471
+2 1 0 1 33 33 966 0 -1 4.000 0 0 0 0 0 2
+ 5447 4487 5323 5499
+2 1 0 0 7 7 965 0 20 4.000 0 0 0 0 0 5
+ 5323 5499 5275 5383 5351 5283 5395 5399 5323 5499
+2 1 0 1 33 33 964 0 -1 4.000 0 0 0 0 0 5
+ 5323 5499 5275 5383 5351 5283 5395 5399 5323 5499
+2 1 0 1 33 33 963 0 -1 4.000 0 0 0 0 0 2
+ 5447 4487 5571 3475
+2 1 0 0 7 7 962 0 20 4.000 0 0 0 0 0 4
+ 5683 3647 5683 3555 5871 3555 5871 3647
+2 1 0 0 7 7 960 0 20 4.000 0 0 0 0 0 4
+ 5683 3647 5683 3555 5871 3555 5871 3647
+2 1 0 0 32 32 958 0 20 4.000 0 0 0 0 0 4
+ 3055 4359 3055 3211 3547 3211 3547 4359
+2 1 0 1 33 33 957 0 -1 4.000 0 0 0 0 0 5
+ 3051 4363 3051 3207 3551 3207 3551 4363 3051 4363
+2 1 0 1 33 33 955 0 -1 4.000 0 0 0 0 0 5
+ 3291 4363 3291 3207 3551 3207 3551 4363 3291 4363
+2 1 0 1 33 33 954 0 -1 4.000 0 0 0 0 0 5
+ 3383 4363 3383 3207 3551 3207 3551 4363 3383 4363
+2 1 0 0 32 32 953 0 20 4.000 0 0 0 0 0 4
+ 3055 2867 3055 1887 3547 1887 3547 2867
+2 1 0 1 33 33 952 0 -1 4.000 0 0 0 0 0 5
+ 3051 2871 3051 1883 3551 1883 3551 2871 3051 2871
+2 1 0 1 33 33 950 0 -1 4.000 0 0 0 0 0 5
+ 3291 2871 3291 1883 3551 1883 3551 2871 3291 2871
+2 1 0 1 33 33 949 0 -1 4.000 0 0 0 0 0 5
+ 3383 2871 3383 1883 3551 1883 3551 2871 3383 2871
+2 1 0 0 32 32 948 0 20 4.000 0 0 0 0 0 4
+ 4527 10303 4527 9299 5019 9299 5019 10303
+2 1 0 1 33 33 947 0 -1 4.000 0 0 0 0 0 5
+ 4523 10307 4523 9295 5023 9295 5023 10307 4523 10307
+2 1 0 1 33 33 945 0 -1 4.000 0 0 0 0 0 5
+ 4763 10307 4763 9295 5023 9295 5023 10307 4763 10307
+2 1 0 1 33 33 944 0 -1 4.000 0 0 0 0 0 5
+ 4855 10307 4855 9295 5023 9295 5023 10307 4855 10307
+2 1 0 0 32 32 943 0 20 4.000 0 0 0 0 0 4
+ 4591 1843 4591 991 5083 991 5083 1843
+2 1 0 1 33 33 942 0 -1 4.000 0 0 0 0 0 5
+ 4587 1847 4587 987 5087 987 5087 1847 4587 1847
+2 1 0 1 33 33 940 0 -1 4.000 0 0 0 0 0 5
+ 4827 1847 4827 987 5087 987 5087 1847 4827 1847
+2 1 0 1 33 33 939 0 -1 4.000 0 0 0 0 0 5
+ 4919 1847 4919 987 5087 987 5087 1847 4919 1847
+2 1 0 0 32 32 938 0 20 4.000 0 0 0 0 0 4
+ 3055 1547 3055 647 3547 647 3547 1547
+2 1 0 1 33 33 937 0 -1 4.000 0 0 0 0 0 5
+ 3051 1551 3051 643 3551 643 3551 1551 3051 1551
+2 1 0 1 33 33 935 0 -1 4.000 0 0 0 0 0 5
+ 3291 1551 3291 643 3551 643 3551 1551 3291 1551
+2 1 0 1 33 33 934 0 -1 4.000 0 0 0 0 0 5
+ 3383 1551 3383 643 3551 643 3551 1551 3383 1551
+2 1 0 0 32 32 933 0 20 4.000 0 0 0 0 0 4
+ 3055 9923 3055 8655 3547 8655 3547 9923
+2 1 0 1 33 33 932 0 -1 4.000 0 0 0 0 0 5
+ 3051 9927 3051 8651 3551 8651 3551 9927 3051 9927
+2 1 0 1 33 33 930 0 -1 4.000 0 0 0 0 0 5
+ 3291 9927 3291 8651 3551 8651 3551 9927 3291 9927
+2 1 0 1 33 33 929 0 -1 4.000 0 0 0 0 0 5
+ 3383 9927 3383 8651 3551 8651 3551 9927 3383 9927
+2 1 0 0 32 32 928 0 20 4.000 0 0 0 0 0 4
+ 859 9827 859 8751 1519 8751 1519 9827
+2 1 0 1 33 33 927 0 -1 4.000 0 0 0 0 0 5
+ 855 9831 855 8747 1523 8747 1523 9831 855 9831
+2 1 0 2 34 34 926 0 -1 4.000 0 0 0 0 0 3
+ 1499 9803 1499 8771 883 8771
+2 1 0 1 33 33 924 0 -1 4.000 0 0 0 0 0 5
+ 1095 9831 1095 8747 1523 8747 1523 9831 1095 9831
+2 1 0 1 33 33 923 0 -1 4.000 0 0 0 0 0 5
+ 1187 9831 1187 8747 1523 8747 1523 9831 1187 9831
+2 1 0 0 32 32 921 0 20 4.000 0 0 0 0 0 4
+ 2991 6375 2991 5547 3483 5547 3483 6375
+2 1 0 1 33 33 920 0 -1 4.000 0 0 0 0 0 5
+ 2987 6379 2987 5543 3487 5543 3487 6379 2987 6379
+2 1 0 1 33 33 918 0 -1 4.000 0 0 0 0 0 5
+ 3227 6379 3227 5543 3487 5543 3487 6379 3227 6379
+2 1 0 1 33 33 917 0 -1 4.000 0 0 0 0 0 5
+ 3319 6379 3319 5543 3487 5543 3487 6379 3319 6379
+2 1 0 1 33 33 916 0 -1 4.000 0 0 0 0 0 2
+ 3855 5959 3491 5959
+2 1 0 1 33 33 915 0 -1 4.000 0 0 0 0 0 2
+ 3855 9887 3855 1111
+2 1 0 0 7 7 914 0 20 4.000 0 0 0 0 0 4
+ 3491 5959 3731 5871 3731 6047 3491 5959
+2 1 0 1 33 33 913 0 -1 4.000 0 0 0 0 0 4
+ 3491 5959 3731 5871 3731 6047 3491 5959
+2 1 0 1 33 33 912 0 -1 4.000 0 0 0 0 0 2
+ 4551 6387 3855 6387
+2 1 0 0 7 7 911 0 20 4.000 0 0 0 0 0 4
+ 4107 6959 4107 5399 4295 5399 4295 6959
+2 1 0 1 33 33 909 0 -1 4.000 0 0 0 0 0 2
+ 4587 4207 3855 4207
+2 1 0 0 7 7 908 0 20 4.000 0 0 0 0 0 4
+ 4391 4899 4391 3487 4579 3487 4579 4899
+2 1 0 1 33 33 906 0 -1 4.000 0 0 0 0 0 2
+ 3555 2415 3855 2415
+2 1 0 0 7 7 905 0 20 4.000 0 0 0 0 0 4
+ 3611 3075 3611 1647 3799 1647 3799 3075
+2 1 0 1 33 33 903 0 -1 4.000 0 0 0 0 0 2
+ 4523 8235 3855 8235
+2 1 0 0 7 7 902 0 20 4.000 0 0 0 0 0 4
+ 4099 8879 4099 7319 4287 7319 4287 8879
+2 1 0 1 33 33 900 0 -1 4.000 0 0 0 0 0 2
+ 4587 1403 3855 1403
+2 1 0 1 33 33 899 0 -1 4.000 0 0 0 0 0 2
+ 4523 9887 3855 9887
+2 1 0 0 7 7 898 0 20 4.000 0 0 0 0 0 4
+ 4099 10531 4099 8971 4287 8971 4287 10531
+2 1 0 0 32 32 896 0 20 4.000 0 0 0 0 0 4
+ 1747 4367 1747 2819 2679 2819 2679 4367
+2 1 0 1 33 33 895 0 -1 4.000 0 0 0 0 0 5
+ 1743 4371 1743 2815 2683 2815 2683 4371 1743 4371
+2 1 0 1 33 33 893 0 -1 4.000 0 0 0 0 0 5
+ 1983 4371 1983 2815 2683 2815 2683 4371 1983 4371
+2 1 0 1 33 33 892 0 -1 4.000 0 0 0 0 0 5
+ 2451 4371 2451 2815 2683 2815 2683 4371 2451 4371
+2 1 0 1 33 33 889 0 -1 4.000 0 0 0 0 0 2
+ 2803 4959 2551 4375
+2 1 0 0 7 7 888 0 20 4.000 0 0 0 0 0 4
+ 2683 4395 2683 4303 2871 4303 2871 4395
+2 1 0 0 7 7 886 0 20 4.000 0 0 0 0 0 5
+ 2551 4375 2651 4451 2635 4575 2539 4499 2551 4375
+2 1 0 1 33 33 885 0 -1 4.000 0 0 0 0 0 5
+ 2551 4375 2651 4451 2635 4575 2539 4499 2551 4375
+2 1 0 1 33 33 884 0 -1 4.000 0 0 0 0 0 2
+ 2803 4959 3055 5539
+2 1 0 0 7 7 883 0 20 4.000 0 0 0 0 0 4
+ 3135 5419 3135 5355 3323 5355 3323 5419
+2 1 0 0 32 32 881 0 20 4.000 0 0 0 0 0 4
+ 1683 9167 1683 7619 2615 7619 2615 9167
+2 1 0 1 33 33 880 0 -1 4.000 0 0 0 0 0 5
+ 1679 9171 1679 7615 2619 7615 2619 9171 1679 9171
+2 1 0 1 33 33 878 0 -1 4.000 0 0 0 0 0 5
+ 1919 9171 1919 7615 2619 7615 2619 9171 1919 9171
+2 1 0 1 33 33 877 0 -1 4.000 0 0 0 0 0 5
+ 2387 9171 2387 7615 2619 7615 2619 9171 2387 9171
+2 1 0 1 33 33 874 0 -1 4.000 0 0 0 0 0 2
+ 2771 6999 2499 7611
+2 1 0 0 7 7 873 0 20 4.000 0 0 0 0 0 4
+ 2631 7675 2631 7583 2819 7583 2819 7675
+2 1 0 0 7 7 871 0 20 4.000 0 0 0 0 0 5
+ 2499 7611 2487 7487 2587 7415 2599 7535 2499 7611
+2 1 0 1 33 33 870 0 -1 4.000 0 0 0 0 0 5
+ 2499 7611 2487 7487 2587 7415 2599 7535 2499 7611
+2 1 0 1 33 33 869 0 -1 4.000 0 0 0 0 0 2
+ 2771 6999 3047 6383
+2 1 0 0 7 7 868 0 20 4.000 0 0 0 0 0 4
+ 2735 6391 2735 6327 2923 6327 2923 6391
+2 1 0 0 7 7 866 0 20 4.000 0 0 0 0 0 4
+ 2735 6391 2735 6327 2923 6327 2923 6391
+2 1 0 0 32 32 864 0 20 4.000 0 0 0 0 0 4
+ 623 6879 623 5043 1755 5043 1755 6879
+2 1 0 1 33 33 863 0 -1 4.000 0 0 0 0 0 5
+ 619 6883 619 5039 1759 5039 1759 6883 619 6883
+2 1 0 1 33 33 861 0 -1 4.000 0 0 0 0 0 5
+ 859 6883 859 5039 1759 5039 1759 6883 859 6883
+2 1 0 1 33 33 860 0 -1 4.000 0 0 0 0 0 5
+ 1139 6883 1139 5039 1759 5039 1759 6883 1139 6883
+2 1 0 1 33 33 856 0 -1 4.000 0 0 0 0 0 2
+ 1731 4707 1591 5035
+2 1 0 0 7 7 855 0 20 4.000 0 0 0 0 0 4
+ 1715 5127 1715 5035 1903 5035 1903 5127
+2 1 0 0 7 7 853 0 20 4.000 0 0 0 0 0 5
+ 1591 5035 1579 4911 1675 4835 1691 4959 1591 5035
+2 1 0 1 33 33 852 0 -1 4.000 0 0 0 0 0 5
+ 1591 5035 1579 4911 1675 4835 1691 4959 1591 5035
+2 1 0 1 33 33 851 0 -1 4.000 0 0 0 0 0 2
+ 1731 4707 1875 4375
+2 1 0 0 7 7 850 0 20 4.000 0 0 0 0 0 4
+ 1571 4363 1571 4299 1759 4299 1759 4363
+2 1 0 0 7 7 848 0 20 4.000 0 0 0 0 0 4
+ 1571 4363 1571 4299 1759 4299 1759 4363
+2 1 0 1 33 33 846 0 -1 4.000 0 0 0 0 0 2
+ 1695 7251 1551 6887
+2 1 0 0 7 7 845 0 20 4.000 0 0 0 0 0 4
+ 1675 6891 1675 6799 1863 6799 1863 6891
+2 1 0 0 7 7 843 0 20 4.000 0 0 0 0 0 5
+ 1551 6887 1647 6963 1631 7087 1535 7011 1551 6887
+2 1 0 1 33 33 842 0 -1 4.000 0 0 0 0 0 5
+ 1551 6887 1647 6963 1631 7087 1535 7011 1551 6887
+2 1 0 1 33 33 841 0 -1 4.000 0 0 0 0 0 2
+ 1695 7251 1839 7611
+2 1 0 0 7 7 840 0 20 4.000 0 0 0 0 0 4
+ 1931 7523 1931 7459 2119 7459 2119 7523
+2 1 0 0 7 7 838 0 20 4.000 0 0 0 0 0 4
+ 1675 6891 1675 6799 1863 6799 1863 6891
+2 1 0 0 7 7 836 0 20 4.000 0 0 0 0 0 4
+ 1931 7523 1931 7459 2119 7459 2119 7523
+2 1 1 1 7 7 834 0 -1 4.000 0 0 0 0 0 2
+ 1191 8743 1191 6887
+2 1 1 1 0 0 833 0 -1 4.000 0 0 0 0 0 2
+ 1191 8743 1191 6887
+2 1 0 1 0 0 832 0 -1 4.000 0 0 0 0 0 2
+ 1191 6887 1251 7031
+2 1 0 1 0 0 831 0 -1 4.000 0 0 0 0 0 2
+ 1191 6887 1131 7031
+2 1 0 0 7 7 830 0 20 4.000 0 0 0 0 0 4
+ 923 8275 923 7351 1111 7351 1111 8275
+2 1 0 0 32 32 828 0 20 4.000 0 0 0 0 0 4
+ 823 2295 823 1051 1555 1051 1555 2295
+2 1 0 1 33 33 827 0 -1 4.000 0 0 0 0 0 5
+ 819 2299 819 1047 1559 1047 1559 2299 819 2299
+2 1 0 1 33 33 825 0 -1 4.000 0 0 0 0 0 5
+ 1059 2299 1059 1047 1559 1047 1559 2299 1059 2299
+2 1 0 1 33 33 824 0 -1 4.000 0 0 0 0 0 5
+ 1151 2299 1151 1047 1559 1047 1559 2299 1151 2299
+2 1 0 1 33 33 822 0 -1 4.000 0 0 0 0 0 2
+ 1191 3671 1191 5035
+2 1 0 1 33 33 821 0 -1 4.000 0 0 0 0 0 2
+ 1191 3671 1191 2303
+2 1 0 1 33 33 820 0 -1 4.000 0 0 0 0 0 2
+ 5419 2791 3855 2791
+2 1 0 0 7 7 819 0 20 4.000 0 0 0 0 0 4
+ 5143 3479 5143 2067 5331 2067 5331 3479
+2 1 0 1 33 33 817 0 -1 4.000 0 0 0 0 0 2
+ 3555 3831 3855 3831
+2 1 0 0 7 7 816 0 20 4.000 0 0 0 0 0 4
+ 3611 4567 3611 3139 3799 3139 3799 4567
+2 1 0 1 33 33 814 0 -1 4.000 0 0 0 0 0 2
+ 3555 1111 3855 1111
+2 1 0 0 7 7 813 0 20 4.000 0 0 0 0 0 4
+ 3611 1783 3611 355 3799 355 3799 1783
+2 1 0 1 33 33 811 0 -1 4.000 0 0 0 0 0 2
+ 3555 9303 3855 9303
+2 1 0 0 7 7 810 0 20 4.000 0 0 0 0 0 4
+ 3607 9879 3607 8507 3795 8507 3795 9879
+2 1 0 0 7 7 808 0 20 4.000 0 0 0 0 0 4
+ 2683 4395 2683 4303 2871 4303 2871 4395
+2 1 0 0 7 7 806 0 20 4.000 0 0 0 0 0 4
+ 2631 7675 2631 7583 2819 7583 2819 7675
+2 1 0 0 7 7 804 0 20 4.000 0 0 0 0 0 4
+ 3135 5419 3135 5355 3323 5355 3323 5419
+2 1 0 0 7 7 802 0 20 4.000 0 0 0 0 0 4
+ 1715 5127 1715 5035 1903 5035 1903 5127
+4 0 0 996 -1 16 10 1.5708 4 150 1080 4719 8827 ExceptionTable\001
+4 0 0 991 -1 16 10 1.5708 4 120 1230 4783 4767 LineNumberTable\001
+4 0 0 986 -1 16 10 1.5708 4 120 375 4747 6543 Code\001
+4 0 0 983 -1 16 10 1.5708 4 150 1035 4967 6951 max_stack : int\001
+4 0 0 982 -1 16 10 1.5708 4 150 1065 5155 6951 max_locals : int\001
+4 0 0 981 -1 16 10 1.5708 4 150 1365 5343 6951 exception_handlers\001
+4 0 0 980 -1 16 10 1.5708 4 150 690 5719 6951 getCode()\001
+4 0 0 974 -1 16 10 1.5708 4 105 90 4819 4947 1\001
+4 0 0 972 -1 16 10 1.5708 4 105 90 4819 4947 1\001
+4 0 0 969 -1 16 10 1.5708 4 120 1335 5615 3407 LocalVariableTable\001
+4 0 0 961 -1 16 10 1.5708 4 105 90 5835 3647 1\001
+4 0 0 959 -1 16 10 1.5708 4 105 90 5835 3647 1\001
+4 0 0 956 -1 16 10 1.5708 4 120 900 3247 4263 InnerClasses\001
+4 0 0 951 -1 16 10 1.5708 4 120 735 3247 2771 SourceFile\001
+4 0 0 946 -1 16 10 1.5708 4 150 810 4719 10227 Deprecated\001
+4 0 0 941 -1 16 10 1.5708 4 120 645 4783 1759 Unknown\001
+4 0 0 936 -1 16 10 1.5708 4 150 645 3247 1427 Synthetic\001
+4 0 0 931 -1 16 10 1.5708 4 120 1035 3247 9827 ConstantValue\001
+4 0 0 925 -1 16 10 1.5708 4 120 825 1051 9735 ClassParser\001
+4 0 0 922 -1 16 10 1.5708 4 135 480 1459 9595 parse()\001
+4 0 0 919 -1 16 10 1.5708 4 120 585 3183 6263 Attribute\001
+4 0 0 910 -1 16 10 1.5708 4 120 1500 4259 6959 <<Method attribute>>\001
+4 0 0 907 -1 16 10 1.5708 4 120 1350 4543 4899 <<Code attribute>>\001
+4 0 0 904 -1 16 10 1.5708 4 120 1350 3763 3075 <<Class attribute>>\001
+4 0 0 901 -1 16 10 1.5708 4 120 1500 4251 8879 <<Method attribute>>\001
+4 0 0 897 -1 16 10 1.5708 4 120 1500 4251 10531 <<Method attribute>>\001
+4 0 0 894 -1 16 10 1.5708 4 120 525 1939 3863 Method\001
+4 0 0 891 -1 16 10 1.5708 4 150 1200 2159 4135 access_flags : int\001
+4 0 0 890 -1 16 10 1.5708 4 150 1185 2347 4135 signature : String\001
+4 0 0 887 -1 16 10 1.5708 4 105 90 2835 4395 1\001
+4 0 0 882 -1 16 10 1.5708 4 60 60 3287 5419 *\001
+4 0 0 879 -1 16 10 1.5708 4 120 330 1875 8571 Field\001
+4 0 0 876 -1 16 10 1.5708 4 150 1200 2095 8935 access_flags : int\001
+4 0 0 875 -1 16 10 1.5708 4 150 1185 2283 8935 signature : String\001
+4 0 0 872 -1 16 10 1.5708 4 105 90 2783 7675 1\001
+4 0 0 867 -1 16 10 1.5708 4 60 60 2887 6391 *\001
+4 0 0 865 -1 16 10 1.5708 4 60 60 2887 6391 *\001
+4 0 0 862 -1 16 10 1.5708 4 120 705 815 6339 JavaClass\001
+4 0 0 859 -1 16 10 1.5708 4 150 1200 1035 6647 access_flags : int\001
+4 0 0 858 -1 16 10 1.5708 4 150 1410 1411 6647 getInterfaceNames()\001
+4 0 0 857 -1 16 10 1.5708 4 150 1485 1599 6647 getSuperclassName()\001
+4 0 0 854 -1 16 10 1.5708 4 105 90 1867 5127 1\001
+4 0 0 849 -1 16 10 1.5708 4 60 60 1723 4363 *\001
+4 0 0 847 -1 16 10 1.5708 4 60 60 1723 4363 *\001
+4 0 0 844 -1 16 10 1.5708 4 105 90 1827 6891 1\001
+4 0 0 839 -1 16 10 1.5708 4 60 60 2083 7523 *\001
+4 0 0 837 -1 16 10 1.5708 4 105 90 1827 6891 1\001
+4 0 0 835 -1 16 10 1.5708 4 60 60 2083 7523 *\001
+4 0 0 829 -1 16 10 1.5708 4 90 870 1075 8275 <<creates>>\001
+4 0 0 826 -1 16 10 1.5708 4 120 945 1015 2167 ConstantPool\001
+4 0 0 823 -1 16 10 1.5708 4 135 945 1423 2063 getConstant()\001
+4 0 0 818 -1 16 10 1.5708 4 120 1350 5295 3479 <<Code attribute>>\001
+4 0 0 815 -1 16 10 1.5708 4 120 1350 3763 4567 <<Class attribute>>\001
+4 0 0 812 -1 16 10 1.5708 4 120 1350 3763 1783 <<Class attribute>>\001
+4 0 0 809 -1 16 10 1.5708 4 120 1305 3759 9879 <<Field attribute>>\001
+4 0 0 807 -1 16 10 1.5708 4 105 90 2835 4395 1\001
+4 0 0 805 -1 16 10 1.5708 4 105 90 2783 7675 1\001
+4 0 0 803 -1 16 10 1.5708 4 60 60 3287 5419 *\001
+4 0 0 801 -1 16 10 1.5708 4 105 90 1867 5127 1\001
+-6
diff --git a/docs/eps/il.eps b/docs/eps/il.eps
new file mode 100644
index 00000000..f2ab8d92
--- /dev/null
+++ b/docs/eps/il.eps
@@ -0,0 +1,513 @@
+%!PS-Adobe-2.0 EPSF-2.0
+%%Title: il.eps
+%%Creator: fig2dev Version 3.2 Patchlevel 1
+%%CreationDate: Wed Dec 2 15:26:46 1998
+%%For: dahm@che (Markus Dahm,,,,,)
+%%Orientation: Portrait
+%%BoundingBox: 0 0 583 386
+%%Pages: 0
+%%BeginSetup
+%%EndSetup
+%%Magnification: 1.0000
+%%EndComments
+/$F2psDict 200 dict def
+$F2psDict begin
+$F2psDict /mtrx matrix put
+/col-1 {0 setgray} bind def
+/col0 {0.000 0.000 0.000 srgb} bind def
+/col1 {0.000 0.000 1.000 srgb} bind def
+/col2 {0.000 1.000 0.000 srgb} bind def
+/col3 {0.000 1.000 1.000 srgb} bind def
+/col4 {1.000 0.000 0.000 srgb} bind def
+/col5 {1.000 0.000 1.000 srgb} bind def
+/col6 {1.000 1.000 0.000 srgb} bind def
+/col7 {1.000 1.000 1.000 srgb} bind def
+/col8 {0.000 0.000 0.560 srgb} bind def
+/col9 {0.000 0.000 0.690 srgb} bind def
+/col10 {0.000 0.000 0.820 srgb} bind def
+/col11 {0.530 0.810 1.000 srgb} bind def
+/col12 {0.000 0.560 0.000 srgb} bind def
+/col13 {0.000 0.690 0.000 srgb} bind def
+/col14 {0.000 0.820 0.000 srgb} bind def
+/col15 {0.000 0.560 0.560 srgb} bind def
+/col16 {0.000 0.690 0.690 srgb} bind def
+/col17 {0.000 0.820 0.820 srgb} bind def
+/col18 {0.560 0.000 0.000 srgb} bind def
+/col19 {0.690 0.000 0.000 srgb} bind def
+/col20 {0.820 0.000 0.000 srgb} bind def
+/col21 {0.560 0.000 0.560 srgb} bind def
+/col22 {0.690 0.000 0.690 srgb} bind def
+/col23 {0.820 0.000 0.820 srgb} bind def
+/col24 {0.500 0.190 0.000 srgb} bind def
+/col25 {0.630 0.250 0.000 srgb} bind def
+/col26 {0.750 0.380 0.000 srgb} bind def
+/col27 {1.000 0.500 0.500 srgb} bind def
+/col28 {1.000 0.630 0.630 srgb} bind def
+/col29 {1.000 0.750 0.750 srgb} bind def
+/col30 {1.000 0.880 0.880 srgb} bind def
+/col31 {1.000 0.840 0.000 srgb} bind def
+
+end
+save
+-84.0 526.0 translate
+1 -1 scale
+
+/cp {closepath} bind def
+/ef {eofill} bind def
+/gr {grestore} bind def
+/gs {gsave} bind def
+/sa {save} bind def
+/rs {restore} bind def
+/l {lineto} bind def
+/m {moveto} bind def
+/rm {rmoveto} bind def
+/n {newpath} bind def
+/s {stroke} bind def
+/sh {show} bind def
+/slc {setlinecap} bind def
+/slj {setlinejoin} bind def
+/slw {setlinewidth} bind def
+/srgb {setrgbcolor} bind def
+/rot {rotate} bind def
+/sc {scale} bind def
+/sd {setdash} bind def
+/ff {findfont} bind def
+/sf {setfont} bind def
+/scf {scalefont} bind def
+/sw {stringwidth} bind def
+/tr {translate} bind def
+/tnt {dup dup currentrgbcolor
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
+ bind def
+/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
+ 4 -2 roll mul srgb} bind def
+/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
+/$F2psEnd {$F2psEnteredState restore end} def
+%%EndProlog
+
+$F2psBegin
+10 setmiterlimit
+n -1000 9337 m -1000 -1000 l 11587 -1000 l 11587 9337 l cp clip
+ 0.06299 0.06299 sc
+% Polyline
+7.500 slw
+ [60] 0 sd
+gs clippath
+5205 7530 m 5175 7650 l 5145 7530 l 5145 7665 l 5205 7665 l cp
+clip
+n 5175 6975 m 5175 7650 l gs col0 s gr gr
+ [] 0 sd
+% arrowhead
+n 5205 7530 m 5175 7650 l 5145 7530 l col0 s
+% Polyline
+ [60] 0 sd
+gs clippath
+5595 7095 m 5625 6975 l 5655 7095 l 5655 6960 l 5595 6960 l cp
+clip
+n 5625 7650 m 5625 6975 l gs col0 s gr gr
+ [] 0 sd
+% arrowhead
+n 5595 7095 m 5625 6975 l 5655 7095 l col0 s
+% Polyline
+ [60] 0 sd
+gs clippath
+5205 3930 m 5175 4050 l 5145 3930 l 5145 4065 l 5205 4065 l cp
+clip
+n 5175 3375 m 5175 4050 l gs col0 s gr gr
+ [] 0 sd
+% arrowhead
+n 5205 3930 m 5175 4050 l 5145 3930 l col0 s
+% Polyline
+ [60] 0 sd
+gs clippath
+5595 3495 m 5625 3375 l 5655 3495 l 5655 3360 l 5595 3360 l cp
+clip
+n 5625 4050 m 5625 3375 l gs col0 s gr gr
+ [] 0 sd
+% arrowhead
+n 5595 3495 m 5625 3375 l 5655 3495 l col0 s
+% Polyline
+n 4380 6750 m 4275 6750 4275 6870 105 arcto 4 {pop} repeat
+ 4275 6975 6420 6975 105 arcto 4 {pop} repeat
+ 6525 6975 6525 6855 105 arcto 4 {pop} repeat
+ 6525 6750 4380 6750 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+4500 6930 m
+gs 1 -1 sc (goto) col0 sh gr
+% Polyline
+n 4380 6300 m 4275 6300 4275 6420 105 arcto 4 {pop} repeat
+ 4275 6525 6420 6525 105 arcto 4 {pop} repeat
+ 6525 6525 6525 6405 105 arcto 4 {pop} repeat
+ 6525 6300 4380 6300 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+4455 6480 m
+gs 1 -1 sc (invokevirtual) col0 sh gr
+% Polyline
+n 4380 5850 m 4275 5850 4275 5970 105 arcto 4 {pop} repeat
+ 4275 6075 6420 6075 105 arcto 4 {pop} repeat
+ 6525 6075 6525 5955 105 arcto 4 {pop} repeat
+ 6525 5850 4380 5850 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+4500 6030 m
+gs 1 -1 sc (aload) col0 sh gr
+% Polyline
+n 4380 5400 m 4275 5400 4275 5520 105 arcto 4 {pop} repeat
+ 4275 5625 6420 5625 105 arcto 4 {pop} repeat
+ 6525 5625 6525 5505 105 arcto 4 {pop} repeat
+ 6525 5400 4380 5400 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+4500 5580 m
+gs 1 -1 sc (getstatic) col0 sh gr
+% Polyline
+n 4380 4950 m 4275 4950 4275 5070 105 arcto 4 {pop} repeat
+ 4275 5175 6420 5175 105 arcto 4 {pop} repeat
+ 6525 5175 6525 5055 105 arcto 4 {pop} repeat
+ 6525 4950 4380 4950 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+4500 5130 m
+gs 1 -1 sc (astore) col0 sh gr
+% Polyline
+n 4380 4500 m 4275 4500 4275 4620 105 arcto 4 {pop} repeat
+ 4275 4725 6420 4725 105 arcto 4 {pop} repeat
+ 6525 4725 6525 4605 105 arcto 4 {pop} repeat
+ 6525 4500 4380 4500 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+4500 4680 m
+gs 1 -1 sc (goto) col0 sh gr
+% Polyline
+n 4380 4050 m 4275 4050 4275 4170 105 arcto 4 {pop} repeat
+ 4275 4275 6420 4275 105 arcto 4 {pop} repeat
+ 6525 4275 6525 4155 105 arcto 4 {pop} repeat
+ 6525 4050 4380 4050 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+4455 4230 m
+gs 1 -1 sc (istore) col0 sh gr
+% Polyline
+gs clippath
+5595 4395 m 5625 4275 l 5655 4395 l 5655 4260 l 5595 4260 l cp
+clip
+n 5625 4500 m 5625 4275 l gs col0 s gr gr
+
+% arrowhead
+n 5595 4395 m 5625 4275 l 5655 4395 l col0 s
+% Polyline
+gs clippath
+5205 4380 m 5175 4500 l 5145 4380 l 5145 4515 l 5205 4515 l cp
+clip
+n 5175 4275 m 5175 4500 l gs col0 s gr gr
+
+% arrowhead
+n 5205 4380 m 5175 4500 l 5145 4380 l col0 s
+% Polyline
+gs clippath
+5595 4845 m 5625 4725 l 5655 4845 l 5655 4710 l 5595 4710 l cp
+clip
+n 5625 4950 m 5625 4725 l gs col0 s gr gr
+
+% arrowhead
+n 5595 4845 m 5625 4725 l 5655 4845 l col0 s
+% Polyline
+gs clippath
+5205 4830 m 5175 4950 l 5145 4830 l 5145 4965 l 5205 4965 l cp
+clip
+n 5175 4725 m 5175 4950 l gs col0 s gr gr
+
+% arrowhead
+n 5205 4830 m 5175 4950 l 5145 4830 l col0 s
+% Polyline
+gs clippath
+5595 5295 m 5625 5175 l 5655 5295 l 5655 5160 l 5595 5160 l cp
+clip
+n 5625 5400 m 5625 5175 l gs col0 s gr gr
+
+% arrowhead
+n 5595 5295 m 5625 5175 l 5655 5295 l col0 s
+% Polyline
+gs clippath
+5205 5280 m 5175 5400 l 5145 5280 l 5145 5415 l 5205 5415 l cp
+clip
+n 5175 5175 m 5175 5400 l gs col0 s gr gr
+
+% arrowhead
+n 5205 5280 m 5175 5400 l 5145 5280 l col0 s
+% Polyline
+gs clippath
+5595 5745 m 5625 5625 l 5655 5745 l 5655 5610 l 5595 5610 l cp
+clip
+n 5625 5850 m 5625 5625 l gs col0 s gr gr
+
+% arrowhead
+n 5595 5745 m 5625 5625 l 5655 5745 l col0 s
+% Polyline
+gs clippath
+5205 5730 m 5175 5850 l 5145 5730 l 5145 5865 l 5205 5865 l cp
+clip
+n 5175 5625 m 5175 5850 l gs col0 s gr gr
+
+% arrowhead
+n 5205 5730 m 5175 5850 l 5145 5730 l col0 s
+% Polyline
+gs clippath
+5595 6195 m 5625 6075 l 5655 6195 l 5655 6060 l 5595 6060 l cp
+clip
+n 5625 6300 m 5625 6075 l gs col0 s gr gr
+
+% arrowhead
+n 5595 6195 m 5625 6075 l 5655 6195 l col0 s
+% Polyline
+gs clippath
+5205 6180 m 5175 6300 l 5145 6180 l 5145 6315 l 5205 6315 l cp
+clip
+n 5175 6075 m 5175 6300 l gs col0 s gr gr
+
+% arrowhead
+n 5205 6180 m 5175 6300 l 5145 6180 l col0 s
+% Polyline
+gs clippath
+5595 6645 m 5625 6525 l 5655 6645 l 5655 6510 l 5595 6510 l cp
+clip
+n 5625 6750 m 5625 6525 l gs col0 s gr gr
+
+% arrowhead
+n 5595 6645 m 5625 6525 l 5655 6645 l col0 s
+% Polyline
+gs clippath
+5205 6630 m 5175 6750 l 5145 6630 l 5145 6765 l 5205 6765 l cp
+clip
+n 5175 6525 m 5175 6750 l gs col0 s gr gr
+
+% arrowhead
+n 5205 6630 m 5175 6750 l 5145 6630 l col0 s
+% Polyline
+n 4380 7650 m 4275 7650 4275 7770 105 arcto 4 {pop} repeat
+ 4275 7875 6420 7875 105 arcto 4 {pop} repeat
+ 6525 7875 6525 7755 105 arcto 4 {pop} repeat
+ 6525 7650 4380 7650 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+4455 7830 m
+gs 1 -1 sc (iload) col0 sh gr
+% Polyline
+n 4380 8100 m 4275 8100 4275 8220 105 arcto 4 {pop} repeat
+ 4275 8325 6420 8325 105 arcto 4 {pop} repeat
+ 6525 8325 6525 8205 105 arcto 4 {pop} repeat
+ 6525 8100 4380 8100 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+4455 8280 m
+gs 1 -1 sc (ireturn) col0 sh gr
+% Polyline
+gs clippath
+5595 7995 m 5625 7875 l 5655 7995 l 5655 7860 l 5595 7860 l cp
+clip
+n 5625 8100 m 5625 7875 l gs col0 s gr gr
+
+% arrowhead
+n 5595 7995 m 5625 7875 l 5655 7995 l col0 s
+% Polyline
+gs clippath
+5205 7980 m 5175 8100 l 5145 7980 l 5145 8115 l 5205 8115 l cp
+clip
+n 5175 7875 m 5175 8100 l gs col0 s gr gr
+
+% arrowhead
+n 5205 7980 m 5175 8100 l 5145 7980 l col0 s
+% Polyline
+gs clippath
+5595 2595 m 5625 2475 l 5655 2595 l 5655 2460 l 5595 2460 l cp
+clip
+n 5625 2700 m 5625 2475 l gs col0 s gr gr
+
+% arrowhead
+n 5595 2595 m 5625 2475 l 5655 2595 l col0 s
+% Polyline
+gs clippath
+5205 2580 m 5175 2700 l 5145 2580 l 5145 2715 l 5205 2715 l cp
+clip
+n 5175 2475 m 5175 2700 l gs col0 s gr gr
+
+% arrowhead
+n 5205 2580 m 5175 2700 l 5145 2580 l col0 s
+% Polyline
+n 4380 3150 m 4275 3150 4275 3270 105 arcto 4 {pop} repeat
+ 4275 3375 6420 3375 105 arcto 4 {pop} repeat
+ 6525 3375 6525 3255 105 arcto 4 {pop} repeat
+ 6525 3150 4380 3150 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+4500 3330 m
+gs 1 -1 sc (getstatic) col0 sh gr
+% Polyline
+n 4380 2700 m 4275 2700 4275 2820 105 arcto 4 {pop} repeat
+ 4275 2925 6420 2925 105 arcto 4 {pop} repeat
+ 6525 2925 6525 2805 105 arcto 4 {pop} repeat
+ 6525 2700 4380 2700 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+4455 2880 m
+gs 1 -1 sc (istore) col0 sh gr
+% Polyline
+n 4380 2250 m 4275 2250 4275 2370 105 arcto 4 {pop} repeat
+ 4275 2475 6420 2475 105 arcto 4 {pop} repeat
+ 6525 2475 6525 2355 105 arcto 4 {pop} repeat
+ 6525 2250 4380 2250 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+4500 2430 m
+gs 1 -1 sc (sipush) col0 sh gr
+% Polyline
+gs clippath
+5595 3045 m 5625 2925 l 5655 3045 l 5655 2910 l 5595 2910 l cp
+clip
+n 5625 3150 m 5625 2925 l gs col0 s gr gr
+
+% arrowhead
+n 5595 3045 m 5625 2925 l 5655 3045 l col0 s
+% Polyline
+gs clippath
+5205 3030 m 5175 3150 l 5145 3030 l 5145 3165 l 5205 3165 l cp
+clip
+n 5175 2925 m 5175 3150 l gs col0 s gr gr
+
+% arrowhead
+n 5205 3030 m 5175 3150 l 5145 3030 l col0 s
+% Polyline
+n 1350 5175 m 3600 5175 l 3600 5625 l 1350 5625 l cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+1575 5400 m
+gs 1 -1 sc (IOException e1) col0 sh gr
+% Polyline
+n 1575 5175 m 1575 4950 l 3825 4950 l 3825 5400 l 3600 5400 l 3600 5175 l
+ 1575 5175 l cp gs 0.00 setgray ef gr gs col0 s gr
+% Polyline
+n 1350 3600 m 3600 3600 l 3600 4050 l 1350 4050 l cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+1575 3825 m
+gs 1 -1 sc (int n) col0 sh gr
+% Polyline
+n 1575 3600 m 1575 3375 l 3825 3375 l 3825 3825 l 3600 3825 l 3600 3600 l
+ 1575 3600 l cp gs 0.00 setgray ef gr gs col0 s gr
+% Polyline
+n 7200 4050 m 10350 4050 l 10350 4500 l 7200 4500 l cp gs col0 s gr
+% Polyline
+n 7425 4050 m 7425 3825 l 10575 3825 l 10575 4275 l 10350 4275 l 10350 4050 l
+ 8325 4050 l gs 0.00 setgray ef gr gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+7425 4275 m
+gs 1 -1 sc (Exception handler 1) col0 sh gr
+% Polyline
+gs clippath
+4152 5071 m 4275 5085 l 4160 5131 l 4294 5113 l 4286 5053 l cp
+clip
+n 3600 5175 m 4275 5085 l gs col0 s gr gr
+
+% arrowhead
+n 4152 5071 m 4275 5085 l 4160 5131 l 4156 5101 l 4152 5071 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+4190 2475 m 4275 2385 l 4243 2504 l 4309 2386 l 4256 2357 l cp
+clip
+n 3600 3600 m 4275 2385 l gs col0 s gr gr
+
+% arrowhead
+n 4190 2475 m 4275 2385 l 4243 2504 l 4217 2490 l 4190 2475 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+4221 6324 m 4275 6435 l 4175 6362 l 4262 6466 l 4308 6427 l cp
+clip
+n 3600 5625 m 4275 6435 l gs col0 s gr gr
+
+% arrowhead
+n 4221 6324 m 4275 6435 l 4175 6362 l 4198 6343 l 4221 6324 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+6635 5029 m 6525 5085 l 6596 4984 l 6494 5072 l 6533 5117 l cp
+clip
+n 7200 4500 m 6525 5085 l gs col0 s gr gr
+
+% arrowhead
+n 6635 5029 m 6525 5085 l 6596 4984 l 6616 5006 l 6635 5029 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+6645 4215 m 6525 4185 l 6645 4155 l 6510 4155 l 6510 4215 l cp
+clip
+n 7200 4185 m 6525 4185 l gs col0 s gr gr
+
+% arrowhead
+n 6645 4215 m 6525 4185 l 6645 4155 l 6645 4185 l 6645 4215 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+6582 3395 m 6525 3285 l 6627 3355 l 6538 3254 l 6493 3294 l cp
+clip
+n 7200 4050 m 6525 3285 l gs col0 s gr gr
+
+% arrowhead
+n 6582 3395 m 6525 3285 l 6627 3355 l 6604 3375 l 6582 3395 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+4329 7977 m 4320 8100 l 4269 7987 l 4293 8120 l 4352 8110 l cp
+clip
+n 3600 4050 m 4320 8100 l gs col0 s gr gr
+
+% arrowhead
+n 4329 7977 m 4320 8100 l 4269 7987 l 4299 7982 l 4329 7977 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+6649 7784 m 6525 7785 l 6633 7726 l 6503 7760 l 6518 7818 l cp
+clip
+n 6525 4635 m 6527 4636 l 6532 4640 l 6542 4646 l 6556 4655 l 6575 4667 l
+ 6600 4683 l 6628 4702 l 6661 4723 l 6695 4746 l 6731 4771 l
+ 6768 4796 l 6804 4821 l 6838 4845 l 6871 4869 l 6902 4892 l
+ 6931 4915 l 6958 4936 l 6983 4957 l 7005 4977 l 7026 4996 l
+ 7045 5015 l 7063 5034 l 7080 5054 l 7095 5073 l 7110 5093 l
+ 7124 5113 l 7137 5133 l 7150 5154 l 7162 5176 l 7174 5199 l
+ 7185 5223 l 7196 5247 l 7207 5273 l 7216 5299 l 7226 5326 l
+ 7235 5353 l 7243 5381 l 7251 5409 l 7258 5438 l 7265 5467 l
+ 7271 5496 l 7276 5525 l 7281 5554 l 7286 5582 l 7290 5611 l
+ 7293 5639 l 7296 5667 l 7299 5694 l 7301 5721 l 7303 5748 l
+ 7305 5775 l 7306 5802 l 7308 5829 l 7309 5857 l 7310 5885 l
+ 7310 5914 l 7311 5944 l 7311 5974 l 7311 6004 l 7311 6035 l
+ 7310 6067 l 7310 6099 l 7309 6131 l 7308 6163 l 7307 6195 l
+ 7306 6227 l 7305 6258 l 7304 6289 l 7302 6320 l 7301 6350 l
+ 7299 6379 l 7298 6407 l 7296 6435 l 7295 6462 l 7293 6489 l
+ 7292 6514 l 7290 6540 l 7288 6567 l 7287 6595 l 7285 6622 l
+ 7283 6650 l 7281 6677 l 7279 6706 l 7277 6734 l 7275 6762 l
+ 7273 6791 l 7270 6820 l 7268 6848 l 7265 6877 l 7263 6905 l
+ 7260 6932 l 7257 6959 l 7255 6986 l 7252 7011 l 7249 7036 l
+ 7246 7060 l 7243 7084 l 7240 7106 l 7237 7128 l 7233 7149 l
+ 7230 7170 l 7226 7195 l 7221 7219 l 7216 7243 l 7211 7268 l
+ 7205 7292 l 7198 7317 l 7191 7342 l 7183 7366 l 7174 7390 l
+ 7165 7414 l 7155 7436 l 7144 7459 l 7133 7480 l 7121 7500 l
+ 7108 7519 l 7095 7537 l 7081 7553 l 7066 7569 l 7051 7584 l
+ 7035 7598 l 7020 7609 l 7003 7621 l 6985 7632 l 6966 7642 l
+ 6945 7653 l 6921 7663 l 6895 7674 l 6867 7684 l 6836 7695 l
+ 6803 7706 l 6767 7717 l 6730 7728 l 6693 7739 l 6656 7750 l
+ 6622 7759 l 6592 7767 l 6567 7774 l 6525 7785 l gs col0 s gr gr
+
+% arrowhead
+n 6649 7784 m 6525 7785 l 6633 7726 l 6641 7755 l 6649 7784 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+6619 7615 m 6525 7695 l 6570 7580 l 6492 7690 l 6541 7725 l cp
+clip
+n 6525 6840 m 6526 6843 l 6529 6850 l 6533 6863 l 6540 6882 l 6549 6908 l
+ 6560 6938 l 6572 6973 l 6585 7010 l 6598 7048 l 6610 7086 l
+ 6622 7122 l 6632 7157 l 6642 7189 l 6650 7219 l 6657 7246 l
+ 6663 7271 l 6667 7294 l 6671 7315 l 6673 7335 l 6675 7354 l
+ 6675 7373 l 6674 7394 l 6672 7415 l 6669 7435 l 6663 7455 l
+ 6656 7476 l 6648 7498 l 6637 7520 l 6624 7544 l 6610 7568 l
+ 6595 7593 l 6579 7617 l 6564 7640 l 6550 7660 l 6525 7695 l gs col0 s gr gr
+
+% arrowhead
+n 6619 7615 m 6525 7695 l 6570 7580 l 6595 7597 l 6619 7615 l cp gs 0.00 setgray ef gr col0 s
+$F2psEnd
+rs
diff --git a/docs/eps/il.fig b/docs/eps/il.fig
new file mode 100644
index 00000000..706e51ce
--- /dev/null
+++ b/docs/eps/il.fig
@@ -0,0 +1,225 @@
+#FIG 3.2
+Portrait
+Center
+Metric
+A4
+100.00
+Single
+-2
+1200 2
+6 4275 2250 6525 8325
+6 5130 6975 5670 7650
+6 5130 6975 5220 7650
+2 1 1 1 0 7 100 0 -1 4.000 0 0 -1 1 0 2
+ 0 0 1.00 60.00 120.00
+ 5175 6975 5175 7650
+-6
+2 1 1 1 0 7 100 0 -1 4.000 0 0 -1 1 0 2
+ 0 0 1.00 60.00 120.00
+ 5625 7650 5625 6975
+-6
+6 5130 3375 5670 4050
+2 1 1 1 0 7 100 0 -1 4.000 0 0 -1 1 0 2
+ 0 0 1.00 60.00 120.00
+ 5175 3375 5175 4050
+2 1 1 1 0 7 100 0 -1 4.000 0 0 -1 1 0 2
+ 0 0 1.00 60.00 120.00
+ 5625 4050 5625 3375
+-6
+6 4275 4050 6525 6975
+6 4275 6750 6525 6975
+2 4 0 1 0 7 100 0 -1 0.000 0 0 7 0 0 5
+ 6525 6975 6525 6750 4275 6750 4275 6975 6525 6975
+4 0 0 100 0 14 14 0.0000 4 195 540 4500 6930 goto\001
+-6
+6 4275 6300 6525 6525
+2 4 0 1 0 7 100 0 -1 0.000 0 0 7 0 0 5
+ 6525 6525 6525 6300 4275 6300 4275 6525 6525 6525
+4 0 0 100 0 14 14 0.0000 4 150 1755 4455 6480 invokevirtual\001
+-6
+6 4275 5850 6525 6075
+2 4 0 1 0 7 100 0 -1 0.000 0 0 7 0 0 5
+ 6525 6075 6525 5850 4275 5850 4275 6075 6525 6075
+4 0 0 100 0 14 14 0.0000 4 150 675 4500 6030 aload\001
+-6
+6 4275 5400 6525 5625
+2 4 0 1 0 7 100 0 -1 0.000 0 0 7 0 0 5
+ 6525 5625 6525 5400 4275 5400 4275 5625 6525 5625
+4 0 0 100 0 14 14 0.0000 4 195 1215 4500 5580 getstatic\001
+-6
+6 4275 4950 6525 5175
+2 4 0 1 0 7 100 0 -1 0.000 0 0 7 0 0 5
+ 6525 5175 6525 4950 4275 4950 4275 5175 6525 5175
+4 0 0 100 0 14 14 0.0000 4 150 810 4500 5130 astore\001
+-6
+6 4275 4500 6525 4725
+2 4 0 1 0 7 100 0 -1 0.000 0 0 7 0 0 5
+ 6525 4725 6525 4500 4275 4500 4275 4725 6525 4725
+4 0 0 100 0 14 14 0.0000 4 195 540 4500 4680 goto\001
+-6
+6 4275 4050 6525 4275
+2 4 0 1 0 7 100 0 -1 0.000 0 0 7 0 0 5
+ 6525 4275 6525 4050 4275 4050 4275 4275 6525 4275
+4 0 0 100 0 14 14 0.0000 4 150 810 4455 4230 istore\001
+-6
+6 4950 4275 5850 4500
+2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
+ 0 0 1.00 60.00 120.00
+ 5625 4500 5625 4275
+2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
+ 0 0 1.00 60.00 120.00
+ 5175 4275 5175 4500
+-6
+6 4950 4725 5850 4950
+2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
+ 0 0 1.00 60.00 120.00
+ 5625 4950 5625 4725
+2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
+ 0 0 1.00 60.00 120.00
+ 5175 4725 5175 4950
+-6
+6 4950 5175 5850 5400
+2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
+ 0 0 1.00 60.00 120.00
+ 5625 5400 5625 5175
+2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
+ 0 0 1.00 60.00 120.00
+ 5175 5175 5175 5400
+-6
+6 4950 5625 5850 5850
+2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
+ 0 0 1.00 60.00 120.00
+ 5625 5850 5625 5625
+2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
+ 0 0 1.00 60.00 120.00
+ 5175 5625 5175 5850
+-6
+6 4950 6075 5850 6300
+2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
+ 0 0 1.00 60.00 120.00
+ 5625 6300 5625 6075
+2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
+ 0 0 1.00 60.00 120.00
+ 5175 6075 5175 6300
+-6
+6 4950 6525 5850 6750
+2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
+ 0 0 1.00 60.00 120.00
+ 5625 6750 5625 6525
+2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
+ 0 0 1.00 60.00 120.00
+ 5175 6525 5175 6750
+-6
+-6
+6 4275 7650 6525 8325
+6 4275 7650 6525 7875
+2 4 0 1 0 7 100 0 -1 0.000 0 0 7 0 0 5
+ 6525 7875 6525 7650 4275 7650 4275 7875 6525 7875
+4 0 0 100 0 14 14 0.0000 4 150 675 4455 7830 iload\001
+-6
+6 4275 8100 6525 8325
+2 4 0 1 0 7 100 0 -1 0.000 0 0 7 0 0 5
+ 6525 8325 6525 8100 4275 8100 4275 8325 6525 8325
+4 0 0 100 0 14 14 0.0000 4 150 945 4455 8280 ireturn\001
+-6
+6 4950 7875 5850 8100
+2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
+ 0 0 1.00 60.00 120.00
+ 5625 8100 5625 7875
+2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
+ 0 0 1.00 60.00 120.00
+ 5175 7875 5175 8100
+-6
+-6
+6 4275 2250 6525 3375
+6 4950 2475 5850 2700
+2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
+ 0 0 1.00 60.00 120.00
+ 5625 2700 5625 2475
+2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
+ 0 0 1.00 60.00 120.00
+ 5175 2475 5175 2700
+-6
+6 4275 3150 6525 3375
+2 4 0 1 0 7 100 0 -1 0.000 0 0 7 0 0 5
+ 6525 3375 6525 3150 4275 3150 4275 3375 6525 3375
+4 0 0 100 0 14 14 0.0000 4 195 1215 4500 3330 getstatic\001
+-6
+6 4275 2700 6525 2925
+2 4 0 1 0 7 100 0 -1 0.000 0 0 7 0 0 5
+ 6525 2925 6525 2700 4275 2700 4275 2925 6525 2925
+4 0 0 100 0 14 14 0.0000 4 150 810 4455 2880 istore\001
+-6
+6 4275 2250 6525 2475
+2 4 0 1 0 7 100 0 -1 0.000 0 0 7 0 0 5
+ 6525 2475 6525 2250 4275 2250 4275 2475 6525 2475
+4 0 0 100 0 14 14 0.0000 4 195 810 4500 2430 sipush\001
+-6
+6 4950 2925 5850 3150
+2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
+ 0 0 1.00 60.00 120.00
+ 5625 3150 5625 2925
+2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
+ 0 0 1.00 60.00 120.00
+ 5175 2925 5175 3150
+-6
+-6
+-6
+6 1350 4950 3825 5625
+6 1350 5175 3600 5625
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 1350 5175 3600 5175 3600 5625 1350 5625 1350 5175
+4 0 0 100 0 14 14 0.0000 4 195 1890 1575 5400 IOException e1\001
+-6
+2 1 0 1 0 0 100 0 20 0.000 0 0 -1 0 0 7
+ 1575 5175 1575 4950 3825 4950 3825 5400 3600 5400 3600 5175
+ 1575 5175
+-6
+6 1350 3375 3825 4050
+6 1350 3600 3600 4050
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 1350 3600 3600 3600 3600 4050 1350 4050 1350 3600
+4 0 0 100 0 14 14 0.0000 4 150 675 1575 3825 int n\001
+-6
+2 1 0 1 0 0 100 0 20 0.000 0 0 -1 0 0 7
+ 1575 3600 1575 3375 3825 3375 3825 3825 3600 3825 3600 3600
+ 1575 3600
+-6
+6 7200 3825 10575 4500
+2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
+ 7200 4050 10350 4050 10350 4500 7200 4500 7200 4050
+2 1 0 1 0 0 100 0 20 0.000 0 0 -1 0 0 7
+ 7425 4050 7425 3825 10575 3825 10575 4275 10350 4275 10350 4050
+ 8325 4050
+4 0 0 100 0 14 14 0.0000 4 195 2565 7425 4275 Exception handler 1\001
+-6
+2 1 0 1 0 7 100 0 -1 0.000 0 0 7 1 0 2
+ 1 1 1.00 60.00 120.00
+ 3600 5175 4275 5085
+2 1 0 1 0 7 100 0 -1 0.000 0 0 7 1 0 2
+ 1 1 1.00 60.00 120.00
+ 3600 3600 4275 2385
+2 1 0 1 0 7 100 0 -1 0.000 0 0 7 1 0 2
+ 1 1 1.00 60.00 120.00
+ 3600 5625 4275 6435
+2 1 0 1 0 7 100 0 -1 0.000 0 0 7 1 0 2
+ 1 1 1.00 60.00 120.00
+ 7200 4500 6525 5085
+2 1 0 1 0 7 100 0 -1 0.000 0 0 7 1 0 2
+ 1 1 1.00 60.00 120.00
+ 7200 4185 6525 4185
+2 1 0 1 0 7 100 0 -1 0.000 0 0 7 1 0 2
+ 1 1 1.00 60.00 120.00
+ 7200 4050 6525 3285
+2 1 0 1 0 7 100 0 -1 0.000 0 0 7 1 0 2
+ 1 1 1.00 60.00 120.00
+ 3600 4050 4320 8100
+3 0 0 1 0 7 100 0 -1 0.000 0 1 0 7
+ 1 1 1.00 60.00 120.00
+ 6525 4635 7200 5040 7335 5760 7290 6570 7245 7200 7110 7650
+ 6525 7785
+ 0.000 1.000 1.000 1.000 1.000 1.000 0.000
+3 0 0 1 0 7 100 0 -1 0.000 0 1 0 3
+ 1 1 1.00 60.00 120.00
+ 6525 6840 6750 7425 6525 7695
+ 0.000 1.000 0.000
diff --git a/docs/eps/instructions.eps b/docs/eps/instructions.eps
new file mode 100644
index 00000000..2ed46dc5
--- /dev/null
+++ b/docs/eps/instructions.eps
@@ -0,0 +1,445 @@
+%!PS-Adobe-3.0 EPSF-3.0
+%%Title: Rose Diagram(s)
+%%Creator: AdobePS5.dll Version 5.0
+%%CreationDate: 7/7/1999 17:43:39
+%%Pages: 1
+%%Orientation: Portrait
+%%PageOrder: Ascend
+%%DocumentNeededResources: (atend)
+%%DocumentSuppliedResources: (atend)
+%%DocumentData: Clean7Bit
+%%TargetDevice: (HP LaserJet 5Si) (2014.108) 1
+%%LanguageLevel: 2
+%%BoundingBox: 13 12 410 830
+%%EndComments
+%%BeginProcSet: epsffit 1 0
+gsave
+1409.418 -167.686 translate
+90 rotate
+1.711 1.711 scale
+%%EndProcSet
+
+
+%%BeginDefaults
+%%PageBoundingBox: 13 12 582 830
+%%EndDefaults
+
+%%BeginProlog
+%%BeginResource: file Pscript_WinNT_ErrorHandler 5.0 0
+/currentpacking where{pop/oldpack currentpacking def/setpacking where{pop false
+setpacking}if}if/$brkpage 64 dict def $brkpage begin/prnt{dup type/stringtype
+ne{=string cvs}if dup length 6 mul/tx exch def/ty 10 def currentpoint/toy exch
+def/tox exch def 1 setgray newpath tox toy 2 sub moveto 0 ty rlineto tx 0
+rlineto 0 ty neg rlineto closepath fill tox toy moveto 0 setgray show}bind def
+/nl{currentpoint exch pop lmargin exch moveto 0 -10 rmoveto}def/=={/cp 0 def
+typeprint nl}def/typeprint{dup type exec}readonly def/lmargin 72 def/rmargin 72
+def/tprint{dup length cp add rmargin gt{nl/cp 0 def}if dup length cp add/cp
+exch def prnt}readonly def/cvsprint{=string cvs tprint( )tprint}readonly def
+/integertype{cvsprint}readonly def/realtype{cvsprint}readonly def/booleantype
+{cvsprint}readonly def/operatortype{(--)tprint =string cvs tprint(-- )tprint}
+readonly def/marktype{pop(-mark- )tprint}readonly def/dicttype{pop
+(-dictionary- )tprint}readonly def/nulltype{pop(-null- )tprint}readonly def
+/filetype{pop(-filestream- )tprint}readonly def/savetype{pop(-savelevel- )
+tprint}readonly def/fonttype{pop(-fontid- )tprint}readonly def/nametype{dup
+xcheck not{(/)tprint}if cvsprint}readonly def/stringtype{dup rcheck{(\()tprint
+tprint(\))tprint}{pop(-string- )tprint}ifelse}readonly def/arraytype{dup rcheck
+{dup xcheck{({)tprint{typeprint}forall(})tprint}{([)tprint{typeprint}forall(])
+tprint}ifelse}{pop(-array- )tprint}ifelse}readonly def/packedarraytype{dup
+rcheck{dup xcheck{({)tprint{typeprint}forall(})tprint}{([)tprint{typeprint}
+forall(])tprint}ifelse}{pop(-packedarray- )tprint}ifelse}readonly def/courier
+/Courier findfont 10 scalefont def end errordict/handleerror{systemdict begin
+$error begin $brkpage begin newerror{/newerror false store vmstatus pop pop 0
+ne{grestoreall}if showpage initgraphics courier setfont lmargin 720 moveto
+(ERROR: )prnt errorname prnt nl(OFFENDING COMMAND: )prnt/command load prnt
+$error/ostack known{nl nl(STACK:)prnt nl nl $error/ostack get aload length{==}
+repeat}if systemdict/showpage get exec(%%[ Error: )print errorname =print
+(; OffendingCommand: )print/command load =print( ]%%)= flush}if end end end}dup
+0 systemdict put dup 4 $brkpage put bind readonly put/currentpacking where{pop
+/setpacking where{pop oldpack setpacking}if}if
+%%EndResource
+userdict /Pscript_WinNT_Incr 230 dict dup begin put
+%%BeginResource: file Pscript_FatalError 5.0 0
+/FatalErrorIf{{initgraphics findfont exch scalefont setfont counttomark 3 div
+cvi{moveto show}repeat showpage quit}{cleartomark}ifelse}bind def
+%%EndResource
+/VM?{vmstatus exch sub exch pop gt{[
+(This job requires more memory than is available in this printer.)100 500
+(Try one or more of the following, and then print again:)100 485
+(For the output format, choose Optimize For Portability.)115 470
+(In the Device Settings page, make sure the Available PostScript Memory is accurate.)
+115 455(Reduce the number of fonts in the document.)115 440
+(Print the document in parts.)115 425 12/Times-Roman showpage
+(%%[ PrinterError: Low Printer VM ]%%)= true FatalErrorIf}if}bind def
+%%BeginResource: file Pscript_Win_Basic 5.0 0
+/d/def load def/,/load load d/~/exch , d/?/ifelse , d/!/pop , d/`/begin , d/^
+/index , d/@/dup , d/+/translate , d/$/roll , d/U/userdict , d/M/moveto , d/-
+/rlineto , d/&/currentdict , d/:/gsave , d/;/grestore , d/F/false , d/T/true ,
+d/N/newpath , d/E/end , d/Ac/arc , d/An/arcn , d/A/ashow , d/D/awidthshow , d/C
+/closepath , d/V/div , d/O/eofill , d/L/fill , d/I/lineto , d/-c/curveto , d/-M
+/rmoveto , d/+S/scale , d/Ji/setfont , d/Lc/setlinecap , d/Lj/setlinejoin , d
+/Lw/setlinewidth , d/Lm/setmiterlimit , d/sd/setdash , d/S/show , d/LH/showpage
+, d/K/stroke , d/W/widthshow , d/R/rotate , d/P/eoclip , d/L2? false
+/languagelevel where{pop languagelevel 2 ge{pop true}if}if d L2?{/xS/xshow , d
+/yS/yshow , d/zS/xyshow , d}if/b{bind d}bind d/bd{bind d}bind d/xd{~ d}bd/ld{,
+d}bd/lw/Lw ld/lc/Lc ld/lj/Lj ld/sg/setgray ld/ADO_mxRot null d/self & d/OrgMx
+matrix currentmatrix d/reinitialize{: OrgMx setmatrix[/TextInit/GraphInit
+/UtilsInit counttomark{@ where{self eq}{F}?{cvx exec}{!}?}repeat cleartomark ;}
+b/initialize{`{/ADO_mxRot ~ d/TextInitialised? F d reinitialize E}{U
+/Pscript_Win_Data 230 dict @ ` put/ADO_mxRot ~ d/TextInitialised? F d
+reinitialize}?}b/terminate{!{& self eq{exit}{E}?}loop E}b/suspend/terminate , d
+/resume{` Pscript_Win_Data `}b/snap{transform 0.25 sub round 0.25 add ~ 0.25
+sub round 0.25 add ~ itransform}b/dsnap{dtransform round ~ round ~ idtransform}
+b<04>cvn{}d/rr{1 ^ 0 - 0 ~ - neg 0 - C}b/rp{4 2 $ M 1 ^ 0 - 0 ~ - neg 0 -}b
+/solid{[]0 sd}b/g{@ not{U/DefIf_save save put}if U/DefIf_bool 2 ^ put}b
+/DefIf_El{if U/DefIf_bool get not @{U/DefIf_save get restore}if}b/e{DefIf_El !}
+b/UDF{L2?{undefinefont}{!}?}b/UDR{L2?{undefineresource}{! !}?}b
+%%EndResource
+%%BeginResource: file Pscript_Win_Utils_L2 5.0 0
+/rf/rectfill , d/fx{1 1 dtransform @ 0 ge{1 sub 0.5}{1 add -0.5}? 3 -1 $ @ 0 ge
+{1 sub 0.5}{1 add -0.5}? 3 1 $ 4 1 $ idtransform 4 -2 $ idtransform}b/BZ{4 -2 $
+snap + +S fx rf}b/rs/rectstroke , d/rc/rectclip , d/UtilsInit{currentglobal{F
+setglobal}if}b/scol{! setcolor}b/colspA/DeviceGray d/colspABC/DeviceRGB d
+/colspRefresh{colspABC setcolorspace}b/SetColSpace{colspABC setcolorspace}b
+%%EndResource
+end
+%%EndProlog
+
+%%BeginSetup
+[ 1 0 0 1 0 0 ] false Pscript_WinNT_Incr dup /initialize get exec
+1 setlinecap 1 setlinejoin
+/mysetup [ 0.24 0 0 -0.24 13.43905 829.74047 ] def
+%%EndSetup
+
+%%Page: 1 1
+%%PageBoundingBox: 13 12 582 830
+%%EndPageComments
+%%BeginPageSetup
+/DeviceRGB dup setcolorspace /colspABC exch def mysetup concat colspRefresh
+%%EndPageSetup
+
+Pscript_WinNT_Incr begin
+%%BeginResource: file Pscript_Win_GdiObject 5.0 0
+/SavedCTM null d/CTMsave{/SavedCTM SavedCTM currentmatrix d}b/CTMrestore
+{SavedCTM setmatrix}b/mp null d/ADO_mxRot null d/GDIHMatrix null d
+/GDIHPatternDict 22 dict d GDIHPatternDict `/PatternType 1 d/PaintType 2 d/Reps
+L2?{1}{5}? d/XStep 8 Reps mul d/YStep XStep d/BBox[0 0 XStep YStep]d/TilingType
+1 d/PaintProc{` 1 Lw[]0 sd PaintData , exec E}b/FGnd null d/BGnd null d
+/HS_Horizontal{horiz}b/HS_Vertical{vert}b/HS_FDiagonal{fdiag}b/HS_BDiagonal
+{biag}b/HS_Cross{horiz vert}b/HS_DiagCross{fdiag biag}b/MaxXYStep XStep YStep
+gt{XStep}{YStep}? d/horiz{Reps{0 4 M XStep 0 - 0 8 +}repeat 0 -8 Reps mul + K}b
+/vert{Reps{4 0 M 0 YStep - 8 0 +}repeat 0 -8 Reps mul + K}b/biag{Reps{0 0 M
+MaxXYStep @ - 0 YStep neg M MaxXYStep @ - 0 8 +}repeat 0 -8 Reps mul + 0 YStep
+M 8 8 - K}b/fdiag{Reps{0 0 M MaxXYStep @ neg - 0 YStep M MaxXYStep @ neg - 0 8
++}repeat 0 -8 Reps mul + MaxXYStep @ M 8 -8 - K}b E/makehatch{4 -2 $/yOrg ~ d
+/xOrg ~ d GDIHPatternDict/PaintData 3 -1 $ put CTMsave GDIHMatrix setmatrix
+GDIHPatternDict matrix xOrg yOrg + mp CTMrestore ~ U ~ 2 ^ put}b/h0{/h0
+/HS_Horizontal makehatch}b/h1{/h1/HS_Vertical makehatch}b/h2{/h2/HS_FDiagonal
+makehatch}b/h3{/h3/HS_BDiagonal makehatch}b/h4{/h4/HS_Cross makehatch}b/h5{/h5
+/HS_DiagCross makehatch}b/GDIBWPatternDict 25 dict @ `/PatternType 1 d
+/PaintType L2?{1}{2}? d/RepsV L2?{1}{6}? d/RepsH L2?{1}{5}? d/BBox[0 0 RepsH 1]
+d/TilingType 1 d/XStep 1 d/YStep 1 d/Height 8 RepsV mul d/Width 8 d/mx[Width 0
+0 Height neg 0 Height]d/FGnd null d/BGnd null d/SetBGndFGnd L2?{{FGnd null ne
+{FGnd aload ! scol BBox aload ! 2 ^ sub ~ 3 ^ sub ~ rf}if BGnd null ne{BGnd
+aload ! scol}if}}{{}}? b/PaintProc{` SetBGndFGnd RepsH{Width Height F mx
+PaintData imagemask Width 0 +}repeat E}b E d/GDIBWPatternMx null d/pfprep{save
+8 1 $/PatternOfTheDay 8 1 $ GDIBWPatternDict `/yOrg ~ d/xOrg ~ d/PaintData ~ d
+/yExt ~ d/Width ~ d/FGnd ~ d/BGnd ~ d/Height yExt RepsV mul d/mx[Width 0 0
+Height 0 0]d E : GDIBWPatternDict ` Width Height E dsnap +S/GDIBWPatternMx
+matrix currentmatrix d ; CTMsave GDIBWPatternMx setmatrix GDIBWPatternDict @ `
+xOrg yOrg E matrix + mp CTMrestore ~ !}b/pfbf{/fEOFill ~ d pfprep hbf fEOFill
+{O}{L}? restore}b/GraphInit{GDIHMatrix null eq{/SavedCTM matrix d : ADO_mxRot
+concat 0 0 snap + : 0.48 @ GDIHPatternDict ` YStep mul ~ XStep mul ~ dsnap
+YStep V ~ XStep V ~ E +S/GDIHMatrix matrix currentmatrix readonly d ; : 0.24
+-0.24 +S GDIBWPatternDict ` Width Height E dsnap +S/GDIBWPatternMx matrix
+currentmatrix readonly d ; ;}if}b
+%%EndResource
+%%BeginResource: file Pscript_Win_GdiObject_L2 5.0 0
+/mp/makepattern , d/hbf{setpattern}b/hf{:/fEOFill ~ d ~ ! setpattern fEOFill{O}
+{L}? ;}b/pbf{: !/fEOFill ~ d GDIBWPatternDict `/yOrg ~ d/xOrg ~ d/PaintData ~ d
+/OutputBPP ~ d/Height ~ d/Width ~ d/PaintType 1 d/PatternType 1 d/TilingType 1
+d/BBox[0 0 Width Height]d/XStep Width d/YStep Height d/mx xOrg yOrg matrix + d
+20 dict @ `/ImageType 1 d/Width Width d/Height Height d/ImageMatrix mx d
+/BitsPerComponent 8 d OutputBPP 24 eq{/Decode[0 1 0 1 0 1]d}{OutputBPP 8 eq{
+/Decode[0 1]d}{/Decode[0 1 0 1 0 1 0 1]d}?}?/DataSource{PaintData}d E/ImageDict
+~ d/PaintProc{` ImageDict image E}b & mx makepattern setpattern E fEOFill{O}{L}
+? ;}b
+%%EndResource
+end reinitialize
+: N 1432 65 209 154 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol 1 Lw N 1641 64 M 1431 64 I 1431 219 I 1641 219 I C
+K
+0 0 0 1 scol Pscript_WinNT_Incr begin
+%%BeginResource: file Pscript_Text 5.0 0
+/TextInit{TextInitialised? not{/Pscript_Windows_Font & d/TextInitialised? T d
+/fM[1 0 0 1 0 0]d/mFM matrix d/iMat[1 0 0.212557 1 0 0]d}if}b/copyfont{1 ^
+length add dict `{1 ^/FID ne{d}{! !}?}forall & E}b/EncodeDict 11 dict d/bullets
+{{/bullet}repeat}b/rF{3 copyfont @ ` ~ EncodeDict ~ get/Encoding ~ 3 ^/0 eq{&
+/CharStrings known{CharStrings/Eth known not{! EncodeDict/ANSIEncodingOld get}
+if}if}if d E}b/mF{@ 7 1 $ findfont ~{@/Encoding get @ StandardEncoding eq{! T}{
+{ISOLatin1Encoding}stopped{! F}{eq}?{T}{@ ` T 32 1 127{Encoding 1 ^ get
+StandardEncoding 3 -1 $ get eq and}for E}?}?}{F}?{1 ^ ~ rF}{0 copyfont}? 6 -2 $
+{T pd_AddEm87 ~ !}{! ~ !/pd_charset @ where{~ get 128 eq{@ FDV 2 copy get @
+length array copy put pd_CoverFCRange}if}{!}?}? 2 ^ ~ definefont fM 5 4 -1 $
+put fM 4 0 put fM makefont Pscript_Windows_Font 3 1 $ put}b/sLT{: Lw -M
+currentpoint snap M 0 - 0 Lc K ;}b/xUP null d/yUP null d/uW null d/xSP null d
+/ySP null d/sW null d/sSU{N/uW ~ d/yUP ~ d/xUP ~ d}b/sU{xUP yUP uW sLT}b/sST{N
+/sW ~ d/ySP ~ d/xSP ~ d}b/sT{xSP ySP sW sLT}b/sR{: + R 0 0 M}b/sRxy{: matrix
+astore concat 0 0 M}b/eR/; , d/AddOrigFP{{&/FontInfo known{&/FontInfo get
+length 6 add}{6}? dict `/WinPitchAndFamily ~ d/WinCharSet ~ d/OrigFontType ~ d
+/OrigFontStyle ~ d/OrigFontName ~ d & E/FontInfo ~ d}{! ! ! ! !}?}b/mFS
+{makefont Pscript_Windows_Font 3 1 $ put}b/mF42D{0 copyfont `/FontName ~ d 2
+copy ~ sub 1 add dict `/.notdef 0 d 2 copy 1 ~{@ 3 ^ sub Encoding ~ get ~ d}for
+& E/CharStrings ~ d ! ! & @ E/FontName get ~ definefont}bind d/mF42{15 dict ` @
+4 1 $/FontName ~ d/FontType 0 d/FMapType 2 d/FontMatrix[1 0 0 1 0 0]d 1 ^ 254
+add 255 idiv @ array/Encoding ~ d 0 1 3 -1 $ 1 sub{@ Encoding 3 1 $ put}for
+/FDepVector Encoding length array d/CharStrings 2 dict `/.notdef 0 d & E d 0 1
+Encoding length 1 sub{@ @ 10 lt{! FontName length 1 add string}{100 lt{FontName
+length 2 add string}{FontName length 3 add string}?}? @ 0 FontName @ length
+string cvs putinterval @ 3 -1 $ @ 4 1 $ 3 string cvs FontName length ~
+putinterval cvn 1 ^ 256 mul @ 255 add 3 -1 $ 4 ^ findfont mF42D FDepVector 3 1
+$ put}for & @ E/FontName get ~ definefont ! ! ! mF}b/UmF{L2?
+{Pscript_Windows_Font ~ undef}{!}?}b/UmF42{@ findfont/FDepVector get{/FontName
+get undefinefont}forall undefinefont}b
+%%EndResource
+end reinitialize
+Pscript_WinNT_Incr begin
+%%BeginResource: file Pscript_Encoding256 5.0 0
+/CharCol256Encoding[/.notdef/breve/caron/dotaccent/dotlessi/fi/fl/fraction
+/hungarumlaut/Lslash/lslash/minus/ogonek/ring/Zcaron/zcaron/.notdef/.notdef
+/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
+/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/exclam/quotedbl/numbersign
+/dollar/percent/ampersand/quotesingle/parenleft/parenright/asterisk/plus/comma
+/hyphen/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon
+/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S
+/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/asciicircum/underscore/grave
+/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright
+/asciitilde/.notdef/.notdef/.notdef/quotesinglbase/florin/quotedblbase/ellipsis
+/dagger/daggerdbl/circumflex/perthousand/Scaron/guilsinglleft/OE/.notdef
+/.notdef/.notdef/.notdef/quoteleft/quoteright/quotedblleft/quotedblright/bullet
+/endash/emdash/tilde/trademark/scaron/guilsinglright/oe/.notdef/.notdef
+/Ydieresis/.notdef/exclamdown/cent/sterling/currency/yen/brokenbar/section
+/dieresis/copyright/ordfeminine/guillemotleft/logicalnot/.notdef/registered
+/macron/degree/plusminus/twosuperior/threesuperior/acute/mu/paragraph
+/periodcentered/cedilla/onesuperior/ordmasculine/guillemotright/onequarter
+/onehalf/threequarters/questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis
+/Aring/AE/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute
+/Icircumflex/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
+/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls
+/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla/egrave/eacute
+/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis/eth/ntilde/ograve
+/oacute/ocircumflex/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex
+/udieresis/yacute/thorn/ydieresis]def EncodeDict/256 CharCol256Encoding put
+%%EndResource
+end reinitialize
+
+%%IncludeResource: font Helvetica
+F /F0 0 /256 T /Helvetica mF
+/F0S21 F0 [33.09 0 0 -33.09 0 0 ] mFS
+F0S21 Ji
+1461 104 M (Instruction)[9 18 17 9 11 18 17 9 7 17 0]xS
+0.602 0 0.199 1 scol N 1641 117 M 1431 117 I 1431 219 I 1641 219 I C
+K
+N 1641 212 M 1431 212 I 1431 219 I 1641 219 I C
+K
+0 0 0 1 scol 1478 153 M (tag)[9 17 0]xS
+1478 191 M (length)[7 17 18 18 9 0]xS
+: N 575 326 321 98 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 896 325 M 574 325 I 574 424 I 896 424 I C
+K
+0 0 0 1 scol 609 365 M (BranchInstruction)[22 11 17 18 17 18 9 18 17 9 11 18 17 9 7 17 0]xS
+0.602 0 0.199 1 scol N 896 378 M 574 378 I 574 424 I 896 424 I C
+K
+N 896 396 M 574 396 I 574 424 I 896 424 I C
+K
+: N 822 556 164 154 rp C
+1 1 0.801 1 scol L ; N 986 555 M 821 555 I 821 710 I 986 710 I C
+K
+0 0 0 1 scol 859 595 M (Select)[22 17 7 17 17 0]xS
+0.602 0 0.199 1 scol N 986 608 M 821 608 I 821 710 I 986 710 I C
+K
+N 986 702 M 821 702 I 821 710 I 986 710 I C
+K
+0 0 0 1 scol 868 644 M (targets)[9 17 11 18 17 9 0]xS
+868 682 M (keys)[16 17 15 0]xS
+: N 584 815 303 100 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 887 814 M 583 814 I 583 915 I 887 915 I C
+K
+0 0 0 1 scol 599 855 M (LOOKUPSWITCH)[18 26 26 22 24 22 22 34 9 21 24 0]xS
+0.602 0 0.199 1 scol N 887 868 M 583 868 I 583 915 I 887 915 I C
+K
+N 887 886 M 583 886 I 583 915 I 887 915 I C
+K
+: N 964 815 267 100 rp C
+1 1 0.801 1 scol L ; N 1231 814 M 963 814 I 963 915 I 1231 915 I C
+K
+0 0 0 1 scol 978 855 M (TABLESWITCH)[21 22 22 18 22 22 34 9 21 24 0]xS
+0.602 0 0.199 1 scol N 1231 868 M 963 868 I 963 915 I 1231 915 I C
+K
+N 1231 886 M 963 886 I 963 915 I 1231 915 I C
+K
+: N 567 557 208 100 rp C
+1 1 0.801 1 scol L ; N 775 556 M 566 556 I 566 657 I 775 657 I C
+K
+0 0 0 1 scol 587 597 M (IfInstruction)[9 10 9 18 17 9 11 18 17 9 7 17 0]xS
+0.602 0 0.199 1 scol N 775 609 M 566 609 I 566 657 I 775 657 I C
+K
+N 775 628 M 566 628 I 566 657 I 775 657 I C
+K
+: N 393 557 143 100 rp C
+1 1 0.801 1 scol L ; N 536 556 M 392 556 I 392 657 I 536 657 I C
+K
+0 0 0 1 scol 415 597 M (GOTO)[26 26 21 0]xS
+0.602 0 0.199 1 scol N 536 609 M 392 609 I 392 657 I 536 657 I C
+K
+N 536 628 M 392 628 I 392 657 I 536 657 I C
+K
+N 730 499 M 730 425 I K
+N 469 499 M 910 499 I K
+N 730 425 M 748 473 I 712 473 I C
+: 1 1 1 1 scol O ; K
+N 469 556 M 469 499 I K
+: N 1843 118 290 100 rp C
+1 1 0.801 1 scol L ; N 2133 117 M 1842 117 I 1842 218 I 2133 218 I C
+K
+0 0 0 1 scol 1865 158 M (ReturnInstruction)[24 17 9 18 11 18 9 18 17 9 11 18 17 9 7 17 0]xS
+0.602 0 0.199 1 scol N 2133 168 M 1842 168 I 1842 218 I 2133 218 I C
+K
+N 2133 186 M 1842 186 I 1842 218 I 2133 218 I C
+K
+: N 1004 325 264 99 rp C
+1 1 0.801 1 scol L ; N 1268 324 M 1003 324 I 1003 424 I 1268 424 I C
+K
+0 0 0 1 scol 1023 364 M (ArrayInstruction)[22 11 11 17 15 9 18 17 9 11 18 17 9 7 17 0]xS
+0.602 0 0.199 1 scol N 1268 377 M 1003 377 I 1003 424 I 1268 424 I C
+K
+N 1268 396 M 1003 396 I 1003 424 I 1268 424 I C
+K
+: N 1704 332 232 188 rp C
+1 1 0.801 1 scol L ; N 1936 331 M 1703 331 I 1703 520 I 1936 520 I C
+K
+0 0 0 1 scol 1722 372 M (CPInstruction)[24 22 9 18 17 9 11 18 17 9 7 17 0]xS
+0.602 0 0.199 1 scol N 1936 382 M 1703 382 I 1703 520 I 1936 520 I C
+K
+N 1936 438 M 1703 438 I 1703 520 I 1936 520 I C
+K
+0 0 0 1 scol 1751 418 M (index)[7 18 18 17 0]xS
+1751 494 M (getType\(\))[18 17 9 21 15 18 17 11 0]xS
+: N 1038 118 274 100 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 1312 117 M 1037 117 I 1037 218 I 1312 218 I C
+K
+0 0 0 1 scol 1059 158 M (StackInstruction)[22 9 17 17 16 9 18 17 9 11 18 17 9 7 17 0]xS
+0.602 0 0.199 1 scol N 1312 170 M 1037 170 I 1037 218 I 1312 218 I C
+K
+N 1312 189 M 1037 189 I 1037 218 I 1312 218 I C
+K
+: N 1312 325 345 99 rp C
+1 1 0.801 1 scol L ; N 1657 324 M 1311 324 I 1311 424 I 1657 424 I C
+K
+0 0 0 1 scol 1329 364 M (ConversionInstruction)[24 17 18 15 17 11 17 7 17 18 9 18 17 9 11 18 17 9 7 17 0]xS
+0.602 0 0.199 1 scol N 1657 377 M 1311 377 I 1311 424 I 1657 424 I C
+K
+N 1657 396 M 1311 396 I 1311 424 I 1657 424 I C
+K
+N 675 556 M 675 499 I K
+: N 619 118 337 100 rp C
+1 1 0.801 1 scol L ; N 956 117 M 618 117 I 618 218 I 956 218 I C
+K
+0 0 0 1 scol 641 158 M (ArithmeticInstruction)[22 11 7 9 18 27 17 9 7 17 9 18 17 9 11 18 17 9 7 17 0]xS
+0.602 0 0.199 1 scol N 956 170 M 618 170 I 618 218 I 956 218 I C
+K
+N 956 189 M 618 189 I 618 218 I 956 218 I C
+K
+: N 1974 326 390 148 rp C
+1 1 0.801 1 scol L ; N 2364 325 M 1973 325 I 1973 474 I 2364 474 I C
+K
+0 0 0 1 scol 1998 366 M (LocalVariableInstruction)[18 17 17 17 7 22 17 11 7 17 18 7 17 9 18 17 9 11 18 17 9 7 17 0]xS
+0.602 0 0.199 1 scol N 2364 376 M 1973 376 I 1973 474 I 2364 474 I C
+K
+N 2364 433 M 1973 433 I 1973 474 I 2364 474 I C
+K
+0 0 0 1 scol 2020 412 M (index)[7 18 18 17 0]xS
+: N 1392 869 263 148 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 1655 868 M 1391 868 I 1391 1017 I 1655 1017 I C
+K
+0 0 0 1 scol 1414 908 M (FieldInstruction)[20 7 17 7 18 9 18 17 9 11 18 17 9 7 17 0]xS
+0.602 0 0.199 1 scol N 1655 921 M 1391 921 I 1391 1017 I 1655 1017 I C
+K
+N 1655 940 M 1391 940 I 1391 1017 I 1655 1017 I C
+K
+0 0 0 1 scol 1439 995 M (getFieldType\(\))[18 17 9 20 7 17 7 18 21 15 18 17 11 0]xS
+: N 1735 869 351 148 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 2086 868 M 1734 868 I 1734 1017 I 2086 1017 I C
+K
+0 0 0 1 scol 1790 908 M (InvokeInstruction)[9 18 15 17 16 17 9 18 17 9 11 18 17 9 7 17 0]xS
+0.602 0 0.199 1 scol N 2086 919 M 1734 919 I 1734 1017 I 2086 1017 I C
+K
+N 2086 937 M 1734 937 I 1734 1017 I 2086 1017 I C
+K
+0 0 0 1 scol 1781 992 M (getArgumentTypes\(\))[18 17 9 22 11 18 18 27 17 18 9 21 15 18 17 17 11 0]xS
+0.602 0 0.199 1 scol N 1539 293 M 1539 220 I K
+N 703 293 M 2171 293 I K
+N 1539 220 M 1557 269 I 1522 269 I C
+: 1 1 1 1 scol O ; K
+N 2171 325 M 2171 293 I K
+N 1826 331 M 1826 293 I K
+N 898 784 M 898 711 I K
+N 737 784 M 1069 784 I K
+N 898 711 M 916 760 I 880 760 I C
+: 1 1 1 1 scol O ; K
+N 737 814 M 737 784 I K
+N 1116 324 M 1116 293 I K
+N 792 219 M 792 293 I K
+N 1487 324 M 1487 293 I K
+N 1984 219 M 1984 293 I K
+N 1166 219 M 1166 293 I K
+: N 1554 623 248 148 rp C
+1 1 0.801 1 scol L ; N 1802 622 M 1553 622 I 1553 771 I 1802 771 I C
+K
+0 0 0 1 scol 1572 663 M (FieldOrMethod)[20 7 17 7 18 26 11 27 17 9 18 17 0]xS
+0.602 0 0.199 1 scol N 1802 676 M 1553 676 I 1553 771 I 1802 771 I C
+K
+N 1802 694 M 1553 694 I 1553 771 I 1802 771 I C
+K
+0 0 0 1 scol 1601 749 M (getName\(\))[18 17 9 24 17 27 17 11 0]xS
+: N 2179 635 186 99 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 2365 634 M 2178 634 I 2178 734 I 2365 734 I C
+K
+0 0 0 1 scol 2232 674 M (NEW)[24 22 0]xS
+0.602 0 0.199 1 scol N 2365 684 M 2178 684 I 2178 734 I 2365 734 I C
+K
+N 2365 703 M 2178 703 I 2178 734 I 2365 734 I C
+K
+N 703 325 M 703 293 I K
+N 1820 594 M 1820 521 I K
+N 1657 594 M 2249 594 I K
+N 1820 521 M 1838 570 I 1802 570 I C
+: 1 1 1 1 scol O ; K
+: N 1889 635 250 99 rp C
+1 1 0.801 1 scol L ; N 2139 634 M 1888 634 I 1888 734 I 2139 734 I C
+K
+0 0 0 1 scol 1907 674 M (INSTANCEOF)[9 24 22 21 22 24 24 22 26 0]xS
+0.602 0 0.199 1 scol N 2139 684 M 1888 684 I 1888 734 I 2139 734 I C
+K
+N 2139 703 M 1888 703 I 1888 734 I 2139 734 I C
+K
+N 2014 634 M 2014 594 I K
+N 2249 634 M 2249 594 I K
+N 1657 622 M 1657 594 I K
+N 1069 814 M 1069 784 I K
+N 1677 845 M 1677 772 I K
+N 1511 845 M 1907 845 I K
+N 1677 772 M 1695 821 I 1660 821 I C
+: 1 1 1 1 scol O ; K
+N 1907 868 M 1907 845 I K
+N 1511 868 M 1511 845 I K
+N 910 555 M 910 499 I K
+LH
+%%PageTrailer
+
+%%Trailer
+%%DocumentNeededResources:
+%%+ font Helvetica
+%%DocumentSuppliedResources:
+Pscript_WinNT_Incr dup /terminate get exec
+%%EOF
+grestore
diff --git a/docs/eps/instructions.fig b/docs/eps/instructions.fig
new file mode 100644
index 00000000..5c88fb55
--- /dev/null
+++ b/docs/eps/instructions.fig
@@ -0,0 +1,245 @@
+#FIG 3.2
+Portrait
+Center
+Inches
+A4
+100.00
+Single
+-2
+1200 2
+0 32 #f9f9f9
+0 33 #303030
+6 75 75 5475 9975
+2 1 0 0 32 32 998 0 20 4.000 0 0 0 0 0 4
+ 95 5002 95 3478 1027 3478 1027 5002
+2 1 0 1 33 33 997 0 -1 4.000 0 0 0 0 0 5
+ 91 5006 91 3474 1031 3474 1031 5006 91 5006
+2 1 0 1 33 33 995 0 -1 4.000 0 0 0 0 0 5
+ 355 5006 355 3474 1031 3474 1031 5006 355 5006
+2 1 0 1 33 33 994 0 -1 4.000 0 0 0 0 0 5
+ 823 5006 823 3474 1031 3474 1031 5006 823 5006
+2 1 0 0 32 32 991 0 20 4.000 0 0 0 0 0 4
+ 1667 9186 1667 7102 2399 7102 2399 9186
+2 1 0 1 33 33 990 0 -1 4.000 0 0 0 0 0 5
+ 1663 9190 1663 7098 2403 7098 2403 9190 1663 9190
+2 1 0 1 33 33 988 0 -1 4.000 0 0 0 0 0 5
+ 1927 9190 1927 7098 2403 7098 2403 9190 1927 9190
+2 1 0 1 33 33 987 0 -1 4.000 0 0 0 0 0 5
+ 2207 9190 2207 7098 2403 7098 2403 9190 2207 9190
+2 1 0 0 32 32 985 0 20 4.000 0 0 0 0 0 4
+ 3295 7806 3295 5538 4227 5538 4227 7806
+2 1 0 1 33 33 984 0 -1 4.000 0 0 0 0 0 5
+ 3291 7810 3291 5534 4231 5534 4231 7810 3291 7810
+2 1 0 1 33 33 982 0 -1 4.000 0 0 0 0 0 5
+ 3555 7810 3555 5534 4231 5534 4231 7810 3555 7810
+2 1 0 1 33 33 981 0 -1 4.000 0 0 0 0 0 5
+ 4023 7810 4023 5534 4231 5534 4231 7810 4023 7810
+2 1 0 0 32 32 978 0 20 4.000 0 0 0 0 0 4
+ 4923 8254 4923 6754 5415 6754 5415 8254
+2 1 0 1 33 33 977 0 -1 4.000 0 0 0 0 0 5
+ 4919 8258 4919 6750 5419 6750 5419 8258 4919 8258
+2 1 0 1 33 33 975 0 -1 4.000 0 0 0 0 0 5
+ 5183 8258 5183 6750 5419 6750 5419 8258 5183 8258
+2 1 0 1 33 33 974 0 -1 4.000 0 0 0 0 0 5
+ 5275 8258 5275 6750 5419 6750 5419 8258 5275 8258
+2 1 0 0 32 32 973 0 20 4.000 0 0 0 0 0 4
+ 4923 6502 4923 5178 5415 5178 5415 6502
+2 1 0 1 33 33 972 0 -1 4.000 0 0 0 0 0 5
+ 4919 6506 4919 5174 5419 5174 5419 6506 4919 6506
+2 1 0 1 33 33 970 0 -1 4.000 0 0 0 0 0 5
+ 5183 6506 5183 5174 5419 5174 5419 6506 5183 6506
+2 1 0 1 33 33 969 0 -1 4.000 0 0 0 0 0 5
+ 5275 6506 5275 5174 5419 5174 5419 6506 5275 6506
+2 1 0 0 32 32 968 0 20 4.000 0 0 0 0 0 4
+ 3859 3986 3859 2446 4815 2446 4815 3986
+2 1 0 1 33 33 967 0 -1 4.000 0 0 0 0 0 5
+ 3855 3990 3855 2442 4819 2442 4819 3990 3855 3990
+2 1 0 1 33 33 965 0 -1 4.000 0 0 0 0 0 5
+ 4319 3990 4319 2442 4819 2442 4819 3990 4319 3990
+2 1 0 1 33 33 964 0 -1 4.000 0 0 0 0 0 5
+ 4411 3990 4411 2442 4819 2442 4819 3990 4411 3990
+2 1 0 0 32 32 961 0 20 4.000 0 0 0 0 0 4
+ 3323 9042 3323 8014 3815 8014 3815 9042
+2 1 0 1 33 33 960 0 -1 4.000 0 0 0 0 0 5
+ 3319 9046 3319 8010 3819 8010 3819 9046 3319 9046
+2 1 0 1 33 33 958 0 -1 4.000 0 0 0 0 0 5
+ 3583 9046 3583 8010 3819 8010 3819 9046 3583 9046
+2 1 0 1 33 33 957 0 -1 4.000 0 0 0 0 0 5
+ 3675 9046 3675 8010 3819 8010 3819 9046 3675 9046
+2 1 0 0 32 32 956 0 20 4.000 0 0 0 0 0 4
+ 3323 9970 3323 9262 3815 9262 3815 9970
+2 1 0 1 33 33 955 0 -1 4.000 0 0 0 0 0 5
+ 3319 9974 3319 9258 3819 9258 3819 9974 3319 9974
+2 1 0 1 33 33 953 0 -1 4.000 0 0 0 0 0 5
+ 3583 9974 3583 9258 3819 9258 3819 9974 3583 9974
+2 1 0 1 33 33 952 0 -1 4.000 0 0 0 0 0 5
+ 3675 9974 3675 9258 3819 9258 3819 9974 3675 9974
+2 1 0 1 33 33 951 0 -1 4.000 0 0 0 0 0 2
+ 2943 8142 2407 8142
+2 1 0 1 33 33 950 0 -1 4.000 0 0 0 0 0 2
+ 2943 9606 2943 6742
+2 1 0 0 7 7 949 0 20 4.000 0 0 0 0 0 4
+ 2407 8142 2647 8054 2647 8230 2407 8142
+2 1 0 1 33 33 948 0 -1 4.000 0 0 0 0 0 4
+ 2407 8142 2647 8054 2647 8230 2407 8142
+2 1 0 1 33 33 947 0 -1 4.000 0 0 0 0 0 2
+ 3291 6742 2943 6742
+2 1 0 1 33 33 946 0 -1 4.000 0 0 0 0 0 2
+ 3319 9606 2943 9606
+2 1 0 0 32 32 945 0 20 4.000 0 0 0 0 0 4
+ 379 2718 379 1282 871 1282 871 2718
+2 1 0 1 33 33 944 0 -1 4.000 0 0 0 0 0 5
+ 375 2722 375 1278 875 1278 875 2722 375 2722
+2 1 0 1 33 33 942 0 -1 4.000 0 0 0 0 0 5
+ 639 2722 639 1278 875 1278 875 2722 639 2722
+2 1 0 1 33 33 941 0 -1 4.000 0 0 0 0 0 5
+ 731 2722 731 1278 875 1278 875 2722 731 2722
+2 1 0 0 32 32 940 0 20 4.000 0 0 0 0 0 4
+ 1659 6878 1659 5570 2151 5570 2151 6878
+2 1 0 1 33 33 939 0 -1 4.000 0 0 0 0 0 5
+ 1655 6882 1655 5566 2155 5566 2155 6882 1655 6882
+2 1 0 1 33 33 937 0 -1 4.000 0 0 0 0 0 5
+ 1919 6882 1919 5566 2155 5566 2155 6882 1919 6882
+2 1 0 1 33 33 936 0 -1 4.000 0 0 0 0 0 5
+ 2011 6882 2011 5566 2155 5566 2155 6882 2011 6882
+2 1 0 0 32 32 935 0 20 4.000 0 0 0 0 0 4
+ 1667 3406 1667 2258 2399 2258 2399 3406
+2 1 0 1 33 33 934 0 -1 4.000 0 0 0 0 0 5
+ 1663 3410 1663 2254 2403 2254 2403 3410 1663 3410
+2 1 0 1 33 33 932 0 -1 4.000 0 0 0 0 0 5
+ 1927 3410 1927 2254 2403 2254 2403 3410 1927 3410
+2 1 0 1 33 33 931 0 -1 4.000 0 0 0 0 0 5
+ 2207 3410 2207 2254 2403 2254 2403 3410 2207 3410
+2 1 0 0 32 32 929 0 20 4.000 0 0 0 0 0 4
+ 379 6710 379 5354 871 5354 871 6710
+2 1 0 1 33 33 928 0 -1 4.000 0 0 0 0 0 5
+ 375 6714 375 5350 875 5350 875 6714 375 6714
+2 1 0 1 33 33 926 0 -1 4.000 0 0 0 0 0 5
+ 639 6714 639 5350 875 5350 875 6714 639 6714
+2 1 0 1 33 33 925 0 -1 4.000 0 0 0 0 0 5
+ 731 6714 731 5350 875 5350 875 6714 731 6714
+2 1 0 0 32 32 924 0 20 4.000 0 0 0 0 0 4
+ 1659 5350 1659 3642 2151 3642 2151 5350
+2 1 0 1 33 33 923 0 -1 4.000 0 0 0 0 0 5
+ 1655 5354 1655 3638 2155 3638 2155 5354 1655 5354
+2 1 0 1 33 33 921 0 -1 4.000 0 0 0 0 0 5
+ 1919 5354 1919 3638 2155 3638 2155 5354 1919 5354
+2 1 0 1 33 33 920 0 -1 4.000 0 0 0 0 0 5
+ 2011 5354 2011 3638 2155 3638 2155 5354 2011 5354
+2 1 0 1 33 33 919 0 -1 4.000 0 0 0 0 0 2
+ 3319 8490 2943 8490
+2 1 0 0 32 32 918 0 20 4.000 0 0 0 0 0 4
+ 379 8786 379 7118 871 7118 871 8786
+2 1 0 1 33 33 917 0 -1 4.000 0 0 0 0 0 5
+ 375 8790 375 7114 875 7114 875 8790 375 8790
+2 1 0 1 33 33 915 0 -1 4.000 0 0 0 0 0 5
+ 639 8790 639 7114 875 7114 875 8790 639 8790
+2 1 0 1 33 33 914 0 -1 4.000 0 0 0 0 0 5
+ 731 8790 731 7114 875 7114 875 8790 731 8790
+2 1 0 0 32 32 913 0 20 4.000 0 0 0 0 0 4
+ 1667 1994 1667 86 2399 86 2399 1994
+2 1 0 1 33 33 912 0 -1 4.000 0 0 0 0 0 5
+ 1663 1998 1663 82 2403 82 2403 1998 1663 1998
+2 1 0 1 33 33 910 0 -1 4.000 0 0 0 0 0 5
+ 1927 1998 1927 82 2403 82 2403 1998 1927 1998
+2 1 0 1 33 33 909 0 -1 4.000 0 0 0 0 0 5
+ 2207 1998 2207 82 2403 82 2403 1998 2207 1998
+2 1 0 0 32 32 907 0 20 4.000 0 0 0 0 0 4
+ 2939 4314 2939 3014 3431 3014 3431 4314
+2 1 0 1 33 33 906 0 -1 4.000 0 0 0 0 0 5
+ 2935 4318 2935 3010 3435 3010 3435 4318 2935 4318
+2 1 0 1 33 33 904 0 -1 4.000 0 0 0 0 0 5
+ 3199 4318 3199 3010 3435 3010 3435 4318 3199 4318
+2 1 0 1 33 33 903 0 -1 4.000 0 0 0 0 0 5
+ 3291 4318 3291 3010 3435 3010 3435 4318 3291 4318
+2 1 0 0 32 32 902 0 20 4.000 0 0 0 0 0 4
+ 2939 2758 2939 1370 3431 1370 3431 2758
+2 1 0 1 33 33 901 0 -1 4.000 0 0 0 0 0 5
+ 2935 2762 2935 1366 3435 1366 3435 2762 2935 2762
+2 1 0 1 33 33 899 0 -1 4.000 0 0 0 0 0 5
+ 3199 2762 3199 1366 3435 1366 3435 2762 3199 2762
+2 1 0 1 33 33 898 0 -1 4.000 0 0 0 0 0 5
+ 3291 2762 3291 1366 3435 1366 3435 2762 3291 2762
+2 1 0 1 33 33 897 0 -1 4.000 0 0 0 0 0 2
+ 1395 4238 1035 4238
+2 1 0 1 33 33 896 0 -1 4.000 0 0 0 0 0 2
+ 1395 8142 1395 1042
+2 1 0 0 7 7 895 0 20 4.000 0 0 0 0 0 4
+ 1035 4238 1275 4150 1275 4326 1035 4238
+2 1 0 1 33 33 894 0 -1 4.000 0 0 0 0 0 4
+ 1035 4238 1275 4150 1275 4326 1035 4238
+2 1 0 1 33 33 893 0 -1 4.000 0 0 0 0 0 2
+ 1663 1042 1395 1042
+2 1 0 1 33 33 892 0 -1 4.000 0 0 0 0 0 2
+ 1663 2866 1395 2866
+2 1 0 1 33 33 891 0 -1 4.000 0 0 0 0 0 2
+ 2767 2894 2407 2894
+2 1 0 1 33 33 890 0 -1 4.000 0 0 0 0 0 2
+ 2767 3818 2767 2094
+2 1 0 0 7 7 889 0 20 4.000 0 0 0 0 0 4
+ 2407 2894 2647 2806 2647 2982 2407 2894
+2 1 0 1 33 33 888 0 -1 4.000 0 0 0 0 0 4
+ 2407 2894 2647 2806 2647 2982 2407 2894
+2 1 0 1 33 33 887 0 -1 4.000 0 0 0 0 0 2
+ 4683 6718 4235 6718
+2 1 0 1 33 33 886 0 -1 4.000 0 0 0 0 0 2
+ 4683 7542 4683 5942
+2 1 0 0 7 7 885 0 20 4.000 0 0 0 0 0 4
+ 4235 6718 4475 6630 4475 6806 4235 6718
+2 1 0 1 33 33 884 0 -1 4.000 0 0 0 0 0 4
+ 4235 6718 4475 6630 4475 6806 4235 6718
+2 1 0 1 33 33 883 0 -1 4.000 0 0 0 0 0 2
+ 4919 7542 4683 7542
+2 1 0 1 33 33 882 0 -1 4.000 0 0 0 0 0 2
+ 1663 8142 1395 8142
+2 1 0 1 33 33 881 0 -1 4.000 0 0 0 0 0 2
+ 1655 6278 1395 6278
+2 1 0 1 33 33 880 0 -1 4.000 0 0 0 0 0 2
+ 879 7930 1395 7930
+2 1 0 1 33 33 879 0 -1 4.000 0 0 0 0 0 2
+ 1655 4494 1395 4494
+2 1 0 1 33 33 878 0 -1 4.000 0 0 0 0 0 2
+ 879 2018 1395 2018
+2 1 0 1 33 33 877 0 -1 4.000 0 0 0 0 0 2
+ 2935 3818 2767 3818
+2 1 0 1 33 33 876 0 -1 4.000 0 0 0 0 0 2
+ 2935 2094 2767 2094
+2 1 0 1 33 33 875 0 -1 4.000 0 0 0 0 0 2
+ 4919 5942 4683 5942
+2 1 1 1 7 7 874 0 -1 4.000 0 0 0 0 0 2
+ 2407 7350 3975 3994
+2 1 1 1 0 0 873 0 -1 4.000 0 0 0 0 0 2
+ 2407 7350 3975 3994
+2 1 0 0 7 7 872 0 20 4.000 0 0 0 0 0 4
+ 3975 3994 3795 4174 3955 4246 3975 3994
+2 1 0 1 33 33 871 0 -1 4.000 0 0 0 0 0 4
+ 3975 3994 3795 4174 3955 4246 3975 3994
+2 1 0 1 33 33 870 0 -1 4.000 0 0 0 0 0 2
+ 879 6074 1395 6074
+4 0 0 996 -1 16 10 1.5708 4 120 720 291 4614 Instruction\001
+4 0 0 993 -1 16 10 1.5708 4 150 660 531 4770 tag : byte\001
+4 0 0 992 -1 16 10 1.5708 4 150 1215 719 4770 length, offset : int\001
+4 0 0 989 -1 16 10 1.5708 4 120 1215 1863 8778 BranchInstruction\001
+4 0 0 986 -1 16 10 1.5708 4 150 1755 2103 8954 target : InstructionHandle\001
+4 0 0 983 -1 16 10 1.5708 4 120 435 3491 6902 Select\001
+4 0 0 980 -1 16 10 1.5708 4 150 1920 3731 7574 targets : InstructionHandle[]\001
+4 0 0 979 -1 16 10 1.5708 4 150 705 3919 7574 keys : int[]\001
+4 0 0 976 -1 16 10 1.5708 4 105 1230 5119 8170 LOOKUPSWITCH\001
+4 0 0 971 -1 16 10 1.5708 4 105 1080 5119 6426 TABLESWITCH\001
+4 0 0 966 -1 16 10 1.5708 4 150 1305 4255 3902 InstructionTargeter\001
+4 0 0 963 -1 16 10 1.5708 4 150 1035 4683 3754 updateTarget()\001
+4 0 0 962 -1 16 10 1.5708 4 120 975 4055 3726 <<Interface>>\001
+4 0 0 959 -1 16 10 1.5708 4 120 810 3519 8946 IfInstruction\001
+4 0 0 954 -1 16 10 1.5708 4 105 450 3519 9858 GOTO\001
+4 0 0 943 -1 16 10 1.5708 4 120 1185 575 2622 ReturnInstruction\001
+4 0 0 938 -1 16 10 1.5708 4 150 1080 1855 6790 ArrayInstruction\001
+4 0 0 933 -1 16 10 1.5708 4 120 930 1863 3318 CPInstruction\001
+4 0 0 930 -1 16 10 1.5708 4 120 675 2103 3174 index : int\001
+4 0 0 927 -1 16 10 1.5708 4 120 1110 575 6610 StackInstruction\001
+4 0 0 922 -1 16 10 1.5708 4 120 1500 1855 5282 ConversionInstruction\001
+4 0 0 916 -1 16 10 1.5708 4 120 1395 575 8690 ArithmeticInstruction\001
+4 0 0 911 -1 16 10 1.5708 4 120 1665 1863 1914 LocalVariableInstruction\001
+4 0 0 908 -1 16 10 1.5708 4 120 675 2103 1762 index : int\001
+4 0 0 905 -1 16 10 1.5708 4 120 1050 3135 4214 FieldInstruction\001
+4 0 0 900 -1 16 10 1.5708 4 120 1185 3135 2674 InvokeInstruction\001
+-6
diff --git a/docs/eps/javaclass.eps b/docs/eps/javaclass.eps
new file mode 100644
index 00000000..cbfa8924
--- /dev/null
+++ b/docs/eps/javaclass.eps
@@ -0,0 +1,525 @@
+%!PS-Adobe-3.0 EPSF-3.0
+%%Title: Rose Diagram(s)
+%%Creator: AdobePS5.dll Version 5.0
+%%CreationDate: 7/7/1999 17:45:7
+%%Pages: 1
+%%Orientation: Portrait
+%%PageOrder: Ascend
+%%DocumentNeededResources: (atend)
+%%DocumentSuppliedResources: (atend)
+%%DocumentData: Clean7Bit
+%%TargetDevice: (HP LaserJet 5Si) (2014.108) 1
+%%LanguageLevel: 2
+%%BoundingBox: 13 12 471 830
+%%EndComments
+%%BeginProcSet: epsffit 1 0
+gsave
+1233.763 -187.599 translate
+90 rotate
+1.782 1.782 scale
+%%EndProcSet
+
+
+%%BeginDefaults
+%%PageBoundingBox: 13 12 582 830
+%%EndDefaults
+
+%%BeginProlog
+%%BeginResource: file Pscript_WinNT_ErrorHandler 5.0 0
+/currentpacking where{pop/oldpack currentpacking def/setpacking where{pop false
+setpacking}if}if/$brkpage 64 dict def $brkpage begin/prnt{dup type/stringtype
+ne{=string cvs}if dup length 6 mul/tx exch def/ty 10 def currentpoint/toy exch
+def/tox exch def 1 setgray newpath tox toy 2 sub moveto 0 ty rlineto tx 0
+rlineto 0 ty neg rlineto closepath fill tox toy moveto 0 setgray show}bind def
+/nl{currentpoint exch pop lmargin exch moveto 0 -10 rmoveto}def/=={/cp 0 def
+typeprint nl}def/typeprint{dup type exec}readonly def/lmargin 72 def/rmargin 72
+def/tprint{dup length cp add rmargin gt{nl/cp 0 def}if dup length cp add/cp
+exch def prnt}readonly def/cvsprint{=string cvs tprint( )tprint}readonly def
+/integertype{cvsprint}readonly def/realtype{cvsprint}readonly def/booleantype
+{cvsprint}readonly def/operatortype{(--)tprint =string cvs tprint(-- )tprint}
+readonly def/marktype{pop(-mark- )tprint}readonly def/dicttype{pop
+(-dictionary- )tprint}readonly def/nulltype{pop(-null- )tprint}readonly def
+/filetype{pop(-filestream- )tprint}readonly def/savetype{pop(-savelevel- )
+tprint}readonly def/fonttype{pop(-fontid- )tprint}readonly def/nametype{dup
+xcheck not{(/)tprint}if cvsprint}readonly def/stringtype{dup rcheck{(\()tprint
+tprint(\))tprint}{pop(-string- )tprint}ifelse}readonly def/arraytype{dup rcheck
+{dup xcheck{({)tprint{typeprint}forall(})tprint}{([)tprint{typeprint}forall(])
+tprint}ifelse}{pop(-array- )tprint}ifelse}readonly def/packedarraytype{dup
+rcheck{dup xcheck{({)tprint{typeprint}forall(})tprint}{([)tprint{typeprint}
+forall(])tprint}ifelse}{pop(-packedarray- )tprint}ifelse}readonly def/courier
+/Courier findfont 10 scalefont def end errordict/handleerror{systemdict begin
+$error begin $brkpage begin newerror{/newerror false store vmstatus pop pop 0
+ne{grestoreall}if showpage initgraphics courier setfont lmargin 720 moveto
+(ERROR: )prnt errorname prnt nl(OFFENDING COMMAND: )prnt/command load prnt
+$error/ostack known{nl nl(STACK:)prnt nl nl $error/ostack get aload length{==}
+repeat}if systemdict/showpage get exec(%%[ Error: )print errorname =print
+(; OffendingCommand: )print/command load =print( ]%%)= flush}if end end end}dup
+0 systemdict put dup 4 $brkpage put bind readonly put/currentpacking where{pop
+/setpacking where{pop oldpack setpacking}if}if
+%%EndResource
+userdict /Pscript_WinNT_Incr 230 dict dup begin put
+%%BeginResource: file Pscript_FatalError 5.0 0
+/FatalErrorIf{{initgraphics findfont exch scalefont setfont counttomark 3 div
+cvi{moveto show}repeat showpage quit}{cleartomark}ifelse}bind def
+%%EndResource
+/VM?{vmstatus exch sub exch pop gt{[
+(This job requires more memory than is available in this printer.)100 500
+(Try one or more of the following, and then print again:)100 485
+(For the output format, choose Optimize For Portability.)115 470
+(In the Device Settings page, make sure the Available PostScript Memory is accurate.)
+115 455(Reduce the number of fonts in the document.)115 440
+(Print the document in parts.)115 425 12/Times-Roman showpage
+(%%[ PrinterError: Low Printer VM ]%%)= true FatalErrorIf}if}bind def
+%%BeginResource: file Pscript_Win_Basic 5.0 0
+/d/def load def/,/load load d/~/exch , d/?/ifelse , d/!/pop , d/`/begin , d/^
+/index , d/@/dup , d/+/translate , d/$/roll , d/U/userdict , d/M/moveto , d/-
+/rlineto , d/&/currentdict , d/:/gsave , d/;/grestore , d/F/false , d/T/true ,
+d/N/newpath , d/E/end , d/Ac/arc , d/An/arcn , d/A/ashow , d/D/awidthshow , d/C
+/closepath , d/V/div , d/O/eofill , d/L/fill , d/I/lineto , d/-c/curveto , d/-M
+/rmoveto , d/+S/scale , d/Ji/setfont , d/Lc/setlinecap , d/Lj/setlinejoin , d
+/Lw/setlinewidth , d/Lm/setmiterlimit , d/sd/setdash , d/S/show , d/LH/showpage
+, d/K/stroke , d/W/widthshow , d/R/rotate , d/P/eoclip , d/L2? false
+/languagelevel where{pop languagelevel 2 ge{pop true}if}if d L2?{/xS/xshow , d
+/yS/yshow , d/zS/xyshow , d}if/b{bind d}bind d/bd{bind d}bind d/xd{~ d}bd/ld{,
+d}bd/lw/Lw ld/lc/Lc ld/lj/Lj ld/sg/setgray ld/ADO_mxRot null d/self & d/OrgMx
+matrix currentmatrix d/reinitialize{: OrgMx setmatrix[/TextInit/GraphInit
+/UtilsInit counttomark{@ where{self eq}{F}?{cvx exec}{!}?}repeat cleartomark ;}
+b/initialize{`{/ADO_mxRot ~ d/TextInitialised? F d reinitialize E}{U
+/Pscript_Win_Data 230 dict @ ` put/ADO_mxRot ~ d/TextInitialised? F d
+reinitialize}?}b/terminate{!{& self eq{exit}{E}?}loop E}b/suspend/terminate , d
+/resume{` Pscript_Win_Data `}b/snap{transform 0.25 sub round 0.25 add ~ 0.25
+sub round 0.25 add ~ itransform}b/dsnap{dtransform round ~ round ~ idtransform}
+b<04>cvn{}d/rr{1 ^ 0 - 0 ~ - neg 0 - C}b/rp{4 2 $ M 1 ^ 0 - 0 ~ - neg 0 -}b
+/solid{[]0 sd}b/g{@ not{U/DefIf_save save put}if U/DefIf_bool 2 ^ put}b
+/DefIf_El{if U/DefIf_bool get not @{U/DefIf_save get restore}if}b/e{DefIf_El !}
+b/UDF{L2?{undefinefont}{!}?}b/UDR{L2?{undefineresource}{! !}?}b
+%%EndResource
+%%BeginResource: file Pscript_Win_Utils_L2 5.0 0
+/rf/rectfill , d/fx{1 1 dtransform @ 0 ge{1 sub 0.5}{1 add -0.5}? 3 -1 $ @ 0 ge
+{1 sub 0.5}{1 add -0.5}? 3 1 $ 4 1 $ idtransform 4 -2 $ idtransform}b/BZ{4 -2 $
+snap + +S fx rf}b/rs/rectstroke , d/rc/rectclip , d/UtilsInit{currentglobal{F
+setglobal}if}b/scol{! setcolor}b/colspA/DeviceGray d/colspABC/DeviceRGB d
+/colspRefresh{colspABC setcolorspace}b/SetColSpace{colspABC setcolorspace}b
+%%EndResource
+end
+%%EndProlog
+
+%%BeginSetup
+[ 1 0 0 1 0 0 ] false Pscript_WinNT_Incr dup /initialize get exec
+1 setlinecap 1 setlinejoin
+/mysetup [ 0.24 0 0 -0.24 13.43905 829.74047 ] def
+%%EndSetup
+
+%%Page: 1 1
+%%PageBoundingBox: 13 12 582 830
+%%EndPageComments
+%%BeginPageSetup
+/DeviceRGB dup setcolorspace /colspABC exch def mysetup concat colspRefresh
+%%EndPageSetup
+
+Pscript_WinNT_Incr begin
+%%BeginResource: file Pscript_Win_GdiObject 5.0 0
+/SavedCTM null d/CTMsave{/SavedCTM SavedCTM currentmatrix d}b/CTMrestore
+{SavedCTM setmatrix}b/mp null d/ADO_mxRot null d/GDIHMatrix null d
+/GDIHPatternDict 22 dict d GDIHPatternDict `/PatternType 1 d/PaintType 2 d/Reps
+L2?{1}{5}? d/XStep 8 Reps mul d/YStep XStep d/BBox[0 0 XStep YStep]d/TilingType
+1 d/PaintProc{` 1 Lw[]0 sd PaintData , exec E}b/FGnd null d/BGnd null d
+/HS_Horizontal{horiz}b/HS_Vertical{vert}b/HS_FDiagonal{fdiag}b/HS_BDiagonal
+{biag}b/HS_Cross{horiz vert}b/HS_DiagCross{fdiag biag}b/MaxXYStep XStep YStep
+gt{XStep}{YStep}? d/horiz{Reps{0 4 M XStep 0 - 0 8 +}repeat 0 -8 Reps mul + K}b
+/vert{Reps{4 0 M 0 YStep - 8 0 +}repeat 0 -8 Reps mul + K}b/biag{Reps{0 0 M
+MaxXYStep @ - 0 YStep neg M MaxXYStep @ - 0 8 +}repeat 0 -8 Reps mul + 0 YStep
+M 8 8 - K}b/fdiag{Reps{0 0 M MaxXYStep @ neg - 0 YStep M MaxXYStep @ neg - 0 8
++}repeat 0 -8 Reps mul + MaxXYStep @ M 8 -8 - K}b E/makehatch{4 -2 $/yOrg ~ d
+/xOrg ~ d GDIHPatternDict/PaintData 3 -1 $ put CTMsave GDIHMatrix setmatrix
+GDIHPatternDict matrix xOrg yOrg + mp CTMrestore ~ U ~ 2 ^ put}b/h0{/h0
+/HS_Horizontal makehatch}b/h1{/h1/HS_Vertical makehatch}b/h2{/h2/HS_FDiagonal
+makehatch}b/h3{/h3/HS_BDiagonal makehatch}b/h4{/h4/HS_Cross makehatch}b/h5{/h5
+/HS_DiagCross makehatch}b/GDIBWPatternDict 25 dict @ `/PatternType 1 d
+/PaintType L2?{1}{2}? d/RepsV L2?{1}{6}? d/RepsH L2?{1}{5}? d/BBox[0 0 RepsH 1]
+d/TilingType 1 d/XStep 1 d/YStep 1 d/Height 8 RepsV mul d/Width 8 d/mx[Width 0
+0 Height neg 0 Height]d/FGnd null d/BGnd null d/SetBGndFGnd L2?{{FGnd null ne
+{FGnd aload ! scol BBox aload ! 2 ^ sub ~ 3 ^ sub ~ rf}if BGnd null ne{BGnd
+aload ! scol}if}}{{}}? b/PaintProc{` SetBGndFGnd RepsH{Width Height F mx
+PaintData imagemask Width 0 +}repeat E}b E d/GDIBWPatternMx null d/pfprep{save
+8 1 $/PatternOfTheDay 8 1 $ GDIBWPatternDict `/yOrg ~ d/xOrg ~ d/PaintData ~ d
+/yExt ~ d/Width ~ d/FGnd ~ d/BGnd ~ d/Height yExt RepsV mul d/mx[Width 0 0
+Height 0 0]d E : GDIBWPatternDict ` Width Height E dsnap +S/GDIBWPatternMx
+matrix currentmatrix d ; CTMsave GDIBWPatternMx setmatrix GDIBWPatternDict @ `
+xOrg yOrg E matrix + mp CTMrestore ~ !}b/pfbf{/fEOFill ~ d pfprep hbf fEOFill
+{O}{L}? restore}b/GraphInit{GDIHMatrix null eq{/SavedCTM matrix d : ADO_mxRot
+concat 0 0 snap + : 0.48 @ GDIHPatternDict ` YStep mul ~ XStep mul ~ dsnap
+YStep V ~ XStep V ~ E +S/GDIHMatrix matrix currentmatrix readonly d ; : 0.24
+-0.24 +S GDIBWPatternDict ` Width Height E dsnap +S/GDIBWPatternMx matrix
+currentmatrix readonly d ; ;}if}b
+%%EndResource
+%%BeginResource: file Pscript_Win_GdiObject_L2 5.0 0
+/mp/makepattern , d/hbf{setpattern}b/hf{:/fEOFill ~ d ~ ! setpattern fEOFill{O}
+{L}? ;}b/pbf{: !/fEOFill ~ d GDIBWPatternDict `/yOrg ~ d/xOrg ~ d/PaintData ~ d
+/OutputBPP ~ d/Height ~ d/Width ~ d/PaintType 1 d/PatternType 1 d/TilingType 1
+d/BBox[0 0 Width Height]d/XStep Width d/YStep Height d/mx xOrg yOrg matrix + d
+20 dict @ `/ImageType 1 d/Width Width d/Height Height d/ImageMatrix mx d
+/BitsPerComponent 8 d OutputBPP 24 eq{/Decode[0 1 0 1 0 1]d}{OutputBPP 8 eq{
+/Decode[0 1]d}{/Decode[0 1 0 1 0 1 0 1]d}?}?/DataSource{PaintData}d E/ImageDict
+~ d/PaintProc{` ImageDict image E}b & mx makepattern setpattern E fEOFill{O}{L}
+? ;}b
+%%EndResource
+end reinitialize
+: N 712 1406 246 93 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol 1 Lw N 958 1405 M 711 1405 I 711 1499 I 958 1499 I C
+K
+0 0 0 1 scol Pscript_WinNT_Incr begin
+%%BeginResource: file Pscript_Text 5.0 0
+/TextInit{TextInitialised? not{/Pscript_Windows_Font & d/TextInitialised? T d
+/fM[1 0 0 1 0 0]d/mFM matrix d/iMat[1 0 0.212557 1 0 0]d}if}b/copyfont{1 ^
+length add dict `{1 ^/FID ne{d}{! !}?}forall & E}b/EncodeDict 11 dict d/bullets
+{{/bullet}repeat}b/rF{3 copyfont @ ` ~ EncodeDict ~ get/Encoding ~ 3 ^/0 eq{&
+/CharStrings known{CharStrings/Eth known not{! EncodeDict/ANSIEncodingOld get}
+if}if}if d E}b/mF{@ 7 1 $ findfont ~{@/Encoding get @ StandardEncoding eq{! T}{
+{ISOLatin1Encoding}stopped{! F}{eq}?{T}{@ ` T 32 1 127{Encoding 1 ^ get
+StandardEncoding 3 -1 $ get eq and}for E}?}?}{F}?{1 ^ ~ rF}{0 copyfont}? 6 -2 $
+{T pd_AddEm87 ~ !}{! ~ !/pd_charset @ where{~ get 128 eq{@ FDV 2 copy get @
+length array copy put pd_CoverFCRange}if}{!}?}? 2 ^ ~ definefont fM 5 4 -1 $
+put fM 4 0 put fM makefont Pscript_Windows_Font 3 1 $ put}b/sLT{: Lw -M
+currentpoint snap M 0 - 0 Lc K ;}b/xUP null d/yUP null d/uW null d/xSP null d
+/ySP null d/sW null d/sSU{N/uW ~ d/yUP ~ d/xUP ~ d}b/sU{xUP yUP uW sLT}b/sST{N
+/sW ~ d/ySP ~ d/xSP ~ d}b/sT{xSP ySP sW sLT}b/sR{: + R 0 0 M}b/sRxy{: matrix
+astore concat 0 0 M}b/eR/; , d/AddOrigFP{{&/FontInfo known{&/FontInfo get
+length 6 add}{6}? dict `/WinPitchAndFamily ~ d/WinCharSet ~ d/OrigFontType ~ d
+/OrigFontStyle ~ d/OrigFontName ~ d & E/FontInfo ~ d}{! ! ! ! !}?}b/mFS
+{makefont Pscript_Windows_Font 3 1 $ put}b/mF42D{0 copyfont `/FontName ~ d 2
+copy ~ sub 1 add dict `/.notdef 0 d 2 copy 1 ~{@ 3 ^ sub Encoding ~ get ~ d}for
+& E/CharStrings ~ d ! ! & @ E/FontName get ~ definefont}bind d/mF42{15 dict ` @
+4 1 $/FontName ~ d/FontType 0 d/FMapType 2 d/FontMatrix[1 0 0 1 0 0]d 1 ^ 254
+add 255 idiv @ array/Encoding ~ d 0 1 3 -1 $ 1 sub{@ Encoding 3 1 $ put}for
+/FDepVector Encoding length array d/CharStrings 2 dict `/.notdef 0 d & E d 0 1
+Encoding length 1 sub{@ @ 10 lt{! FontName length 1 add string}{100 lt{FontName
+length 2 add string}{FontName length 3 add string}?}? @ 0 FontName @ length
+string cvs putinterval @ 3 -1 $ @ 4 1 $ 3 string cvs FontName length ~
+putinterval cvn 1 ^ 256 mul @ 255 add 3 -1 $ 4 ^ findfont mF42D FDepVector 3 1
+$ put}for & @ E/FontName get ~ definefont ! ! ! mF}b/UmF{L2?
+{Pscript_Windows_Font ~ undef}{!}?}b/UmF42{@ findfont/FDepVector get{/FontName
+get undefinefont}forall undefinefont}b
+%%EndResource
+end reinitialize
+Pscript_WinNT_Incr begin
+%%BeginResource: file Pscript_Encoding256 5.0 0
+/CharCol256Encoding[/.notdef/breve/caron/dotaccent/dotlessi/fi/fl/fraction
+/hungarumlaut/Lslash/lslash/minus/ogonek/ring/Zcaron/zcaron/.notdef/.notdef
+/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
+/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/exclam/quotedbl/numbersign
+/dollar/percent/ampersand/quotesingle/parenleft/parenright/asterisk/plus/comma
+/hyphen/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon
+/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S
+/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/asciicircum/underscore/grave
+/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright
+/asciitilde/.notdef/.notdef/.notdef/quotesinglbase/florin/quotedblbase/ellipsis
+/dagger/daggerdbl/circumflex/perthousand/Scaron/guilsinglleft/OE/.notdef
+/.notdef/.notdef/.notdef/quoteleft/quoteright/quotedblleft/quotedblright/bullet
+/endash/emdash/tilde/trademark/scaron/guilsinglright/oe/.notdef/.notdef
+/Ydieresis/.notdef/exclamdown/cent/sterling/currency/yen/brokenbar/section
+/dieresis/copyright/ordfeminine/guillemotleft/logicalnot/.notdef/registered
+/macron/degree/plusminus/twosuperior/threesuperior/acute/mu/paragraph
+/periodcentered/cedilla/onesuperior/ordmasculine/guillemotright/onequarter
+/onehalf/threequarters/questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis
+/Aring/AE/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute
+/Icircumflex/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
+/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls
+/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla/egrave/eacute
+/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis/eth/ntilde/ograve
+/oacute/ocircumflex/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex
+/udieresis/yacute/thorn/ydieresis]def EncodeDict/256 CharCol256Encoding put
+%%EndResource
+end reinitialize
+
+%%IncludeResource: font Helvetica
+F /F0 0 /256 T /Helvetica mF
+/F0S1C F0 [28.75 0 0 -28.75 0 0 ] mFS
+F0S1C Ji
+735 1441 M (ExceptionTable)[19 13 15 16 16 8 7 16 16 19 16 16 7 0]xS
+0.602 0 0.199 1 scol N 958 1456 M 711 1456 I 711 1499 I 958 1499 I C
+K
+N 958 1473 M 711 1473 I 711 1499 I 958 1499 I C
+K
+: N 1484 1418 275 93 rp C
+1 1 0.801 1 scol L ; N 1759 1417 M 1483 1417 I 1483 1511 I 1759 1511 I C
+K
+0 0 0 1 scol 1505 1453 M (LineNumberTable)[16 7 16 16 21 16 25 16 16 10 19 16 16 7 0]xS
+0.602 0 0.199 1 scol N 1759 1469 M 1483 1469 I 1483 1511 I 1759 1511 I C
+K
+N 1759 1485 M 1483 1485 I 1483 1511 I 1759 1511 I C
+K
+: N 1039 1411 318 253 rp C
+1 1 0.801 1 scol L ; N 1357 1410 M 1038 1410 I 1038 1664 I 1357 1664 I C
+K
+0 0 0 1 scol 1163 1446 M (Code)[21 16 16 0]xS
+0.602 0 0.199 1 scol N 1357 1462 M 1038 1462 I 1038 1664 I 1357 1664 I C
+K
+N 1357 1578 M 1038 1578 I 1038 1664 I 1357 1664 I C
+K
+0 0 0 1 scol 1083 1493 M (max_stack : int)[25 16 13 16 15 8 16 15 14 8 8 8 7 16 0]xS
+1083 1527 M (max_locals : int)[25 16 13 16 7 16 15 16 7 15 8 8 8 7 16 0]xS
+1083 1560 M (exception_handlers)[16 13 15 16 16 8 7 16 16 16 16 16 16 16 7 16 10 0]xS
+1083 1626 M (getCode\(\))[16 16 8 21 16 16 16 10 0]xS
+0.602 0 0.199 1 scol N 1420 1499 M 1358 1508 I K
+N 1358 1508 M 1380 1516 I 1398 1502 I 1377 1494 I 1358 1508 I C
+: 1 1 1 1 scol O ; K
+N 1420 1499 M 1482 1487 I K
+N 1462 1432 16 34 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1462 1459 M (1)S
+N 1462 1432 16 34 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1462 1459 M (1)S
+: N 1742 1576 291 93 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 2033 1575 M 1741 1575 I 1741 1669 I 2033 1669 I C
+K
+0 0 0 1 scol 1762 1611 M (LocalVariableTable)[16 16 15 16 7 19 16 10 7 16 16 7 16 19 16 16 7 0]xS
+0.602 0 0.199 1 scol N 2033 1626 M 1741 1626 I 1741 1669 I 2033 1669 I C
+K
+N 2033 1643 M 1741 1643 I 1741 1669 I 2033 1669 I C
+K
+N 1549 1580 M 1358 1556 I K
+N 1358 1556 M 1380 1547 I 1398 1562 I 1377 1570 I 1358 1556 I C
+: 1 1 1 1 scol O ; K
+N 1549 1580 M 1740 1603 I K
+: N 1709 1625 15 34 rp C
+1 1 1 1 scol L ; N 1709 1625 16 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1709 1652 M (1)S
+: N 1709 1625 15 34 rp C
+1 1 1 1 scol L ; N 1709 1625 16 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1709 1652 M (1)S
+: N 1573 1128 218 93 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 1791 1127 M 1572 1127 I 1572 1221 I 1791 1221 I C
+K
+0 0 0 1 scol 1597 1163 M (InnerClasses)[7 16 16 16 10 21 7 16 15 15 16 0]xS
+0.602 0 0.199 1 scol N 1791 1178 M 1572 1178 I 1572 1221 I 1791 1221 I C
+K
+N 1791 1195 M 1572 1195 I 1572 1221 I 1791 1221 I C
+K
+: N 1855 1128 186 93 rp C
+1 1 0.801 1 scol L ; N 2041 1127 M 1854 1127 I 1854 1221 I 2041 1221 I C
+K
+0 0 0 1 scol 1878 1163 M (SourceFile)[19 16 16 10 15 16 18 7 7 0]xS
+0.602 0 0.199 1 scol N 2041 1178 M 1854 1178 I 1854 1221 I 2041 1221 I C
+K
+N 2041 1195 M 1854 1195 I 1854 1221 I 2041 1221 I C
+K
+: N 450 1406 190 93 rp C
+1 1 0.801 1 scol L ; N 640 1405 M 449 1405 I 449 1499 I 640 1499 I C
+K
+0 0 0 1 scol 470 1441 M (Deprecated)[21 16 16 10 16 15 16 8 16 0]xS
+0.602 0 0.199 1 scol N 640 1456 M 449 1456 I 449 1499 I 640 1499 I C
+K
+N 640 1473 M 449 1473 I 449 1499 I 640 1499 I C
+K
+: N 2049 1418 161 93 rp C
+1 1 0.801 1 scol L ; N 2210 1417 M 2048 1417 I 2048 1511 I 2210 1511 I C
+K
+0 0 0 1 scol 2069 1453 M (Unknown)[21 16 14 16 16 21 0]xS
+0.602 0 0.199 1 scol N 2210 1469 M 2048 1469 I 2048 1511 I 2210 1511 I C
+K
+N 2210 1485 M 2048 1485 I 2048 1511 I 2210 1511 I C
+K
+: N 2105 1128 171 93 rp C
+1 1 0.801 1 scol L ; N 2276 1127 M 2104 1127 I 2104 1221 I 2276 1221 I C
+K
+0 0 0 1 scol 2131 1163 M (Synthetic)[19 13 16 8 16 16 8 7 0]xS
+0.602 0 0.199 1 scol N 2276 1178 M 2104 1178 I 2104 1221 I 2276 1221 I C
+K
+N 2276 1195 M 2104 1195 I 2104 1221 I 2276 1221 I C
+K
+: N 521 1128 240 93 rp C
+1 1 0.801 1 scol L ; N 761 1127 M 520 1127 I 520 1221 I 761 1221 I C
+K
+0 0 0 1 scol 546 1163 M (ConstantValue)[21 16 16 15 8 16 16 8 19 16 7 16 0]xS
+0.602 0 0.199 1 scol N 761 1177 M 520 1177 I 520 1221 I 761 1221 I C
+K
+N 761 1193 M 520 1193 I 520 1221 I 761 1221 I C
+K
+: N 491 628 204 125 rp C
+1 1 0.801 1 scol L ; N 695 627 M 490 627 I 490 753 I 695 753 I C
+K
+0.496 0.496 0.496 1 scol 1 Lj 1 Lc 12 Lw solid N 495 748 M 691 748 I 691 632 I : 0.754 0.754 +S K
+; 0 0 0 1 scol 513 663 M (ClassParser)[21 7 16 15 15 19 16 10 15 16 0]xS
+0.602 0 0.199 1 scol 1 Lw solid N 695 676 M 490 676 I 490 753 I 695 753 I C
+K
+N 695 693 M 490 693 I 490 753 I 695 753 I C
+K
+0 0 0 1 scol 535 741 M (parse\(\))[16 16 10 15 16 10 0]xS
+: N 1168 1116 157 93 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 1325 1115 M 1167 1115 I 1167 1209 I 1325 1209 I C
+K
+0 0 0 1 scol 1192 1151 M (Attribute)[19 8 8 10 7 16 16 8 0]xS
+0.602 0 0.199 1 scol N 1325 1164 M 1167 1164 I 1167 1209 I 1325 1209 I C
+K
+N 1325 1181 M 1167 1181 I 1167 1209 I 1325 1209 I C
+K
+N 1225 1279 M 1225 1210 I K
+N 528 1279 M 2187 1279 I K
+N 1225 1210 M 1242 1255 I 1209 1255 I C
+: 1 1 1 1 scol O ; K
+N 1190 1410 M 1190 1279 I K
+N 1091 1329 276 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1091 1356 M (<<Method attribute>>)[17 17 23 16 8 16 16 16 8 16 8 8 10 7 16 16 8 16 17 0]xS
+0.602 0 0.199 1 scol N 1602 1417 M 1602 1279 I K
+N 1479 1381 251 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1479 1408 M (<<Code attribute>>)[17 17 21 16 16 16 8 16 8 8 10 7 16 16 8 16 17 0]xS
+0.602 0 0.199 1 scol N 1941 1222 M 1941 1279 I K
+N 1823 1234 255 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1823 1261 M (<<Class attribute>>)[17 17 21 7 16 15 15 8 16 8 8 10 7 16 16 8 16 17 0]xS
+0.602 0 0.199 1 scol N 840 1405 M 840 1279 I K
+N 728 1326 276 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 728 1353 M (<<Method attribute>>)[17 17 23 16 8 16 16 16 8 16 8 8 10 7 16 16 8 16 17 0]xS
+0.602 0 0.199 1 scol N 2132 1417 M 2132 1279 I K
+N 528 1405 M 528 1279 I K
+N 416 1326 276 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 416 1353 M (<<Method attribute>>)[17 17 23 16 8 16 16 16 8 16 8 8 10 7 16 16 8 16 17 0]xS
+0.602 0 0.199 1 scol N 1870 1575 M 1870 1279 I K
+N 1748 1523 250 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1748 1550 M (<<Code attribute>>)[17 17 21 16 16 16 8 16 8 8 10 7 16 16 8 16 17 0]xS
+0.602 0 0.199 1 scol N 1673 1222 M 1673 1279 I K
+N 1541 1234 255 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1541 1261 M (<<Class attribute>>)[17 17 21 7 16 15 15 8 16 8 8 10 7 16 16 8 16 17 0]xS
+0.602 0 0.199 1 scol N 2187 1222 M 2187 1279 I K
+N 2068 1234 255 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 2068 1261 M (<<Class attribute>>)[17 17 21 7 16 15 15 8 16 8 8 10 7 16 16 8 16 17 0]xS
+0.602 0 0.199 1 scol N 638 1222 M 638 1279 I K
+N 536 1233 245 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 536 1260 M (<<Field attribute>>)[17 17 18 7 16 7 16 8 16 8 8 10 7 16 16 8 16 17 0]xS
+: N 1130 845 233 126 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 1363 844 M 1129 844 I 1129 971 I 1363 971 I C
+K
+0 0 0 1 scol
+%%IncludeResource: font Helvetica-Oblique
+F /F1 0 /256 T /Helvetica-Oblique mF
+/F1S1C F1 [28.75 0 0 -28.75 0 0 ] mFS
+F1S1C Ji
+1150 880 M (FieldOrMethod)[18 7 16 7 16 23 10 24 16 8 16 16 0]xS
+0.602 0 0.199 1 scol N 1363 894 M 1129 894 I 1129 971 I 1363 971 I C
+K
+N 1363 911 M 1129 911 I 1129 971 I 1363 971 I C
+K
+0 0 0 1 scol 1174 960 M (getName\(\))[16 16 8 21 16 24 16 10 0]xS
+: N 571 845 214 126 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 785 844 M 570 844 I 570 971 I 785 971 I C
+K
+0 0 0 1 scol 594 880 M (AccessFlags)[19 15 15 16 15 15 18 7 16 16 0]xS
+0.602 0 0.199 1 scol N 785 894 M 570 894 I 570 971 I 785 971 I C
+K
+N 785 911 M 570 911 I 570 971 I 785 971 I C
+K
+0 0 0 1 scol 614 960 M (isPublic\(\))[7 15 19 16 16 7 7 15 10 0]xS
+0.602 0 0.199 1 scol N 1128 908 M 786 908 I K
+N 786 908 M 831 925 I 831 891 I C
+: 1 1 1 1 scol O ; K
+N 1237 1043 M 1237 972 I K
+N 992 1043 M 1497 1043 I K
+N 1237 972 M 1253 1017 I 1220 1017 I C
+: 1 1 1 1 scol O ; K
+: N 1494 1023 134 84 rp C
+1 1 0.801 1 scol L ; N 1628 1022 M 1493 1022 I 1493 1107 I 1628 1107 I C
+K
+0 0 0 1 scol F0S1C Ji
+1513 1058 M (Method)[23 16 8 16 16 0]xS
+0.602 0 0.199 1 scol N 1628 1074 M 1493 1074 I 1493 1107 I 1628 1107 I C
+K
+N 1628 1090 M 1493 1090 I 1493 1107 I 1628 1107 I C
+K
+N 1409 1111 M 1492 1085 I K
+N 1488 1110 16 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1488 1137 M (1)S
+0.602 0 0.199 1 scol N 1492 1085 M 1476 1102 I 1454 1097 I 1470 1080 I 1492 1085 I C
+: 1 1 1 1 scol O ; K
+N 1409 1111 M 1326 1136 I K
+N 1341 1157 11 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1341 1184 M (*)S
+N 1488 1110 16 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1488 1137 M (1)S
+N 1341 1157 11 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1341 1184 M (*)S
+0.602 0 0.199 1 scol N 1497 1028 M 1497 1043 I K
+: N 1734 802 235 139 rp C
+1 1 0.801 1 scol L ; N 1969 801 M 1733 801 I 1733 941 I 1969 941 I C
+K
+0 0 0 1 scol 1764 837 M (ConstantPool)[21 16 16 15 8 16 16 8 19 16 16 0]xS
+0.602 0 0.199 1 scol N 1969 853 M 1733 853 I 1733 941 I 1969 941 I C
+K
+N 1969 869 M 1733 869 I 1733 941 I 1969 941 I C
+K
+0 0 0 1 scol 1777 918 M (getConstant\(\))[16 16 8 21 16 16 15 8 16 16 8 10 0]xS
+: N 1088 610 317 160 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 1405 609 M 1087 609 I 1087 770 I 1405 770 I C
+K
+0 0 0 1 scol 1179 645 M (JavaClass)[15 16 13 16 21 7 16 15 0]xS
+0.602 0 0.199 1 scol N 1405 659 M 1087 659 I 1087 770 I 1405 770 I C
+K
+N 1405 676 M 1087 676 I 1087 770 I 1405 770 I C
+K
+0 0 0 1 scol 1131 724 M (getInterfaceNames\(\))[16 16 8 7 16 8 16 10 8 16 15 16 21 16 25 16 15 10 0]xS
+1131 757 M (getSuperclassName\(\))[16 16 8 19 16 16 16 10 15 7 16 15 15 21 16 25 16 10 0]xS
+0.602 0 0.199 1 scol N 1419 896 M 1314 771 I K
+N 1287 794 16 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1287 821 M (1)S
+0.602 0 0.199 1 scol N 1314 771 M 1336 779 I 1340 802 I 1318 794 I 1314 771 I C
+: 1 1 1 1 scol O ; K
+N 1419 896 M 1524 1021 I K
+N 1539 966 11 34 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1539 993 M (*)S
+N 1287 794 16 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1287 821 M (1)S
+N 1539 966 11 34 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1539 993 M (*)S
+1 1 1 1 scol [ 72 24 ] 0 sd N 696 690 M 1086 690 I K
+0 0 0 1 scol [ 72 24 ] 0 sd N 696 690 M 1086 690 I K
+3 Lw solid N 1086 690 M 1059 701 I : 0.754 0.754 +S K
+; N 1086 690 M 1059 679 I : 0.754 0.754 +S K
+; N 847 641 164 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 847 668 M (<<creates>>)[17 17 15 10 16 16 8 16 15 17 0]xS
+0.602 0 0.199 1 scol 1 Lw solid N 1569 786 M 1406 737 I K
+N 1569 786 M 1732 835 I K
+N 1086 751 M 786 866 I K
+N 786 866 M 834 866 I 822 834 I C
+: 1 1 1 1 scol O ; K
+: N 865 1023 134 84 rp C
+1 1 0.801 1 scol L ; N 999 1022 M 864 1022 I 864 1107 I 999 1107 I C
+K
+0 0 0 1 scol 899 1058 M (Field)[18 7 16 7 0]xS
+0.602 0 0.199 1 scol N 999 1072 M 864 1072 I 864 1107 I 999 1107 I C
+K
+N 999 1089 M 864 1089 I 864 1107 I 999 1107 I C
+K
+N 1083 1111 M 1000 1086 I K
+N 990 1111 16 34 rp C
+1 1 1 1 scol L 0 0 0 1 scol 990 1138 M (1)S
+0.602 0 0.199 1 scol N 1000 1086 M 1023 1081 I 1039 1098 I 1017 1102 I 1000 1086 I C
+: 1 1 1 1 scol O ; K
+N 1083 1111 M 1166 1136 I K
+N 1165 1079 11 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1165 1106 M (*)S
+N 990 1111 16 34 rp C
+1 1 1 1 scol L 0 0 0 1 scol 990 1138 M (1)S
+N 1165 1079 11 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1165 1106 M (*)S
+0.602 0 0.199 1 scol N 992 1067 M 992 1043 I K
+N 1072 896 M 1177 771 I K
+N 1190 794 16 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1190 821 M (1)S
+0.602 0 0.199 1 scol N 1177 771 M 1173 794 I 1150 802 I 1155 779 I 1177 771 I C
+: 1 1 1 1 scol O ; K
+N 1072 896 M 967 1021 I K
+N 1004 1018 11 34 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1004 1045 M (*)S
+N 1190 794 16 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1190 821 M (1)S
+N 1004 1018 11 34 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1004 1045 M (*)S
+LH
+%%PageTrailer
+
+%%Trailer
+%%DocumentNeededResources:
+%%+ font Helvetica-Oblique
+%%+ font Helvetica
+%%DocumentSuppliedResources:
+Pscript_WinNT_Incr dup /terminate get exec
+%%EOF
+grestore
diff --git a/docs/eps/javaclass.fig b/docs/eps/javaclass.fig
new file mode 100644
index 00000000..380a6537
--- /dev/null
+++ b/docs/eps/javaclass.fig
@@ -0,0 +1,353 @@
+#FIG 3.2
+Portrait
+Center
+Inches
+A4
+100.00
+Single
+-2
+1200 2
+0 32 #f9f9f9
+0 33 #303030
+0 34 #7e7e7e
+6 1939 6082 2499 7310
+2 1 0 1 33 33 866 0 -1 4.000 0 0 0 0 0 5
+ 1951 7310 1939 7186 2039 7114 2051 7234 1951 7310
+2 1 0 1 33 33 865 0 -1 4.000 0 0 0 0 0 2
+ 2227 6698 2499 6082
+-6
+2 1 0 0 32 32 998 0 20 4.000 0 0 0 0 0 4
+ 3983 8614 3983 7314 4475 7314 4475 8614
+2 1 0 1 33 33 997 0 -1 4.000 0 0 0 0 0 5
+ 3979 8618 3979 7310 4479 7310 4479 8618 3979 8618
+2 1 0 1 33 33 995 0 -1 4.000 0 0 0 0 0 5
+ 4243 8618 4243 7310 4479 7310 4479 8618 4243 8618
+2 1 0 1 33 33 994 0 -1 4.000 0 0 0 0 0 5
+ 4335 8618 4335 7310 4479 7310 4479 8618 4335 8618
+2 1 0 0 32 32 993 0 20 4.000 0 0 0 0 0 4
+ 4047 4530 4047 3078 4539 3078 4539 4530
+2 1 0 1 33 33 992 0 -1 4.000 0 0 0 0 0 5
+ 4043 4534 4043 3074 4543 3074 4543 4534 4043 4534
+2 1 0 1 33 33 990 0 -1 4.000 0 0 0 0 0 5
+ 4307 4534 4307 3074 4543 3074 4543 4534 4307 4534
+2 1 0 1 33 33 989 0 -1 4.000 0 0 0 0 0 5
+ 4399 4534 4399 3074 4543 3074 4543 4534 4399 4534
+2 1 0 0 32 32 988 0 20 4.000 0 0 0 0 0 4
+ 4011 6882 4011 5206 5343 5206 5343 6882
+2 1 0 1 33 33 987 0 -1 4.000 0 0 0 0 0 5
+ 4007 6886 4007 5202 5347 5202 5347 6886 4007 6886
+2 1 0 1 33 33 985 0 -1 4.000 0 0 0 0 0 5
+ 4271 6886 4271 5202 5347 5202 5347 6886 4271 6886
+2 1 0 1 33 33 984 0 -1 4.000 0 0 0 0 0 5
+ 4927 6886 4927 5202 5347 5202 5347 6886 4927 6886
+2 1 0 1 33 33 979 0 -1 4.000 0 0 0 0 0 2
+ 4475 4870 4523 5198
+2 1 0 0 7 7 978 0 20 4.000 0 0 0 0 0 5
+ 4523 5198 4567 5082 4491 4986 4447 5098 4523 5198
+2 1 0 1 33 33 977 0 -1 4.000 0 0 0 0 0 5
+ 4523 5198 4567 5082 4491 4986 4447 5098 4523 5198
+2 1 0 1 33 33 976 0 -1 4.000 0 0 0 0 0 2
+ 4475 4870 4411 4538
+2 1 0 0 7 7 975 0 20 4.000 0 0 0 0 0 4
+ 4119 4650 4119 4558 4307 4558 4307 4650
+2 1 0 0 7 7 973 0 20 4.000 0 0 0 0 0 4
+ 4119 4650 4119 4558 4307 4558 4307 4650
+2 1 0 0 32 32 971 0 20 4.000 0 0 0 0 0 4
+ 4879 3166 4879 1626 5371 1626 5371 3166
+2 1 0 1 33 33 970 0 -1 4.000 0 0 0 0 0 5
+ 4875 3170 4875 1622 5375 1622 5375 3170 4875 3170
+2 1 0 1 33 33 968 0 -1 4.000 0 0 0 0 0 5
+ 5139 3170 5139 1622 5375 1622 5375 3170 5139 3170
+2 1 0 1 33 33 967 0 -1 4.000 0 0 0 0 0 5
+ 5231 3170 5231 1622 5375 1622 5375 3170 5231 3170
+2 1 0 1 33 33 966 0 -1 4.000 0 0 0 0 0 2
+ 4903 4186 4779 5198
+2 1 0 0 7 7 965 0 20 4.000 0 0 0 0 0 5
+ 4779 5198 4731 5082 4807 4982 4851 5098 4779 5198
+2 1 0 1 33 33 964 0 -1 4.000 0 0 0 0 0 5
+ 4779 5198 4731 5082 4807 4982 4851 5098 4779 5198
+2 1 0 1 33 33 963 0 -1 4.000 0 0 0 0 0 2
+ 4903 4186 5027 3174
+2 1 0 0 7 7 962 0 20 4.000 0 0 0 0 0 4
+ 5139 3346 5139 3254 5327 3254 5327 3346
+2 1 0 0 7 7 960 0 20 4.000 0 0 0 0 0 4
+ 5139 3346 5139 3254 5327 3254 5327 3346
+2 1 0 0 32 32 958 0 20 4.000 0 0 0 0 0 4
+ 2511 4058 2511 2910 3003 2910 3003 4058
+2 1 0 1 33 33 957 0 -1 4.000 0 0 0 0 0 5
+ 2507 4062 2507 2906 3007 2906 3007 4062 2507 4062
+2 1 0 1 33 33 955 0 -1 4.000 0 0 0 0 0 5
+ 2771 4062 2771 2906 3007 2906 3007 4062 2771 4062
+2 1 0 1 33 33 954 0 -1 4.000 0 0 0 0 0 5
+ 2863 4062 2863 2906 3007 2906 3007 4062 2863 4062
+2 1 0 0 32 32 953 0 20 4.000 0 0 0 0 0 4
+ 2511 2566 2511 1586 3003 1586 3003 2566
+2 1 0 1 33 33 952 0 -1 4.000 0 0 0 0 0 5
+ 2507 2570 2507 1582 3007 1582 3007 2570 2507 2570
+2 1 0 1 33 33 950 0 -1 4.000 0 0 0 0 0 5
+ 2751 2570 2751 1582 3007 1582 3007 2570 2751 2570
+2 1 0 1 33 33 949 0 -1 4.000 0 0 0 0 0 5
+ 2843 2570 2843 1582 3007 1582 3007 2570 2843 2570
+2 1 0 0 32 32 948 0 20 4.000 0 0 0 0 0 4
+ 3983 10002 3983 8998 4475 8998 4475 10002
+2 1 0 1 33 33 947 0 -1 4.000 0 0 0 0 0 5
+ 3979 10006 3979 8994 4479 8994 4479 10006 3979 10006
+2 1 0 1 33 33 945 0 -1 4.000 0 0 0 0 0 5
+ 4243 10006 4243 8994 4479 8994 4479 10006 4243 10006
+2 1 0 1 33 33 944 0 -1 4.000 0 0 0 0 0 5
+ 4335 10006 4335 8994 4479 8994 4479 10006 4335 10006
+2 1 0 0 32 32 943 0 20 4.000 0 0 0 0 0 4
+ 4047 1542 4047 690 4539 690 4539 1542
+2 1 0 1 33 33 942 0 -1 4.000 0 0 0 0 0 5
+ 4043 1546 4043 686 4543 686 4543 1546 4043 1546
+2 1 0 1 33 33 940 0 -1 4.000 0 0 0 0 0 5
+ 4287 1546 4287 686 4543 686 4543 1546 4287 1546
+2 1 0 1 33 33 939 0 -1 4.000 0 0 0 0 0 5
+ 4379 1546 4379 686 4543 686 4543 1546 4379 1546
+2 1 0 0 32 32 938 0 20 4.000 0 0 0 0 0 4
+ 2511 1246 2511 346 3003 346 3003 1246
+2 1 0 1 33 33 937 0 -1 4.000 0 0 0 0 0 5
+ 2507 1250 2507 342 3007 342 3007 1250 2507 1250
+2 1 0 1 33 33 935 0 -1 4.000 0 0 0 0 0 5
+ 2751 1250 2751 342 3007 342 3007 1250 2751 1250
+2 1 0 1 33 33 934 0 -1 4.000 0 0 0 0 0 5
+ 2843 1250 2843 342 3007 342 3007 1250 2843 1250
+2 1 0 0 32 32 933 0 20 4.000 0 0 0 0 0 4
+ 2511 9622 2511 8354 3003 8354 3003 9622
+2 1 0 1 33 33 932 0 -1 4.000 0 0 0 0 0 5
+ 2507 9626 2507 8350 3007 8350 3007 9626 2507 9626
+2 1 0 1 33 33 930 0 -1 4.000 0 0 0 0 0 5
+ 2771 9626 2771 8350 3007 8350 3007 9626 2771 9626
+2 1 0 1 33 33 929 0 -1 4.000 0 0 0 0 0 5
+ 2863 9626 2863 8350 3007 8350 3007 9626 2863 9626
+2 1 0 0 32 32 928 0 20 4.000 0 0 0 0 0 4
+ 315 9526 315 8450 975 8450 975 9526
+2 1 0 1 33 33 927 0 -1 4.000 0 0 0 0 0 5
+ 311 9530 311 8446 979 8446 979 9530 311 9530
+2 1 0 2 34 34 926 0 -1 4.000 0 0 0 0 0 3
+ 955 9502 955 8470 339 8470
+2 1 0 1 33 33 924 0 -1 4.000 0 0 0 0 0 5
+ 575 9530 575 8446 979 8446 979 9530 575 9530
+2 1 0 1 33 33 923 0 -1 4.000 0 0 0 0 0 5
+ 667 9530 667 8446 979 8446 979 9530 667 9530
+2 1 0 0 32 32 921 0 20 4.000 0 0 0 0 0 4
+ 2447 6074 2447 5246 2939 5246 2939 6074
+2 1 0 1 33 33 920 0 -1 4.000 0 0 0 0 0 5
+ 2443 6078 2443 5242 2943 5242 2943 6078 2443 6078
+2 1 0 1 33 33 918 0 -1 4.000 0 0 0 0 0 5
+ 2707 6078 2707 5242 2943 5242 2943 6078 2707 6078
+2 1 0 1 33 33 917 0 -1 4.000 0 0 0 0 0 5
+ 2799 6078 2799 5242 2943 5242 2943 6078 2799 6078
+2 1 0 1 33 33 916 0 -1 4.000 0 0 0 0 0 2
+ 3311 5658 2947 5658
+2 1 0 1 33 33 915 0 -1 4.000 0 0 0 0 0 2
+ 3311 9586 3311 810
+2 1 0 0 7 7 914 0 20 4.000 0 0 0 0 0 4
+ 2947 5658 3187 5570 3187 5746 2947 5658
+2 1 0 1 33 33 913 0 -1 4.000 0 0 0 0 0 4
+ 2947 5658 3187 5570 3187 5746 2947 5658
+2 1 0 1 33 33 912 0 -1 4.000 0 0 0 0 0 2
+ 4007 6086 3311 6086
+2 1 0 0 7 7 911 0 20 4.000 0 0 0 0 0 4
+ 3563 6658 3563 5098 3751 5098 3751 6658
+2 1 0 1 33 33 909 0 -1 4.000 0 0 0 0 0 2
+ 4043 3906 3311 3906
+2 1 0 0 7 7 908 0 20 4.000 0 0 0 0 0 4
+ 3847 4598 3847 3186 4035 3186 4035 4598
+2 1 0 1 33 33 906 0 -1 4.000 0 0 0 0 0 2
+ 3011 2114 3311 2114
+2 1 0 0 7 7 905 0 20 4.000 0 0 0 0 0 4
+ 3067 2774 3067 1346 3255 1346 3255 2774
+2 1 0 1 33 33 903 0 -1 4.000 0 0 0 0 0 2
+ 3979 7934 3311 7934
+2 1 0 0 7 7 902 0 20 4.000 0 0 0 0 0 4
+ 3555 8578 3555 7018 3743 7018 3743 8578
+2 1 0 1 33 33 900 0 -1 4.000 0 0 0 0 0 2
+ 4043 1102 3311 1102
+2 1 0 1 33 33 899 0 -1 4.000 0 0 0 0 0 2
+ 3979 9586 3311 9586
+2 1 0 0 7 7 898 0 20 4.000 0 0 0 0 0 4
+ 3555 10230 3555 8670 3743 8670 3743 10230
+2 1 0 0 32 32 896 0 20 4.000 0 0 0 0 0 4
+ 1203 4066 1203 2518 2135 2518 2135 4066
+2 1 0 1 33 33 895 0 -1 4.000 0 0 0 0 0 5
+ 1199 4070 1199 2514 2139 2514 2139 4070 1199 4070
+2 1 0 1 33 33 893 0 -1 4.000 0 0 0 0 0 5
+ 1463 4070 1463 2514 2139 2514 2139 4070 1463 4070
+2 1 0 1 33 33 892 0 -1 4.000 0 0 0 0 0 5
+ 1931 4070 1931 2514 2139 2514 2139 4070 1931 4070
+2 1 0 1 33 33 889 0 -1 4.000 0 0 0 0 0 2
+ 2259 4658 2003 4074
+2 1 0 0 7 7 888 0 20 4.000 0 0 0 0 0 4
+ 2135 4090 2135 3998 2323 3998 2323 4090
+2 1 0 0 7 7 886 0 20 4.000 0 0 0 0 0 5
+ 2003 4074 2103 4150 2091 4270 1991 4198 2003 4074
+2 1 0 1 33 33 885 0 -1 4.000 0 0 0 0 0 5
+ 2003 4074 2103 4150 2091 4270 1991 4198 2003 4074
+2 1 0 1 33 33 884 0 -1 4.000 0 0 0 0 0 2
+ 2259 4658 2503 5238
+2 1 0 0 7 7 883 0 20 4.000 0 0 0 0 0 4
+ 2583 5122 2583 5058 2771 5058 2771 5122
+2 1 0 0 7 7 881 0 20 4.000 0 0 0 0 0 4
+ 2135 4090 2135 3998 2323 3998 2323 4090
+2 1 0 0 7 7 879 0 20 4.000 0 0 0 0 0 4
+ 2583 5122 2583 5058 2771 5058 2771 5122
+2 1 0 0 32 32 877 0 20 4.000 0 0 0 0 0 4
+ 1139 8866 1139 7318 2071 7318 2071 8866
+2 1 0 1 33 33 876 0 -1 4.000 0 0 0 0 0 5
+ 1135 8870 1135 7314 2075 7314 2075 8870 1135 8870
+2 1 0 1 33 33 874 0 -1 4.000 0 0 0 0 0 5
+ 1399 8870 1399 7314 2075 7314 2075 8870 1399 8870
+2 1 0 1 33 33 873 0 -1 4.000 0 0 0 0 0 5
+ 1867 8870 1867 7314 2075 7314 2075 8870 1867 8870
+2 1 0 1 33 33 870 0 -1 4.000 0 0 0 0 0 2
+ 2227 6698 1951 7310
+2 1 0 0 7 7 869 0 20 4.000 0 0 0 0 0 4
+ 2083 7378 2083 7286 2271 7286 2271 7378
+2 1 0 0 7 7 867 0 20 4.000 0 0 0 0 0 5
+ 1951 7310 1939 7186 2039 7114 2051 7234 1951 7310
+2 1 0 0 7 7 864 0 20 4.000 0 0 0 0 0 4
+ 2187 6090 2187 6026 2375 6026 2375 6090
+2 1 0 0 7 7 862 0 20 4.000 0 0 0 0 0 4
+ 2083 7378 2083 7286 2271 7286 2271 7378
+2 1 0 0 7 7 860 0 20 4.000 0 0 0 0 0 4
+ 2187 6090 2187 6026 2375 6026 2375 6090
+2 1 0 0 32 32 858 0 20 4.000 0 0 0 0 0 4
+ 79 6578 79 4742 1211 4742 1211 6578
+2 1 0 1 33 33 857 0 -1 4.000 0 0 0 0 0 5
+ 75 6582 75 4738 1215 4738 1215 6582 75 6582
+2 1 0 1 33 33 855 0 -1 4.000 0 0 0 0 0 5
+ 339 6582 339 4738 1215 4738 1215 6582 339 6582
+2 1 0 1 33 33 854 0 -1 4.000 0 0 0 0 0 5
+ 619 6582 619 4738 1215 4738 1215 6582 619 6582
+2 1 0 1 33 33 850 0 -1 4.000 0 0 0 0 0 2
+ 1187 4406 1043 4734
+2 1 0 0 7 7 849 0 20 4.000 0 0 0 0 0 4
+ 1163 4826 1163 4734 1351 4734 1351 4826
+2 1 0 0 7 7 847 0 20 4.000 0 0 0 0 0 5
+ 1043 4734 1031 4610 1131 4538 1143 4658 1043 4734
+2 1 0 1 33 33 846 0 -1 4.000 0 0 0 0 0 5
+ 1043 4734 1031 4610 1131 4538 1143 4658 1043 4734
+2 1 0 1 33 33 845 0 -1 4.000 0 0 0 0 0 2
+ 1187 4406 1331 4074
+2 1 0 0 7 7 844 0 20 4.000 0 0 0 0 0 4
+ 1027 4062 1027 3998 1215 3998 1215 4062
+2 1 0 0 7 7 842 0 20 4.000 0 0 0 0 0 4
+ 1163 4826 1163 4734 1351 4734 1351 4826
+2 1 0 0 7 7 840 0 20 4.000 0 0 0 0 0 4
+ 1027 4062 1027 3998 1215 3998 1215 4062
+2 1 0 1 33 33 838 0 -1 4.000 0 0 0 0 0 2
+ 1151 6950 1003 6586
+2 1 0 0 7 7 837 0 20 4.000 0 0 0 0 0 4
+ 1127 6590 1127 6498 1315 6498 1315 6590
+2 1 0 0 7 7 835 0 20 4.000 0 0 0 0 0 5
+ 1003 6586 1099 6662 1083 6786 987 6710 1003 6586
+2 1 0 1 33 33 834 0 -1 4.000 0 0 0 0 0 5
+ 1003 6586 1099 6662 1083 6786 987 6710 1003 6586
+2 1 0 1 33 33 833 0 -1 4.000 0 0 0 0 0 2
+ 1151 6950 1291 7310
+2 1 0 0 7 7 832 0 20 4.000 0 0 0 0 0 4
+ 1383 7222 1383 7158 1571 7158 1571 7222
+2 1 0 0 7 7 830 0 20 4.000 0 0 0 0 0 4
+ 1127 6590 1127 6498 1315 6498 1315 6590
+2 1 0 0 7 7 828 0 20 4.000 0 0 0 0 0 4
+ 1383 7222 1383 7158 1571 7158 1571 7222
+2 1 1 1 7 7 826 0 -1 4.000 0 0 0 0 0 2
+ 647 8442 647 6586
+2 1 1 1 0 0 825 0 -1 4.000 0 0 0 0 0 2
+ 647 8442 647 6586
+2 1 0 1 0 0 824 0 -1 4.000 0 0 0 0 0 2
+ 647 6586 707 6730
+2 1 0 1 0 0 823 0 -1 4.000 0 0 0 0 0 2
+ 647 6586 587 6730
+2 1 0 0 7 7 822 0 20 4.000 0 0 0 0 0 4
+ 379 7974 379 7050 567 7050 567 7974
+2 1 0 0 32 32 820 0 20 4.000 0 0 0 0 0 4
+ 279 1994 279 750 1011 750 1011 1994
+2 1 0 1 33 33 819 0 -1 4.000 0 0 0 0 0 5
+ 275 1998 275 746 1015 746 1015 1998 275 1998
+2 1 0 1 33 33 817 0 -1 4.000 0 0 0 0 0 5
+ 519 1998 519 746 1015 746 1015 1998 519 1998
+2 1 0 1 33 33 816 0 -1 4.000 0 0 0 0 0 5
+ 611 1998 611 746 1015 746 1015 1998 611 1998
+2 1 0 1 33 33 814 0 -1 4.000 0 0 0 0 0 2
+ 647 3370 647 4734
+2 1 0 1 33 33 813 0 -1 4.000 0 0 0 0 0 2
+ 647 3370 647 2002
+2 1 0 1 33 33 812 0 -1 4.000 0 0 0 0 0 2
+ 4875 2490 3311 2490
+2 1 0 1 33 33 809 0 -1 4.000 0 0 0 0 0 2
+ 3011 3530 3311 3530
+2 1 0 0 7 7 808 0 20 4.000 0 0 0 0 0 4
+ 3067 4266 3067 2838 3255 2838 3255 4266
+2 1 0 1 33 33 806 0 -1 4.000 0 0 0 0 0 2
+ 3011 810 3311 810
+2 1 0 0 7 7 805 0 20 4.000 0 0 0 0 0 4
+ 3067 1482 3067 54 3255 54 3255 1482
+2 1 0 1 33 33 803 0 -1 4.000 0 0 0 0 0 2
+ 3011 9002 3311 9002
+2 1 0 0 7 7 802 0 20 4.000 0 0 0 0 0 4
+ 3063 9578 3063 8206 3251 8206 3251 9578
+2 1 0 1 0 0 866 0 -1 0.000 0 0 0 0 0 5
+ 1224 5762 1331 5699 1439 5760 1335 5821 1224 5762
+2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
+ 1451 5759 2426 5759
+4 0 0 996 -1 16 10 1.5708 4 150 1080 4179 8526 ExceptionTable\001
+4 0 0 991 -1 16 10 1.5708 4 120 1230 4243 4466 LineNumberTable\001
+4 0 0 986 -1 16 10 1.5708 4 120 375 4207 6242 Code\001
+4 0 0 983 -1 16 10 1.5708 4 150 1035 4447 6650 max_stack : int\001
+4 0 0 982 -1 16 10 1.5708 4 150 1065 4635 6650 max_locals : int\001
+4 0 0 981 -1 16 10 1.5708 4 150 1365 4823 6650 exception_handlers\001
+4 0 0 980 -1 16 10 1.5708 4 150 690 5199 6650 getCode()\001
+4 0 0 974 -1 16 10 1.5708 4 105 90 4271 4650 1\001
+4 0 0 972 -1 16 10 1.5708 4 105 90 4271 4650 1\001
+4 0 0 969 -1 16 10 1.5708 4 120 1335 5075 3106 LocalVariableTable\001
+4 0 0 961 -1 16 10 1.5708 4 105 90 5291 3346 1\001
+4 0 0 959 -1 16 10 1.5708 4 105 90 5291 3346 1\001
+4 0 0 956 -1 16 10 1.5708 4 120 900 2707 3962 InnerClasses\001
+4 0 0 951 -1 16 10 1.5708 4 120 735 2707 2470 SourceFile\001
+4 0 0 946 -1 16 10 1.5708 4 150 810 4179 9926 Deprecated\001
+4 0 0 941 -1 16 10 1.5708 4 120 645 4243 1458 Unknown\001
+4 0 0 936 -1 16 10 1.5708 4 150 645 2707 1126 Synthetic\001
+4 0 0 931 -1 16 10 1.5708 4 120 1035 2707 9526 ConstantValue\001
+4 0 0 925 -1 16 10 1.5708 4 120 825 511 9434 ClassParser\001
+4 0 0 919 -1 16 10 1.5708 4 120 585 2643 5962 Attribute\001
+4 0 0 910 -1 16 10 1.5708 4 120 1500 3715 6658 <<Method attribute>>\001
+4 0 0 904 -1 16 10 1.5708 4 120 1350 3219 2774 <<Class attribute>>\001
+4 0 0 901 -1 16 10 1.5708 4 120 1500 3707 8578 <<Method attribute>>\001
+4 0 0 897 -1 16 10 1.5708 4 120 1500 3707 10230 <<Method attribute>>\001
+4 0 0 894 -1 16 10 1.5708 4 120 525 1399 3562 Method\001
+4 0 0 891 -1 16 10 1.5708 4 150 1200 1639 3834 access_flags : int\001
+4 0 0 890 -1 16 10 1.5708 4 150 1185 1827 3834 signature : String\001
+4 0 0 887 -1 16 10 1.5708 4 105 90 2287 4090 1\001
+4 0 0 882 -1 16 10 1.5708 4 60 60 2735 5122 *\001
+4 0 0 880 -1 16 10 1.5708 4 105 90 2287 4090 1\001
+4 0 0 878 -1 16 10 1.5708 4 60 60 2735 5122 *\001
+4 0 0 875 -1 16 10 1.5708 4 120 330 1335 8270 Field\001
+4 0 0 872 -1 16 10 1.5708 4 150 1200 1575 8634 access_flags : int\001
+4 0 0 871 -1 16 10 1.5708 4 150 1185 1763 8634 signature : String\001
+4 0 0 868 -1 16 10 1.5708 4 105 90 2235 7378 1\001
+4 0 0 863 -1 16 10 1.5708 4 60 60 2339 6090 *\001
+4 0 0 861 -1 16 10 1.5708 4 105 90 2235 7378 1\001
+4 0 0 859 -1 16 10 1.5708 4 60 60 2339 6090 *\001
+4 0 0 856 -1 16 10 1.5708 4 120 705 275 6038 JavaClass\001
+4 0 0 853 -1 16 10 1.5708 4 150 1200 515 6346 access_flags : int\001
+4 0 0 852 -1 16 10 1.5708 4 150 1410 891 6346 getInterfaceNames()\001
+4 0 0 851 -1 16 10 1.5708 4 150 1485 1079 6346 getSuperclassName()\001
+4 0 0 848 -1 16 10 1.5708 4 105 90 1315 4826 1\001
+4 0 0 843 -1 16 10 1.5708 4 60 60 1179 4062 *\001
+4 0 0 841 -1 16 10 1.5708 4 105 90 1315 4826 1\001
+4 0 0 839 -1 16 10 1.5708 4 60 60 1179 4062 *\001
+4 0 0 836 -1 16 10 1.5708 4 105 90 1279 6590 1\001
+4 0 0 831 -1 16 10 1.5708 4 60 60 1535 7222 *\001
+4 0 0 829 -1 16 10 1.5708 4 105 90 1279 6590 1\001
+4 0 0 827 -1 16 10 1.5708 4 60 60 1535 7222 *\001
+4 0 0 821 -1 16 10 1.5708 4 90 870 531 7974 <<creates>>\001
+4 0 0 818 -1 16 10 1.5708 4 120 945 475 1866 ConstantPool\001
+4 0 0 815 -1 16 10 1.5708 4 135 945 883 1762 getConstant()\001
+4 0 0 807 -1 16 10 1.5708 4 120 1350 3219 4266 <<Class attribute>>\001
+4 0 0 804 -1 16 10 1.5708 4 120 1350 3219 1482 <<Class attribute>>\001
+4 0 0 801 -1 16 10 1.5708 4 120 1305 3215 9578 <<Field attribute>>\001
+4 0 0 922 -1 16 10 1.5708 4 135 480 864 9294 parse()\001
+4 0 0 907 -1 16 10 1.5708 4 120 1350 3924 4583 <<Code attribute>>\001
+4 0 0 810 -1 16 10 1.5708 4 120 1350 4725 3075 <<Code attribute>>\001
diff --git a/docs/eps/jvm.eps b/docs/eps/jvm.eps
new file mode 100644
index 00000000..c85c7617
--- /dev/null
+++ b/docs/eps/jvm.eps
@@ -0,0 +1,218 @@
+%!PS-Adobe-2.0 EPSF-2.0
+%%Title: jvm.eps
+%%Creator: fig2dev Version 3.2 Patchlevel 1
+%%CreationDate: Thu Nov 19 11:55:18 1998
+%%For: dahm@che (Markus Dahm,,,,,)
+%%Orientation: Portrait
+%%BoundingBox: 0 0 439 199
+%%Pages: 0
+%%BeginSetup
+%%EndSetup
+%%Magnification: 1.0000
+%%EndComments
+/$F2psDict 200 dict def
+$F2psDict begin
+$F2psDict /mtrx matrix put
+/col-1 {0 setgray} bind def
+/col0 {0.000 0.000 0.000 srgb} bind def
+/col1 {0.000 0.000 1.000 srgb} bind def
+/col2 {0.000 1.000 0.000 srgb} bind def
+/col3 {0.000 1.000 1.000 srgb} bind def
+/col4 {1.000 0.000 0.000 srgb} bind def
+/col5 {1.000 0.000 1.000 srgb} bind def
+/col6 {1.000 1.000 0.000 srgb} bind def
+/col7 {1.000 1.000 1.000 srgb} bind def
+/col8 {0.000 0.000 0.560 srgb} bind def
+/col9 {0.000 0.000 0.690 srgb} bind def
+/col10 {0.000 0.000 0.820 srgb} bind def
+/col11 {0.530 0.810 1.000 srgb} bind def
+/col12 {0.000 0.560 0.000 srgb} bind def
+/col13 {0.000 0.690 0.000 srgb} bind def
+/col14 {0.000 0.820 0.000 srgb} bind def
+/col15 {0.000 0.560 0.560 srgb} bind def
+/col16 {0.000 0.690 0.690 srgb} bind def
+/col17 {0.000 0.820 0.820 srgb} bind def
+/col18 {0.560 0.000 0.000 srgb} bind def
+/col19 {0.690 0.000 0.000 srgb} bind def
+/col20 {0.820 0.000 0.000 srgb} bind def
+/col21 {0.560 0.000 0.560 srgb} bind def
+/col22 {0.690 0.000 0.690 srgb} bind def
+/col23 {0.820 0.000 0.820 srgb} bind def
+/col24 {0.500 0.190 0.000 srgb} bind def
+/col25 {0.630 0.250 0.000 srgb} bind def
+/col26 {0.750 0.380 0.000 srgb} bind def
+/col27 {1.000 0.500 0.500 srgb} bind def
+/col28 {1.000 0.630 0.630 srgb} bind def
+/col29 {1.000 0.750 0.750 srgb} bind def
+/col30 {1.000 0.880 0.880 srgb} bind def
+/col31 {1.000 0.840 0.000 srgb} bind def
+
+end
+save
+-17.0 217.0 translate
+1 -1 scale
+
+/cp {closepath} bind def
+/ef {eofill} bind def
+/gr {grestore} bind def
+/gs {gsave} bind def
+/sa {save} bind def
+/rs {restore} bind def
+/l {lineto} bind def
+/m {moveto} bind def
+/rm {rmoveto} bind def
+/n {newpath} bind def
+/s {stroke} bind def
+/sh {show} bind def
+/slc {setlinecap} bind def
+/slj {setlinejoin} bind def
+/slw {setlinewidth} bind def
+/srgb {setrgbcolor} bind def
+/rot {rotate} bind def
+/sc {scale} bind def
+/sd {setdash} bind def
+/ff {findfont} bind def
+/sf {setfont} bind def
+/scf {scalefont} bind def
+/sw {stringwidth} bind def
+/tr {translate} bind def
+/tnt {dup dup currentrgbcolor
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
+ bind def
+/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
+ 4 -2 roll mul srgb} bind def
+/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
+/$F2psEnd {$F2psEnteredState restore end} def
+%%EndProlog
+
+$F2psBegin
+10 setmiterlimit
+n -1000 4612 m -1000 -1000 l 8588 -1000 l 8588 4612 l cp clip
+ 0.06000 0.06000 sc
+/Courier ff 285.00 scf sf
+6600 1575 m
+gs 1 -1 sc (java) col0 sh gr
+/Courier ff 285.00 scf sf
+2550 1575 m
+gs 1 -1 sc (javac) col0 sh gr
+/Courier-Bold ff 150.00 scf sf
+4290 1155 m
+gs 1 -1 sc (08 1a 42 ...) col0 sh gr
+/Courier-Bold ff 150.00 scf sf
+4290 990 m
+gs 1 -1 sc (ca fe ba be) col0 sh gr
+% Polyline
+7.500 slw
+n 6405 1200 m 6300 1200 6300 1695 105 arcto 4 {pop} repeat
+ 6300 1800 7395 1800 105 arcto 4 {pop} repeat
+ 7500 1800 7500 1305 105 arcto 4 {pop} repeat
+ 7500 1200 6405 1200 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+% Polyline
+n 2505 1200 m 2400 1200 2400 1695 105 arcto 4 {pop} repeat
+ 2400 1800 3495 1800 105 arcto 4 {pop} repeat
+ 3600 1800 3600 1305 105 arcto 4 {pop} repeat
+ 3600 1200 2505 1200 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+% Polyline
+30.000 slw
+gs clippath
+2280 1470 m 2400 1500 l 2280 1530 l 2445 1530 l 2445 1470 l cp
+clip
+n 1800 1500 m 2400 1500 l gs col0 s gr gr
+
+% arrowhead
+7.500 slw
+n 2280 1470 m 2400 1500 l 2280 1530 l 2280 1500 l 2280 1470 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+30.000 slw
+gs clippath
+4080 1470 m 4200 1500 l 4080 1530 l 4245 1530 l 4245 1470 l cp
+clip
+n 3600 1500 m 4200 1500 l gs col0 s gr gr
+
+% arrowhead
+7.500 slw
+n 4080 1470 m 4200 1500 l 4080 1530 l 4080 1500 l 4080 1470 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+30.000 slw
+gs clippath
+6180 1470 m 6300 1500 l 6180 1530 l 6345 1530 l 6345 1470 l cp
+clip
+n 5700 1500 m 6300 1500 l gs col0 s gr gr
+
+% arrowhead
+7.500 slw
+n 6180 1470 m 6300 1500 l 6180 1530 l 6180 1500 l 6180 1470 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+30.000 slw
+n 5415 615 m 5415 915 l 5715 915 l gs col0 s gr
+% Polyline
+n 4215 615 m 4215 2415 l 5715 2415 l 5715 915 l 5415 615 l 4215 615 l cp gs col0 s gr
+% Polyline
+gs clippath
+7006 1136 m 6900 1200 l 6964 1094 l 6847 1211 l 6889 1253 l cp
+clip
+n 7500 600 m 6900 1200 l gs col0 s gr gr
+
+% arrowhead
+7.500 slw
+n 7006 1136 m 6900 1200 l 6964 1094 l 6985 1115 l 7006 1136 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+30.000 slw
+gs clippath
+6630 1080 m 6600 1200 l 6570 1080 l 6570 1245 l 6630 1245 l cp
+clip
+n 6600 1200 m 6600 600 l gs col0 s gr gr
+
+% arrowhead
+7.500 slw
+n 6630 1080 m 6600 1200 l 6570 1080 l 6600 1080 l 6630 1080 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+n 300 3000 m 3600 3000 l 3600 3600 l 300 3600 l cp gs 0.90 setgray ef gr gs col0 s gr
+% Polyline
+n 4200 3000 m 7500 3000 l 7500 3600 l 4200 3600 l cp gs 0.90 setgray ef gr gs col0 s gr
+% Polyline
+n 1500 600 m 1500 900 l 1800 900 l gs col0 s gr
+% Polyline
+n 300 600 m 300 2400 l 1800 2400 l 1800 900 l 1500 600 l 300 600 l cp gs col0 s gr
+/Helvetica ff 180.00 scf sf
+6450 450 m
+gs 1 -1 sc (Other classes) col0 sh gr
+/Courier ff 150.00 scf sf
+375 975 m
+gs 1 -1 sc (public class) col0 sh gr
+/Courier ff 150.00 scf sf
+375 1140 m
+gs 1 -1 sc (HelloWorld {) col0 sh gr
+/Courier ff 150.00 scf sf
+375 1305 m
+gs 1 -1 sc ( ...) col0 sh gr
+/Courier ff 150.00 scf sf
+375 1635 m
+gs 1 -1 sc ( void hello\(\) {) col0 sh gr
+/Courier ff 150.00 scf sf
+375 1800 m
+gs 1 -1 sc ( ...) col0 sh gr
+/Courier ff 150.00 scf sf
+375 1965 m
+gs 1 -1 sc ( }) col0 sh gr
+/Courier ff 150.00 scf sf
+375 2130 m
+gs 1 -1 sc (}) col0 sh gr
+/Helvetica ff 180.00 scf sf
+4275 2625 m
+gs 1 -1 sc (HelloWorld.class) col0 sh gr
+/Helvetica-Bold ff 300.00 scf sf
+900 3375 m
+gs 1 -1 sc (Java language) col0 sh gr
+/Helvetica-Bold ff 300.00 scf sf
+4350 3375 m
+gs 1 -1 sc (Java Virtual Machine) col0 sh gr
+/Helvetica ff 180.00 scf sf
+375 2625 m
+gs 1 -1 sc (HelloWorld.java) col-1 sh gr
+$F2psEnd
+rs
diff --git a/docs/eps/jvm.fig b/docs/eps/jvm.fig
new file mode 100644
index 00000000..b8688c64
--- /dev/null
+++ b/docs/eps/jvm.fig
@@ -0,0 +1,62 @@
+#FIG 3.2
+Portrait
+Center
+Inches
+A4
+100.00
+Single
+-2
+1200 2
+6 2400 1200 3600 1800
+2 4 0 1 0 7 100 0 -1 0.000 0 0 7 0 0 5
+ 3600 1800 3600 1200 2400 1200 2400 1800 3600 1800
+4 0 0 836 -1 12 19 0.0000 4 225 825 2550 1575 javac\001
+-6
+6 4215 840 5415 1290
+4 0 0 100 0 14 10 0.0000 4 105 1080 4290 1155 08 1a 42 ...\001
+4 0 0 100 0 14 10 0.0000 4 105 990 4290 990 ca fe ba be\001
+-6
+6 6300 1200 7500 1800
+2 4 0 1 0 7 100 0 -1 0.000 0 0 7 0 0 5
+ 7500 1800 7500 1200 6300 1200 6300 1800 7500 1800
+4 0 0 837 -1 12 19 0.0000 4 225 660 6600 1575 java\001
+-6
+2 1 0 3 0 7 100 0 -1 0.000 0 0 -1 1 0 2
+ 1 1 1.00 60.00 120.00
+ 1800 1500 2400 1500
+2 1 0 3 0 7 100 0 -1 0.000 0 0 -1 1 0 2
+ 1 1 1.00 60.00 120.00
+ 3600 1500 4200 1500
+2 1 0 3 0 7 100 0 -1 0.000 0 0 -1 1 0 2
+ 1 1 1.00 60.00 120.00
+ 5700 1500 6300 1500
+2 1 0 3 0 7 100 0 -1 0.000 0 0 -1 0 0 3
+ 5415 615 5415 915 5715 915
+2 1 0 3 0 7 100 0 -1 0.000 0 0 -1 0 0 6
+ 4215 615 4215 2415 5715 2415 5715 915 5415 615 4215 615
+2 1 0 3 0 7 100 0 -1 0.000 0 0 -1 1 0 2
+ 1 1 1.00 60.00 120.00
+ 7500 600 6900 1200
+2 1 0 3 0 7 100 0 -1 0.000 0 0 -1 0 1 2
+ 1 1 1.00 60.00 120.00
+ 6600 1200 6600 600
+2 2 0 1 0 0 100 0 2 0.000 0 0 -1 0 0 5
+ 300 3000 3600 3000 3600 3600 300 3600 300 3000
+2 2 0 1 0 0 100 0 2 0.000 0 0 -1 0 0 5
+ 4200 3000 7500 3000 7500 3600 4200 3600 4200 3000
+2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 3
+ 1500 600 1500 900 1800 900
+2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 6
+ 300 600 300 2400 1800 2400 1800 900 1500 600 300 600
+4 0 0 100 0 16 12 0.0000 4 135 1110 6450 450 Other classes\001
+4 0 0 100 0 5 10 0.0000 0 135 1080 375 975 public class\001
+4 0 0 100 0 5 10 0.0000 0 135 1080 375 1140 HelloWorld {\001
+4 0 0 100 0 5 10 0.0000 0 15 450 375 1305 ...\001
+4 0 0 100 0 5 10 0.0000 0 135 1440 375 1635 void hello() {\001
+4 0 0 100 0 5 10 0.0000 0 15 630 375 1800 ...\001
+4 0 0 100 0 5 10 0.0000 0 135 270 375 1965 }\001
+4 0 0 100 0 5 10 0.0000 0 135 90 375 2130 }\001
+4 0 -1 0 0 16 12 0.0000 4 180 1305 375 2625 HelloWorld.java\001
+4 0 0 100 0 16 12 0.0000 4 135 1380 4275 2625 HelloWorld.class\001
+4 0 0 100 0 18 20 0.0000 4 285 2055 900 3375 Java language\001
+4 0 0 100 0 18 20 0.0000 4 255 2985 4350 3375 Java Virtual Machine\001
diff --git a/docs/generic.mdl b/docs/generic.mdl
new file mode 100644
index 00000000..24dbc853
--- /dev/null
+++ b/docs/generic.mdl
@@ -0,0 +1,2860 @@
+
+(object Petal
+ version 42
+ _written "Rose 4.5.8054a"
+ charSet 0)
+
+(object Design "Logical View"
+ is_unit TRUE
+ is_loaded TRUE
+ defaults (object defaults
+ rightMargin 0.000000
+ leftMargin 0.000000
+ topMargin 0.000000
+ bottomMargin 0.000000
+ pageOverlap 0.000000
+ clipIconLabels TRUE
+ autoResize TRUE
+ snapToGrid TRUE
+ gridX 16
+ gridY 16
+ defaultFont (object Font
+ size 10
+ face "Arial"
+ bold FALSE
+ italics FALSE
+ underline FALSE
+ strike FALSE
+ color 0
+ default_color TRUE)
+ showMessageNum 1
+ showClassOfObject TRUE
+ notation "Unified")
+ root_usecase_package (object Class_Category "Use Case View"
+ quid "3659ABB20065"
+ exportControl "Public"
+ global TRUE
+ logical_models (list unit_reference_list)
+ logical_presentations (list unit_reference_list
+ (object UseCaseDiagram "Main"
+ quid "3659ABB60100"
+ title "Main"
+ zoom 100
+ max_height 28350
+ max_width 21600
+ origin_x 0
+ origin_y 0
+ items (list diagram_item_list))))
+ root_category (object Class_Category "Logical View"
+ quid "3659ABB20064"
+ exportControl "Public"
+ global TRUE
+ subsystem "Component View"
+ quidu "3659ABB2006D"
+ logical_models (list unit_reference_list
+ (object Class "ClassGen"
+ quid "3659ABD700A2"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "3783462E016B"
+ supplier "Logical View::AccessFlags"
+ quidu "378345EC0044"))
+ operations (list Operations
+ (object Operation "addInterface"
+ quid "3659AD040069"
+ parameters (list Parameters
+ (object Parameter "String name"))
+ result "void"
+ concurrency "Sequential"
+ opExportControl "Public"
+ uid 0)
+ (object Operation "addMethod"
+ quid "378349A800F3"
+ concurrency "Sequential"
+ opExportControl "Public"
+ uid 0))
+ module "Component View::ClassGen"
+ quidu "3659AD9C02CB"
+ language "Java")
+ (object Class "ConstantPoolGen"
+ quid "3659AC570165"
+ operations (list Operations
+ (object Operation "addClass"
+ quid "3659ADC40188"
+ parameters (list Parameters
+ (object Parameter "String name"))
+ result "int"
+ concurrency "Sequential"
+ opExportControl "Public"
+ uid 0)
+ (object Operation "addMethodRef"
+ quid "3659AEE40132"
+ parameters (list Parameters
+ (object Parameter "String class_name")
+ (object Parameter "String method_name")
+ (object Parameter "String signature"))
+ result "int"
+ concurrency "Sequential"
+ opExportControl "Public"
+ uid 0)
+ (object Operation "addInteger"
+ quid "3659AF0D00EB"
+ parameters (list Parameters
+ (object Parameter "int i"))
+ result "int"
+ concurrency "Sequential"
+ opExportControl "Public"
+ uid 0))
+ language "Java")
+ (object Class "FieldGen"
+ quid "3659AC6101C3"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "3783462A0025"
+ supplier "Logical View::AccessFlags"
+ quidu "378345EC0044"))
+ operations (list Operations
+ (object Operation "getField"
+ quid "3659ACAE020A"
+ result "Field"
+ concurrency "Sequential"
+ opExportControl "Public"
+ uid 0)
+ (object Operation "setInitValue"
+ quid "3659AF4200BF"
+ result "void"
+ concurrency "Sequential"
+ opExportControl "Public"
+ uid 0))
+ language "Java")
+ (object Class "MethodGen"
+ quid "3659AC6A014E"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "378346310292"
+ supplier "Logical View::AccessFlags"
+ quidu "378345EC0044"))
+ operations (list Operations
+ (object Operation "addException"
+ quid "3659AFD703D0"
+ concurrency "Sequential"
+ opExportControl "Public"
+ uid 0))
+ language "Java")
+ (object Class "Instruction"
+ quid "3659B1E8013C"
+ class_attributes (list class_attribute_list
+ (object ClassAttribute "tag"
+ quid "3659B221030A")
+ (object ClassAttribute "length"
+ quid "3659B24C00D1"))
+ language "Java")
+ (object Class "BranchInstruction"
+ quid "3659B29302BE"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "3659B3CC01E2"
+ supplier "Logical View::Instruction"
+ quidu "3659B1E8013C"))
+ realized_interfaces (list realize_rel_list
+ (object Realize_Relationship
+ quid "3659B46B028B"
+ supplier "Logical View::InstructionTargeter"
+ quidu "3659B40603BC"))
+ language "Java")
+ (object Class "Select"
+ quid "3659B30602D8"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "3659B3C5014C"
+ supplier "Logical View::BranchInstruction"
+ quidu "3659B29302BE"))
+ class_attributes (list class_attribute_list
+ (object ClassAttribute "targets"
+ quid "3659B3670056")
+ (object ClassAttribute "keys"
+ quid "3659B3740073"))
+ language "Java")
+ (object Class "LOOKUPSWITCH"
+ quid "3659B38B0315"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "3659B3B503CA"
+ supplier "Logical View::Select"
+ quidu "3659B30602D8"))
+ language "Java")
+ (object Class "TABLESWITCH"
+ quid "3659B3A200BF"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "3659B3BC013F"
+ supplier "Logical View::Select"
+ quidu "3659B30602D8"))
+ language "Java")
+ (object Class "InstructionTargeter"
+ quid "3659B40603BC"
+ stereotype "Interface"
+ operations (list Operations
+ (object Operation "updateTarget"
+ quid "3659B42302EB"
+ concurrency "Sequential"
+ opExportControl "Public"
+ uid 0))
+ language "Java")
+ (object Class "CodeExceptionGen"
+ quid "3659B4D200E4"
+ realized_interfaces (list realize_rel_list
+ (object Realize_Relationship
+ quid "3659B54B016B"
+ supplier "Logical View::InstructionTargeter"
+ quidu "3659B40603BC"))
+ language "Java")
+ (object Class "IfInstruction"
+ quid "3659B617007E"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "3659B63001F6"
+ supplier "Logical View::BranchInstruction"
+ quidu "3659B29302BE"))
+ language "Java")
+ (object Class "GOTO"
+ quid "3659B6220174"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "3659B63700D4"
+ supplier "Logical View::BranchInstruction"
+ quidu "3659B29302BE"))
+ realized_interfaces (list realize_rel_list
+ (object Realize_Relationship
+ quid "365A91AE021A"
+ supplier "Logical View::UnconditionalBranch"
+ quidu "365A919F0395"))
+ language "Java")
+ (object Class "Type"
+ quid "3659B87D0135"
+ operations (list Operations
+ (object Operation "getSignature"
+ quid "3659B8FB00F0"
+ concurrency "Sequential"
+ opExportControl "Public"
+ uid 0))
+ language "Java")
+ (object Class "BasicType"
+ quid "3659B90B02AB"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "3659B99402DA"
+ supplier "Logical View::Type"
+ quidu "3659B87D0135"))
+ language "Java")
+ (object Class "ReferenceType"
+ quid "3659B91D0030"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "3659B9990043"
+ supplier "Logical View::Type"
+ quidu "3659B87D0135"))
+ language "Java")
+ (object Class "ObjectType"
+ quid "3659B927039C"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "3659B9B0028B"
+ supplier "Logical View::ReferenceType"
+ quidu "3659B91D0030"))
+ operations (list Operations
+ (object Operation "getClassName"
+ quid "3659B95401E8"
+ concurrency "Sequential"
+ opExportControl "Public"
+ uid 0))
+ language "Java")
+ (object Class "ArrayType"
+ quid "3659B931024C"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "3659B9B30181"
+ supplier "Logical View::ReferenceType"
+ quidu "3659B91D0030"))
+ operations (list Operations
+ (object Operation "getDimensions"
+ quid "3659B979012D"
+ result "int"
+ concurrency "Sequential"
+ opExportControl "Public"
+ uid 0))
+ language "Java")
+ (object Class "InstructionList"
+ quid "3659BAA803D2"
+ operations (list Operations
+ (object Operation "append"
+ quid "37834B1C0057"
+ concurrency "Sequential"
+ opExportControl "Public"
+ uid 0))
+ language "Java")
+ (object Class "LocalVariableGen"
+ quid "3659BC2A02C8"
+ realized_interfaces (list realize_rel_list
+ (object Realize_Relationship
+ quid "3659BC390248"
+ supplier "Logical View::InstructionTargeter"
+ quidu "3659B40603BC"))
+ language "Java")
+ (object Class "ReturnInstruction"
+ quid "365A9132032A"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "365A98DC03CB"
+ supplier "Logical View::Instruction"
+ quidu "3659B1E8013C")))
+ (object Class "ArrayInstruction"
+ quid "365A913A02DB"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "365A98E5007B"
+ supplier "Logical View::Instruction"
+ quidu "3659B1E8013C")))
+ (object Class "CPInstruction"
+ quid "365A91430360"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "365A98BE016F"
+ supplier "Logical View::Instruction"
+ quidu "3659B1E8013C"))
+ operations (list Operations
+ (object Operation "getType"
+ quid "37836CEF008A"
+ concurrency "Sequential"
+ opExportControl "Public"
+ uid 0))
+ class_attributes (list class_attribute_list
+ (object ClassAttribute "index"
+ quid "365A926F02D6")))
+ (object Class "StackInstruction"
+ quid "365A91560097"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "365AB1A8029D"
+ supplier "Logical View::Instruction"
+ quidu "3659B1E8013C")))
+ (object Class "ConversionInstruction"
+ quid "365A91690116"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "365A98EA0295"
+ supplier "Logical View::Instruction"
+ quidu "3659B1E8013C")))
+ (object Class "UnconditionalBranch"
+ quid "365A919F0395"
+ stereotype "Interface")
+ (object Class "ArithmeticInstruction"
+ quid "365A921A03E2"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "365A98B0025F"
+ supplier "Logical View::Instruction"
+ quidu "3659B1E8013C")))
+ (object Class "LocalVariableInstruction"
+ quid "365A926500FA"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "365A98B8008A"
+ supplier "Logical View::Instruction"
+ quidu "3659B1E8013C"))
+ class_attributes (list class_attribute_list
+ (object ClassAttribute "index"
+ quid "365A988E01E8")))
+ (object Class "FieldInstruction"
+ quid "365A92F300CD"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "37836FAF0231"
+ supplier "Logical View::FieldOrMethod"
+ quidu "37836D4602A2"))
+ operations (list Operations
+ (object Operation "getFieldType"
+ quid "37836D250377"
+ result "Type"
+ concurrency "Sequential"
+ opExportControl "Public"
+ uid 0)))
+ (object Class "InvokeInstruction"
+ quid "365A931601C7"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "37836FB302A5"
+ supplier "Logical View::FieldOrMethod"
+ quidu "37836D4602A2"))
+ operations (list Operations
+ (object Operation "getArgumentTypes"
+ quid "37836D890190"
+ result "Type[]"
+ concurrency "Sequential"
+ opExportControl "Public"
+ uid 0)))
+ (object Class "AccessFlags"
+ quid "378345EC0044"
+ operations (list Operations
+ (object Operation "isPublic"
+ quid "378345EC0045"
+ result "boolean"
+ concurrency "Sequential"
+ opExportControl "Public"
+ uid 0))
+ abstract TRUE)
+ (object Class "InstructionHandle"
+ quid "3783485F01C2")
+ (object Class "FieldOrMethod"
+ quid "37836D4602A2"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "37836E8702CC"
+ supplier "Logical View::CPInstruction"
+ quidu "365A91430360"))
+ operations (list Operations
+ (object Operation "getName"
+ quid "37836D5003D3"
+ concurrency "Sequential"
+ opExportControl "Public"
+ uid 0)))
+ (object Class "NEW"
+ quid "37836DE502D3"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "37836E5F03A1"
+ supplier "Logical View::CPInstruction"
+ quidu "365A91430360")))
+ (object Class "INSTANCEOF"
+ quid "37836EC1013F"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "37836ED7023B"
+ supplier "Logical View::CPInstruction"
+ quidu "365A91430360")))
+ (object Class "NewInterface"
+ quid "378370F400C6"
+ stereotype "Interface")
+ (object Association "$UNNAMED$0"
+ quid "3659BBA60048"
+ roles (list role_list
+ (object Role "$UNNAMED$1"
+ quid "3659BBA60250"
+ supplier "Logical View::ClassGen"
+ quidu "3659ABD700A2"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$2"
+ quid "3659BBA60264"
+ supplier "Logical View::ConstantPoolGen"
+ quidu "3659AC570165"
+ client_cardinality (value cardinality "1")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$3"
+ quid "3659BBC8024F"
+ roles (list role_list
+ (object Role "$UNNAMED$4"
+ quid "3659BBC803C2"
+ supplier "Logical View::ClassGen"
+ quidu "3659ABD700A2"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$5"
+ quid "3659BBC803CC"
+ supplier "Logical View::MethodGen"
+ quidu "3659AC6A014E"
+ client_cardinality (value cardinality "n")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$6"
+ quid "3659BBD40076"
+ roles (list role_list
+ (object Role "$UNNAMED$7"
+ quid "3659BBD402BB"
+ supplier "Logical View::ClassGen"
+ quidu "3659ABD700A2"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$8"
+ quid "3659BBD402CF"
+ supplier "Logical View::FieldGen"
+ quidu "3659AC6101C3"
+ client_cardinality (value cardinality "n")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$9"
+ quid "3659BCA400E3"
+ roles (list role_list
+ (object Role "$UNNAMED$10"
+ quid "3659BCA40292"
+ supplier "Logical View::MethodGen"
+ quidu "3659AC6A014E"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$11"
+ quid "3659BCA402A6"
+ supplier "Logical View::LocalVariableGen"
+ quidu "3659BC2A02C8"
+ client_cardinality (value cardinality "n")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$12"
+ quid "3659BCB20350"
+ roles (list role_list
+ (object Role "$UNNAMED$13"
+ quid "3659BCB3017B"
+ supplier "Logical View::MethodGen"
+ quidu "3659AC6A014E"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$14"
+ quid "3659BCB3018F"
+ supplier "Logical View::CodeExceptionGen"
+ quidu "3659B4D200E4"
+ client_cardinality (value cardinality "n")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$15"
+ quid "3659BDBE03D8"
+ roles (list role_list
+ (object Role "$UNNAMED$16"
+ quid "3659BDBF02FD"
+ supplier "Logical View::Type"
+ quidu "3659B87D0135"
+ is_navigable TRUE)
+ (object Role "$UNNAMED$17"
+ quid "3659BDBF0311"
+ supplier "Logical View::FieldGen"
+ quidu "3659AC6101C3"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$18"
+ quid "3659BDC7022C"
+ roles (list role_list
+ (object Role "$UNNAMED$19"
+ quid "3659BDC8030A"
+ supplier "Logical View::Type"
+ quidu "3659B87D0135"
+ is_navigable TRUE)
+ (object Role "$UNNAMED$20"
+ quid "3659BDC80314"
+ supplier "Logical View::MethodGen"
+ quidu "3659AC6A014E"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$21"
+ quid "365A9D0C02A0"
+ roles (list role_list
+ (object Role "$UNNAMED$22"
+ quid "365A9D0D008F"
+ supplier "Logical View::InstructionList"
+ quidu "3659BAA803D2"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$23"
+ quid "365A9D0D0099"
+ supplier "Logical View::Instruction"
+ quidu "3659B1E8013C"
+ client_cardinality (value cardinality "n")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$24"
+ quid "37834AD601AB"
+ roles (list role_list
+ (object Role "$UNNAMED$25"
+ quid "37834AD60346"
+ supplier "Logical View::InstructionList"
+ quidu "3659BAA803D2"
+ client_cardinality (value cardinality "1")
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$26"
+ quid "37834AD60347"
+ supplier "Logical View::InstructionHandle"
+ quidu "3783485F01C2"
+ client_cardinality (value cardinality "n")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$27"
+ quid "37834B0902D1"
+ roles (list role_list
+ (object Role "$UNNAMED$28"
+ quid "37834B0A0246"
+ supplier "Logical View::InstructionList"
+ quidu "3659BAA803D2"
+ is_navigable TRUE)
+ (object Role "$UNNAMED$29"
+ quid "37834B0A0250"
+ supplier "Logical View::MethodGen"
+ quidu "3659AC6A014E"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$30"
+ quid "37834B7A02FB"
+ roles (list role_list
+ (object Role "$UNNAMED$31"
+ quid "37834B7B0271"
+ supplier "Logical View::Instruction"
+ quidu "3659B1E8013C"
+ client_cardinality (value cardinality "1")
+ is_navigable TRUE)
+ (object Role "$UNNAMED$32"
+ quid "37834B7B028F"
+ supplier "Logical View::InstructionHandle"
+ quidu "3783485F01C2"
+ client_cardinality (value cardinality "1")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$33"
+ quid "37834BAE0382"
+ stereotype "targets"
+ roles (list role_list
+ (object Role "targets"
+ quid "37834BB001C3"
+ label "targets"
+ supplier "Logical View::InstructionHandle"
+ quidu "3783485F01C2"
+ client_cardinality (value cardinality "n")
+ is_navigable TRUE)
+ (object Role "$UNNAMED$34"
+ quid "37834BB001CD"
+ supplier "Logical View::InstructionTargeter"
+ quidu "3659B40603BC"
+ client_cardinality (value cardinality "n")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$35"
+ quid "37834DCC011F"
+ roles (list role_list
+ (object Role "$UNNAMED$36"
+ quid "37834DCC0300"
+ supplier "Logical View::ConstantPoolGen"
+ quidu "3659AC570165"
+ is_navigable TRUE)
+ (object Role "$UNNAMED$37"
+ quid "37834DCC030A"
+ supplier "Logical View::ClassGen"
+ quidu "3659ABD700A2"
+ is_navigable TRUE))))
+ logical_presentations (list unit_reference_list
+ (object ClassDiagram "ClassGen"
+ quid "3659ABB6013B"
+ title "ClassGen"
+ zoom 100
+ max_height 28350
+ max_width 21600
+ origin_x 0
+ origin_y 0
+ items (list diagram_item_list
+ (object ClassView "Class" "Logical View::BasicType" @1
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (352, 656)
+ label (object ItemLabel
+ Parent_View @1
+ location (242, 605)
+ fill_color 13434879
+ nlines 1
+ max_width 220
+ justify 0
+ label "BasicType")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659B90B02AB"
+ width 238
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::ObjectType" @2
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (432, 384)
+ label (object ItemLabel
+ Parent_View @2
+ location (260, 303)
+ fill_color 13434879
+ nlines 1
+ max_width 344
+ justify 0
+ label "ObjectType")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659B927039C"
+ compartment (object Compartment
+ Parent_View @2
+ location (260, 363)
+ icon_style "Icon"
+ fill_color 13434879
+ anchor 2
+ nlines 2
+ max_width 350)
+ width 362
+ height 186
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::ArrayType" @3
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (880, 384)
+ label (object ItemLabel
+ Parent_View @3
+ location (707, 303)
+ fill_color 13434879
+ nlines 1
+ max_width 346
+ justify 0
+ label "ArrayType")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659B931024C"
+ compartment (object Compartment
+ Parent_View @3
+ location (707, 363)
+ icon_style "Icon"
+ fill_color 13434879
+ anchor 2
+ nlines 2
+ max_width 353)
+ width 364
+ height 186
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::ReferenceType" @4
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (688, 656)
+ label (object ItemLabel
+ Parent_View @4
+ location (540, 605)
+ fill_color 13434879
+ nlines 1
+ max_width 296
+ justify 0
+ label "ReferenceType")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659B91D0030"
+ width 314
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::FieldGen" @5
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1072, 800)
+ label (object ItemLabel
+ Parent_View @5
+ location (927, 694)
+ fill_color 13434879
+ nlines 1
+ max_width 290
+ justify 0
+ label "FieldGen")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659AC6101C3"
+ compartment (object Compartment
+ Parent_View @5
+ location (927, 754)
+ icon_style "Icon"
+ fill_color 13434879
+ anchor 2
+ nlines 3
+ max_width 296)
+ width 308
+ height 236
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::AccessFlags" @6
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1344, 384)
+ font (object Font
+ italics TRUE)
+ label (object ItemLabel
+ Parent_View @6
+ location (1210, 306)
+ fill_color 13434879
+ nlines 1
+ max_width 268
+ justify 0
+ label "AccessFlags")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "378345EC0044"
+ compartment (object Compartment
+ Parent_View @6
+ location (1210, 366)
+ font (object Font
+ italics TRUE)
+ icon_style "Icon"
+ fill_color 13434879
+ anchor 2
+ nlines 2
+ max_width 231)
+ width 286
+ height 180
+ annotation 8
+ autoResize TRUE)
+ (object InheritTreeView "" @7
+ location (1344, 602)
+ line_color 3342489
+ fill_color 13434879
+ supplier @6
+ vertices (list Points
+ (1344, 602)
+ (1344, 474)))
+ (object InheritView "" @8
+ stereotype TRUE
+ line_color 3342489
+ quidu "3783462A0025"
+ client @5
+ supplier @6
+ line_style 3
+ origin_attachment (1059, 682)
+ terminal_attachment (1059, 602)
+ drawSupplier @7)
+ (object InheritTreeView "" @9
+ location (678, 500)
+ line_color 3342489
+ fill_color 13434879
+ supplier @4
+ vertices (list Points
+ (678, 500)
+ (678, 593)))
+ (object InheritView "" @10
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659B9B0028B"
+ client @2
+ supplier @4
+ line_style 3
+ origin_attachment (369, 477)
+ terminal_attachment (406, 500)
+ drawSupplier @9)
+ (object InheritView "" @11
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659B9B30181"
+ client @3
+ supplier @4
+ line_style 3
+ origin_attachment (881, 477)
+ terminal_attachment (918, 500)
+ drawSupplier @9)
+ (object ClassView "Class" "Logical View::LocalVariableGen" @12
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (736, 1344)
+ label (object ItemLabel
+ Parent_View @12
+ location (551, 1294)
+ fill_color 13434879
+ nlines 1
+ max_width 370
+ justify 0
+ label "LocalVariableGen")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659BC2A02C8"
+ width 388
+ height 125
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::CodeExceptionGen" @13
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (736, 1168)
+ label (object ItemLabel
+ Parent_View @13
+ location (546, 1117)
+ fill_color 13434879
+ nlines 1
+ max_width 380
+ justify 0
+ label "CodeExceptionGen")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659B4D200E4"
+ width 398
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::Type" @14
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (512, 928)
+ label (object ItemLabel
+ Parent_View @14
+ location (359, 847)
+ fill_color 13434879
+ nlines 1
+ max_width 306
+ justify 0
+ label "Type")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659B87D0135"
+ compartment (object Compartment
+ Parent_View @14
+ location (359, 907)
+ icon_style "Icon"
+ fill_color 13434879
+ anchor 2
+ nlines 2
+ max_width 312)
+ width 324
+ height 186
+ annotation 8
+ autoResize TRUE)
+ (object InheritTreeView "" @15
+ location (512, 745)
+ line_color 3342489
+ fill_color 13434879
+ supplier @14
+ vertices (list Points
+ (512, 745)
+ (512, 835)))
+ (object AssociationViewNew "$UNNAMED$15" @16
+ location (795, 862)
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659BDBE03D8"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$16" @17
+ Parent_View @16
+ location (-869, -50)
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659BDBF02FD"
+ client @16
+ supplier @14
+ line_style 0)
+ (object RoleView "$UNNAMED$17" @18
+ Parent_View @16
+ location (-869, -50)
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659BDBF0311"
+ client @16
+ supplier @5
+ line_style 0)))
+ (object InheritView "" @19
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659B99402DA"
+ client @1
+ supplier @14
+ line_style 3
+ origin_attachment (347, 719)
+ terminal_attachment (347, 745)
+ drawSupplier @15)
+ (object InheritView "" @20
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659B9990043"
+ client @4
+ supplier @14
+ line_style 3
+ origin_attachment (669, 719)
+ terminal_attachment (669, 745)
+ drawSupplier @15)
+ (object ClassView "Class" "Logical View::MethodGen" @21
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1328, 1104)
+ label (object ItemLabel
+ Parent_View @21
+ location (1165, 1023)
+ fill_color 13434879
+ nlines 1
+ max_width 326
+ justify 0
+ label "MethodGen")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659AC6A014E"
+ compartment (object Compartment
+ Parent_View @21
+ location (1165, 1083)
+ icon_style "Icon"
+ fill_color 13434879
+ anchor 2
+ nlines 2
+ max_width 322)
+ width 344
+ height 186
+ annotation 8
+ autoResize TRUE)
+ (object AssociationViewNew "$UNNAMED$9" @22
+ location (1022, 1227)
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659BCA400E3"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$10" @23
+ Parent_View @22
+ location (254, -597)
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659BCA40292"
+ client @22
+ supplier @21
+ line_style 0)
+ (object RoleView "$UNNAMED$11" @24
+ Parent_View @22
+ location (254, -597)
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659BCA402A6"
+ client @22
+ supplier @12
+ line_style 0
+ label (object SegLabel @25
+ Parent_View @24
+ location (922, 1326)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "*"
+ pctDist 0.900000
+ height 54
+ orientation 0))))
+ (object AssociationViewNew "$UNNAMED$12" @26
+ location (1045, 1134)
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659BCB20350"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$13" @27
+ Parent_View @26
+ location (-235, -722)
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659BCB3017B"
+ client @26
+ supplier @21
+ line_style 0)
+ (object RoleView "$UNNAMED$14" @28
+ Parent_View @26
+ location (-235, -722)
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659BCB3018F"
+ client @26
+ supplier @13
+ line_style 0
+ label (object SegLabel @29
+ Parent_View @28
+ location (942, 1092)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "*"
+ pctDist 0.900000
+ height 54
+ orientation 1))))
+ (object AssociationViewNew "$UNNAMED$18" @30
+ location (914, 1014)
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659BDC7022C"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$19" @31
+ Parent_View @30
+ location (-1390, 6)
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659BDC8030A"
+ client @30
+ supplier @14
+ line_style 0)
+ (object RoleView "$UNNAMED$20" @32
+ Parent_View @30
+ location (-1390, 6)
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659BDC80314"
+ client @30
+ supplier @21
+ line_style 0)))
+ (object InheritView "" @33
+ stereotype TRUE
+ line_color 3342489
+ quidu "378346310292"
+ client @21
+ supplier @6
+ line_style 3
+ origin_attachment (1344, 1011)
+ terminal_attachment (1344, 602)
+ drawSupplier @7)
+ (object ClassView "Class" "Logical View::BranchInstruction" @34
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (720, 1520)
+ label (object ItemLabel
+ Parent_View @34
+ location (546, 1468)
+ fill_color 13434879
+ nlines 1
+ max_width 348
+ justify 0
+ label "BranchInstruction")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659B29302BE"
+ width 366
+ height 128
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::InstructionList" @35
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1904, 1104)
+ label (object ItemLabel
+ Parent_View @35
+ location (1759, 1023)
+ fill_color 13434879
+ nlines 1
+ max_width 290
+ justify 0
+ label "InstructionList")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659BAA803D2"
+ compartment (object Compartment
+ Parent_View @35
+ location (1759, 1083)
+ icon_style "Icon"
+ fill_color 16777215
+ anchor 2
+ nlines 2
+ max_width 215)
+ width 308
+ height 186
+ annotation 8
+ autoResize TRUE)
+ (object AssociationViewNew "$UNNAMED$27" @36
+ location (1624, 1104)
+ stereotype TRUE
+ line_color 3342489
+ quidu "37834B0902D1"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$28" @37
+ Parent_View @36
+ location (328, -64)
+ stereotype TRUE
+ line_color 3342489
+ quidu "37834B0A0246"
+ client @36
+ supplier @35
+ line_style 0)
+ (object RoleView "$UNNAMED$29" @38
+ Parent_View @36
+ location (328, -64)
+ stereotype TRUE
+ line_color 3342489
+ quidu "37834B0A0250"
+ client @36
+ supplier @21
+ line_style 0)))
+ (object ClassView "Class" "Logical View::Instruction" @39
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1312, 1408)
+ label (object ItemLabel
+ Parent_View @39
+ location (1209, 1324)
+ fill_color 13434879
+ nlines 1
+ max_width 207
+ justify 0
+ label "Instruction")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659B1E8013C"
+ compartment (object Compartment
+ Parent_View @39
+ location (1209, 1384)
+ icon_style "Icon"
+ fill_color 13434879
+ anchor 2
+ nlines 3
+ max_width 159)
+ width 225
+ height 193
+ annotation 8
+ autoResize TRUE)
+ (object InheritView "" @40
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659B3CC01E2"
+ client @34
+ supplier @39
+ line_style 0)
+ (object ClassView "Class" "Logical View::InstructionHandle" @41
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1904, 1408)
+ label (object ItemLabel
+ Parent_View @41
+ location (1730, 1356)
+ fill_color 13434879
+ nlines 1
+ max_width 348
+ justify 0
+ label "InstructionHandle")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3783485F01C2"
+ width 366
+ height 128
+ annotation 8
+ autoResize TRUE)
+ (object AssociationViewNew "$UNNAMED$24" @42
+ location (1904, 1270)
+ stereotype TRUE
+ line_color 3342489
+ quidu "37834AD601AB"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$25" @43
+ Parent_View @42
+ location (48, -266)
+ stereotype TRUE
+ line_color 3342489
+ quidu "37834AD60346"
+ client @42
+ supplier @35
+ line_style 0
+ label (object SegLabel @44
+ Parent_View @43
+ location (1958, 1204)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "1"
+ pctDist 0.900000
+ height 54
+ orientation 1))
+ (object RoleView "$UNNAMED$26" @45
+ Parent_View @42
+ location (48, -266)
+ stereotype TRUE
+ line_color 3342489
+ quidu "37834AD60347"
+ client @42
+ supplier @41
+ line_style 0
+ label (object SegLabel @46
+ Parent_View @45
+ location (1958, 1336)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "*"
+ pctDist 0.900000
+ height 54
+ orientation 0))))
+ (object AssociationViewNew "$UNNAMED$30" @47
+ location (1572, 1408)
+ stereotype TRUE
+ line_color 3342489
+ quidu "37834B7A02FB"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$31" @48
+ Parent_View @47
+ location (-332, 48)
+ stereotype TRUE
+ line_color 3342489
+ quidu "37834B7B0271"
+ client @47
+ supplier @39
+ line_style 0
+ label (object SegLabel @49
+ Parent_View @48
+ location (1440, 1462)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "1"
+ pctDist 0.900000
+ height 54
+ orientation 0))
+ (object RoleView "$UNNAMED$32" @50
+ Parent_View @47
+ location (-332, 48)
+ stereotype TRUE
+ line_color 3342489
+ quidu "37834B7B028F"
+ client @47
+ supplier @41
+ line_style 0
+ label (object SegLabel @51
+ Parent_View @50
+ location (1704, 1462)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "1"
+ pctDist 0.900000
+ height 54
+ orientation 1))))
+ (object ClassView "Class" "Logical View::InstructionTargeter" @52
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (192, 1344)
+ label (object ItemLabel
+ Parent_View @52
+ location (8, 1285)
+ fill_color 13434879
+ nlines 1
+ max_width 368
+ justify 0
+ label "InstructionTargeter")
+ stereotype (object ItemLabel
+ Parent_View @52
+ location (8, 1235)
+ fill_color 13434879
+ anchor 10
+ nlines 1
+ max_width 368
+ justify 0
+ label "<<Interface>>")
+ icon "Interface"
+ icon_style "Label"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659B40603BC"
+ compartment (object Compartment
+ Parent_View @52
+ location (8, 1345)
+ icon_style "Icon"
+ fill_color 13434879
+ anchor 2
+ nlines 2
+ max_width 318)
+ width 386
+ height 242
+ annotation 8
+ autoResize TRUE)
+ (object RealizeView "" @53
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659B54B016B"
+ client @13
+ supplier @52
+ line_style 0)
+ (object RealizeView "" @54
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659BC390248"
+ client @12
+ supplier @52
+ line_style 0)
+ (object AssociationViewNew "$UNNAMED$33" @55
+ location (1043, 1616)
+ stereotype (object SegLabel @56
+ Parent_View @55
+ location (1296, 1579)
+ anchor 10
+ anchor_loc 1
+ nlines 1
+ max_width 450
+ justify 0
+ label "<<targets>>"
+ pctDist 4.733333
+ height 38
+ orientation 0)
+ line_color 3342489
+ quidu "37834BAE0382"
+ roleview_list (list RoleViews
+ (object RoleView "targets" @57
+ Parent_View @55
+ location (323, 96)
+ stereotype TRUE
+ line_color 3342489
+ quidu "37834BB001C3"
+ client @55
+ supplier @41
+ vertices (list Points
+ (1043, 1616)
+ (1903, 1616)
+ (1903, 1472))
+ line_style 0
+ label (object SegLabel @58
+ Parent_View @57
+ location (1957, 1573)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "*"
+ pctDist 0.900000
+ height 54
+ orientation 1))
+ (object RoleView "$UNNAMED$34" @59
+ Parent_View @55
+ location (323, 96)
+ stereotype TRUE
+ line_color 3342489
+ quidu "37834BB001CD"
+ client @55
+ supplier @52
+ vertices (list Points
+ (1043, 1616)
+ (191, 1616)
+ (191, 1465))
+ line_style 0
+ label (object SegLabel @60
+ Parent_View @59
+ location (245, 1565)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "*"
+ pctDist 0.900000
+ height 54
+ orientation 1))))
+ (object ClassView "Class" "Logical View::ConstantPoolGen" @61
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1888, 448)
+ label (object ItemLabel
+ Parent_View @61
+ location (1715, 317)
+ fill_color 13434879
+ nlines 1
+ max_width 346
+ justify 0
+ label "ConstantPoolGen")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659AC570165"
+ compartment (object Compartment
+ Parent_View @61
+ location (1715, 377)
+ icon_style "Icon"
+ fill_color 13434879
+ anchor 2
+ nlines 4
+ max_width 343)
+ width 364
+ height 286
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::ClassGen" @62
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1632, 800)
+ label (object ItemLabel
+ Parent_View @62
+ location (1483, 694)
+ fill_color 13434879
+ nlines 1
+ max_width 298
+ justify 0
+ label "ClassGen")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659ABD700A2"
+ compartment (object Compartment
+ Parent_View @62
+ location (1483, 754)
+ icon_style "Icon"
+ fill_color 13434879
+ anchor 2
+ nlines 3
+ max_width 303)
+ width 316
+ height 236
+ annotation 8
+ autoResize TRUE)
+ (object InheritView "" @63
+ stereotype TRUE
+ line_color 3342489
+ quidu "3783462E016B"
+ client @62
+ supplier @6
+ line_style 3
+ origin_attachment (1634, 682)
+ terminal_attachment (1634, 602)
+ drawSupplier @7)
+ (object AssociationViewNew "$UNNAMED$35" @64
+ location (1751, 636)
+ stereotype TRUE
+ line_color 3342489
+ quidu "37834DCC011F"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$36" @65
+ Parent_View @64
+ location (119, -164)
+ stereotype TRUE
+ line_color 3342489
+ quidu "37834DCC0300"
+ client @64
+ supplier @61
+ line_style 0)
+ (object RoleView "$UNNAMED$37" @66
+ Parent_View @64
+ location (119, -164)
+ stereotype TRUE
+ line_color 3342489
+ quidu "37834DCC030A"
+ client @64
+ supplier @62
+ line_style 0)))
+ (object RealizeView "" @67
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659B46B028B"
+ client @34
+ supplier @52
+ line_style 0)))
+ (object ClassDiagram "Instructions"
+ quid "3659B32A024D"
+ title "Instructions"
+ zoom 100
+ max_height 28350
+ max_width 21600
+ origin_x 216
+ origin_y 0
+ items (list diagram_item_list
+ (object ClassView "Class" "Logical View::Instruction" @68
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1904, 176)
+ label (object ItemLabel
+ Parent_View @68
+ location (1782, 91)
+ fill_color 13434879
+ nlines 1
+ max_width 244
+ justify 0
+ label "Instruction")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659B1E8013C"
+ compartment (object Compartment
+ Parent_View @68
+ location (1782, 151)
+ icon_style "Icon"
+ fill_color 16777215
+ anchor 2
+ nlines 3
+ max_width 159)
+ width 262
+ height 194
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::BranchInstruction" @69
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (912, 464)
+ label (object ItemLabel
+ Parent_View @69
+ location (721, 414)
+ fill_color 13434879
+ nlines 1
+ max_width 382
+ justify 0
+ label "BranchInstruction")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659B29302BE"
+ width 400
+ height 125
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::Select" @70
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1120, 784)
+ label (object ItemLabel
+ Parent_View @70
+ location (1026, 699)
+ fill_color 13434879
+ nlines 1
+ max_width 188
+ justify 0
+ label "Select")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659B30602D8"
+ compartment (object Compartment
+ Parent_View @70
+ location (1026, 759)
+ icon_style "Icon"
+ fill_color 16777215
+ anchor 2
+ nlines 3
+ max_width 175)
+ width 206
+ height 194
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::LOOKUPSWITCH" @71
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (912, 1072)
+ label (object ItemLabel
+ Parent_View @71
+ location (732, 1021)
+ fill_color 13434879
+ nlines 1
+ max_width 360
+ justify 0
+ label "LOOKUPSWITCH")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659B38B0315"
+ width 378
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::TABLESWITCH" @72
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1360, 1072)
+ label (object ItemLabel
+ Parent_View @72
+ location (1202, 1021)
+ fill_color 13434879
+ nlines 1
+ max_width 316
+ justify 0
+ label "TABLESWITCH")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659B3A200BF"
+ width 334
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::IfInstruction" @73
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (832, 752)
+ label (object ItemLabel
+ Parent_View @73
+ location (711, 701)
+ fill_color 13434879
+ nlines 1
+ max_width 242
+ justify 0
+ label "IfInstruction")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659B617007E"
+ width 260
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::GOTO" @74
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (576, 752)
+ label (object ItemLabel
+ Parent_View @74
+ location (495, 701)
+ fill_color 13434879
+ nlines 1
+ max_width 162
+ justify 0
+ label "GOTO")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "3659B6220174"
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object InheritTreeView "" @75
+ location (905, 618)
+ line_color 3342489
+ fill_color 13434879
+ supplier @69
+ vertices (list Points
+ (905, 618)
+ (905, 526)))
+ (object InheritView "" @76
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659B63700D4"
+ client @74
+ supplier @69
+ line_style 3
+ origin_attachment (581, 689)
+ terminal_attachment (581, 618)
+ drawSupplier @75)
+ (object ClassView "Class" "Logical View::ReturnInstruction" @77
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2464, 208)
+ label (object ItemLabel
+ Parent_View @77
+ location (2292, 157)
+ fill_color 13434879
+ nlines 1
+ max_width 344
+ justify 0
+ label "ReturnInstruction")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365A9132032A"
+ width 362
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::ArrayInstruction" @78
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1408, 464)
+ label (object ItemLabel
+ Parent_View @78
+ location (1252, 413)
+ fill_color 13434879
+ nlines 1
+ max_width 312
+ justify 0
+ label "ArrayInstruction")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365A913A02DB"
+ width 330
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::CPInstruction" @79
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2256, 528)
+ label (object ItemLabel
+ Parent_View @79
+ location (2120, 422)
+ fill_color 13434879
+ nlines 1
+ max_width 272
+ justify 0
+ label "CPInstruction")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365A91430360"
+ compartment (object Compartment
+ Parent_View @79
+ location (2120, 482)
+ icon_style "Icon"
+ fill_color 16777215
+ anchor 2
+ nlines 3
+ max_width 219)
+ width 290
+ height 236
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::StackInstruction" @80
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1456, 208)
+ label (object ItemLabel
+ Parent_View @80
+ location (1294, 157)
+ fill_color 13434879
+ nlines 1
+ max_width 324
+ justify 0
+ label "StackInstruction")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365A91560097"
+ width 342
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::ConversionInstruction" @81
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1840, 464)
+ label (object ItemLabel
+ Parent_View @81
+ location (1634, 413)
+ fill_color 13434879
+ nlines 1
+ max_width 412
+ justify 0
+ label "ConversionInstruction")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365A91690116"
+ width 430
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object InheritView "" @82
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659B63001F6"
+ client @73
+ supplier @69
+ line_style 3
+ origin_attachment (837, 689)
+ terminal_attachment (837, 618)
+ drawSupplier @75)
+ (object ClassView "Class" "Logical View::ArithmeticInstruction" @83
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (976, 208)
+ label (object ItemLabel
+ Parent_View @83
+ location (775, 157)
+ fill_color 13434879
+ nlines 1
+ max_width 402
+ justify 0
+ label "ArithmeticInstruction")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365A921A03E2"
+ width 420
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::LocalVariableInstruction" @84
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2688, 496)
+ label (object ItemLabel
+ Parent_View @84
+ location (2454, 415)
+ fill_color 13434879
+ nlines 1
+ max_width 468
+ justify 0
+ label "LocalVariableInstruction")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365A926500FA"
+ compartment (object Compartment
+ Parent_View @84
+ location (2454, 475)
+ icon_style "Icon"
+ fill_color 16777215
+ anchor 2
+ nlines 2
+ max_width 147)
+ width 486
+ height 186
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::FieldInstruction" @85
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1888, 1168)
+ label (object ItemLabel
+ Parent_View @85
+ location (1733, 1087)
+ fill_color 13434879
+ nlines 1
+ max_width 310
+ justify 0
+ label "FieldInstruction")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365A92F300CD"
+ compartment (object Compartment
+ Parent_View @85
+ location (1733, 1147)
+ icon_style "Icon"
+ fill_color 16777215
+ anchor 2
+ nlines 2
+ max_width 306)
+ width 328
+ height 186
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::InvokeInstruction" @86
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2368, 1168)
+ label (object ItemLabel
+ Parent_View @86
+ location (2158, 1087)
+ fill_color 13434879
+ nlines 1
+ max_width 420
+ justify 0
+ label "InvokeInstruction")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "365A931601C7"
+ compartment (object Compartment
+ Parent_View @86
+ location (2158, 1147)
+ icon_style "Icon"
+ fill_color 16777215
+ anchor 2
+ nlines 2
+ max_width 416)
+ width 438
+ height 186
+ annotation 8
+ autoResize TRUE)
+ (object InheritTreeView "" @87
+ location (1908, 363)
+ line_color 3342489
+ fill_color 13434879
+ supplier @68
+ vertices (list Points
+ (1908, 363)
+ (1908, 273)))
+ (object InheritView "" @88
+ stereotype TRUE
+ line_color 3342489
+ quidu "365A98B8008A"
+ client @84
+ supplier @68
+ line_style 3
+ origin_attachment (2691, 403)
+ terminal_attachment (2691, 363)
+ drawSupplier @87)
+ (object InheritView "" @89
+ stereotype TRUE
+ line_color 3342489
+ quidu "365A98BE016F"
+ client @79
+ supplier @68
+ line_style 3
+ origin_attachment (2263, 410)
+ terminal_attachment (2263, 363)
+ drawSupplier @87)
+ (object InheritTreeView "" @90
+ location (1113, 971)
+ line_color 3342489
+ fill_color 13434879
+ supplier @70
+ vertices (list Points
+ (1113, 971)
+ (1113, 881)))
+ (object InheritView "" @91
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659B3B503CA"
+ client @71
+ supplier @70
+ line_style 3
+ origin_attachment (913, 1009)
+ terminal_attachment (913, 971)
+ drawSupplier @90)
+ (object InheritView "" @92
+ stereotype TRUE
+ line_color 3342489
+ quidu "365A98E5007B"
+ client @78
+ supplier @68
+ line_style 3
+ origin_attachment (1383, 401)
+ terminal_attachment (1383, 363)
+ drawSupplier @87)
+ (object InheritView "" @93
+ stereotype TRUE
+ line_color 3342489
+ quidu "365A98B0025F"
+ client @83
+ supplier @68
+ line_style 3
+ origin_attachment (981, 271)
+ terminal_attachment (981, 363)
+ drawSupplier @87)
+ (object InheritView "" @94
+ stereotype TRUE
+ line_color 3342489
+ quidu "365A98EA0295"
+ client @81
+ supplier @68
+ line_style 3
+ origin_attachment (1843, 401)
+ terminal_attachment (1843, 363)
+ drawSupplier @87)
+ (object InheritView "" @95
+ stereotype TRUE
+ line_color 3342489
+ quidu "365A98DC03CB"
+ client @77
+ supplier @68
+ line_style 3
+ origin_attachment (2459, 271)
+ terminal_attachment (2459, 363)
+ drawSupplier @87)
+ (object InheritView "" @96
+ stereotype TRUE
+ line_color 3342489
+ quidu "365AB1A8029D"
+ client @80
+ supplier @68
+ line_style 3
+ origin_attachment (1445, 271)
+ terminal_attachment (1445, 363)
+ drawSupplier @87)
+ (object ClassView "Class" "Logical View::FieldOrMethod" @97
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2080, 864)
+ label (object ItemLabel
+ Parent_View @97
+ location (1934, 783)
+ fill_color 13434879
+ nlines 1
+ max_width 292
+ justify 0
+ label "FieldOrMethod")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "37836D4602A2"
+ compartment (object Compartment
+ Parent_View @97
+ location (1934, 843)
+ icon_style "Icon"
+ fill_color 13434879
+ anchor 2
+ nlines 2
+ max_width 237)
+ width 310
+ height 186
+ annotation 8
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::NEW" @98
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2816, 848)
+ label (object ItemLabel
+ Parent_View @98
+ location (2709, 797)
+ fill_color 13434879
+ nlines 1
+ max_width 214
+ justify 0
+ label "NEW")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "37836DE502D3"
+ width 232
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object InheritView "" @99
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659B3CC01E2"
+ client @69
+ supplier @68
+ line_style 3
+ origin_attachment (871, 402)
+ terminal_attachment (871, 363)
+ drawSupplier @87)
+ (object InheritTreeView "" @100
+ location (2256, 736)
+ line_color 3342489
+ fill_color 13434879
+ supplier @79
+ vertices (list Points
+ (2256, 736)
+ (2256, 646)))
+ (object ClassView "Class" "Logical View::INSTANCEOF" @101
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2496, 848)
+ label (object ItemLabel
+ Parent_View @101
+ location (2349, 797)
+ fill_color 13434879
+ nlines 1
+ max_width 294
+ justify 0
+ label "INSTANCEOF")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "37836EC1013F"
+ width 312
+ height 126
+ annotation 8
+ autoResize TRUE)
+ (object InheritView "" @102
+ stereotype TRUE
+ line_color 3342489
+ quidu "37836ED7023B"
+ client @101
+ supplier @79
+ line_style 3
+ origin_attachment (2496, 785)
+ terminal_attachment (2496, 736)
+ drawSupplier @100)
+ (object InheritView "" @103
+ stereotype TRUE
+ line_color 3342489
+ quidu "37836E5F03A1"
+ client @98
+ supplier @79
+ line_style 3
+ origin_attachment (2787, 785)
+ terminal_attachment (2787, 736)
+ drawSupplier @100)
+ (object InheritView "" @104
+ stereotype TRUE
+ line_color 3342489
+ quidu "37836E8702CC"
+ client @97
+ supplier @79
+ line_style 3
+ origin_attachment (2054, 771)
+ terminal_attachment (2054, 736)
+ drawSupplier @100)
+ (object InheritView "" @105
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659B3BC013F"
+ client @72
+ supplier @70
+ line_style 3
+ origin_attachment (1325, 1009)
+ terminal_attachment (1325, 971)
+ drawSupplier @90)
+ (object InheritTreeView "" @106
+ location (2079, 1047)
+ line_color 3342489
+ fill_color 13434879
+ supplier @97
+ vertices (list Points
+ (2079, 1047)
+ (2079, 957)))
+ (object InheritView "" @107
+ stereotype TRUE
+ line_color 3342489
+ quidu "37836FB302A5"
+ client @86
+ supplier @97
+ line_style 3
+ origin_attachment (2363, 1075)
+ terminal_attachment (2363, 1047)
+ drawSupplier @106)
+ (object InheritView "" @108
+ stereotype TRUE
+ line_color 3342489
+ quidu "37836FAF0231"
+ client @85
+ supplier @97
+ line_style 3
+ origin_attachment (1873, 1075)
+ terminal_attachment (1873, 1047)
+ drawSupplier @106)
+ (object InheritView "" @109
+ stereotype TRUE
+ line_color 3342489
+ quidu "3659B3C5014C"
+ client @70
+ supplier @69
+ line_style 3
+ origin_attachment (1128, 687)
+ terminal_attachment (1128, 618)
+ drawSupplier @75)))))
+ root_subsystem (object SubSystem "Component View"
+ quid "3659ABB2006D"
+ physical_models (list unit_reference_list
+ (object module "ClassGen" "NotAModuleType" "NotAModulePart"
+ quid "3659AD9C02CB"
+ stereotype ""
+ language "Java"))
+ physical_presentations (list unit_reference_list
+ (object Module_Diagram "Main"
+ quid "3659ABB600FF"
+ title "Main"
+ zoom 100
+ max_height 28350
+ max_width 21600
+ origin_x 0
+ origin_y 0
+ items (list diagram_item_list))))
+ process_structure (object Processes
+ quid "3659ABB2006E"
+ ProcsNDevs (list
+ (object Process_Diagram "Deployment View"
+ quid "3659ABB20077"
+ title "Deployment View"
+ zoom 100
+ max_height 28350
+ max_width 21600
+ origin_x 0
+ origin_y 0
+ items (list diagram_item_list))))
+ properties (object Properties
+ attributes (list Attribute_Set
+ (object Attribute
+ tool "DDL"
+ name "propertyId"
+ value "809135966")
+ (object Attribute
+ tool "DDL"
+ name "default__Project"
+ value (list Attribute_Set
+ (object Attribute
+ tool "DDL"
+ name "DataBase"
+ value ("DataBaseSet" 800))
+ (object Attribute
+ tool "DDL"
+ name "DataBaseSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "DDL"
+ name "ANSI"
+ value 800)
+ (object Attribute
+ tool "DDL"
+ name "Oracle"
+ value 801)
+ (object Attribute
+ tool "DDL"
+ name "SQLServer"
+ value 802)
+ (object Attribute
+ tool "DDL"
+ name "Sybase"
+ value 803)
+ (object Attribute
+ tool "DDL"
+ name "Watcom"
+ value 804)))
+ (object Attribute
+ tool "DDL"
+ name "PrimaryKeyColumnName"
+ value "Id")
+ (object Attribute
+ tool "DDL"
+ name "PrimaryKeyColumnType"
+ value "NUMBER(5)")
+ (object Attribute
+ tool "DDL"
+ name "ViewName"
+ value "V_")
+ (object Attribute
+ tool "DDL"
+ name "TableName"
+ value "T_")
+ (object Attribute
+ tool "DDL"
+ name "InheritSuffix"
+ value "_V")
+ (object Attribute
+ tool "DDL"
+ name "DropClause"
+ value FALSE)
+ (object Attribute
+ tool "DDL"
+ name "BaseViews"
+ value FALSE)
+ (object Attribute
+ tool "DDL"
+ name "DDLScriptFilename"
+ value "DDL1.SQL")))
+ (object Attribute
+ tool "DDL"
+ name "default__Attribute"
+ value (list Attribute_Set
+ (object Attribute
+ tool "DDL"
+ name "ColumnType"
+ value "VARCHAR")
+ (object Attribute
+ tool "DDL"
+ name "Length"
+ value "")
+ (object Attribute
+ tool "DDL"
+ name "NullsOK"
+ value TRUE)
+ (object Attribute
+ tool "DDL"
+ name "PrimaryKey"
+ value FALSE)
+ (object Attribute
+ tool "DDL"
+ name "Unique"
+ value FALSE)
+ (object Attribute
+ tool "DDL"
+ name "CompositeUnique"
+ value FALSE)
+ (object Attribute
+ tool "DDL"
+ name "CheckConstraint"
+ value "")))
+ (object Attribute
+ tool "DDL"
+ name "HiddenTool"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "propertyId"
+ value "809135966")
+ (object Attribute
+ tool "IDL"
+ name "default__Project"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "CreateMissingDirectories"
+ value TRUE)
+ (object Attribute
+ tool "IDL"
+ name "StopOnError"
+ value TRUE)
+ (object Attribute
+ tool "IDL"
+ name "Directory"
+ value "AUTO GENERATE")
+ (object Attribute
+ tool "IDL"
+ name "GeneratePreserveRegions"
+ value TRUE)))
+ (object Attribute
+ tool "IDL"
+ name "default__Class"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "ImplementationType"
+ value "")
+ (object Attribute
+ tool "IDL"
+ name "ConstValue"
+ value "")
+ (object Attribute
+ tool "IDL"
+ name "GenerateDefaultSpecifier"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "DefaultSpecifier"
+ value "")
+ (object Attribute
+ tool "IDL"
+ name "IDLElement"
+ value TRUE)
+ (object Attribute
+ tool "IDL"
+ name "IDLSpecificationType"
+ value ("IDLSpecSet" 22))
+ (object Attribute
+ tool "IDL"
+ name "IDLSpecSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "Interface"
+ value 22)
+ (object Attribute
+ tool "IDL"
+ name "Typedef"
+ value 54)
+ (object Attribute
+ tool "IDL"
+ name "Enumeration"
+ value 8)
+ (object Attribute
+ tool "IDL"
+ name "Const"
+ value 71)
+ (object Attribute
+ tool "IDL"
+ name "Exception"
+ value 61)
+ (object Attribute
+ tool "IDL"
+ name "Struct"
+ value 51)
+ (object Attribute
+ tool "IDL"
+ name "Union"
+ value 81)))))
+ (object Attribute
+ tool "IDL"
+ name "default__Module-Spec"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "Generate"
+ value TRUE)
+ (object Attribute
+ tool "IDL"
+ name "CmIdentification"
+ value (value Text " %X% %Q% %Z% %W%"))
+ (object Attribute
+ tool "IDL"
+ name "CopyrightNotice"
+ value (value Text ""))
+ (object Attribute
+ tool "IDL"
+ name "FileName"
+ value "AUTO GENERATE")
+ (object Attribute
+ tool "IDL"
+ name "GenerateIDLModule"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "InclusionProtectionSymbol"
+ value "AUTO GENERATE")
+ (object Attribute
+ tool "IDL"
+ name "AdditionalIncludes"
+ value (value Text ""))
+ (object Attribute
+ tool "IDL"
+ name "IncludeBySimpleName"
+ value FALSE)))
+ (object Attribute
+ tool "IDL"
+ name "default__Module-Body"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "CmIdentification"
+ value (value Text " %X% %Q% %Z% %W%"))
+ (object Attribute
+ tool "IDL"
+ name "CopyrightNotice"
+ value (value Text ""))
+ (object Attribute
+ tool "IDL"
+ name "FileName"
+ value "AUTO GENERATE")
+ (object Attribute
+ tool "IDL"
+ name "AdditionalIncludes"
+ value (value Text ""))
+ (object Attribute
+ tool "IDL"
+ name "IncludeBySimpleName"
+ value FALSE)))
+ (object Attribute
+ tool "IDL"
+ name "default__Operation"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "OperationIsOneWay"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "Context"
+ value "")
+ (object Attribute
+ tool "IDL"
+ name "Raises"
+ value "")))
+ (object Attribute
+ tool "IDL"
+ name "default__Attribute"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "CaseSpecifier"
+ value "")
+ (object Attribute
+ tool "IDL"
+ name "GenerateDataMember"
+ value TRUE)
+ (object Attribute
+ tool "IDL"
+ name "DataMemberName"
+ value "$relationship")
+ (object Attribute
+ tool "IDL"
+ name "IsReadOnly"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "IsConst"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "ConstValue"
+ value "")))
+ (object Attribute
+ tool "IDL"
+ name "default__Has"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "NameIfUnlabeled"
+ value "the_$supplier")
+ (object Attribute
+ tool "IDL"
+ name "GenerateDataMember"
+ value TRUE)
+ (object Attribute
+ tool "IDL"
+ name "DataMemberName"
+ value "$relationship")
+ (object Attribute
+ tool "IDL"
+ name "GenerateForwardReference"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "IsReadOnly"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "BoundedHasRelType"
+ value ("HasRelTypeSet" 47))
+ (object Attribute
+ tool "IDL"
+ name "HasRelTypeSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "Array"
+ value 24)
+ (object Attribute
+ tool "IDL"
+ name "Sequence"
+ value 47)))))
+ (object Attribute
+ tool "IDL"
+ name "default__Role"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "NameIfUnlabeled"
+ value "the_$supplier")
+ (object Attribute
+ tool "IDL"
+ name "GenerateDataMember"
+ value TRUE)
+ (object Attribute
+ tool "IDL"
+ name "DataMemberName"
+ value "$relationship")
+ (object Attribute
+ tool "IDL"
+ name "GenerateForwardReference"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "IsReadOnly"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "BoundedRoleType"
+ value ("AssocTypeSet" 47))
+ (object Attribute
+ tool "IDL"
+ name "AssocTypeSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "Array"
+ value 24)
+ (object Attribute
+ tool "IDL"
+ name "Sequence"
+ value 47)))))
+ (object Attribute
+ tool "IDL"
+ name "default__Uses"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "GenerateForwardReference"
+ value FALSE)))
+ (object Attribute
+ tool "IDL"
+ name "default__Subsystem"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "Directory"
+ value "AUTO GENERATE")))
+ (object Attribute
+ tool "IDL"
+ name "HiddenTool"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "propertyId"
+ value "809135966")
+ (object Attribute
+ tool "Java"
+ name "default__Project"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Java"
+ name "CreateMissingDirectories"
+ value TRUE)
+ (object Attribute
+ tool "Java"
+ name "StopOnError"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Directory"
+ value "AUTO GENERATE")
+ (object Attribute
+ tool "Java"
+ name "UsePrefixes"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "InstanceVariablePrefix"
+ value "m_")
+ (object Attribute
+ tool "Java"
+ name "ClassVariablePrefix"
+ value "s_")
+ (object Attribute
+ tool "Java"
+ name "DefaultAttributeDataType"
+ value "int")
+ (object Attribute
+ tool "Java"
+ name "DefaultOperationReturnType"
+ value "void")))
+ (object Attribute
+ tool "Java"
+ name "default__Class"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Java"
+ name "Final"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "GenerateDefaultConstructor"
+ value TRUE)
+ (object Attribute
+ tool "Java"
+ name "ConstructorIs"
+ value ("Ctor_Set" 62))
+ (object Attribute
+ tool "Java"
+ name "Ctor_Set"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Java"
+ name "Public"
+ value 62)
+ (object Attribute
+ tool "Java"
+ name "Protected"
+ value 63)
+ (object Attribute
+ tool "Java"
+ name "Private"
+ value 64)))
+ (object Attribute
+ tool "Java"
+ name "GenerateFinalizer"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "GenerateStaticInitializer"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "GenerateInstanceInitializer"
+ value FALSE)))
+ (object Attribute
+ tool "Java"
+ name "default__Module-Spec"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Java"
+ name "Generate"
+ value TRUE)
+ (object Attribute
+ tool "Java"
+ name "CmIdentification"
+ value (value Text ""))
+ (object Attribute
+ tool "Java"
+ name "CopyrightNotice"
+ value (value Text ""))
+ (object Attribute
+ tool "Java"
+ name "AdditionalImports"
+ value (value Text ""))))
+ (object Attribute
+ tool "Java"
+ name "default__Module-Body"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Java"
+ name "Generate"
+ value TRUE)
+ (object Attribute
+ tool "Java"
+ name "CmIdentification"
+ value (value Text ""))
+ (object Attribute
+ tool "Java"
+ name "CopyrightNotice"
+ value (value Text ""))
+ (object Attribute
+ tool "Java"
+ name "AdditionalImports"
+ value (value Text ""))))
+ (object Attribute
+ tool "Java"
+ name "default__Operation"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Java"
+ name "Abstract"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Static"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Final"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Native"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Synchronized"
+ value FALSE)))
+ (object Attribute
+ tool "Java"
+ name "default__Attribute"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Java"
+ name "GenerateDataMember"
+ value TRUE)
+ (object Attribute
+ tool "Java"
+ name "Final"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Transient"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Volatile"
+ value FALSE)))
+ (object Attribute
+ tool "Java"
+ name "default__Role"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Java"
+ name "GenerateDataMember"
+ value TRUE)
+ (object Attribute
+ tool "Java"
+ name "ContainerClass"
+ value "")
+ (object Attribute
+ tool "Java"
+ name "InitialValue"
+ value "")
+ (object Attribute
+ tool "Java"
+ name "Final"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Transient"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Volatile"
+ value FALSE)))
+ (object Attribute
+ tool "Java"
+ name "HiddenTool"
+ value FALSE)
+ (object Attribute
+ tool "SCC"
+ name "HiddenTool"
+ value FALSE))
+ quid "3659ABB2006F"))
diff --git a/docs/manual.bib b/docs/manual.bib
new file mode 100644
index 00000000..57baa038
--- /dev/null
+++ b/docs/manual.bib
@@ -0,0 +1,185 @@
+@InProceedings{ada,
+ author = {Tucker Taft},
+ title = {\protect{Programming the Internet in Ada95}},
+ booktitle = {Proceedings Ada-Europe International Conference on
+ Reliable Software Technologies},
+ year = {1996}
+}
+
+@InProceedings{agesen,
+ author = {O. Agesen and S. N. Freund and J. C. Mitchell},
+ title = {\protect{Adding Type Parameterization to the Java
+ Language}},
+ booktitle = {Proceedings OOPSLA'97},
+ year = {1997},
+ address = {Atlanta, GA}
+}
+
+@TechReport{aspect,
+ author = {Gregor Kiczales and John Lamping and Anurag
+ Mendhekar and Chris Maeda and Cristina Lopes and
+ Jean-Marc Loingtier and John Irwin},
+ title = {\protect{Aspect-Oriented Programming}},
+ institution = {Xerox Palo Alto Research Center},
+ year = {1997},
+ key = {SPL97-008 P9710042}
+}
+
+@TechReport{barat,
+ author = {B. Bokowski and A. Spiegel},
+ title = {\protect{Barat -- A Front-End for Java}},
+ institution = {Freie Universit\"at Berlin},
+ year = {1998},
+ key = {B-98-09}
+}
+
+@InProceedings{bca,
+ author = {Ralph Keller and Urs H{\"o}lzle},
+ title = {\protect{Binary Component Adaptation}},
+ booktitle = {Proceedings ECOOP'98},
+ publisher = {Springer},
+ editor = {Eric Jul},
+ year = {1998}
+}
+
+@InProceedings{bit,
+ author = {Han Bok Lee and Benjamin G. Zorn},
+ title = {\protect{BIT: A Tool for Instrumenting Java
+ Bytecodes}},
+ booktitle = {Proceedings USENIX Symposium on Internet
+ Technologies and Systems},
+ year = {1998}
+}
+
+@Manual{classfile,
+ title = {The classfile API},
+ author = {Shawn Silverman},
+ organization = {University of Manitoba},
+ address = {\url{http://Meurrens.ML.org/ip-Links/java/codeEngineering/viewers.html}},
+ year = {1998}
+}
+
+@Manual{classfilters,
+ title = {The ClassFilters package},
+ author = {Pascal Costanza},
+ organization = {Universit{\"a}t Bonn},
+ address = {\url{http://www.cs.uni-bonn.de/~costanza/ClassFilters/}},
+ year = {1998}
+}
+
+@InProceedings{classloader,
+ author = {Sheng Lian and Gilad Bracha},
+ title = {\protect{Dynamic Class Loading in the Java Virtual
+ Machine}},
+ booktitle = {Proceedings OOPSLA'98},
+ year = {1998}
+}
+
+@Book{design,
+ author = {E. Gamma and R. Helm and R. Johnson and
+ J. Vlissides},
+ title = {Design Patterns: Elements of Reusable
+ Object-Oriented Software},
+ publisher = {Addison-Wesley},
+ year = {1995}
+}
+
+@InProceedings{eiffel,
+ author = {Suzanne Collin and Dominique Colnet and Olivier
+ Zendra},
+ title = {\protect{Type Inference for Late Binding. The
+ SmallEiffel Compiler}},
+ booktitle = {Proceedings JMLC'97},
+ year = {1997}
+}
+
+@Book{gosling,
+ author = {J. Gosling and B. Joy and G. Steele},
+ title = {The Java Language Specification},
+ publisher = {Addison-Wesley},
+ year = {1996}
+}
+
+@Manual{inside,
+ title = {Inside Java Class Files},
+ author = {Matt T. Yourst},
+ organization = {Laserstars Technologies},
+ address =
+ {\url{http://www.laserstars.com/articles/ddj/insidejcf/}},
+ year = {1998}
+}
+
+@Book{jasmin,
+ author = {J. Meyer and T. Downing},
+ title = {Java Virtual Machine},
+ publisher = {O'Reilly},
+ year = {1997}
+}
+
+@InProceedings{jawa,
+ author = {C. Fischer and D. Meemken},
+ title = {\protect{JaWa: Java with Assertions}},
+ editor = {Clemens Cap},
+ booktitle = {Proceedings JIT'98},
+ publisher = {Springer},
+ year = {1998}
+}
+
+@InProceedings{joie,
+ author = {Geoff Cohen and Jeff Chase and David Kaminsky},
+ title = {\protect{Automatic Program Transformation with
+ JOIE}},
+ booktitle = {Proceedings USENIX Annual Technical Symposium},
+ year = {1998}
+}
+
+@Book{jvm,
+ author = {Tim Lindholm and Frank Yellin},
+ title = {The Java Virtual Machine Specification},
+ publisher = {Addison-Wesley},
+ year = {1997}
+}
+
+@InProceedings{myers,
+ author = {A.C. Myers and J. A. Bank and B. Liskov},
+ title = {\protect{Parameterized Types for Java}},
+ booktitle = {Proceedings POPL'97},
+ year = {1997},
+ address = {Paris, France}
+}
+
+@InProceedings{pmg,
+ author = {B. Bokowski and M. Dahm},
+ title = {\protect{Poor Man's Genericity for Java}},
+ publisher = {Springer},
+ editor = {Clemens Cap},
+ booktitle = {Proceedings JIT'98},
+ year = {1998}
+}
+
+@Manual{reflection,
+ title = {Reflection API},
+ author = {JavaSoft},
+ address = {\url{http://java.sun.com/products/jdk/1.1/docs/guide/reflection/}},
+ year = {1998}
+}
+
+@InProceedings{statistic,
+ author = {D. Antonioli and M. Pilz},
+ title = {\protect{Statistische Analyse von Java-Classfiles}},
+ publisher = {Springer},
+ editor = {Clemens Cap},
+ booktitle = {Proceedings JIT'98},
+ year = {1998}
+}
+
+@InProceedings{thies,
+ author = {M. Thies and U. Kastens},
+ title = {\protect{Statische Analyse von Bibliotheken als
+ Grundlage dynamischer Optimierung}},
+ publisher = {Springer},
+ editor = {Clemens Cap},
+ booktitle = {Proceedings JIT'98},
+ year = {1998},
+}
+
diff --git a/docs/manual.ps b/docs/manual.ps
new file mode 100644
index 00000000..c6024074
--- /dev/null
+++ b/docs/manual.ps
@@ -0,0 +1,4988 @@
+%!PS-Adobe-2.0
+%%Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software
+%%Title: manual.dvi
+%%Pages: 31
+%%PageOrder: Ascend
+%%BoundingBox: 0 0 596 842
+%%DocumentFonts: Palatino-Roman Palatino-Bold Courier Palatino-Italic
+%%+ Helvetica Helvetica-Oblique Courier-Bold
+%%DocumentPaperSizes: a4
+%%EndComments
+%DVIPSWebPage: (www.radicaleye.com)
+%DVIPSCommandLine: /usr/bin/dvips manual.dvi
+%DVIPSParameters: dpi=600, compressed
+%DVIPSSource: TeX output 2001.10.08:1345
+%%BeginProcSet: texc.pro
+%!
+/TeXDict 300 dict def TeXDict begin/N{def}def/B{bind def}N/S{exch}N/X{S
+N}B/A{dup}B/TR{translate}N/isls false N/vsize 11 72 mul N/hsize 8.5 72
+mul N/landplus90{false}def/@rigin{isls{[0 landplus90{1 -1}{-1 1}ifelse 0
+0 0]concat}if 72 Resolution div 72 VResolution div neg scale isls{
+landplus90{VResolution 72 div vsize mul 0 exch}{Resolution -72 div hsize
+mul 0}ifelse TR}if Resolution VResolution vsize -72 div 1 add mul TR[
+matrix currentmatrix{A A round sub abs 0.00001 lt{round}if}forall round
+exch round exch]setmatrix}N/@landscape{/isls true N}B/@manualfeed{
+statusdict/manualfeed true put}B/@copies{/#copies X}B/FMat[1 0 0 -1 0 0]
+N/FBB[0 0 0 0]N/nn 0 N/IEn 0 N/ctr 0 N/df-tail{/nn 8 dict N nn begin
+/FontType 3 N/FontMatrix fntrx N/FontBBox FBB N string/base X array
+/BitMaps X/BuildChar{CharBuilder}N/Encoding IEn N end A{/foo setfont}2
+array copy cvx N load 0 nn put/ctr 0 N[}B/sf 0 N/df{/sf 1 N/fntrx FMat N
+df-tail}B/dfs{div/sf X/fntrx[sf 0 0 sf neg 0 0]N df-tail}B/E{pop nn A
+definefont setfont}B/Cw{Cd A length 5 sub get}B/Ch{Cd A length 4 sub get
+}B/Cx{128 Cd A length 3 sub get sub}B/Cy{Cd A length 2 sub get 127 sub}
+B/Cdx{Cd A length 1 sub get}B/Ci{Cd A type/stringtype ne{ctr get/ctr ctr
+1 add N}if}B/id 0 N/rw 0 N/rc 0 N/gp 0 N/cp 0 N/G 0 N/CharBuilder{save 3
+1 roll S A/base get 2 index get S/BitMaps get S get/Cd X pop/ctr 0 N Cdx
+0 Cx Cy Ch sub Cx Cw add Cy setcachedevice Cw Ch true[1 0 0 -1 -.1 Cx
+sub Cy .1 sub]/id Ci N/rw Cw 7 add 8 idiv string N/rc 0 N/gp 0 N/cp 0 N{
+rc 0 ne{rc 1 sub/rc X rw}{G}ifelse}imagemask restore}B/G{{id gp get/gp
+gp 1 add N A 18 mod S 18 idiv pl S get exec}loop}B/adv{cp add/cp X}B
+/chg{rw cp id gp 4 index getinterval putinterval A gp add/gp X adv}B/nd{
+/cp 0 N rw exit}B/lsh{rw cp 2 copy get A 0 eq{pop 1}{A 255 eq{pop 254}{
+A A add 255 and S 1 and or}ifelse}ifelse put 1 adv}B/rsh{rw cp 2 copy
+get A 0 eq{pop 128}{A 255 eq{pop 127}{A 2 idiv S 128 and or}ifelse}
+ifelse put 1 adv}B/clr{rw cp 2 index string putinterval adv}B/set{rw cp
+fillstr 0 4 index getinterval putinterval adv}B/fillstr 18 string 0 1 17
+{2 copy 255 put pop}for N/pl[{adv 1 chg}{adv 1 chg nd}{1 add chg}{1 add
+chg nd}{adv lsh}{adv lsh nd}{adv rsh}{adv rsh nd}{1 add adv}{/rc X nd}{
+1 add set}{1 add clr}{adv 2 chg}{adv 2 chg nd}{pop nd}]A{bind pop}
+forall N/D{/cc X A type/stringtype ne{]}if nn/base get cc ctr put nn
+/BitMaps get S ctr S sf 1 ne{A A length 1 sub A 2 index S get sf div put
+}if put/ctr ctr 1 add N}B/I{cc 1 add D}B/bop{userdict/bop-hook known{
+bop-hook}if/SI save N @rigin 0 0 moveto/V matrix currentmatrix A 1 get A
+mul exch 0 get A mul add .99 lt{/QV}{/RV}ifelse load def pop pop}N/eop{
+SI restore userdict/eop-hook known{eop-hook}if showpage}N/@start{
+userdict/start-hook known{start-hook}if pop/VResolution X/Resolution X
+1000 div/DVImag X/IEn 256 array N 2 string 0 1 255{IEn S A 360 add 36 4
+index cvrs cvn put}for pop 65781.76 div/vsize X 65781.76 div/hsize X}N
+/p{show}N/RMat[1 0 0 -1 0 0]N/BDot 260 string N/Rx 0 N/Ry 0 N/V{}B/RV/v{
+/Ry X/Rx X V}B statusdict begin/product where{pop false[(Display)(NeXT)
+(LaserWriter 16/600)]{A length product length le{A length product exch 0
+exch getinterval eq{pop true exit}if}{pop}ifelse}forall}{false}ifelse
+end{{gsave TR -.1 .1 TR 1 1 scale Rx Ry false RMat{BDot}imagemask
+grestore}}{{gsave TR -.1 .1 TR Rx Ry scale 1 1 false RMat{BDot}
+imagemask grestore}}ifelse B/QV{gsave newpath transform round exch round
+exch itransform moveto Rx 0 rlineto 0 Ry neg rlineto Rx neg 0 rlineto
+fill grestore}B/a{moveto}B/delta 0 N/tail{A/delta X 0 rmoveto}B/M{S p
+delta add tail}B/b{S p tail}B/c{-4 M}B/d{-3 M}B/e{-2 M}B/f{-1 M}B/g{0 M}
+B/h{1 M}B/i{2 M}B/j{3 M}B/k{4 M}B/w{0 rmoveto}B/l{p -4 w}B/m{p -3 w}B/n{
+p -2 w}B/o{p -1 w}B/q{p 1 w}B/r{p 2 w}B/s{p 3 w}B/t{p 4 w}B/x{0 S
+rmoveto}B/y{3 2 roll p a}B/bos{/SS save N}B/eos{SS restore}B end
+
+%%EndProcSet
+%%BeginProcSet: 8r.enc
+% @@psencodingfile@{
+% author = "S. Rahtz, P. MacKay, Alan Jeffrey, B. Horn, K. Berry",
+% version = "0.6",
+% date = "22 June 1996",
+% filename = "8r.enc",
+% email = "kb@@mail.tug.org",
+% address = "135 Center Hill Rd. // Plymouth, MA 02360",
+% codetable = "ISO/ASCII",
+% checksum = "119 662 4424",
+% docstring = "Encoding for TrueType or Type 1 fonts to be used with TeX."
+% @}
+%
+% Idea is to have all the characters normally included in Type 1 fonts
+% available for typesetting. This is effectively the characters in Adobe
+% Standard Encoding + ISO Latin 1 + extra characters from Lucida.
+%
+% Character code assignments were made as follows:
+%
+% (1) the Windows ANSI characters are almost all in their Windows ANSI
+% positions, because some Windows users cannot easily reencode the
+% fonts, and it makes no difference on other systems. The only Windows
+% ANSI characters not available are those that make no sense for
+% typesetting -- rubout (127 decimal), nobreakspace (160), softhyphen
+% (173). quotesingle and grave are moved just because it's such an
+% irritation not having them in TeX positions.
+%
+% (2) Remaining characters are assigned arbitrarily to the lower part
+% of the range, avoiding 0, 10 and 13 in case we meet dumb software.
+%
+% (3) Y&Y Lucida Bright includes some extra text characters; in the
+% hopes that other PostScript fonts, perhaps created for public
+% consumption, will include them, they are included starting at 0x12.
+%
+% (4) Remaining positions left undefined are for use in (hopefully)
+% upward-compatible revisions, if someday more characters are generally
+% available.
+%
+% (5) hyphen appears twice for compatibility with both ASCII and Windows.
+%
+/TeXBase1Encoding [
+% 0x00 (encoded characters from Adobe Standard not in Windows 3.1)
+ /.notdef /dotaccent /fi /fl
+ /fraction /hungarumlaut /Lslash /lslash
+ /ogonek /ring /.notdef
+ /breve /minus /.notdef
+% These are the only two remaining unencoded characters, so may as
+% well include them.
+ /Zcaron /zcaron
+% 0x10
+ /caron /dotlessi
+% (unusual TeX characters available in, e.g., Lucida Bright)
+ /dotlessj /ff /ffi /ffl
+ /.notdef /.notdef /.notdef /.notdef
+ /.notdef /.notdef /.notdef /.notdef
+ % very contentious; it's so painful not having quoteleft and quoteright
+ % at 96 and 145 that we move the things normally found there down to here.
+ /grave /quotesingle
+% 0x20 (ASCII begins)
+ /space /exclam /quotedbl /numbersign
+ /dollar /percent /ampersand /quoteright
+ /parenleft /parenright /asterisk /plus /comma /hyphen /period /slash
+% 0x30
+ /zero /one /two /three /four /five /six /seven
+ /eight /nine /colon /semicolon /less /equal /greater /question
+% 0x40
+ /at /A /B /C /D /E /F /G /H /I /J /K /L /M /N /O
+% 0x50
+ /P /Q /R /S /T /U /V /W
+ /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore
+% 0x60
+ /quoteleft /a /b /c /d /e /f /g /h /i /j /k /l /m /n /o
+% 0x70
+ /p /q /r /s /t /u /v /w
+ /x /y /z /braceleft /bar /braceright /asciitilde
+ /.notdef % rubout; ASCII ends
+% 0x80
+ /.notdef /.notdef /quotesinglbase /florin
+ /quotedblbase /ellipsis /dagger /daggerdbl
+ /circumflex /perthousand /Scaron /guilsinglleft
+ /OE /.notdef /.notdef /.notdef
+% 0x90
+ /.notdef /.notdef /.notdef /quotedblleft
+ /quotedblright /bullet /endash /emdash
+ /tilde /trademark /scaron /guilsinglright
+ /oe /.notdef /.notdef /Ydieresis
+% 0xA0
+ /.notdef % nobreakspace
+ /exclamdown /cent /sterling
+ /currency /yen /brokenbar /section
+ /dieresis /copyright /ordfeminine /guillemotleft
+ /logicalnot
+ /hyphen % Y&Y (also at 45); Windows' softhyphen
+ /registered
+ /macron
+% 0xD0
+ /degree /plusminus /twosuperior /threesuperior
+ /acute /mu /paragraph /periodcentered
+ /cedilla /onesuperior /ordmasculine /guillemotright
+ /onequarter /onehalf /threequarters /questiondown
+% 0xC0
+ /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla
+ /Egrave /Eacute /Ecircumflex /Edieresis
+ /Igrave /Iacute /Icircumflex /Idieresis
+% 0xD0
+ /Eth /Ntilde /Ograve /Oacute
+ /Ocircumflex /Otilde /Odieresis /multiply
+ /Oslash /Ugrave /Uacute /Ucircumflex
+ /Udieresis /Yacute /Thorn /germandbls
+% 0xE0
+ /agrave /aacute /acircumflex /atilde
+ /adieresis /aring /ae /ccedilla
+ /egrave /eacute /ecircumflex /edieresis
+ /igrave /iacute /icircumflex /idieresis
+% 0xF0
+ /eth /ntilde /ograve /oacute
+ /ocircumflex /otilde /odieresis /divide
+ /oslash /ugrave /uacute /ucircumflex
+ /udieresis /yacute /thorn /ydieresis
+] def
+
+%%EndProcSet
+%%BeginProcSet: texps.pro
+%!
+TeXDict begin/rf{findfont dup length 1 add dict begin{1 index/FID ne 2
+index/UniqueID ne and{def}{pop pop}ifelse}forall[1 index 0 6 -1 roll
+exec 0 exch 5 -1 roll VResolution Resolution div mul neg 0 0]/Metrics
+exch def dict begin Encoding{exch dup type/integertype ne{pop pop 1 sub
+dup 0 le{pop}{[}ifelse}{FontMatrix 0 get div Metrics 0 get div def}
+ifelse}forall Metrics/Metrics currentdict end def[2 index currentdict
+end definefont 3 -1 roll makefont/setfont cvx]cvx def}def/ObliqueSlant{
+dup sin S cos div neg}B/SlantFont{4 index mul add}def/ExtendFont{3 -1
+roll mul exch}def/ReEncodeFont{CharStrings rcheck{/Encoding false def
+dup[exch{dup CharStrings exch known not{pop/.notdef/Encoding true def}
+if}forall Encoding{]exch pop}{cleartomark}ifelse}if/Encoding exch def}
+def end
+
+%%EndProcSet
+%%BeginProcSet: special.pro
+%!
+TeXDict begin/SDict 200 dict N SDict begin/@SpecialDefaults{/hs 612 N
+/vs 792 N/ho 0 N/vo 0 N/hsc 1 N/vsc 1 N/ang 0 N/CLIP 0 N/rwiSeen false N
+/rhiSeen false N/letter{}N/note{}N/a4{}N/legal{}N}B/@scaleunit 100 N
+/@hscale{@scaleunit div/hsc X}B/@vscale{@scaleunit div/vsc X}B/@hsize{
+/hs X/CLIP 1 N}B/@vsize{/vs X/CLIP 1 N}B/@clip{/CLIP 2 N}B/@hoffset{/ho
+X}B/@voffset{/vo X}B/@angle{/ang X}B/@rwi{10 div/rwi X/rwiSeen true N}B
+/@rhi{10 div/rhi X/rhiSeen true N}B/@llx{/llx X}B/@lly{/lly X}B/@urx{
+/urx X}B/@ury{/ury X}B/magscale true def end/@MacSetUp{userdict/md known
+{userdict/md get type/dicttype eq{userdict begin md length 10 add md
+maxlength ge{/md md dup length 20 add dict copy def}if end md begin
+/letter{}N/note{}N/legal{}N/od{txpose 1 0 mtx defaultmatrix dtransform S
+atan/pa X newpath clippath mark{transform{itransform moveto}}{transform{
+itransform lineto}}{6 -2 roll transform 6 -2 roll transform 6 -2 roll
+transform{itransform 6 2 roll itransform 6 2 roll itransform 6 2 roll
+curveto}}{{closepath}}pathforall newpath counttomark array astore/gc xdf
+pop ct 39 0 put 10 fz 0 fs 2 F/|______Courier fnt invertflag{PaintBlack}
+if}N/txpose{pxs pys scale ppr aload pop por{noflips{pop S neg S TR pop 1
+-1 scale}if xflip yflip and{pop S neg S TR 180 rotate 1 -1 scale ppr 3
+get ppr 1 get neg sub neg ppr 2 get ppr 0 get neg sub neg TR}if xflip
+yflip not and{pop S neg S TR pop 180 rotate ppr 3 get ppr 1 get neg sub
+neg 0 TR}if yflip xflip not and{ppr 1 get neg ppr 0 get neg TR}if}{
+noflips{TR pop pop 270 rotate 1 -1 scale}if xflip yflip and{TR pop pop
+90 rotate 1 -1 scale ppr 3 get ppr 1 get neg sub neg ppr 2 get ppr 0 get
+neg sub neg TR}if xflip yflip not and{TR pop pop 90 rotate ppr 3 get ppr
+1 get neg sub neg 0 TR}if yflip xflip not and{TR pop pop 270 rotate ppr
+2 get ppr 0 get neg sub neg 0 S TR}if}ifelse scaleby96{ppr aload pop 4
+-1 roll add 2 div 3 1 roll add 2 div 2 copy TR .96 dup scale neg S neg S
+TR}if}N/cp{pop pop showpage pm restore}N end}if}if}N/normalscale{
+Resolution 72 div VResolution 72 div neg scale magscale{DVImag dup scale
+}if 0 setgray}N/psfts{S 65781.76 div N}N/startTexFig{/psf$SavedState
+save N userdict maxlength dict begin/magscale true def normalscale
+currentpoint TR/psf$ury psfts/psf$urx psfts/psf$lly psfts/psf$llx psfts
+/psf$y psfts/psf$x psfts currentpoint/psf$cy X/psf$cx X/psf$sx psf$x
+psf$urx psf$llx sub div N/psf$sy psf$y psf$ury psf$lly sub div N psf$sx
+psf$sy scale psf$cx psf$sx div psf$llx sub psf$cy psf$sy div psf$ury sub
+TR/showpage{}N/erasepage{}N/copypage{}N/p 3 def @MacSetUp}N/doclip{
+psf$llx psf$lly psf$urx psf$ury currentpoint 6 2 roll newpath 4 copy 4 2
+roll moveto 6 -1 roll S lineto S lineto S lineto closepath clip newpath
+moveto}N/endTexFig{end psf$SavedState restore}N/@beginspecial{SDict
+begin/SpecialSave save N gsave normalscale currentpoint TR
+@SpecialDefaults count/ocount X/dcount countdictstack N}N/@setspecial{
+CLIP 1 eq{newpath 0 0 moveto hs 0 rlineto 0 vs rlineto hs neg 0 rlineto
+closepath clip}if ho vo TR hsc vsc scale ang rotate rwiSeen{rwi urx llx
+sub div rhiSeen{rhi ury lly sub div}{dup}ifelse scale llx neg lly neg TR
+}{rhiSeen{rhi ury lly sub div dup scale llx neg lly neg TR}if}ifelse
+CLIP 2 eq{newpath llx lly moveto urx lly lineto urx ury lineto llx ury
+lineto closepath clip}if/showpage{}N/erasepage{}N/copypage{}N newpath}N
+/@endspecial{count ocount sub{pop}repeat countdictstack dcount sub{end}
+repeat grestore SpecialSave restore end}N/@defspecial{SDict begin}N
+/@fedspecial{end}B/li{lineto}B/rl{rlineto}B/rc{rcurveto}B/np{/SaveX
+currentpoint/SaveY X N 1 setlinecap newpath}N/st{stroke SaveX SaveY
+moveto}N/fil{fill SaveX SaveY moveto}N/ellipse{/endangle X/startangle X
+/yrad X/xrad X/savematrix matrix currentmatrix N TR xrad yrad scale 0 0
+1 startangle endangle arc savematrix setmatrix}N end
+
+%%EndProcSet
+TeXDict begin 39158280 55380996 1000 600 600 (manual.dvi)
+@start /Fa 145[60 60 3[60 3[60 3[60 97[{TeXBase1Encoding ReEncodeFont}5
+99.6264 /Courier-Bold rf
+%DVIPSBitmapFont: Fb cmr8 8 1
+/Fb 1 44 df<EC0380B3A4B812FCA3C7D80380C7FCB3A42E2F7CA737>43
+D E
+%EndDVIPSBitmapFont
+%DVIPSBitmapFont: Fc cmr10 10.95 1
+/Fc 1 62 df<007FB912E0BA12F0A26C18E0CDFCAE007FB912E0BA12F0A26C18E03C167B
+A147>61 D E
+%EndDVIPSBitmapFont
+%DVIPSBitmapFont: Fd cmsy10 10.95 1
+/Fd 1 55 df<176017F01601A2EE03E0A2EE07C0A2EE0F80A2EE1F00A2163EA25EA25EA2
+4B5AA24B5AA24B5AA24B5AA24BC7FCA2153EA25DA25DA24A5AA24A5AA24A5AA24A5AA24A
+C8FCA2143EA25CA25CA2495AA2495AA2495AA2495AA249C9FCA2133EA25BA25BA2485AA2
+485AA2485AA2485AA248CAFCA2123EA25AA25AA25A12602C5473C000>54
+D E
+%EndDVIPSBitmapFont
+/Fe 179[51 6[61 1[66 61 66[{TeXBase1Encoding ReEncodeFont}4
+90.9091 /Helvetica rf /Ff 103[55 26[55 55 55 55 55 55
+55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55
+55 55 55 55 55 55 55 1[55 1[55 3[55 55 55 55 55 55 55
+55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 1[55
+55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55
+55 55 55 55 55 55 55 2[55 55 55 33[{TeXBase1Encoding ReEncodeFont}86
+90.9091 /Courier rf /Fg 107[50 25[50 55 50 83 55 61 33
+44 39 1[61 55 61 89 33 61 33 33 61 55 39 50 61 44 61
+50 12[66 61 2[61 83 1[100 61 2[39 83 83 55 61 83 72 1[78
+6[25 1[50 50 50 50 50 50 50 50 2[25 33 5[28 35[61 61
+2[{TeXBase1Encoding ReEncodeFont}54 99.6264 /Palatino-Bold
+rf /Fh 134[60 60 60 60 60 60 60 60 60 60 60 60 60 60
+60 60 60 60 60 60 60 60 60 60 60 3[60 1[60 3[60 60 2[60
+60 1[60 60 60 60 60 2[60 60 1[60 60 1[60 60 60 5[60 8[60
+1[60 60 60 60 60 2[60 60 5[60 34[{TeXBase1Encoding ReEncodeFont}53
+99.6264 /Courier rf /Fi 135[50 50 50 1[50 50 50 1[50
+50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 38[50 10[50
+50 46[{TeXBase1Encoding ReEncodeFont}25 83.022 /Courier
+rf /Fj 135[43 1[47 50 27 35 33 1[50 45 48 73 24 1[19
+24 48 46 1[40 51 37 46 42 12[51 18[65 18[21 28 21 44[{
+TeXBase1Encoding ReEncodeFont}25 83.022 /Palatino-Roman
+rf /Fk 205[29 29 49[{TeXBase1Encoding ReEncodeFont}2
+58.1154 /Palatino-Roman rf /Fm 134[66 60 100 66 73 40
+53 47 1[73 66 73 106 40 73 40 40 73 1[47 60 73 53 1[60
+9[120 2[80 1[86 1[73 2[120 2[47 1[100 100 3[86 80 93
+10[60 60 60 60 60 60 2[30 43[73 2[{TeXBase1Encoding ReEncodeFont}41
+119.552 /Palatino-Bold rf /Fn 205[33 33 49[{
+TeXBase1Encoding ReEncodeFont}2 66.4176 /Palatino-Roman
+rf /Fo 179[55 6[66 1[72 66 66[{TeXBase1Encoding ReEncodeFont}4
+99.6264 /Helvetica rf /Fp 134[50 2[50 55 33 39 39 1[50
+44 55 1[28 2[28 50 50 1[39 50 41 46 44 97[{
+TeXBase1Encoding ReEncodeFont}18 99.6264 /Palatino-Italic
+rf /Fq 107[50 50 24[50 55 51 83 56 60 32 42 39 56 60
+54 58 88 29 55 23 29 58 55 33 48 61 44 55 50 3[33 1[33
+66 66 1[100 72 78 61 52 67 1[60 78 83 94 61 72 33 34
+83 76 55 61 77 71 61 78 6[25 50 50 50 50 50 50 50 50
+50 50 1[25 33 25 2[33 33 28 1[84 33[61 60 2[{
+TeXBase1Encoding ReEncodeFont}74 99.6264 /Palatino-Roman
+rf /Fr 135[72 1[80 88 48 64 56 1[88 80 88 128 48 2[48
+88 1[56 72 88 64 1[72 10[112 1[96 1[104 1[88 2[143 88
+1[56 56 1[120 1[88 1[104 96 112 12[72 72 72 72 49[{
+TeXBase1Encoding ReEncodeFont}35 143.462 /Palatino-Bold
+rf /Fs 134[45 45 66 45 51 30 35 35 1[45 40 51 71 25 40
+25 25 45 45 25 35 45 37 42 40 8[66 1[66 71 56 51 61 1[56
+71 71 86 51 1[30 30 2[51 56 71 61 1[66 6[23 45 45 45
+9[30 5[25 35[50 48 2[{TeXBase1Encoding ReEncodeFont}50
+90.9091 /Palatino-Italic rf /Ft 87[30 17[45 1[45 45 24[45
+51 47 76 51 55 30 39 36 51 55 50 53 80 26 51 21 26 53
+51 30 44 56 40 50 45 3[30 1[30 61 61 61 91 66 71 56 48
+61 1[55 71 76 86 56 66 30 31 76 69 51 56 70 64 56 71
+5[23 23 45 45 45 45 45 45 45 45 45 45 55 23 30 23 2[30
+30 25 35[55 55 2[{TeXBase1Encoding ReEncodeFont}78 90.9091
+/Palatino-Roman rf /Fu 139[39 1[47 2[65 9[57 1[53 66
+18[94 22[60 5[60 60 60 3[30 44[{TeXBase1Encoding ReEncodeFont}12
+119.552 /Palatino-Roman rf /Fv 138[72 1[72 72 3[72 72
+72 72 1[72 72 2[72 72 1[72 72 32[72 17[72 46[{
+TeXBase1Encoding ReEncodeFont}15 119.552 /Courier rf
+/Fw 138[87 1[61 57 4[127 1[80 2[83 6[72 19[136 8[111
+68[{TeXBase1Encoding ReEncodeFont}9 143.462 /Palatino-Roman
+rf /Fx 139[30 40 35 2[51 56 4[30 3[45 1[40 56 45 10[71
+20[71 15[45 45 1[23 46[{TeXBase1Encoding ReEncodeFont}15
+90.9091 /Palatino-Bold rf /Fy 134[96 3[104 56 73 68 1[103
+94 100 152 50 2[50 1[96 1[82 105 76 95 86 20[105 6[105
+133 122 105 24[57 57 40[{TeXBase1Encoding ReEncodeFont}24
+172.188 /Palatino-Roman rf end
+%%EndProlog
+%%BeginSetup
+%%Feature: *Resolution 600dpi
+TeXDict begin
+%%BeginPaperSize: a4
+a4
+%%EndPaperSize
+
+%%EndSetup
+%%Page: 1 1
+1 0 bop 429 814 a Fy(Byte)44 b(Code)g(Engineering)g(Library)g(\(BCEL\))
+749 1021 y(Description)h(and)f(usage)f(manual)1685 1229
+y Fx(V)-10 b(ersion)23 b(1.0)1452 1528 y Fw(Markus)35
+b(Dahm)1159 1826 y Fv(markus.dahm@berlin.de)1507 2066
+y Fu(October)c(8,)f(2001)1738 2421 y Fx(Abstract)380
+2581 y Ft(Extensions)k(and)i(impr)n(ovements)f(of)h(the)g(pr)n
+(ogramming)g(language)g(Java)h(and)f(its)g(r)n(e-)244
+2693 y(lated)26 b(execution)e(envir)n(onment)i(\(Java)i(V)-5
+b(irtual)26 b(Machine,)h(JVM\))g(ar)n(e)f(the)f(subject)g(of)h(a)h(lar)
+n(ge)244 2806 y(number)f(of)h(r)n(esear)n(ch)f(pr)n(ojects)g(and)g(pr)n
+(oposals.)39 b(Ther)n(e)25 b(ar)n(e)i(pr)n(ojects,)f(for)h(instance,)g
+(to)f(add)244 2919 y(parameterized)17 b(types)e(to)i(Java,)j(to)d
+(implement)g(\223Aspect-Oriented)f(Pr)n(ogramming\224,)j(to)d(per)n(-)
+244 3032 y(form)23 b(sophisticated)e(static)i(analysis,)f(and)h(to)f
+(impr)n(ove)h(the)f(r)o(un-time)h(performance.)380 3145
+y(Since)c(Java)i(classes)d(ar)n(e)i(compiled)f(into)f(portable)h
+(binary)h(class)f(\002les)g(\(called)h Fs(byte)g(code)p
+Ft(\),)h(it)244 3258 y(is)e(the)f(most)g(convenient)g(and)h
+(platform-independent)e(way)i(to)f(implement)h(these)e(impr)n(ove-)244
+3371 y(ments)k(not)g(by)h(writing)g(a)g(new)f(compiler)i(or)e(changing)
+h(the)f(JVM,)h(but)g(by)g(transforming)f(the)244 3484
+y(byte)j(code.)33 b(These)23 b(transformations)h(can)h(either)f(be)h
+(performed)e(after)h(compile-time,)i(or)e(at)244 3597
+y(load-time.)44 b(Many)28 b(pr)n(ogrammers)f(ar)n(e)h(doing)f(this)h
+(by)g(implementing)g(their)f(own)g(special-)244 3710
+y(ized)32 b(byte)e(code)h(manipulation)i(tools,)f(which)h(ar)n(e,)g
+(however)-7 b(,)33 b(r)n(estricted)d(in)i(the)f(range)g(of)244
+3823 y(their)22 b(r)n(e-usability)-10 b(.)380 3935 y(T)i(o)27
+b(deal)h(with)g(the)f(necessary)f(class)i(\002le)g(transformations,)g
+(we)f(intr)n(oduce)g(an)h(API)f(that)244 4048 y(helps)22
+b(developers)e(to)i(conveniently)g(implement)h(their)f
+(transformations.)0 4392 y Fr(1)143 b(Introduction)0
+4620 y Fq(The)32 b(Java)g(language)g([GJS96])h(has)f(become)g(very)h
+(popular)f(and)g(many)g(r)n(esear)n(ch)h(pr)n(ojects)h(deal)0
+4741 y(with)28 b(further)g(impr)n(ovements)h(of)e(the)h(language)f(or)h
+(its)g(r)o(un-time)g(behavior)-7 b(.)38 b(The)27 b(possibility)i(to)0
+4861 y(extend)e(a)f(language)h(with)g(new)f(concepts)i(is)f(sur)n(ely)g
+(a)g(desirable)f(featur)n(e,)h(but)h(implementation)0
+4981 y(issues)37 b(should)h(be)e(hidden)h(fr)n(om)g(the)g(user)-7
+b(.)67 b(Fortunately)-11 b(,)42 b(the)37 b(concepts)h(of)f(the)g(Java)g
+(V)-5 b(irtual)0 5102 y(Machine)23 b(permit)g(the)g(user)n(-transpar)n
+(ent)i(implementation)f(of)f(such)h(extensions)g(with)f(r)n(elatively)0
+5222 y(little)j(ef)n(fort.)146 5342 y(Because)20 b(the)h(tar)n(get)h
+(language)f(of)g(Java)f(is)h(an)f(interpr)n(eted)h(language)g(with)g(a)
+f(small)h(and)f(easy-)0 5463 y(to-understand)i(set)f(of)g(instr)o
+(uctions)i(\(the)e Fp(byte)f(code)p Fq(\),)h(developers)g(can)g
+(implement)f(and)g(test)h(their)1888 5712 y(1)p eop
+%%Page: 2 2
+2 1 bop 0 407 a Fq(concepts)32 b(in)g(a)f(very)h(elegant)f(way)-11
+b(.)50 b(One)32 b(can)f(write)h(a)f(plug-in)h(r)n(eplacement)f(for)i
+(the)e(system's)0 527 y(class)38 b(loader)g(which)g(is)g(r)n
+(esponsible)h(for)g(dynamically)f(loading)g(class)g(\002les)h(at)f(r)o
+(un-time)g(and)0 648 y(passing)30 b(the)h(byte)f(code)g(to)h(the)f(V)-5
+b(irtual)31 b(Machine)e(\(see)h(section)h(4.1\).)46 b(Class)30
+b(loaders)g(may)g(thus)0 768 y(be)f(used)f(to)i(inter)n(cept)g(the)f
+(loading)g(pr)n(ocess)h(and)f(transform)i(classes)e(befor)n(e)g(they)h
+(get)f(actually)0 888 y(executed)c(by)h(the)g(JVM)f([LB98].)31
+b(While)25 b(the)g(original)h(class)g(\002les)g(always)f(r)n(emain)g
+(unalter)n(ed,)h(the)0 1009 y(behavior)32 b(of)g(the)f(class)h(loader)f
+(may)g(be)g(r)n(econ\002gur)n(ed)i(for)f(every)g(execution)g(or)g
+(instr)o(umented)0 1129 y(dynamically)-11 b(.)146 1249
+y(The)34 b Fo(BCEL)40 b Fq(API)33 b(\(Byte)i(Code)f(Engineering)h
+(Library\),)i(formerly)f(known)f(as)f(JavaClass,)j(is)0
+1370 y(a)h(toolkit)i(for)e(the)g(static)h(analysis)g(and)e(dynamic)h
+(cr)n(eation)h(or)g(transformation)h(of)f(Java)e(class)0
+1490 y(\002les.)70 b(It)37 b(enables)h(developers)g(to)g(implement)g
+(the)g(desir)n(ed)g(featur)n(es)g(on)g(a)g(high)g(level)g(of)g(ab-)0
+1611 y(straction)30 b(without)g(handling)f(all)f(the)g(internal)h
+(details)f(of)h(the)g(Java)f(class)h(\002le)g(format)g(and)f(thus)0
+1731 y(r)n(e-inventing)e(the)f(wheel)f(every)h(time.)31
+b Fo(BCEL)e Fq(is)24 b(written)i(entir)n(ely)g(in)e(Java)h(and)f(fr)n
+(eely)h(available)0 1851 y(under)g(the)g(terms)h(of)f(the)g(Apache)f
+(License.)1752 1815 y Fn(1)146 1972 y Fq(This)33 b(paper)f(is)g(str)o
+(uctur)n(ed)i(as)f(follows:)46 b(W)-9 b(e)31 b(give)i(a)f(brief)g
+(description)i(of)e(the)h(Java)f(V)-5 b(irtual)0 2092
+y(Machine)40 b(and)f(the)h(class)g(\002le)g(format)h(in)f(section)h(2.)
+75 b(Section)41 b(3)e(intr)n(oduces)j(the)d Fo(BCEL)46
+b Fq(API.)0 2213 y(Section)28 b(4)e(describes)h(some)g(typical)g
+(application)g(ar)n(eas)g(and)f(example)g(pr)n(ojects.)38
+b(The)26 b(appendix)0 2333 y(contains)k(code)f(examples)g(that)h(ar)n
+(e)f(to)h(long)f(to)h(be)f(pr)n(esented)g(in)g(the)g(main)g(part)h(of)f
+(this)h(paper)-7 b(.)0 2453 y(All)24 b(examples)h(ar)n(e)g(included)g
+(in)g(the)g(down-loadable)g(distribution.)0 2749 y Fm(1.1)119
+b(Related)29 b(work)0 2939 y Fq(Ther)n(e)37 b(ar)n(e)g(a)g(number)g(of)
+g(pr)n(oposals)i(and)d(class)i(libraries)f(that)h(have)f(some)g
+(similarities)g(with)2 3059 y(B)t(C)t(E)t(L)r(:)28 b(The)e(JOIE)f
+([CCK98)o(])h(toolkit)h(can)f(be)f(used)g(to)h(instr)o(ument)h(class)f
+(loaders)g(with)g(dynamic)0 3180 y(behavior)-7 b(.)73
+b(Similarly)-11 b(,)43 b(\223Binary)c(Component)h(Adaptation\224)e
+([KH98])i(allows)f(components)h(to)0 3300 y(be)30 b(adapted)g(and)h
+(evolved)g(on-the-\003y)-11 b(.)48 b(Han)30 b(Lee's)g(\223Byte-code)i
+(Instr)o(umenting)g(T)-9 b(ool\224)31 b([LZ98])0 3421
+y(allows)20 b(the)g(user)g(to)g(insert)g(calls)g(to)g(analysis)g
+(methods)g(anywher)n(e)g(in)g(the)f(byte)h(code.)30 b(The)19
+b(Jasmin)0 3541 y(language)i([MD97])g(can)f(be)h(used)f(to)i
+(hand-write)f(or)g(generate)g(pseudo-assembler)g(code.)30
+b(D-Java)0 3661 y([Sil98])25 b(and)g(JCF)g([Y)-9 b(ou98])25
+b(ar)n(e)g(class)h(viewing)f(tools.)146 3782 y(In)f(contrast)h(to)g
+(these)f(pr)n(ojects,)h Fo(BCEL)j Fq(is)c(intended)f(to)i(be)e(a)h
+(general)g(purpose)g(tool)h(for)g(\223byte)0 3902 y(code)31
+b(engineering\224.)48 b(It)30 b(gives)h(full)g(contr)n(ol)i(to)e(the)g
+(developer)f(on)h(a)g(high)g(level)f(of)h(abstraction)0
+4022 y(and)25 b(is)g(not)g(r)n(estricted)i(to)f(any)f(particular)h
+(application)f(ar)n(ea.)0 4363 y Fr(2)143 b(The)35 b(Java)g(V)-8
+b(irtual)34 b(Machine)0 4590 y Fq(Readers)f(alr)n(eady)h(familiar)g
+(with)g(the)g(Java)g(V)-5 b(irtual)34 b(Machine)g(and)f(the)h(Java)g
+(class)g(\002le)g(format)0 4711 y(may)25 b(want)g(to)h(skip)g(this)f
+(section)h(and)f(pr)n(oceed)g(with)g(section)h(3.)146
+4831 y(Pr)n(ograms)34 b(written)g(in)e(the)g(Java)h(language)f(ar)n(e)h
+(compiled)f(into)h(a)f(portable)h(binary)g(format)0 4951
+y(called)27 b Fp(byte)g(code)p Fq(.)38 b(Every)27 b(class)h(is)g(r)n
+(epr)n(esented)g(by)f(a)h(single)f(class)h(\002le)f(containing)i(class)
+f(r)n(elated)0 5072 y(data)g(and)f(byte)i(code)f(instr)o(uctions.)42
+b(These)27 b(\002les)h(ar)n(e)g(loaded)f(dynamically)i(into)f(an)g
+(interpr)n(eter)0 5192 y(\(Java)d(V)-5 b(irtual)25 b(Machine,)g(JVM\))g
+(and)g(executed.)p 0 5271 1530 4 v 116 5333 a Fk(1)149
+5363 y Fj(The)c(distribution)g(is)g(available)e(at)h
+Fi(http://jakarta.apache.org/bcel/)p Fj(,)14 b(including)21
+b(several)f(code)g(ex-)0 5463 y(amples)h(and)f(javadoc)g(manuals.)1888
+5712 y Fq(2)p eop
+%%Page: 3 3
+3 2 bop 146 407 a Fq(Figur)n(e)21 b(1)f(illustrates)i(the)e(pr)n
+(ocedur)n(e)h(of)g(compiling)f(and)g(executing)h(a)f(Java)g(class:)29
+b(The)20 b(sour)n(ce)0 527 y(\002le)f(\()p Fh(HelloWorld.java)p
+Fq(\))d(is)j(compiled)g(into)h(a)e(Java)i(class)f(\002le)g(\()p
+Fh(HelloWorld.class)p Fq(\),)e(loaded)0 648 y(by)32 b(the)f(byte)h
+(code)g(interpr)n(eter)g(and)f(executed.)51 b(In)30 b(or)n(der)j(to)f
+(implement)f(additional)g(featur)n(es,)0 768 y(r)n(esear)n(chers)k(may)
+e(want)h(to)g(transform)h(class)f(\002les)g(\(drawn)f(with)h(bold)g
+(lines\))f(befor)n(e)h(they)g(get)0 888 y(actually)26
+b(executed.)31 b(This)25 b(application)g(ar)n(ea)g(is)g(one)g(of)h(the)
+f(main)f(issues)i(of)f(this)h(article.)0 2794 y @beginspecial
+0 @llx 0 @lly 439 @urx 199 @ury 4590 @rwi @setspecial
+%%BeginDocument: eps/jvm.eps
+%!PS-Adobe-2.0 EPSF-2.0
+%%Title: jvm.eps
+%%Creator: fig2dev Version 3.2 Patchlevel 1
+%%CreationDate: Thu Nov 19 11:55:18 1998
+%%For: dahm@che (Markus Dahm,,,,,)
+%%Orientation: Portrait
+%%BoundingBox: 0 0 439 199
+%%Pages: 0
+%%BeginSetup
+%%EndSetup
+%%Magnification: 1.0000
+%%EndComments
+/$F2psDict 200 dict def
+$F2psDict begin
+$F2psDict /mtrx matrix put
+/col-1 {0 setgray} bind def
+/col0 {0.000 0.000 0.000 srgb} bind def
+/col1 {0.000 0.000 1.000 srgb} bind def
+/col2 {0.000 1.000 0.000 srgb} bind def
+/col3 {0.000 1.000 1.000 srgb} bind def
+/col4 {1.000 0.000 0.000 srgb} bind def
+/col5 {1.000 0.000 1.000 srgb} bind def
+/col6 {1.000 1.000 0.000 srgb} bind def
+/col7 {1.000 1.000 1.000 srgb} bind def
+/col8 {0.000 0.000 0.560 srgb} bind def
+/col9 {0.000 0.000 0.690 srgb} bind def
+/col10 {0.000 0.000 0.820 srgb} bind def
+/col11 {0.530 0.810 1.000 srgb} bind def
+/col12 {0.000 0.560 0.000 srgb} bind def
+/col13 {0.000 0.690 0.000 srgb} bind def
+/col14 {0.000 0.820 0.000 srgb} bind def
+/col15 {0.000 0.560 0.560 srgb} bind def
+/col16 {0.000 0.690 0.690 srgb} bind def
+/col17 {0.000 0.820 0.820 srgb} bind def
+/col18 {0.560 0.000 0.000 srgb} bind def
+/col19 {0.690 0.000 0.000 srgb} bind def
+/col20 {0.820 0.000 0.000 srgb} bind def
+/col21 {0.560 0.000 0.560 srgb} bind def
+/col22 {0.690 0.000 0.690 srgb} bind def
+/col23 {0.820 0.000 0.820 srgb} bind def
+/col24 {0.500 0.190 0.000 srgb} bind def
+/col25 {0.630 0.250 0.000 srgb} bind def
+/col26 {0.750 0.380 0.000 srgb} bind def
+/col27 {1.000 0.500 0.500 srgb} bind def
+/col28 {1.000 0.630 0.630 srgb} bind def
+/col29 {1.000 0.750 0.750 srgb} bind def
+/col30 {1.000 0.880 0.880 srgb} bind def
+/col31 {1.000 0.840 0.000 srgb} bind def
+
+end
+save
+-17.0 217.0 translate
+1 -1 scale
+
+/cp {closepath} bind def
+/ef {eofill} bind def
+/gr {grestore} bind def
+/gs {gsave} bind def
+/sa {save} bind def
+/rs {restore} bind def
+/l {lineto} bind def
+/m {moveto} bind def
+/rm {rmoveto} bind def
+/n {newpath} bind def
+/s {stroke} bind def
+/sh {show} bind def
+/slc {setlinecap} bind def
+/slj {setlinejoin} bind def
+/slw {setlinewidth} bind def
+/srgb {setrgbcolor} bind def
+/rot {rotate} bind def
+/sc {scale} bind def
+/sd {setdash} bind def
+/ff {findfont} bind def
+/sf {setfont} bind def
+/scf {scalefont} bind def
+/sw {stringwidth} bind def
+/tr {translate} bind def
+/tnt {dup dup currentrgbcolor
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
+ bind def
+/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
+ 4 -2 roll mul srgb} bind def
+/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
+/$F2psEnd {$F2psEnteredState restore end} def
+%%EndProlog
+
+$F2psBegin
+10 setmiterlimit
+n -1000 4612 m -1000 -1000 l 8588 -1000 l 8588 4612 l cp clip
+ 0.06000 0.06000 sc
+/Courier ff 285.00 scf sf
+6600 1575 m
+gs 1 -1 sc (java) col0 sh gr
+/Courier ff 285.00 scf sf
+2550 1575 m
+gs 1 -1 sc (javac) col0 sh gr
+/Courier-Bold ff 150.00 scf sf
+4290 1155 m
+gs 1 -1 sc (08 1a 42 ...) col0 sh gr
+/Courier-Bold ff 150.00 scf sf
+4290 990 m
+gs 1 -1 sc (ca fe ba be) col0 sh gr
+% Polyline
+7.500 slw
+n 6405 1200 m 6300 1200 6300 1695 105 arcto 4 {pop} repeat
+ 6300 1800 7395 1800 105 arcto 4 {pop} repeat
+ 7500 1800 7500 1305 105 arcto 4 {pop} repeat
+ 7500 1200 6405 1200 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+% Polyline
+n 2505 1200 m 2400 1200 2400 1695 105 arcto 4 {pop} repeat
+ 2400 1800 3495 1800 105 arcto 4 {pop} repeat
+ 3600 1800 3600 1305 105 arcto 4 {pop} repeat
+ 3600 1200 2505 1200 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+% Polyline
+30.000 slw
+gs clippath
+2280 1470 m 2400 1500 l 2280 1530 l 2445 1530 l 2445 1470 l cp
+clip
+n 1800 1500 m 2400 1500 l gs col0 s gr gr
+
+% arrowhead
+7.500 slw
+n 2280 1470 m 2400 1500 l 2280 1530 l 2280 1500 l 2280 1470 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+30.000 slw
+gs clippath
+4080 1470 m 4200 1500 l 4080 1530 l 4245 1530 l 4245 1470 l cp
+clip
+n 3600 1500 m 4200 1500 l gs col0 s gr gr
+
+% arrowhead
+7.500 slw
+n 4080 1470 m 4200 1500 l 4080 1530 l 4080 1500 l 4080 1470 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+30.000 slw
+gs clippath
+6180 1470 m 6300 1500 l 6180 1530 l 6345 1530 l 6345 1470 l cp
+clip
+n 5700 1500 m 6300 1500 l gs col0 s gr gr
+
+% arrowhead
+7.500 slw
+n 6180 1470 m 6300 1500 l 6180 1530 l 6180 1500 l 6180 1470 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+30.000 slw
+n 5415 615 m 5415 915 l 5715 915 l gs col0 s gr
+% Polyline
+n 4215 615 m 4215 2415 l 5715 2415 l 5715 915 l 5415 615 l 4215 615 l cp gs col0 s gr
+% Polyline
+gs clippath
+7006 1136 m 6900 1200 l 6964 1094 l 6847 1211 l 6889 1253 l cp
+clip
+n 7500 600 m 6900 1200 l gs col0 s gr gr
+
+% arrowhead
+7.500 slw
+n 7006 1136 m 6900 1200 l 6964 1094 l 6985 1115 l 7006 1136 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+30.000 slw
+gs clippath
+6630 1080 m 6600 1200 l 6570 1080 l 6570 1245 l 6630 1245 l cp
+clip
+n 6600 1200 m 6600 600 l gs col0 s gr gr
+
+% arrowhead
+7.500 slw
+n 6630 1080 m 6600 1200 l 6570 1080 l 6600 1080 l 6630 1080 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+n 300 3000 m 3600 3000 l 3600 3600 l 300 3600 l cp gs 0.90 setgray ef gr gs col0 s gr
+% Polyline
+n 4200 3000 m 7500 3000 l 7500 3600 l 4200 3600 l cp gs 0.90 setgray ef gr gs col0 s gr
+% Polyline
+n 1500 600 m 1500 900 l 1800 900 l gs col0 s gr
+% Polyline
+n 300 600 m 300 2400 l 1800 2400 l 1800 900 l 1500 600 l 300 600 l cp gs col0 s gr
+/Helvetica ff 180.00 scf sf
+6450 450 m
+gs 1 -1 sc (Other classes) col0 sh gr
+/Courier ff 150.00 scf sf
+375 975 m
+gs 1 -1 sc (public class) col0 sh gr
+/Courier ff 150.00 scf sf
+375 1140 m
+gs 1 -1 sc (HelloWorld {) col0 sh gr
+/Courier ff 150.00 scf sf
+375 1305 m
+gs 1 -1 sc ( ...) col0 sh gr
+/Courier ff 150.00 scf sf
+375 1635 m
+gs 1 -1 sc ( void hello\(\) {) col0 sh gr
+/Courier ff 150.00 scf sf
+375 1800 m
+gs 1 -1 sc ( ...) col0 sh gr
+/Courier ff 150.00 scf sf
+375 1965 m
+gs 1 -1 sc ( }) col0 sh gr
+/Courier ff 150.00 scf sf
+375 2130 m
+gs 1 -1 sc (}) col0 sh gr
+/Helvetica ff 180.00 scf sf
+4275 2625 m
+gs 1 -1 sc (HelloWorld.class) col0 sh gr
+/Helvetica-Bold ff 300.00 scf sf
+900 3375 m
+gs 1 -1 sc (Java language) col0 sh gr
+/Helvetica-Bold ff 300.00 scf sf
+4350 3375 m
+gs 1 -1 sc (Java Virtual Machine) col0 sh gr
+/Helvetica ff 180.00 scf sf
+375 2625 m
+gs 1 -1 sc (HelloWorld.java) col-1 sh gr
+$F2psEnd
+rs
+
+%%EndDocument
+ @endspecial 781 2998 a(Figur)n(e)g(1:)31 b(Compilation)25
+b(and)g(execution)h(of)f(Java)g(classes)146 3370 y(Note)e(that)g(the)f
+(use)h(of)g(the)f(general)g(term)h(\223Java\224)f(implies)g(two)h
+(meanings:)30 b(on)23 b(the)f(one)g(hand,)0 3491 y(Java)i(as)f(a)g(pr)n
+(ogramming)i(language)f(is)g(meant,)f(on)h(the)g(other)g(hand,)f(the)h
+(Java)g(V)-5 b(irtual)23 b(Machine,)0 3611 y(which)k(is)g(not)g
+(necessarily)h(tar)n(geted)g(by)f(the)g(Java)f(language)h(exclusively)
+-11 b(,)28 b(but)g(may)e(be)h(used)g(by)0 3731 y(other)j(languages)f
+(as)g(well)f(\(e.g.)43 b(Eif)n(fel)29 b([CCZ97],)g(or)h(Ada)e([T)-9
+b(af96]\).)42 b(W)-9 b(e)28 b(assume)h(the)g(r)n(eader)g(to)0
+3852 y(be)g(familiar)h(with)g(the)f(Java)h(language)g(and)f(to)h(have)f
+(a)h(general)f(understanding)h(of)g(the)g(V)-5 b(irtual)0
+3972 y(Machine.)0 4320 y Fm(2.1)119 b(Java)29 b(class)h(\002le)g
+(format)0 4525 y Fq(Giving)g(a)f(full)g(overview)h(of)g(the)f(design)g
+(issues)h(of)f(the)h(Java)f(class)h(\002le)f(format)h(and)f(the)g
+(associ-)0 4645 y(ated)h(byte)g(code)g(instr)o(uctions)j(is)d(beyond)g
+(the)g(scope)h(of)f(this)h(paper)-7 b(.)45 b(W)-9 b(e)29
+b(will)h(just)h(give)f(a)g(brief)0 4766 y(intr)n(oduction)36
+b(covering)e(the)g(details)f(that)i(ar)n(e)e(necessary)h(for)g
+(understanding)g(the)g(r)n(est)g(of)g(this)0 4886 y(paper)-7
+b(.)39 b(The)28 b(format)h(of)f(class)h(\002les)f(and)f(the)h(byte)h
+(code)f(instr)o(uction)i(set)f(ar)n(e)f(described)g(in)f(mor)n(e)0
+5007 y(detail)k(in)f(the)h(\223Java)g(V)-5 b(irtual)31
+b(Machine)g(Speci\002cation\224)h([L)-9 b(Y97])2542 4970
+y Fn(2)2579 5007 y Fq(,)32 b(and)f(in)f([MD97].)49 b(Especially)-11
+b(,)0 5127 y(we)23 b(will)g(not)h(deal)e(with)i(the)f(security)h
+(constraints)h(that)f(the)f(Java)g(V)-5 b(irtual)24 b(Machine)f(has)g
+(to)g(check)0 5247 y(at)i(r)o(un-time,)h(i.e.)k(the)25
+b(byte)h(code)f(veri\002er)-7 b(.)p 0 5371 1530 4 v 116
+5433 a Fk(2)149 5463 y Fj(Also)21 b(available)f(online)i(at)e
+Fi(http://www.javasoft.com/docs/books/)o(vmspe)o(c/inde)o(x.htm)o(l)
+1888 5712 y Fq(3)p eop
+%%Page: 4 4
+4 3 bop 146 407 a Fq(Figur)n(e)40 b(2)e(shows)i(a)e(simpli\002ed)h
+(example)f(of)h(the)g(contents)h(of)f(a)g(Java)f(class)i(\002le:)58
+b(It)38 b(starts)0 527 y(with)c(a)f(header)g(containing)h(a)f
+(\223magic)h(number)7 b(\224)33 b(\()p Fh(0xCAFEBABE)p
+Fq(\))f(and)h(the)g(version)h(number)-7 b(,)0 648 y(followed)33
+b(by)f(the)g Fp(constant)h(pool)p Fq(,)g(which)g(can)e(be)h(r)n(oughly)
+i(thought)g(of)e(as)g(the)g(text)h(segment)f(of)0 768
+y(an)j(executable,)j(the)e Fp(access)e(rights)g Fq(of)i(the)g(class)g
+(encoded)f(by)h(a)f(bit)h(mask,)i(a)d(list)h(of)g(interfaces)0
+888 y(implemented)19 b(by)h(the)f(class,)i(lists)f(containing)h(the)f
+(\002elds)f(and)g(methods)h(of)g(the)g(class,)h(and)e(\002nally)0
+1009 y(the)35 b Fp(class)f(attributes)p Fq(,)j(e.g.)60
+b(the)35 b Fh(SourceFile)d Fq(attribute)37 b(telling)e(the)g(name)f(of)
+h(the)g(sour)n(ce)h(\002le.)0 1129 y(Attributes)28 b(ar)n(e)f(a)g(way)g
+(of)g(putting)h(additional,)g(e.g.)36 b(user)n(-de\002ned,)28
+b(information)g(into)g(class)f(\002le)0 1249 y(data)e(str)o(uctur)n
+(es.)34 b(For)26 b(example,)f(a)g(custom)h(class)g(loader)f(may)h
+(evaluate)f(such)g(attribute)i(data)e(in)0 1370 y(or)n(der)h(to)f
+(perform)h(its)f(transformations.)33 b(The)25 b(JVM)g(speci\002cation)h
+(declar)n(es)f(that)g(unknown,)g(i.e.)0 1490 y(user)n(-de\002ned)g
+(attributes)i(must)e(be)g(ignor)n(ed)h(by)f(any)g(V)-5
+b(irtual)25 b(Machine)g(implementation.)0 5123 y @beginspecial
+0 @llx 0 @lly 520 @urx 460 @ury 4590 @rwi @setspecial
+%%BeginDocument: eps/classfile.eps
+%!PS-Adobe-2.0 EPSF-2.0
+%%Title: classfile.eps
+%%Creator: fig2dev Version 3.2 Patchlevel 1
+%%CreationDate: Mon Nov 30 16:01:26 1998
+%%For: dahm@che (Markus Dahm,,,,,)
+%%Orientation: Portrait
+%%BoundingBox: 0 0 520 460
+%%Pages: 0
+%%BeginSetup
+%%EndSetup
+%%Magnification: 1.0000
+%%EndComments
+/$F2psDict 200 dict def
+$F2psDict begin
+$F2psDict /mtrx matrix put
+/col-1 {0 setgray} bind def
+/col0 {0.000 0.000 0.000 srgb} bind def
+/col1 {0.000 0.000 1.000 srgb} bind def
+/col2 {0.000 1.000 0.000 srgb} bind def
+/col3 {0.000 1.000 1.000 srgb} bind def
+/col4 {1.000 0.000 0.000 srgb} bind def
+/col5 {1.000 0.000 1.000 srgb} bind def
+/col6 {1.000 1.000 0.000 srgb} bind def
+/col7 {1.000 1.000 1.000 srgb} bind def
+/col8 {0.000 0.000 0.560 srgb} bind def
+/col9 {0.000 0.000 0.690 srgb} bind def
+/col10 {0.000 0.000 0.820 srgb} bind def
+/col11 {0.530 0.810 1.000 srgb} bind def
+/col12 {0.000 0.560 0.000 srgb} bind def
+/col13 {0.000 0.690 0.000 srgb} bind def
+/col14 {0.000 0.820 0.000 srgb} bind def
+/col15 {0.000 0.560 0.560 srgb} bind def
+/col16 {0.000 0.690 0.690 srgb} bind def
+/col17 {0.000 0.820 0.820 srgb} bind def
+/col18 {0.560 0.000 0.000 srgb} bind def
+/col19 {0.690 0.000 0.000 srgb} bind def
+/col20 {0.820 0.000 0.000 srgb} bind def
+/col21 {0.560 0.000 0.560 srgb} bind def
+/col22 {0.690 0.000 0.690 srgb} bind def
+/col23 {0.820 0.000 0.820 srgb} bind def
+/col24 {0.500 0.190 0.000 srgb} bind def
+/col25 {0.630 0.250 0.000 srgb} bind def
+/col26 {0.750 0.380 0.000 srgb} bind def
+/col27 {1.000 0.500 0.500 srgb} bind def
+/col28 {1.000 0.630 0.630 srgb} bind def
+/col29 {1.000 0.750 0.750 srgb} bind def
+/col30 {1.000 0.880 0.880 srgb} bind def
+/col31 {1.000 0.840 0.000 srgb} bind def
+
+end
+save
+-17.0 540.0 translate
+1 -1 scale
+
+/cp {closepath} bind def
+/ef {eofill} bind def
+/gr {grestore} bind def
+/gs {gsave} bind def
+/sa {save} bind def
+/rs {restore} bind def
+/l {lineto} bind def
+/m {moveto} bind def
+/rm {rmoveto} bind def
+/n {newpath} bind def
+/s {stroke} bind def
+/sh {show} bind def
+/slc {setlinecap} bind def
+/slj {setlinejoin} bind def
+/slw {setlinewidth} bind def
+/srgb {setrgbcolor} bind def
+/rot {rotate} bind def
+/sc {scale} bind def
+/sd {setdash} bind def
+/ff {findfont} bind def
+/sf {setfont} bind def
+/scf {scalefont} bind def
+/sw {stringwidth} bind def
+/tr {translate} bind def
+/tnt {dup dup currentrgbcolor
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
+ bind def
+/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
+ 4 -2 roll mul srgb} bind def
+/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
+/$F2psEnd {$F2psEnteredState restore end} def
+%%EndProlog
+
+$F2psBegin
+10 setmiterlimit
+n -1000 10000 m -1000 -1000 l 9937 -1000 l 9937 10000 l cp clip
+ 0.06000 0.06000 sc
+% Polyline
+7.500 slw
+n 2999 6599 m 2400 6599 l 2400 6749 l 2999 6749 l cp gs col0 s gr
+% Polyline
+n 2400 6749 m 2999 6749 l 2999 6899 l 2400 6899 l cp gs col0 s gr
+% Polyline
+n 2999 6899 m 2400 6899 l 2400 7049 l 2999 7049 l cp gs col0 s gr
+% Polyline
+n 2400 7049 m 2999 7049 l 2999 7200 l 2400 7200 l cp gs col0 s gr
+% Polyline
+n 2400 7200 m 2999 7200 l 2999 7349 l 2400 7349 l cp gs col0 s gr
+% Polyline
+30.000 slw
+ [15 45] 45 sd
+n 2699 7424 m 2699 7724 l gs col0 s gr [] 0 sd
+% Polyline
+7.500 slw
+n 299 6449 m 3299 6449 l 3299 7949 l 299 7949 l cp gs col0 s gr
+/Helvetica-Bold ff 210.00 scf sf
+599 6824 m
+gs 1 -1 sc (Methods) col0 sh gr
+% Polyline
+n 2999 5099 m 2400 5099 l 2400 5249 l 2999 5249 l cp gs col0 s gr
+% Polyline
+n 2400 5249 m 2999 5249 l 2999 5399 l 2400 5399 l cp gs col0 s gr
+% Polyline
+n 2999 5399 m 2400 5399 l 2400 5549 l 2999 5549 l cp gs col0 s gr
+% Polyline
+n 2400 5549 m 2999 5549 l 2999 5699 l 2400 5699 l cp gs col0 s gr
+% Polyline
+n 2400 5699 m 2999 5699 l 2999 5849 l 2400 5849 l cp gs col0 s gr
+% Polyline
+30.000 slw
+ [15 45] 45 sd
+n 2699 5924 m 2699 6224 l gs col0 s gr [] 0 sd
+% Polyline
+7.500 slw
+n 299 4949 m 3299 4949 l 3299 6449 l 299 6449 l cp gs col0 s gr
+/Helvetica-Bold ff 210.00 scf sf
+599 5399 m
+gs 1 -1 sc (Fields) col0 sh gr
+% Polyline
+n 299 4199 m 3299 4199 l 3299 4949 l 299 4949 l cp gs col0 s gr
+/Helvetica-Bold ff 210.00 scf sf
+599 4649 m
+gs 1 -1 sc (Implemented interfaces) col0 sh gr
+% Polyline
+n 299 3449 m 3299 3449 l 3299 4199 l 299 4199 l cp gs col0 s gr
+/Helvetica-Bold ff 210.00 scf sf
+599 3899 m
+gs 1 -1 sc (Access rights) col0 sh gr
+% Polyline
+n 299 1349 m 3299 1349 l 3299 2099 l 299 2099 l cp gs col0 s gr
+/Helvetica-Bold ff 210.00 scf sf
+599 1799 m
+gs 1 -1 sc (Header) col0 sh gr
+% Polyline
+n 2999 2249 m 2400 2249 l 2400 2400 l 2999 2400 l cp gs col0 s gr
+% Polyline
+n 2400 2400 m 2999 2400 l 2999 2549 l 2400 2549 l cp gs col0 s gr
+% Polyline
+n 2999 2549 m 2400 2549 l 2400 2699 l 2999 2699 l cp gs col0 s gr
+% Polyline
+n 2400 2699 m 2999 2699 l 2999 2849 l 2400 2849 l cp gs col0 s gr
+% Polyline
+n 2400 2849 m 2999 2849 l 2999 2999 l 2400 2999 l cp gs col0 s gr
+% Polyline
+30.000 slw
+ [15 45] 45 sd
+n 2699 3074 m 2699 3374 l gs col0 s gr [] 0 sd
+% Polyline
+7.500 slw
+n 299 2099 m 3299 2099 l 3299 3449 l 299 3449 l cp gs col0 s gr
+/Helvetica-Bold ff 210.00 scf sf
+599 2549 m
+gs 1 -1 sc (Constant pool) col0 sh gr
+% Polyline
+n 299 7949 m 3299 7949 l 3299 8699 l 299 8699 l cp gs col0 s gr
+/Helvetica-Bold ff 210.00 scf sf
+599 8400 m
+gs 1 -1 sc (Class attributes) col0 sh gr
+% Polyline
+n 4800 2999 m 7499 2999 l 7499 4349 l 4800 4349 l cp gs col0 s gr
+/Helvetica-Bold ff 210.00 scf sf
+5099 3299 m
+gs 1 -1 sc (ConstantFieldref) col0 sh gr
+/Helvetica ff 210.00 scf sf
+5099 3600 m
+gs 1 -1 sc ("aVariable") col0 sh gr
+/Helvetica ff 210.00 scf sf
+5099 3884 m
+gs 1 -1 sc ("[Ljava/lang/Object;") col0 sh gr
+/Helvetica ff 210.00 scf sf
+5099 4199 m
+gs 1 -1 sc ("HelloWorld") col0 sh gr
+% Polyline
+n 5024 2624 m 7124 2624 l 7124 2924 l 5024 2924 l cp gs col0 s gr
+/Helvetica ff 210.00 scf sf
+5099 2849 m
+gs 1 -1 sc ("java/io/PrintStream") col0 sh gr
+% Polyline
+n 4800 1649 m 7499 1649 l 7499 2999 l 4800 2999 l cp gs col0 s gr
+/Helvetica-Bold ff 210.00 scf sf
+5099 1949 m
+gs 1 -1 sc (ConstantMethodRef) col0 sh gr
+/Helvetica ff 210.00 scf sf
+5099 2249 m
+gs 1 -1 sc ("println") col0 sh gr
+/Helvetica ff 210.00 scf sf
+5099 2534 m
+gs 1 -1 sc ("\(Ljava/lang/String;\)V") col0 sh gr
+% Polyline
+n 4800 4349 m 7499 4349 l 7499 5099 l 4800 5099 l cp gs col0 s gr
+/Helvetica-Bold ff 210.00 scf sf
+5099 4649 m
+gs 1 -1 sc (ConstantClass) col0 sh gr
+/Helvetica ff 210.00 scf sf
+5099 4949 m
+gs 1 -1 sc ("java/io/PrintStream") col0 sh gr
+% Polyline
+n 4080 6500 m 3975 6500 3975 7770 105 arcto 4 {pop} repeat
+ 3975 7875 8820 7875 105 arcto 4 {pop} repeat
+ 8925 7875 8925 6605 105 arcto 4 {pop} repeat
+ 8925 6500 4080 6500 105 arcto 4 {pop} repeat
+ cp gs 0.00 setgray ef gr gs col0 s gr
+% Polyline
+n 3855 6725 m 3750 6725 3750 7995 105 arcto 4 {pop} repeat
+ 3750 8100 8595 8100 105 arcto 4 {pop} repeat
+ 8700 8100 8700 6830 105 arcto 4 {pop} repeat
+ 8700 6725 3855 6725 105 arcto 4 {pop} repeat
+ cp gs col7 1.00 shd ef gr gs col0 s gr
+% Polyline
+30.000 slw
+ [15 45] 45 sd
+n 6150 7800 m 6150 7950 l gs col0 s gr [] 0 sd
+% Polyline
+7.500 slw
+n 5550 7200 m 7200 7200 l 7200 7425 l 5550 7425 l cp gs col0 s gr
+% Polyline
+n 5550 7500 m 8625 7500 l 8625 7725 l 5550 7725 l cp gs col0 s gr
+/Courier-Bold ff 180.00 scf sf
+4050 7050 m
+gs 1 -1 sc (getstatic java.lang.System.out) col0 sh gr
+/Courier-Bold ff 180.00 scf sf
+4050 7650 m
+gs 1 -1 sc (invokevirtual java.io.PrintStream.println) col0 sh gr
+/Courier-Bold ff 180.00 scf sf
+4050 7350 m
+gs 1 -1 sc (ldc "Hello, world") col0 sh gr
+% Polyline
+ [15 45] 45 sd
+n 2400 2249 m 4800 1649 l gs col0 s gr [] 0 sd
+% Polyline
+ [15 45] 45 sd
+n 2400 2849 m 4800 5849 l gs col0 s gr [] 0 sd
+% Polyline
+gs clippath
+4693 3661 m 4800 3600 l 4734 3705 l 4832 3611 l 4790 3568 l cp
+clip
+n 2999 5324 m 4800 3600 l gs col0 s gr gr
+
+% arrowhead
+n 4693 3661 m 4800 3600 l 4734 3705 l 4713 3683 l 4693 3661 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+3669 7107 m 3750 7200 l 3635 7156 l 3745 7233 l 3779 7184 l cp
+clip
+n 2999 6674 m 3750 7200 l gs col0 s gr gr
+
+% arrowhead
+n 3669 7107 m 3750 7200 l 3635 7156 l 3652 7131 l 3669 7107 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+n 5099 1649 m 5099 1349 l 7799 1349 l 7799 5549 l 7499 5549 l 7499 1649 l
+ 5099 1649 l cp gs 0.00 setgray ef gr gs col0 s gr
+% Polyline
+ [15 45] 45 sd
+n 2999 2849 m 4800 4049 l gs col0 s gr [] 0 sd
+% Polyline
+ [15 45] 45 sd
+n 2999 2249 m 4800 2024 l gs col0 s gr [] 0 sd
+% Polyline
+gs clippath
+7609 2533 m 7500 2475 l 7624 2475 l 7493 2442 l 7478 2500 l cp
+clip
+n 7800 2550 m 7500 2475 l gs col7 s gr gr
+
+% arrowhead
+n 7609 2533 m 7500 2475 l 7624 2475 l 7616 2504 l 7609 2533 l cp gs col7 1.00 shd ef gr col7 s
+% Polyline
+n 4800 5099 m 7499 5099 l 7499 5849 l 4800 5849 l cp gs col0 s gr
+% Polyline
+n 7800 7500 m 7801 7499 l 7804 7496 l 7809 7491 l 7816 7483 l 7826 7472 l
+ 7840 7457 l 7856 7440 l 7875 7419 l 7897 7395 l 7921 7368 l
+ 7946 7340 l 7973 7310 l 7999 7279 l 8026 7247 l 8052 7216 l
+ 8078 7184 l 8102 7152 l 8125 7121 l 8147 7090 l 8167 7059 l
+ 8186 7029 l 8203 6998 l 8220 6966 l 8235 6934 l 8250 6900 l
+ 8261 6873 l 8272 6845 l 8282 6816 l 8292 6786 l 8303 6756 l
+ 8313 6724 l 8323 6692 l 8333 6659 l 8343 6626 l 8353 6592 l
+ 8363 6557 l 8373 6522 l 8382 6487 l 8392 6451 l 8402 6415 l
+ 8412 6379 l 8421 6342 l 8431 6305 l 8440 6268 l 8449 6231 l
+ 8458 6194 l 8467 6157 l 8476 6120 l 8484 6082 l 8492 6045 l
+ 8500 6007 l 8508 5969 l 8515 5932 l 8522 5894 l 8528 5856 l
+ 8535 5817 l 8540 5778 l 8545 5739 l 8550 5700 l 8554 5664 l
+ 8557 5628 l 8560 5591 l 8563 5554 l 8565 5517 l 8567 5479 l
+ 8568 5440 l 8570 5401 l 8571 5362 l 8572 5322 l 8572 5281 l
+ 8573 5241 l 8573 5200 l 8573 5159 l 8573 5117 l 8573 5076 l
+ 8572 5034 l 8572 4992 l 8571 4950 l 8570 4908 l 8570 4866 l
+ 8569 4824 l 8568 4783 l 8567 4741 l 8566 4700 l 8565 4659 l
+ 8564 4619 l 8563 4578 l 8562 4538 l 8561 4499 l 8560 4460 l
+ 8559 4421 l 8558 4383 l 8557 4346 l 8555 4309 l 8554 4272 l
+ 8552 4236 l 8550 4200 l 8548 4161 l 8545 4121 l 8542 4083 l
+ 8540 4044 l 8537 4006 l 8534 3968 l 8531 3930 l 8528 3892 l
+ 8526 3854 l 8523 3815 l 8520 3777 l 8517 3739 l 8515 3702 l
+ 8512 3664 l 8509 3626 l 8506 3588 l 8503 3551 l 8500 3514 l
+ 8497 3477 l 8493 3440 l 8490 3404 l 8486 3368 l 8481 3333 l
+ 8477 3298 l 8471 3264 l 8466 3231 l 8460 3199 l 8453 3167 l
+ 8446 3136 l 8438 3107 l 8430 3078 l 8421 3051 l 8411 3025 l
+ 8400 3000 l 8385 2969 l 8368 2941 l 8349 2913 l 8328 2887 l
+ 8305 2862 l 8279 2838 l 8251 2814 l 8220 2790 l 8187 2767 l
+ 8153 2744 l 8117 2721 l 8080 2699 l 8043 2678 l 8006 2657 l
+ 7970 2638 l 7937 2620 l 7907 2604 l 7879 2590 l 7856 2578 l
+ 7837 2568 l 7823 2561 l 7812 2556 l 7805 2553 l 7802 2551 l
+ 7800 2550 l gs col0 s gr
+% Polyline
+gs clippath
+4723 4703 m 4800 4800 l 4687 4750 l 4794 4833 l 4830 4785 l cp
+clip
+n 5025 2775 m 5024 2776 l 5020 2779 l 5015 2784 l 5006 2792 l 4993 2804 l
+ 4977 2818 l 4957 2836 l 4934 2857 l 4908 2881 l 4879 2907 l
+ 4849 2935 l 4818 2964 l 4786 2994 l 4754 3023 l 4723 3053 l
+ 4693 3082 l 4664 3110 l 4637 3137 l 4612 3163 l 4589 3188 l
+ 4568 3212 l 4549 3235 l 4531 3257 l 4515 3278 l 4500 3300 l
+ 4485 3324 l 4471 3347 l 4457 3371 l 4444 3396 l 4432 3420 l
+ 4419 3445 l 4408 3470 l 4396 3495 l 4385 3520 l 4374 3546 l
+ 4363 3571 l 4352 3596 l 4342 3622 l 4332 3647 l 4323 3673 l
+ 4314 3698 l 4306 3724 l 4299 3749 l 4292 3775 l 4286 3800 l
+ 4281 3825 l 4278 3850 l 4276 3875 l 4275 3900 l 4276 3925 l
+ 4278 3950 l 4282 3975 l 4287 4001 l 4293 4027 l 4301 4053 l
+ 4309 4080 l 4319 4106 l 4329 4133 l 4340 4160 l 4351 4187 l
+ 4363 4214 l 4375 4241 l 4387 4268 l 4399 4294 l 4411 4320 l
+ 4423 4345 l 4434 4370 l 4446 4394 l 4457 4417 l 4468 4439 l
+ 4478 4460 l 4489 4481 l 4500 4500 l 4513 4522 l 4528 4543 l
+ 4543 4563 l 4559 4583 l 4578 4603 l 4597 4623 l 4618 4643 l
+ 4640 4664 l 4663 4685 l 4686 4705 l 4709 4724 l 4730 4742 l
+ 4749 4758 l 4765 4772 l 4778 4783 l 4800 4800 l gs col0 s gr gr
+
+% arrowhead
+n 4723 4703 m 4800 4800 l 4687 4750 l 4705 4727 l 4723 4703 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+7591 5782 m 7499 5699 l 7619 5728 l 7500 5665 l 7472 5719 l cp
+clip
+n 7200 7275 m 7203 7274 l 7208 7271 l 7219 7265 l 7235 7257 l 7256 7246 l
+ 7282 7233 l 7312 7217 l 7346 7200 l 7381 7182 l 7417 7163 l
+ 7453 7144 l 7487 7126 l 7520 7109 l 7551 7092 l 7580 7076 l
+ 7607 7061 l 7631 7048 l 7654 7034 l 7676 7022 l 7696 7010 l
+ 7714 6998 l 7733 6986 l 7750 6975 l 7770 6961 l 7790 6947 l
+ 7810 6933 l 7829 6918 l 7847 6903 l 7866 6887 l 7883 6871 l
+ 7901 6855 l 7917 6837 l 7933 6820 l 7947 6802 l 7961 6784 l
+ 7973 6766 l 7984 6748 l 7994 6729 l 8003 6711 l 8010 6693 l
+ 8016 6675 l 8021 6656 l 8025 6638 l 8028 6618 l 8030 6598 l
+ 8031 6578 l 8031 6556 l 8030 6534 l 8029 6511 l 8026 6487 l
+ 8023 6462 l 8019 6438 l 8015 6412 l 8009 6387 l 8004 6362 l
+ 7997 6338 l 7991 6314 l 7984 6291 l 7977 6269 l 7971 6247 l
+ 7964 6226 l 7957 6207 l 7950 6187 l 7942 6167 l 7934 6146 l
+ 7926 6126 l 7918 6106 l 7909 6086 l 7900 6066 l 7891 6046 l
+ 7881 6027 l 7871 6008 l 7861 5990 l 7850 5972 l 7840 5956 l
+ 7829 5940 l 7818 5925 l 7807 5911 l 7797 5898 l 7785 5886 l
+ 7774 5874 l 7762 5863 l 7750 5852 l 7737 5841 l 7722 5830 l
+ 7707 5819 l 7689 5807 l 7670 5795 l 7648 5782 l 7625 5769 l
+ 7602 5755 l 7578 5742 l 7555 5729 l 7535 5718 l 7499 5699 l gs col0 s gr gr
+
+% arrowhead
+n 7591 5782 m 7499 5699 l 7619 5728 l 7605 5755 l 7591 5782 l cp gs 0.00 setgray ef gr col0 s
+/Helvetica ff 210.00 scf sf
+975 9000 m
+gs 1 -1 sc (HelloWorld.class) col0 sh gr
+/Helvetica ff 210.00 scf sf
+5099 5699 m
+gs 1 -1 sc ("Hello, world") col0 sh gr
+/Helvetica-Bold ff 210.00 scf sf
+5099 5399 m
+gs 1 -1 sc (ConstantString) col0 sh gr
+$F2psEnd
+rs
+
+%%EndDocument
+ @endspecial 1252 5327 a(Figur)n(e)h(2:)31 b(Java)25
+b(class)g(\002le)g(format)1888 5712 y(4)p eop
+%%Page: 5 5
+5 4 bop 146 407 a Fq(Because)20 b(all)f(of)h(the)g(information)h
+(needed)d(to)i(dynamically)g(r)n(esolve)h(the)f(symbolic)g(r)n(efer)n
+(ences)0 527 y(to)32 b(classes,)h(\002elds)e(and)g(methods)h(at)f(r)o
+(un-time)h(is)f(coded)h(with)f(string)i(constants,)h(the)d(constant)0
+648 y(pool)40 b(contains)g(in)g(fact)g(the)f(lar)n(gest)i(portion)f(of)
+g(an)f(average)h(class)f(\002le,)k(appr)n(oximately)e(60\045)0
+768 y([AP98)o(].)31 b(The)25 b(byte)h(code)f(instr)o(uctions)i
+(themselves)f(just)g(make)e(up)h(12\045.)146 893 y(The)43
+b(right)g(upper)g(box)g(shows)h(a)e(\223zoomed\224)h(excerpt)g(of)g
+(the)g(constant)h(pool,)j(while)c(the)0 1014 y(r)n(ounded)37
+b(box)g(below)f(depicts)h(some)g(instr)o(uctions)i(that)e(ar)n(e)f
+(contained)h(within)g(a)f(method)g(of)0 1134 y(the)e(example)f(class.)
+56 b(These)34 b(instr)o(uctions)i(r)n(epr)n(esent)e(the)f
+(straightforwar)n(d)k(translation)e(of)f(the)0 1254 y(well-known)26
+b(statement:)179 1522 y Fh(System.out.println\("Hello,)54
+b(world"\);)146 1784 y Fq(The)22 b(\002rst)h(instr)o(uction)h(loads)e
+(the)g(contents)h(of)f(the)g(\002eld)g Fh(out)f Fq(of)h(class)h
+Fh(java.lang.System)0 1904 y Fq(onto)30 b(the)g(operand)f(stack.)44
+b(This)29 b(is)h(an)e(instance)i(of)f(the)h(class)f Fh
+(java.io.PrintStream)p Fq(.)39 b(The)0 2025 y Fh(ldc)25
+b Fq(\(\223Load)g(constant\224\))i(pushes)f(a)f(r)n(efer)n(ence)h(to)g
+(the)g(string)h(\224Hello)e(world\224)h(on)g(the)g(stack.)33
+b(The)0 2145 y(next)28 b(instr)o(uction)j(invokes)e(the)f(instance)g
+(method)g Fh(println)f Fq(which)h(takes)g(both)h(values)f(as)g(pa-)0
+2265 y(rameters)36 b(\(Instance)g(methods)g(always)h(implicitly)f(take)
+g(an)g(instance)g(r)n(efer)n(ence)g(as)f(their)i(\002rst)0
+2386 y(ar)n(gument\).)146 2511 y(Instr)o(uctions,)24
+b(other)d(data)g(str)o(uctur)n(es)i(within)e(the)g(class)g(\002le)f
+(and)h(constants)h(themselves)f(may)0 2632 y(r)n(efer)33
+b(to)g(constants)h(in)f(the)f(constant)i(pool.)54 b(Such)33
+b(r)n(efer)n(ences)g(ar)n(e)g(implemented)f(via)g(\002xed)h(in-)0
+2752 y(dexes)h(encoded)g(dir)n(ectly)i(into)f(the)f(instr)o(uctions.)62
+b(This)34 b(is)g(illustrated)i(for)f(some)f(items)h(of)g(the)0
+2872 y(\002gur)n(e)26 b(emphasized)e(with)h(a)g(surr)n(ounding)i(box.)
+146 2998 y(For)h(example,)f(the)h Fh(invokevirtual)c
+Fq(instr)o(uction)29 b(r)n(efers)f(to)g(a)f Fh(MethodRef)e
+Fq(constant)j(that)0 3118 y(contains)34 b(information)h(about)f(the)g
+(name)f(of)h(the)f(called)g(method,)j(the)d(signatur)n(e)i(\(i.e.)56
+b(the)33 b(en-)0 3238 y(coded)38 b(ar)n(gument)h(and)f(r)n(eturn)h
+(types\),)j(and)c(to)h(which)f(class)h(the)f(method)h(belongs.)71
+b(In)37 b(fact,)0 3359 y(as)c(emphasized)f(by)h(the)g(boxed)g(value,)i
+(the)e Fh(MethodRef)d Fq(constant)35 b(itself)e(just)h(r)n(efers)f(to)h
+(other)0 3479 y(entries)23 b(holding)f(the)h(r)n(eal)f(data,)g(e.g.)30
+b(it)23 b(r)n(efers)g(to)g(a)f Fh(ConstantClass)d Fq(entry)k
+(containing)g(a)f(sym-)0 3599 y(bolic)36 b(r)n(efer)n(ence)h(to)f(the)g
+(class)g Fh(java.io.PrintStream)p Fq(.)60 b(T)-9 b(o)36
+b(keep)f(the)h(class)g(\002le)g(compact,)0 3720 y(such)29
+b(constants)i(ar)n(e)e(typically)h(shar)n(ed)f(by)g(dif)n(fer)n(ent)h
+(instr)o(uctions.)45 b(Similarly)-11 b(,)30 b(a)f(\002eld)f(is)h(r)n
+(epr)n(e-)0 3840 y(sented)23 b(by)g(a)f Fh(Fieldref)f
+Fq(constant)k(that)e(includes)g(information)h(about)g(the)f(name,)f
+(the)h(type)g(and)0 3961 y(the)i(containing)h(class)g(of)f(the)g
+(\002eld.)146 4086 y(The)37 b(constant)i(pool)f(basically)g(holds)f
+(the)h(following)g(types)g(of)g(constants:)57 b(Refer)n(ences)37
+b(to)0 4206 y(methods,)25 b(\002elds)g(and)g(classes,)g(strings,)i
+(integers,)f(\003oats,)f(longs,)h(and)e(doubles.)0 4540
+y Fm(2.2)119 b(Byte)30 b(code)g(instruction)f(set)0 4741
+y Fq(The)f(JVM)h(is)f(a)g(stack-oriented)i(interpr)n(eter)g(that)f(cr)n
+(eates)g(a)f(local)g(stack)i(frame)e(of)h(\002xed)f(size)g(for)0
+4861 y(every)21 b(method)f(invocation.)31 b(The)19 b(size)h(of)h(the)f
+(local)h(stack)g(has)f(to)h(be)f(computed)g(by)h(the)f(compiler)-7
+b(.)0 4981 y(V)e(alues)21 b(may)h(also)g(be)f(stor)n(ed)i
+(intermediately)f(in)f(a)h(frame)f(ar)n(ea)h(containing)g
+Fp(local)f(variables)g Fq(which)0 5102 y(can)28 b(be)g(used)g(like)h(a)
+f(set)h(of)f(r)n(egisters.)43 b(These)28 b(local)g(variables)h(ar)n(e)f
+(number)n(ed)h(fr)n(om)g(0)f(to)h(65535,)0 5222 y(i.e.)60
+b(you)36 b(have)e(a)h(maximum)g(of)g(65536)f(of)h(local)g(variables.)61
+b(The)34 b(stack)i(frames)f(of)g(caller)g(and)0 5342
+y(callee)25 b(method)i(ar)n(e)f(overlapping,)h(i.e.)34
+b(the)26 b(caller)g(pushes)g(ar)n(guments)h(onto)h(the)e(operand)g
+(stack)0 5463 y(and)f(the)g(called)f(method)i(r)n(eceives)f(them)g(in)g
+(local)g(variables.)1888 5712 y(5)p eop
+%%Page: 6 6
+6 5 bop 146 407 a Fq(The)32 b(byte)g(code)g(instr)o(uction)j(set)d
+(curr)n(ently)i(consists)f(of)g(212)e(instr)o(uctions,)36
+b(44)31 b(opcodes)i(ar)n(e)0 527 y(marked)g(as)g(r)n(eserved)g(and)g
+(may)g(be)f(used)h(for)h(futur)n(e)g(extensions)g(or)g(intermediate)f
+(optimiza-)0 648 y(tions)22 b(within)f(the)g(V)-5 b(irtual)21
+b(Machine.)29 b(The)21 b(instr)o(uction)i(set)e(can)g(be)g(r)n(oughly)h
+(gr)n(ouped)g(as)f(follows:)0 893 y Fg(Stack)k(operations:)49
+b Fq(Constants)26 b(can)e(be)h(pushed)f(onto)i(the)f(stack)g(either)g
+(by)g(loading)g(them)g(fr)n(om)244 1013 y(the)f(constant)h(pool)f(with)
+h(the)e Fh(ldc)g Fq(instr)o(uction)j(or)f(with)f(special)g
+(\223short-cut\224)h(instr)o(uctions)244 1134 y(wher)n(e)37
+b(the)g(operand)f(is)h(encoded)g(into)g(the)g(instr)o(uctions,)43
+b(e.g.)66 b Fh(iconst)p 3211 1134 30 4 v 34 w(0)37 b
+Fq(or)g Fh(bipush)244 1254 y Fq(\(push)25 b(byte)h(value\).)0
+1469 y Fg(Arithmetic)e(operations:)50 b Fq(The)36 b(instr)o(uction)k
+(set)d(of)h(the)f(Java)h(V)-5 b(irtual)37 b(Machine)g(distinguishes)244
+1590 y(its)24 b(operand)e(types)i(using)g(dif)n(fer)n(ent)g(instr)o
+(uctions)h(to)f(operate)f(on)h(values)f(of)g(speci\002c)h(type.)244
+1710 y(Arithmetic)32 b(operations)g(starting)i(with)d
+Fh(i)p Fq(,)i(for)f(example,)h(denote)e(an)g(integer)h(operation.)244
+1831 y(E.g.,)k Fh(iadd)e Fq(that)h(adds)f(two)h(integers)g(and)f
+(pushes)g(the)g(r)n(esult)i(back)e(on)h(the)f(stack.)60
+b(The)244 1951 y(Java)23 b(types)h Fh(boolean)p Fq(,)d
+Fh(byte)p Fq(,)i Fh(short)p Fq(,)f(and)g Fh(char)g Fq(ar)n(e)h(handled)
+f(as)h(integers)h(by)g(the)f(JVM.)0 2166 y Fg(Control)j(\003ow:)49
+b Fq(Ther)n(e)40 b(ar)n(e)g(branch)h(instr)o(uctions)i(like)d
+Fh(goto)g Fq(and)g Fh(if)p 2836 2166 V 35 w(icmpeq)p
+Fq(,)j(which)d(com-)244 2287 y(par)n(es)32 b(two)h(integers)g(for)h
+(equality)-11 b(.)52 b(Ther)n(e)33 b(is)f(also)h(a)f
+Fh(jsr)f Fq(\(jump)i(sub-r)n(outine\))h(and)e Fh(ret)244
+2407 y Fq(pair)26 b(of)i(instr)o(uctions)h(that)e(is)g(used)f(to)h
+(implement)g(the)f Fh(finally)f Fq(clause)i(of)g Fh(try-catch)244
+2528 y Fq(blocks.)32 b(Exceptions)26 b(may)f(be)g(thr)n(own)h(with)g
+(the)f Fh(athrow)e Fq(instr)o(uction.)244 2696 y(Branch)30
+b(tar)n(gets)i(ar)n(e)f(coded)f(as)h(of)n(fsets)h(fr)n(om)f(the)g(curr)
+n(ent)g(byte)g(code)g(position,)i(i.e.)46 b(with)244
+2816 y(an)25 b(integer)g(number)-7 b(.)0 3031 y Fg(Load)25
+b(and)f(store)i(operations)49 b Fq(for)31 b(local)h(variables)f(like)f
+Fh(iload)g Fq(and)g Fh(istore)p Fq(.)47 b(Ther)n(e)31
+b(ar)n(e)g(also)244 3152 y(array)26 b(operations)g(like)f
+Fh(iastore)e Fq(which)i(stor)n(es)i(an)d(integer)i(value)f(into)g(an)g
+(array)-11 b(.)0 3367 y Fg(Field)25 b(access:)50 b Fq(The)24
+b(value)g(of)h(an)f(instance)h(\002eld)f(may)g(be)g(r)n(etrieved)i
+(with)e Fh(getfield)f Fq(and)h(writ-)244 3488 y(ten)d(with)g
+Fh(putfield)p Fq(.)28 b(For)22 b(static)g(\002elds,)g(ther)n(e)g(ar)n
+(e)f Fh(getstatic)e Fq(and)h Fh(putstatic)f Fq(coun-)244
+3608 y(terparts.)0 3824 y Fg(Method)25 b(invocation:)50
+b Fq(Methods)20 b(may)f(either)g(be)g(called)f(via)h(static)h(r)n(efer)
+n(ences)g(with)f Fh(invokesta-)244 3944 y(tic)40 b Fq(or)i(be)f(bound)g
+(virtually)i(with)e(the)g Fh(invokevirtual)e Fq(instr)o(uction.)81
+b(Super)41 b(class)244 4064 y(methods)25 b(and)g(private)g(methods)h
+(ar)n(e)f(invoked)h(with)f Fh(invokespecial)p Fq(.)0
+4280 y Fg(Object)g(allocation:)50 b Fq(Class)28 b(instances)g(ar)n(e)g
+(allocated)g(with)h(the)f Fh(new)f Fq(instr)o(uction,)k(arrays)e(of)f
+(ba-)244 4400 y(sic)j(type)g(like)f Fh(int[])f Fq(with)i
+Fh(newarray)p Fq(,)f(arrays)i(of)f(r)n(efer)n(ences)g(like)f
+Fh(String[][])e Fq(with)244 4521 y Fh(anewarray)23 b
+Fq(or)i Fh(multianewarray)p Fq(.)0 4736 y Fg(Conversion)h(and)e(type)h
+(checking:)49 b Fq(For)23 b(stack)g(operands)g(of)f(basic)g(type)h
+(ther)n(e)f(exist)h(casting)g(op-)244 4856 y(erations)35
+b(like)e Fh(f2i)g Fq(which)i(converts)g(a)e(\003oat)h(value)g(into)h
+(an)e(integer)-7 b(.)58 b(The)33 b(validity)i(of)f(a)244
+4977 y(type)24 b(cast)h(may)f(be)f(checked)h(with)g Fh(checkcast)e
+Fq(and)i(the)g Fh(instanceof)d Fq(operator)k(can)f(be)244
+5097 y(dir)n(ectly)i(mapped)e(to)i(the)f(equally)g(named)f(instr)o
+(uction.)146 5342 y(Most)38 b(instr)o(uctions)i(have)c(a)h(\002xed)g
+(length,)j(but)d(ther)n(e)g(ar)n(e)g(also)g(some)g(variable-length)h
+(in-)0 5463 y(str)o(uctions:)59 b(In)37 b(particular)-7
+b(,)41 b(the)d Fh(lookupswitch)c Fq(and)j Fh(tableswitch)f
+Fq(instr)o(uctions,)43 b(which)1888 5712 y(6)p eop
+%%Page: 7 7
+7 6 bop 0 407 a Fq(ar)n(e)31 b(used)f(to)h(implement)g
+Fh(switch\(\))d Fq(statements.)49 b(Since)31 b(the)g(number)f(of)h
+Fh(case)f Fq(clauses)h(may)0 527 y(vary)-11 b(,)26 b(these)f(instr)o
+(uctions)i(contain)f(a)f(variable)g(number)g(of)g(statements.)146
+648 y(W)-9 b(e)27 b(will)g(not)h(list)g(all)f(byte)h(code)g(instr)o
+(uctions)i(her)n(e,)e(since)f(these)h(ar)n(e)f(explained)g(in)g(detail)
+g(in)0 768 y(the)g(JVM)g(speci\002cation.)37 b(The)26
+b(opcode)h(names)f(ar)n(e)h(mostly)h(self-explaining,)f(so)g
+(understanding)0 888 y(the)e(following)h(code)g(examples)e(should)i(be)
+e(fairly)i(intuitive.)0 1183 y Fm(2.3)119 b(Method)30
+b(code)0 1373 y Fq(Non-abstract)35 b(methods)g(contain)f(an)g
+(attribute)h(\()p Fh(Code)p Fq(\))e(that)h(holds)g(the)g(following)h
+(data:)48 b(The)0 1493 y(maximum)27 b(size)f(of)h(the)f(method's)h
+(stack)g(frame,)g(the)f(number)h(of)g(local)g(variables)f(and)g(an)g
+(array)0 1614 y(of)i(byte)h(code)f(instr)o(uctions.)43
+b(Optionally)-11 b(,)29 b(it)g(may)f(also)g(contain)h(information)g
+(about)g(the)f(names)0 1734 y(of)d(local)h(variables)f(and)g(sour)n(ce)
+h(\002le)f(line)f(numbers)i(that)f(can)g(be)g(used)g(by)g(a)g(debugger)
+-7 b(.)146 1855 y(Whenever)23 b(an)h(exception)h(is)f(thr)n(own,)h(the)
+f(JVM)g(performs)h(exception)f(handling)g(by)g(looking)0
+1975 y(into)31 b(a)f(table)h(of)g(exception)g(handlers.)47
+b(The)31 b(table)f(marks)h(handlers,)h(i.e.)47 b(pieces)30
+b(of)h(code,)h(to)f(be)0 2095 y(r)n(esponsible)23 b(for)h(exceptions)f
+(of)h(certain)f(types)g(that)g(ar)n(e)g(raised)g(within)g(a)f(given)h
+(ar)n(ea)f(of)i(the)e(byte)0 2216 y(code.)63 b(When)35
+b(ther)n(e)g(is)h(no)g(appr)n(opriate)g(handler)f(the)h(exception)g(is)
+g(pr)n(opagated)g(back)g(to)h(the)0 2336 y(caller)29
+b(of)h(the)f(method.)43 b(The)29 b(handler)g(information)h(is)f(itself)
+h(stor)n(ed)g(in)f(an)g(attribute)i(contained)0 2456
+y(within)25 b(the)h Fh(Code)e Fq(attribute.)0 2751 y
+Fm(2.4)119 b(Byte)30 b(code)g(of)n(fsets)0 2941 y Fq(T)-9
+b(ar)n(gets)32 b(of)g(branch)f(instr)o(uctions)j(like)d
+Fh(goto)f Fq(ar)n(e)h(encoded)g(as)g(r)n(elative)h(of)n(fsets)g(in)f
+(the)h(array)f(of)0 3062 y(byte)i(codes.)55 b(Exception)33
+b(handlers)g(and)f(local)h(variables)g(r)n(efer)g(to)g(absolute)h(addr)
+n(esses)e(within)0 3182 y(the)26 b(byte)g(code.)34 b(The)26
+b(former)h(contains)f(r)n(efer)n(ences)h(to)g(the)f(start)h(and)e(the)h
+(end)g(of)g(the)g Fh(try)f Fq(block,)0 3302 y(and)d(to)i(the)e(instr)o
+(uction)j(handler)e(code.)30 b(The)22 b(latter)h(marks)h(the)e(range)h
+(in)g(which)g(a)f(local)h(variable)0 3423 y(is)g(valid,)f(i.e.)30
+b(its)23 b(scope.)30 b(This)23 b(makes)f(it)h(dif)n(\002cult)h(to)f
+(insert)g(or)g(delete)f(code)g(ar)n(eas)h(on)f(this)h(level)f(of)0
+3543 y(abstraction,)29 b(since)f(one)f(has)g(to)h(r)n(ecompute)g(the)f
+(of)n(fsets)i(every)f(time)f(and)g(update)f(the)i(r)n(eferring)0
+3663 y(objects.)k(W)-9 b(e)24 b(will)h(see)g(in)g(section)h(3.3)e(how)i
+Fo(BCEL)i Fq(r)n(emedies)d(this)h(r)n(estriction.)0 3958
+y Fm(2.5)119 b(T)-11 b(ype)30 b(information)0 4148 y
+Fq(Java)k(is)h(a)f(type-safe)h(language)f(and)g(the)g(information)i
+(about)f(the)f(types)h(of)g(\002elds,)i(local)d(vari-)0
+4269 y(ables,)27 b(and)g(methods)g(is)g(stor)n(ed)h(in)f
+Fp(signatur)n(es)p Fq(.)37 b(These)26 b(ar)n(e)h(strings)i(stor)n(ed)f
+(in)f(the)g(constant)h(pool)0 4389 y(and)35 b(encoded)h(in)f(a)g
+(special)h(format.)64 b(For)36 b(example)f(the)h(ar)n(gument)h(and)e(r)
+n(eturn)h(types)h(of)f(the)0 4509 y Fh(main)24 b Fq(method)120
+4688 y Fh(public)58 b(static)g(void)h(main\(String[])e(argv\))146
+4866 y Fq(ar)n(e)25 b(r)n(epr)n(esented)h(by)f(the)g(signatur)n(e)120
+5044 y Fh(\([java/lang/String;\)V)146 5222 y Fq(Classes)19
+b(and)g(arrays)h(ar)n(e)f(internally)g(r)n(epr)n(esented)h(by)f
+(strings)i(like)e Fh("java/lang/String")p Fq(,)0 5342
+y(basic)k(types)g(like)g Fh(float)e Fq(by)i(an)f(integer)h(number)-7
+b(.)30 b(W)-5 b(ithin)22 b(signatur)n(es)i(they)f(ar)n(e)g(r)n(epr)n
+(esented)g(by)0 5463 y(single)i(characters,)h(e.g.,)f
+Fh("I")p Fq(,)f(for)i(integer)-7 b(.)1888 5712 y(7)p
+eop
+%%Page: 8 8
+8 7 bop 0 407 a Fm(2.6)119 b(Code)30 b(example)0 608
+y Fq(The)25 b(following)i(example)e(pr)n(ogram)i(pr)n(ompts)g(for)f(a)f
+(number)h(and)f(prints)h(the)g(faculty)g(of)g(it.)33
+b(The)0 728 y Fh(readLine\(\))19 b Fq(method)i(r)n(eading)g(fr)n(om)h
+(the)f(standar)n(d)h(input)f(may)g(raise)g(an)g Fh(IOException)d
+Fq(and)0 849 y(if)h(a)g(misspelled)f(number)h(is)h(passed)e(to)i
+Fh(parseInt\(\))d Fq(it)i(thr)n(ows)i(a)e Fh(NumberFormatException)p
+Fq(.)0 969 y(Thus,)25 b(the)g(critical)h(ar)n(ea)f(of)h(code)f(must)g
+(be)g(encapsulated)g(in)g(a)f Fh(try-catch)f Fq(block.)0
+1230 y Ff(import)52 b(java.io.*;)0 1343 y(public)g(class)g(Faculty)f({)
+109 1456 y(private)g(static)h(BufferedReader)c(in)54
+b(=)g(new)f(BufferedReader\(n)o(ew)1745 1569 y(InputStreamReade)o(r\()o
+(Sy)o(st)o(em.)o(in)o(\)\))o(;)109 1682 y(public)f(static)g(final)g
+(int)h(fac\(int)f(n\))h({)218 1795 y(return)f(\(n)i(==)f(0\)?)g(1)i(:)f
+(n)g(*)g(fac\(n)e(-)i(1\);)109 1907 y(})109 2020 y(public)e(static)g
+(final)g(int)h(readInt\(\))e({)218 2133 y(int)i(n)h(=)h(4711;)218
+2246 y(try)e({)327 2359 y(System.out.prin)o(t\(")o(Pl)o(ea)o(se)48
+b(enter)k(a)i(number>)e("\);)327 2472 y(n)i(=)g(Integer.parseInt)o(\(i)
+o(n.)o(re)o(adL)o(in)o(e\()o(\)\))o(;)218 2585 y(})g(catch\(IOExcepti)o
+(on)48 b(e1\))53 b({)h(System.err.print)o(ln)o(\(e)o(1\))o(;)48
+b(})327 2698 y(catch\(NumberFor)o(mat)o(Ex)o(ce)o(pt)o(io)o(n)h(e2\))k
+({)h(System.err.pri)o(ntl)o(n\()o(e2)o(\);)48 b(})218
+2811 y(return)k(n;)109 2924 y(})109 3037 y(public)g(static)g(void)g
+(main\(String[])d(argv\))j({)218 3149 y(int)h(n)h(=)h(readInt\(\);)218
+3262 y(System.out.prin)o(tl)o(n\(")o(Fa)o(cu)o(lt)o(y)48
+b(of)54 b(")g(+)g(n)g(+)g(")h(is)e(")h(+)g(fac\(n\)\);)109
+3375 y(}})146 3631 y Ft(This)23 b(code)f(example)g(typically)h
+(compiles)g(to)f(the)g(following)h(chunks)e(of)i(byte)f(code:)0
+3921 y Fg(2.6.1)99 b(Method)25 b(fac)0 4108 y Ff(0:)108
+b(iload_0)0 4221 y(1:)g(ifne)653 b(#8)0 4334 y(4:)108
+b(iconst_1)0 4447 y(5:)g(goto)653 b(#16)0 4560 y(8:)108
+b(iload_0)0 4672 y(9:)g(iload_0)0 4785 y(10:)53 b(iconst_1)0
+4898 y(11:)g(isub)0 5011 y(12:)g(invokestatic)213 b(Faculty.fac)49
+b(\(I\)I)k(\(12\))0 5124 y(15:)g(imul)0 5237 y(16:)g(ireturn)0
+5463 y(LocalVariable\(s)o(ta)o(rt)o(_p)o(c)c(=)54 b(0,)f(length)f(=)i
+(16,)f(index)g(=)h(0:int)e(n\))1888 5712 y Fq(8)p eop
+%%Page: 9 9
+9 8 bop 146 407 a Ft(The)21 b(method)f Ff(fac)h Ft(has)g(only)g(one)g
+(local)i(variable,)g(the)e(ar)n(gument)g Ff(n)p Ft(,)g(stor)n(ed)f(in)i
+(slot)f(0.)28 b(This)21 b(variable's)0 520 y(scope)k(ranges)g(fr)n(om)h
+(the)g(start)f(of)h(the)f(byte)g(code)g(sequence)g(to)g(the)g(very)h
+(end.)37 b(If)26 b(the)f(value)i(of)f Ff(n)g Ft(\(stor)n(ed)0
+633 y(in)i(local)h(variable)g(0,)g(i.e.)41 b(the)27 b(value)h(fetched)e
+(with)i Ff(iload)p 2148 633 28 4 v 30 w(0)p Ft(\))f(is)h(not)e(equal)i
+(to)f(0,)h(the)f Ff(ifne)e Ft(instr)o(uction)0 746 y(branches)20
+b(to)f(the)g(byte)g(code)g(at)h(of)n(fset)f(8,)h(otherwise)e(a)j(1)f
+(is)g(pushed)e(onto)g(the)h(operand)g(stack)g(and)h(the)f(con-)0
+858 y(tr)n(ol)24 b(\003ow)h(branches)f(to)g(the)f(\002nal)i(r)n(eturn.)
+33 b(For)23 b(ease)h(of)g(r)n(eading,)g(the)g(of)n(fsets)f(of)h(the)g
+(branch)h(instr)o(uctions,)0 971 y(which)e(ar)n(e)g(actually)h(r)n
+(elative,)f(ar)n(e)g(displayed)f(as)g(absolute)h(addr)n(esses)d(in)j
+(these)e(examples.)146 1084 y(If)27 b(r)n(ecursion)f(has)g(to)g
+(continue,)h(the)f(ar)n(guments)f(for)i(the)e(multiplication)j(\()p
+Ff(n)f Ft(and)f Ff(fac\(n)53 b(-)h(1\))p Ft(\))26 b(ar)n(e)0
+1197 y(evaluated)21 b(and)g(the)f(r)n(esults)g(pushed)f(onto)h(the)g
+(operand)f(stack.)27 b(After)20 b(the)h(multiplication)h(operation)e
+(has)0 1310 y(been)i(performed)f(the)h(function)h(r)n(eturns)e(the)h
+(computed)f(value)i(fr)n(om)g(the)f(top)g(of)h(the)e(stack.)0
+1569 y Fg(2.6.2)99 b(Method)25 b(readInt)0 1745 y Ff(0:)108
+b(sipush)434 b(4711)0 1858 y(3:)108 b(istore_0)0 1971
+y(4:)g(getstatic)269 b(java.lang.Syst)o(em.)o(ou)o(t)48
+b(Ljava/io/PrintS)o(tre)o(am)o(;)0 2084 y(7:)108 b(ldc)599
+b("Please)51 b(enter)h(a)j(number>)c(")0 2197 y(9:)108
+b(invokevirtual)49 b(java.io.PrintS)o(tre)o(am)o(.p)o(ri)o(nt)f
+(\(Ljava/lang/Str)o(in)o(g;)o(\)V)0 2310 y(12:)53 b(getstatic)269
+b(Faculty.in)50 b(Ljava/io/Buffe)o(red)o(Re)o(ad)o(er)o(;)0
+2423 y(15:)j(invokevirtual)c(java.io.Buffer)o(edR)o(ea)o(de)o(r.)o(re)o
+(adL)o(in)o(e)f(\(\)Ljava/lang/St)o(rin)o(g;)0 2536 y(18:)53
+b(invokestatic)104 b(java.lang.Inte)o(ger)o(.p)o(ar)o(se)o(In)o(t)49
+b(\(Ljava/lang/St)o(ri)o(ng)o(;\))o(I)0 2649 y(21:)k(istore_0)0
+2762 y(22:)g(goto)544 b(#44)0 2875 y(25:)53 b(astore_1)0
+2987 y(26:)g(getstatic)269 b(java.lang.Syst)o(em.)o(er)o(r)48
+b(Ljava/io/PrintS)o(tre)o(am)o(;)0 3100 y(29:)53 b(aload_1)0
+3213 y(30:)g(invokevirtual)c(java.io.PrintS)o(tre)o(am)o(.p)o(ri)o(nt)o
+(ln)f(\(Ljava/lang/Obj)o(ec)o(t;)o(\)V)0 3326 y(33:)53
+b(goto)544 b(#44)0 3439 y(36:)53 b(astore_1)0 3552 y(37:)g(getstatic)
+269 b(java.lang.Syst)o(em.)o(er)o(r)48 b(Ljava/io/PrintS)o(tre)o(am)o
+(;)0 3665 y(40:)53 b(aload_1)0 3778 y(41:)g(invokevirtual)c
+(java.io.PrintS)o(tre)o(am)o(.p)o(ri)o(nt)o(ln)f(\(Ljava/lang/Obj)o(ec)
+o(t;)o(\)V)0 3891 y(44:)53 b(iload_0)0 4004 y(45:)g(ireturn)0
+4229 y(Exception)d(handler\(s\))g(=)0 4342 y(From)216
+b(To)327 b(Handler)51 b(Type)0 4455 y(4)381 b(22)327
+b(25)f(java.io.IOExcep)o(ti)o(on)o(\(6\))0 4568 y(4)381
+b(22)327 b(36)f(NumberFormatExc)o(ep)o(ti)o(on\()o(10)o(\))146
+4785 y Ft(First)34 b(the)g(local)j(variable)f Ff(n)f
+Ft(\(in)g(slot)g(0\))g(is)g(initialized)i(to)d(the)g(value)h(4711.)67
+b(The)34 b(next)g(instr)o(uction,)0 4898 y Ff(getstatic)p
+Ft(,)f(loads)i(the)f(static)g Ff(System.out)d Ft(\002eld)j(onto)f(the)h
+(stack.)64 b(Then)34 b(a)h(string)e(is)i(loaded)f(and)0
+5011 y(printed,)21 b(a)i(number)g(r)n(ead)f(fr)n(om)h(the)f(standar)n
+(d)g(input)h(and)f(assigned)f(to)h Ff(n)p Ft(.)146 5124
+y(If)g(one)f(of)h(the)f(called)h(methods)e(\()p Ff(readLine\(\))e
+Ft(and)k Ff(parseInt\(\))p Ft(\))17 b(thr)n(ows)k(an)h(exception,)f
+(the)f(Java)0 5237 y(V)-5 b(irtual)26 b(Machine)h(calls)h(one)d(of)h
+(the)f(declar)n(ed)h(exception)f(handlers,)h(depending)e(on)h(the)g
+(type)g(of)h(the)f(ex-)0 5350 y(ception.)36 b(The)24
+b Ff(try)p Ft(-clause)h(itself)h(does)e(not)g(pr)n(oduce)h(any)g(code,)
+g(it)h(mer)n(ely)f(de\002nes)f(the)h(range)g(in)h(which)0
+5463 y(the)e(following)h(handlers)f(ar)n(e)h(active.)35
+b(In)24 b(the)g(example)g(the)g(speci\002ed)g(sour)n(ce)g(code)g(ar)n
+(ea)h(maps)g(to)f(a)h(byte)1888 5712 y Fq(9)p eop
+%%Page: 10 10
+10 9 bop 0 407 a Ft(code)23 b(ar)n(ea)h(ranging)f(fr)n(om)h(of)n(fset)f
+(4)h(\(inclusive\))h(to)e(22)h(\(exclusive\).)31 b(If)24
+b(no)f(exception)f(has)h(occurr)n(ed)g(\(\223nor)n(-)0
+520 y(mal\224)i(execution)e(\003ow\))h(the)f Ff(goto)f
+Ft(instr)o(uctions)h(branch)i(behind)e(the)g(handler)g(code.)31
+b(Ther)n(e)23 b(the)g(value)h(of)0 633 y Ff(n)e Ft(is)h(loaded)f(and)h
+(r)n(eturned.)146 750 y(For)e(example)g(the)f(handler)h(for)g
+Ff(java.io.IOExcep)o(ti)o(on)15 b Ft(starts)20 b(at)h(of)n(fset)g(25.)
+28 b(It)20 b(simply)i(prints)e(the)0 863 y(err)n(or)i(and)h(branches)f
+(back)i(to)e(the)f(normal)j(execution)d(\003ow)-8 b(,)22
+b(i.e.)28 b(as)23 b(if)g(no)f(exception)g(had)g(occurr)n(ed.)0
+1223 y Fr(3)143 b(The)35 b(BCEL)g(API)0 1443 y Ft(The)25
+b Fe(BCEL)j Ft(API)d(abstracts)h(fr)n(om)g(the)f(concr)n(ete)h(cir)n
+(cumstances)g(of)g(the)f(Java)j(V)-5 b(irtual)26 b(Machine)h(and)f(how)
+0 1556 y(to)c(r)n(ead)h(and)f(write)g(binary)i(Java)g(class)f(\002les.)
+k(The)22 b(API)g(mainly)i(consists)d(of)i(thr)n(ee)f(parts:)127
+1795 y(1.)49 b(A)26 b(package)f(that)h(contains)g(classes)g(that)g
+(describe)f(\223static\224)i(constraints)e(of)h(class)h(\002les,)f
+(i.e.,)g(r)n(e\003ect)244 1908 y(the)g(class)h(\002le)f(format)h(and)g
+(is)f(not)g(intended)f(for)h(byte)g(code)g(modi\002cations.)39
+b(The)26 b(classes)g(may)h(be)244 2021 y(used)e(to)h(r)n(ead)g(and)h
+(write)f(class)g(\002les)h(fr)n(om)g(or)f(to)g(a)h(\002le.)39
+b(This)26 b(is)h(useful)f(especially)g(for)h(analyzing)244
+2134 y(Java)34 b(classes)f(without)e(having)j(the)e(sour)n(ce)g
+(\002les)g(at)h(hand.)59 b(The)32 b(main)i(data)f(str)o(uctur)n(e)e(is)
+i(called)244 2247 y Ff(JavaClass)19 b Ft(which)k(contains)f(methods,)f
+(\002elds,)g(etc..)127 2453 y(2.)49 b(A)23 b(package)h(to)f
+(dynamically)i(generate)d(or)h(modify)h Ff(JavaClass)19
+b Ft(objects.)31 b(It)23 b(may)h(be)g(used)e(e.g.)30
+b(to)244 2565 y(insert)20 b(analysis)i(code,)e(to)h(strip)g
+(unnecessary)e(information)j(fr)n(om)g(class)f(\002les,)g(or)g(to)g
+(implement)g(the)244 2678 y(code)h(generator)f(back-end)h(of)h(a)g
+(Java)h(compiler)-7 b(.)127 2884 y(3.)49 b(V)-8 b(arious)21
+b(code)g(examples)h(and)g(utilities)g(like)g(a)h(class)f(\002le)g
+(viewer)-7 b(,)22 b(a)h(tool)e(to)h(convert)f(class)i(\002les)e(into)
+244 2997 y(HTML,)g(and)i(a)g(converter)f(fr)n(om)h(class)g(\002les)f
+(to)g(the)g(Jasmin)i(assembly)e(language)g([MD97)r(].)0
+3313 y Fm(3.1)119 b(JavaClass)0 3499 y Ft(The)16 b(\223static\224)j
+(component)d(of)h(the)f Fe(BCEL)i Ft(API)e(r)n(esides)g(in)i(the)e
+(package)h Ff(de.fub.bytecode)o(.c)o(la)o(ss)o(fi)o(le)0
+3612 y Ft(and)22 b(r)n(epr)n(esents)e(class)i(\002les.)27
+b(All)c(of)f(the)f(binary)i(components)d(and)i(data)g(str)o(uctur)n(es)
+f(declar)n(ed)g(in)i(the)e(JVM)0 3725 y(speci\002cation)27
+b([L)-8 b(Y97])26 b(and)h(described)e(in)i(section)e(2)i(ar)n(e)g
+(mapped)f(to)g(classes.)38 b(Figur)n(e)26 b(3)h(shows)e(an)i(UML)0
+3837 y(diagram)34 b(of)f(the)g(hierar)n(chy)g(of)h(classes)f(of)g(the)f
+Fe(BCEL)k Ft(API.)c(Figur)n(e)h(8)h(in)f(the)g(appendix)f(also)i(shows)
+e(a)0 3950 y(detailed)22 b(diagram)h(of)g(the)f Ff(ConstantPool)17
+b Ft(components.)146 4068 y(The)23 b(top-level)g(data)g(str)o(uctur)n
+(e)g(is)g Ff(JavaClass)p Ft(,)c(which)24 b(in)g(most)f(cases)g(is)g(cr)
+n(eated)g(by)g(a)h Ff(ClassPar-)0 4181 y(ser)d Ft(object)g(that)h(is)g
+(capable)h(of)f(parsing)f(binary)i(class)f(\002les.)27
+b(A)22 b Ff(JavaClass)c Ft(object)k(basically)h(consists)e(of)0
+4294 y(\002elds,)h(methods,)e(symbolic)j(r)n(efer)n(ences)f(to)g(the)g
+(super)f(class)i(and)g(to)f(the)f(implemented)h(interfaces.)146
+4411 y(The)c(constant)f(pool)g(serves)g(as)h(some)f(kind)g(of)h
+(central)h(r)n(epository)c(and)j(is)g(thus)f(of)h(outstanding)e(impor)n
+(-)0 4524 y(tance)29 b(for)g(all)h(components.)45 b Ff(ConstantPool)24
+b Ft(objects)k(contain)i(an)f(array)h(of)f(\002xed)f(size)h(of)g
+Ff(Constant)0 4637 y Ft(entries,)34 b(which)g(may)f(be)g(r)n(etrieved)f
+(via)i(the)f Ff(getConstant\(\))27 b Ft(method)32 b(taking)g(an)i
+(integer)d(index)i(as)0 4750 y(ar)n(gument.)58 b(Indexes)31
+b(to)h(the)h(constant)f(pool)g(may)h(be)g(contained)g(in)g(instr)o
+(uctions)f(as)i(well)f(as)g(in)g(other)0 4863 y(components)21
+b(of)h(a)i(class)f(\002le)f(and)h(in)g(constant)f(pool)g(entries)f
+(themselves.)146 4980 y(Methods)j(and)i(\002elds)f(contain)h(a)g
+(signatur)n(e,)g(symbolically)h(de\002ning)e(their)g(types.)35
+b(Access)25 b(\003ags)h(like)0 5093 y Ff(public)52 b(static)g(final)26
+b Ft(occur)i(in)h(several)f(places)h(and)f(ar)n(e)h(encoded)d(by)j(an)f
+(integer)f(bit)i(mask,)g(e.g.)0 5206 y Ff(public)52 b(static)g(final)20
+b Ft(matches)j(to)f(the)f(Java)k(expr)n(ession)109 5463
+y Ff(int)53 b(access_flags)c(=)54 b(ACC_PUBLIC)c(|)55
+b(ACC_STATIC)50 b(|)k(ACC_FINAL;)1863 5712 y Fq(10)p
+eop
+%%Page: 11 11
+11 10 bop 570 5113 a @beginspecial 13 @llx 12 @lly 471
+@urx 830 @ury 3221 @rwi @setspecial
+%%BeginDocument: eps/javaclass.eps
+%!PS-Adobe-3.0 EPSF-3.0
+%%Title: Rose Diagram(s)
+%%Creator: AdobePS5.dll Version 5.0
+%%CreationDate: 7/7/1999 17:45:7
+%%Pages: 1
+%%Orientation: Portrait
+%%PageOrder: Ascend
+%%DocumentNeededResources: (atend)
+%%DocumentSuppliedResources: (atend)
+%%DocumentData: Clean7Bit
+%%TargetDevice: (HP LaserJet 5Si) (2014.108) 1
+%%LanguageLevel: 2
+%%BoundingBox: 13 12 471 830
+%%EndComments
+%%BeginProcSet: epsffit 1 0
+gsave
+1233.763 -187.599 translate
+90 rotate
+1.782 1.782 scale
+%%EndProcSet
+
+
+%%BeginDefaults
+%%PageBoundingBox: 13 12 582 830
+%%EndDefaults
+
+%%BeginProlog
+%%BeginResource: file Pscript_WinNT_ErrorHandler 5.0 0
+/currentpacking where{pop/oldpack currentpacking def/setpacking where{pop false
+setpacking}if}if/$brkpage 64 dict def $brkpage begin/prnt{dup type/stringtype
+ne{=string cvs}if dup length 6 mul/tx exch def/ty 10 def currentpoint/toy exch
+def/tox exch def 1 setgray newpath tox toy 2 sub moveto 0 ty rlineto tx 0
+rlineto 0 ty neg rlineto closepath fill tox toy moveto 0 setgray show}bind def
+/nl{currentpoint exch pop lmargin exch moveto 0 -10 rmoveto}def/=={/cp 0 def
+typeprint nl}def/typeprint{dup type exec}readonly def/lmargin 72 def/rmargin 72
+def/tprint{dup length cp add rmargin gt{nl/cp 0 def}if dup length cp add/cp
+exch def prnt}readonly def/cvsprint{=string cvs tprint( )tprint}readonly def
+/integertype{cvsprint}readonly def/realtype{cvsprint}readonly def/booleantype
+{cvsprint}readonly def/operatortype{(--)tprint =string cvs tprint(-- )tprint}
+readonly def/marktype{pop(-mark- )tprint}readonly def/dicttype{pop
+(-dictionary- )tprint}readonly def/nulltype{pop(-null- )tprint}readonly def
+/filetype{pop(-filestream- )tprint}readonly def/savetype{pop(-savelevel- )
+tprint}readonly def/fonttype{pop(-fontid- )tprint}readonly def/nametype{dup
+xcheck not{(/)tprint}if cvsprint}readonly def/stringtype{dup rcheck{(\()tprint
+tprint(\))tprint}{pop(-string- )tprint}ifelse}readonly def/arraytype{dup rcheck
+{dup xcheck{({)tprint{typeprint}forall(})tprint}{([)tprint{typeprint}forall(])
+tprint}ifelse}{pop(-array- )tprint}ifelse}readonly def/packedarraytype{dup
+rcheck{dup xcheck{({)tprint{typeprint}forall(})tprint}{([)tprint{typeprint}
+forall(])tprint}ifelse}{pop(-packedarray- )tprint}ifelse}readonly def/courier
+/Courier findfont 10 scalefont def end errordict/handleerror{systemdict begin
+$error begin $brkpage begin newerror{/newerror false store vmstatus pop pop 0
+ne{grestoreall}if showpage initgraphics courier setfont lmargin 720 moveto
+(ERROR: )prnt errorname prnt nl(OFFENDING COMMAND: )prnt/command load prnt
+$error/ostack known{nl nl(STACK:)prnt nl nl $error/ostack get aload length{==}
+repeat}if systemdict/showpage get exec(%%[ Error: )print errorname =print
+(; OffendingCommand: )print/command load =print( ]%%)= flush}if end end end}dup
+0 systemdict put dup 4 $brkpage put bind readonly put/currentpacking where{pop
+/setpacking where{pop oldpack setpacking}if}if
+%%EndResource
+userdict /Pscript_WinNT_Incr 230 dict dup begin put
+%%BeginResource: file Pscript_FatalError 5.0 0
+/FatalErrorIf{{initgraphics findfont exch scalefont setfont counttomark 3 div
+cvi{moveto show}repeat showpage quit}{cleartomark}ifelse}bind def
+%%EndResource
+/VM?{vmstatus exch sub exch pop gt{[
+(This job requires more memory than is available in this printer.)100 500
+(Try one or more of the following, and then print again:)100 485
+(For the output format, choose Optimize For Portability.)115 470
+(In the Device Settings page, make sure the Available PostScript Memory is accurate.)
+115 455(Reduce the number of fonts in the document.)115 440
+(Print the document in parts.)115 425 12/Times-Roman showpage
+(%%[ PrinterError: Low Printer VM ]%%)= true FatalErrorIf}if}bind def
+%%BeginResource: file Pscript_Win_Basic 5.0 0
+/d/def load def/,/load load d/~/exch , d/?/ifelse , d/!/pop , d/`/begin , d/^
+/index , d/@/dup , d/+/translate , d/$/roll , d/U/userdict , d/M/moveto , d/-
+/rlineto , d/&/currentdict , d/:/gsave , d/;/grestore , d/F/false , d/T/true ,
+d/N/newpath , d/E/end , d/Ac/arc , d/An/arcn , d/A/ashow , d/D/awidthshow , d/C
+/closepath , d/V/div , d/O/eofill , d/L/fill , d/I/lineto , d/-c/curveto , d/-M
+/rmoveto , d/+S/scale , d/Ji/setfont , d/Lc/setlinecap , d/Lj/setlinejoin , d
+/Lw/setlinewidth , d/Lm/setmiterlimit , d/sd/setdash , d/S/show , d/LH/showpage
+, d/K/stroke , d/W/widthshow , d/R/rotate , d/P/eoclip , d/L2? false
+/languagelevel where{pop languagelevel 2 ge{pop true}if}if d L2?{/xS/xshow , d
+/yS/yshow , d/zS/xyshow , d}if/b{bind d}bind d/bd{bind d}bind d/xd{~ d}bd/ld{,
+d}bd/lw/Lw ld/lc/Lc ld/lj/Lj ld/sg/setgray ld/ADO_mxRot null d/self & d/OrgMx
+matrix currentmatrix d/reinitialize{: OrgMx setmatrix[/TextInit/GraphInit
+/UtilsInit counttomark{@ where{self eq}{F}?{cvx exec}{!}?}repeat cleartomark ;}
+b/initialize{`{/ADO_mxRot ~ d/TextInitialised? F d reinitialize E}{U
+/Pscript_Win_Data 230 dict @ ` put/ADO_mxRot ~ d/TextInitialised? F d
+reinitialize}?}b/terminate{!{& self eq{exit}{E}?}loop E}b/suspend/terminate , d
+/resume{` Pscript_Win_Data `}b/snap{transform 0.25 sub round 0.25 add ~ 0.25
+sub round 0.25 add ~ itransform}b/dsnap{dtransform round ~ round ~ idtransform}
+b<04>cvn{}d/rr{1 ^ 0 - 0 ~ - neg 0 - C}b/rp{4 2 $ M 1 ^ 0 - 0 ~ - neg 0 -}b
+/solid{[]0 sd}b/g{@ not{U/DefIf_save save put}if U/DefIf_bool 2 ^ put}b
+/DefIf_El{if U/DefIf_bool get not @{U/DefIf_save get restore}if}b/e{DefIf_El !}
+b/UDF{L2?{undefinefont}{!}?}b/UDR{L2?{undefineresource}{! !}?}b
+%%EndResource
+%%BeginResource: file Pscript_Win_Utils_L2 5.0 0
+/rf/rectfill , d/fx{1 1 dtransform @ 0 ge{1 sub 0.5}{1 add -0.5}? 3 -1 $ @ 0 ge
+{1 sub 0.5}{1 add -0.5}? 3 1 $ 4 1 $ idtransform 4 -2 $ idtransform}b/BZ{4 -2 $
+snap + +S fx rf}b/rs/rectstroke , d/rc/rectclip , d/UtilsInit{currentglobal{F
+setglobal}if}b/scol{! setcolor}b/colspA/DeviceGray d/colspABC/DeviceRGB d
+/colspRefresh{colspABC setcolorspace}b/SetColSpace{colspABC setcolorspace}b
+%%EndResource
+end
+%%EndProlog
+
+%%BeginSetup
+[ 1 0 0 1 0 0 ] false Pscript_WinNT_Incr dup /initialize get exec
+1 setlinecap 1 setlinejoin
+/mysetup [ 0.24 0 0 -0.24 13.43905 829.74047 ] def
+%%EndSetup
+
+%%Page: 1 1
+%%PageBoundingBox: 13 12 582 830
+%%EndPageComments
+%%BeginPageSetup
+/DeviceRGB dup setcolorspace /colspABC exch def mysetup concat colspRefresh
+%%EndPageSetup
+
+Pscript_WinNT_Incr begin
+%%BeginResource: file Pscript_Win_GdiObject 5.0 0
+/SavedCTM null d/CTMsave{/SavedCTM SavedCTM currentmatrix d}b/CTMrestore
+{SavedCTM setmatrix}b/mp null d/ADO_mxRot null d/GDIHMatrix null d
+/GDIHPatternDict 22 dict d GDIHPatternDict `/PatternType 1 d/PaintType 2 d/Reps
+L2?{1}{5}? d/XStep 8 Reps mul d/YStep XStep d/BBox[0 0 XStep YStep]d/TilingType
+1 d/PaintProc{` 1 Lw[]0 sd PaintData , exec E}b/FGnd null d/BGnd null d
+/HS_Horizontal{horiz}b/HS_Vertical{vert}b/HS_FDiagonal{fdiag}b/HS_BDiagonal
+{biag}b/HS_Cross{horiz vert}b/HS_DiagCross{fdiag biag}b/MaxXYStep XStep YStep
+gt{XStep}{YStep}? d/horiz{Reps{0 4 M XStep 0 - 0 8 +}repeat 0 -8 Reps mul + K}b
+/vert{Reps{4 0 M 0 YStep - 8 0 +}repeat 0 -8 Reps mul + K}b/biag{Reps{0 0 M
+MaxXYStep @ - 0 YStep neg M MaxXYStep @ - 0 8 +}repeat 0 -8 Reps mul + 0 YStep
+M 8 8 - K}b/fdiag{Reps{0 0 M MaxXYStep @ neg - 0 YStep M MaxXYStep @ neg - 0 8
++}repeat 0 -8 Reps mul + MaxXYStep @ M 8 -8 - K}b E/makehatch{4 -2 $/yOrg ~ d
+/xOrg ~ d GDIHPatternDict/PaintData 3 -1 $ put CTMsave GDIHMatrix setmatrix
+GDIHPatternDict matrix xOrg yOrg + mp CTMrestore ~ U ~ 2 ^ put}b/h0{/h0
+/HS_Horizontal makehatch}b/h1{/h1/HS_Vertical makehatch}b/h2{/h2/HS_FDiagonal
+makehatch}b/h3{/h3/HS_BDiagonal makehatch}b/h4{/h4/HS_Cross makehatch}b/h5{/h5
+/HS_DiagCross makehatch}b/GDIBWPatternDict 25 dict @ `/PatternType 1 d
+/PaintType L2?{1}{2}? d/RepsV L2?{1}{6}? d/RepsH L2?{1}{5}? d/BBox[0 0 RepsH 1]
+d/TilingType 1 d/XStep 1 d/YStep 1 d/Height 8 RepsV mul d/Width 8 d/mx[Width 0
+0 Height neg 0 Height]d/FGnd null d/BGnd null d/SetBGndFGnd L2?{{FGnd null ne
+{FGnd aload ! scol BBox aload ! 2 ^ sub ~ 3 ^ sub ~ rf}if BGnd null ne{BGnd
+aload ! scol}if}}{{}}? b/PaintProc{` SetBGndFGnd RepsH{Width Height F mx
+PaintData imagemask Width 0 +}repeat E}b E d/GDIBWPatternMx null d/pfprep{save
+8 1 $/PatternOfTheDay 8 1 $ GDIBWPatternDict `/yOrg ~ d/xOrg ~ d/PaintData ~ d
+/yExt ~ d/Width ~ d/FGnd ~ d/BGnd ~ d/Height yExt RepsV mul d/mx[Width 0 0
+Height 0 0]d E : GDIBWPatternDict ` Width Height E dsnap +S/GDIBWPatternMx
+matrix currentmatrix d ; CTMsave GDIBWPatternMx setmatrix GDIBWPatternDict @ `
+xOrg yOrg E matrix + mp CTMrestore ~ !}b/pfbf{/fEOFill ~ d pfprep hbf fEOFill
+{O}{L}? restore}b/GraphInit{GDIHMatrix null eq{/SavedCTM matrix d : ADO_mxRot
+concat 0 0 snap + : 0.48 @ GDIHPatternDict ` YStep mul ~ XStep mul ~ dsnap
+YStep V ~ XStep V ~ E +S/GDIHMatrix matrix currentmatrix readonly d ; : 0.24
+-0.24 +S GDIBWPatternDict ` Width Height E dsnap +S/GDIBWPatternMx matrix
+currentmatrix readonly d ; ;}if}b
+%%EndResource
+%%BeginResource: file Pscript_Win_GdiObject_L2 5.0 0
+/mp/makepattern , d/hbf{setpattern}b/hf{:/fEOFill ~ d ~ ! setpattern fEOFill{O}
+{L}? ;}b/pbf{: !/fEOFill ~ d GDIBWPatternDict `/yOrg ~ d/xOrg ~ d/PaintData ~ d
+/OutputBPP ~ d/Height ~ d/Width ~ d/PaintType 1 d/PatternType 1 d/TilingType 1
+d/BBox[0 0 Width Height]d/XStep Width d/YStep Height d/mx xOrg yOrg matrix + d
+20 dict @ `/ImageType 1 d/Width Width d/Height Height d/ImageMatrix mx d
+/BitsPerComponent 8 d OutputBPP 24 eq{/Decode[0 1 0 1 0 1]d}{OutputBPP 8 eq{
+/Decode[0 1]d}{/Decode[0 1 0 1 0 1 0 1]d}?}?/DataSource{PaintData}d E/ImageDict
+~ d/PaintProc{` ImageDict image E}b & mx makepattern setpattern E fEOFill{O}{L}
+? ;}b
+%%EndResource
+end reinitialize
+: N 712 1406 246 93 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol 1 Lw N 958 1405 M 711 1405 I 711 1499 I 958 1499 I C
+K
+0 0 0 1 scol Pscript_WinNT_Incr begin
+%%BeginResource: file Pscript_Text 5.0 0
+/TextInit{TextInitialised? not{/Pscript_Windows_Font & d/TextInitialised? T d
+/fM[1 0 0 1 0 0]d/mFM matrix d/iMat[1 0 0.212557 1 0 0]d}if}b/copyfont{1 ^
+length add dict `{1 ^/FID ne{d}{! !}?}forall & E}b/EncodeDict 11 dict d/bullets
+{{/bullet}repeat}b/rF{3 copyfont @ ` ~ EncodeDict ~ get/Encoding ~ 3 ^/0 eq{&
+/CharStrings known{CharStrings/Eth known not{! EncodeDict/ANSIEncodingOld get}
+if}if}if d E}b/mF{@ 7 1 $ findfont ~{@/Encoding get @ StandardEncoding eq{! T}{
+{ISOLatin1Encoding}stopped{! F}{eq}?{T}{@ ` T 32 1 127{Encoding 1 ^ get
+StandardEncoding 3 -1 $ get eq and}for E}?}?}{F}?{1 ^ ~ rF}{0 copyfont}? 6 -2 $
+{T pd_AddEm87 ~ !}{! ~ !/pd_charset @ where{~ get 128 eq{@ FDV 2 copy get @
+length array copy put pd_CoverFCRange}if}{!}?}? 2 ^ ~ definefont fM 5 4 -1 $
+put fM 4 0 put fM makefont Pscript_Windows_Font 3 1 $ put}b/sLT{: Lw -M
+currentpoint snap M 0 - 0 Lc K ;}b/xUP null d/yUP null d/uW null d/xSP null d
+/ySP null d/sW null d/sSU{N/uW ~ d/yUP ~ d/xUP ~ d}b/sU{xUP yUP uW sLT}b/sST{N
+/sW ~ d/ySP ~ d/xSP ~ d}b/sT{xSP ySP sW sLT}b/sR{: + R 0 0 M}b/sRxy{: matrix
+astore concat 0 0 M}b/eR/; , d/AddOrigFP{{&/FontInfo known{&/FontInfo get
+length 6 add}{6}? dict `/WinPitchAndFamily ~ d/WinCharSet ~ d/OrigFontType ~ d
+/OrigFontStyle ~ d/OrigFontName ~ d & E/FontInfo ~ d}{! ! ! ! !}?}b/mFS
+{makefont Pscript_Windows_Font 3 1 $ put}b/mF42D{0 copyfont `/FontName ~ d 2
+copy ~ sub 1 add dict `/.notdef 0 d 2 copy 1 ~{@ 3 ^ sub Encoding ~ get ~ d}for
+& E/CharStrings ~ d ! ! & @ E/FontName get ~ definefont}bind d/mF42{15 dict ` @
+4 1 $/FontName ~ d/FontType 0 d/FMapType 2 d/FontMatrix[1 0 0 1 0 0]d 1 ^ 254
+add 255 idiv @ array/Encoding ~ d 0 1 3 -1 $ 1 sub{@ Encoding 3 1 $ put}for
+/FDepVector Encoding length array d/CharStrings 2 dict `/.notdef 0 d & E d 0 1
+Encoding length 1 sub{@ @ 10 lt{! FontName length 1 add string}{100 lt{FontName
+length 2 add string}{FontName length 3 add string}?}? @ 0 FontName @ length
+string cvs putinterval @ 3 -1 $ @ 4 1 $ 3 string cvs FontName length ~
+putinterval cvn 1 ^ 256 mul @ 255 add 3 -1 $ 4 ^ findfont mF42D FDepVector 3 1
+$ put}for & @ E/FontName get ~ definefont ! ! ! mF}b/UmF{L2?
+{Pscript_Windows_Font ~ undef}{!}?}b/UmF42{@ findfont/FDepVector get{/FontName
+get undefinefont}forall undefinefont}b
+%%EndResource
+end reinitialize
+Pscript_WinNT_Incr begin
+%%BeginResource: file Pscript_Encoding256 5.0 0
+/CharCol256Encoding[/.notdef/breve/caron/dotaccent/dotlessi/fi/fl/fraction
+/hungarumlaut/Lslash/lslash/minus/ogonek/ring/Zcaron/zcaron/.notdef/.notdef
+/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
+/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/exclam/quotedbl/numbersign
+/dollar/percent/ampersand/quotesingle/parenleft/parenright/asterisk/plus/comma
+/hyphen/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon
+/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S
+/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/asciicircum/underscore/grave
+/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright
+/asciitilde/.notdef/.notdef/.notdef/quotesinglbase/florin/quotedblbase/ellipsis
+/dagger/daggerdbl/circumflex/perthousand/Scaron/guilsinglleft/OE/.notdef
+/.notdef/.notdef/.notdef/quoteleft/quoteright/quotedblleft/quotedblright/bullet
+/endash/emdash/tilde/trademark/scaron/guilsinglright/oe/.notdef/.notdef
+/Ydieresis/.notdef/exclamdown/cent/sterling/currency/yen/brokenbar/section
+/dieresis/copyright/ordfeminine/guillemotleft/logicalnot/.notdef/registered
+/macron/degree/plusminus/twosuperior/threesuperior/acute/mu/paragraph
+/periodcentered/cedilla/onesuperior/ordmasculine/guillemotright/onequarter
+/onehalf/threequarters/questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis
+/Aring/AE/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute
+/Icircumflex/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
+/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls
+/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla/egrave/eacute
+/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis/eth/ntilde/ograve
+/oacute/ocircumflex/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex
+/udieresis/yacute/thorn/ydieresis]def EncodeDict/256 CharCol256Encoding put
+%%EndResource
+end reinitialize
+
+%%IncludeResource: font Helvetica
+F /F0 0 /256 T /Helvetica mF
+/F0S1C F0 [28.75 0 0 -28.75 0 0 ] mFS
+F0S1C Ji
+735 1441 M (ExceptionTable)[19 13 15 16 16 8 7 16 16 19 16 16 7 0]xS
+0.602 0 0.199 1 scol N 958 1456 M 711 1456 I 711 1499 I 958 1499 I C
+K
+N 958 1473 M 711 1473 I 711 1499 I 958 1499 I C
+K
+: N 1484 1418 275 93 rp C
+1 1 0.801 1 scol L ; N 1759 1417 M 1483 1417 I 1483 1511 I 1759 1511 I C
+K
+0 0 0 1 scol 1505 1453 M (LineNumberTable)[16 7 16 16 21 16 25 16 16 10 19 16 16 7 0]xS
+0.602 0 0.199 1 scol N 1759 1469 M 1483 1469 I 1483 1511 I 1759 1511 I C
+K
+N 1759 1485 M 1483 1485 I 1483 1511 I 1759 1511 I C
+K
+: N 1039 1411 318 253 rp C
+1 1 0.801 1 scol L ; N 1357 1410 M 1038 1410 I 1038 1664 I 1357 1664 I C
+K
+0 0 0 1 scol 1163 1446 M (Code)[21 16 16 0]xS
+0.602 0 0.199 1 scol N 1357 1462 M 1038 1462 I 1038 1664 I 1357 1664 I C
+K
+N 1357 1578 M 1038 1578 I 1038 1664 I 1357 1664 I C
+K
+0 0 0 1 scol 1083 1493 M (max_stack : int)[25 16 13 16 15 8 16 15 14 8 8 8 7 16 0]xS
+1083 1527 M (max_locals : int)[25 16 13 16 7 16 15 16 7 15 8 8 8 7 16 0]xS
+1083 1560 M (exception_handlers)[16 13 15 16 16 8 7 16 16 16 16 16 16 16 7 16 10 0]xS
+1083 1626 M (getCode\(\))[16 16 8 21 16 16 16 10 0]xS
+0.602 0 0.199 1 scol N 1420 1499 M 1358 1508 I K
+N 1358 1508 M 1380 1516 I 1398 1502 I 1377 1494 I 1358 1508 I C
+: 1 1 1 1 scol O ; K
+N 1420 1499 M 1482 1487 I K
+N 1462 1432 16 34 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1462 1459 M (1)S
+N 1462 1432 16 34 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1462 1459 M (1)S
+: N 1742 1576 291 93 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 2033 1575 M 1741 1575 I 1741 1669 I 2033 1669 I C
+K
+0 0 0 1 scol 1762 1611 M (LocalVariableTable)[16 16 15 16 7 19 16 10 7 16 16 7 16 19 16 16 7 0]xS
+0.602 0 0.199 1 scol N 2033 1626 M 1741 1626 I 1741 1669 I 2033 1669 I C
+K
+N 2033 1643 M 1741 1643 I 1741 1669 I 2033 1669 I C
+K
+N 1549 1580 M 1358 1556 I K
+N 1358 1556 M 1380 1547 I 1398 1562 I 1377 1570 I 1358 1556 I C
+: 1 1 1 1 scol O ; K
+N 1549 1580 M 1740 1603 I K
+: N 1709 1625 15 34 rp C
+1 1 1 1 scol L ; N 1709 1625 16 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1709 1652 M (1)S
+: N 1709 1625 15 34 rp C
+1 1 1 1 scol L ; N 1709 1625 16 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1709 1652 M (1)S
+: N 1573 1128 218 93 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 1791 1127 M 1572 1127 I 1572 1221 I 1791 1221 I C
+K
+0 0 0 1 scol 1597 1163 M (InnerClasses)[7 16 16 16 10 21 7 16 15 15 16 0]xS
+0.602 0 0.199 1 scol N 1791 1178 M 1572 1178 I 1572 1221 I 1791 1221 I C
+K
+N 1791 1195 M 1572 1195 I 1572 1221 I 1791 1221 I C
+K
+: N 1855 1128 186 93 rp C
+1 1 0.801 1 scol L ; N 2041 1127 M 1854 1127 I 1854 1221 I 2041 1221 I C
+K
+0 0 0 1 scol 1878 1163 M (SourceFile)[19 16 16 10 15 16 18 7 7 0]xS
+0.602 0 0.199 1 scol N 2041 1178 M 1854 1178 I 1854 1221 I 2041 1221 I C
+K
+N 2041 1195 M 1854 1195 I 1854 1221 I 2041 1221 I C
+K
+: N 450 1406 190 93 rp C
+1 1 0.801 1 scol L ; N 640 1405 M 449 1405 I 449 1499 I 640 1499 I C
+K
+0 0 0 1 scol 470 1441 M (Deprecated)[21 16 16 10 16 15 16 8 16 0]xS
+0.602 0 0.199 1 scol N 640 1456 M 449 1456 I 449 1499 I 640 1499 I C
+K
+N 640 1473 M 449 1473 I 449 1499 I 640 1499 I C
+K
+: N 2049 1418 161 93 rp C
+1 1 0.801 1 scol L ; N 2210 1417 M 2048 1417 I 2048 1511 I 2210 1511 I C
+K
+0 0 0 1 scol 2069 1453 M (Unknown)[21 16 14 16 16 21 0]xS
+0.602 0 0.199 1 scol N 2210 1469 M 2048 1469 I 2048 1511 I 2210 1511 I C
+K
+N 2210 1485 M 2048 1485 I 2048 1511 I 2210 1511 I C
+K
+: N 2105 1128 171 93 rp C
+1 1 0.801 1 scol L ; N 2276 1127 M 2104 1127 I 2104 1221 I 2276 1221 I C
+K
+0 0 0 1 scol 2131 1163 M (Synthetic)[19 13 16 8 16 16 8 7 0]xS
+0.602 0 0.199 1 scol N 2276 1178 M 2104 1178 I 2104 1221 I 2276 1221 I C
+K
+N 2276 1195 M 2104 1195 I 2104 1221 I 2276 1221 I C
+K
+: N 521 1128 240 93 rp C
+1 1 0.801 1 scol L ; N 761 1127 M 520 1127 I 520 1221 I 761 1221 I C
+K
+0 0 0 1 scol 546 1163 M (ConstantValue)[21 16 16 15 8 16 16 8 19 16 7 16 0]xS
+0.602 0 0.199 1 scol N 761 1177 M 520 1177 I 520 1221 I 761 1221 I C
+K
+N 761 1193 M 520 1193 I 520 1221 I 761 1221 I C
+K
+: N 491 628 204 125 rp C
+1 1 0.801 1 scol L ; N 695 627 M 490 627 I 490 753 I 695 753 I C
+K
+0.496 0.496 0.496 1 scol 1 Lj 1 Lc 12 Lw solid N 495 748 M 691 748 I 691 632 I : 0.754 0.754 +S K
+; 0 0 0 1 scol 513 663 M (ClassParser)[21 7 16 15 15 19 16 10 15 16 0]xS
+0.602 0 0.199 1 scol 1 Lw solid N 695 676 M 490 676 I 490 753 I 695 753 I C
+K
+N 695 693 M 490 693 I 490 753 I 695 753 I C
+K
+0 0 0 1 scol 535 741 M (parse\(\))[16 16 10 15 16 10 0]xS
+: N 1168 1116 157 93 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 1325 1115 M 1167 1115 I 1167 1209 I 1325 1209 I C
+K
+0 0 0 1 scol 1192 1151 M (Attribute)[19 8 8 10 7 16 16 8 0]xS
+0.602 0 0.199 1 scol N 1325 1164 M 1167 1164 I 1167 1209 I 1325 1209 I C
+K
+N 1325 1181 M 1167 1181 I 1167 1209 I 1325 1209 I C
+K
+N 1225 1279 M 1225 1210 I K
+N 528 1279 M 2187 1279 I K
+N 1225 1210 M 1242 1255 I 1209 1255 I C
+: 1 1 1 1 scol O ; K
+N 1190 1410 M 1190 1279 I K
+N 1091 1329 276 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1091 1356 M (<<Method attribute>>)[17 17 23 16 8 16 16 16 8 16 8 8 10 7 16 16 8 16 17 0]xS
+0.602 0 0.199 1 scol N 1602 1417 M 1602 1279 I K
+N 1479 1381 251 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1479 1408 M (<<Code attribute>>)[17 17 21 16 16 16 8 16 8 8 10 7 16 16 8 16 17 0]xS
+0.602 0 0.199 1 scol N 1941 1222 M 1941 1279 I K
+N 1823 1234 255 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1823 1261 M (<<Class attribute>>)[17 17 21 7 16 15 15 8 16 8 8 10 7 16 16 8 16 17 0]xS
+0.602 0 0.199 1 scol N 840 1405 M 840 1279 I K
+N 728 1326 276 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 728 1353 M (<<Method attribute>>)[17 17 23 16 8 16 16 16 8 16 8 8 10 7 16 16 8 16 17 0]xS
+0.602 0 0.199 1 scol N 2132 1417 M 2132 1279 I K
+N 528 1405 M 528 1279 I K
+N 416 1326 276 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 416 1353 M (<<Method attribute>>)[17 17 23 16 8 16 16 16 8 16 8 8 10 7 16 16 8 16 17 0]xS
+0.602 0 0.199 1 scol N 1870 1575 M 1870 1279 I K
+N 1748 1523 250 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1748 1550 M (<<Code attribute>>)[17 17 21 16 16 16 8 16 8 8 10 7 16 16 8 16 17 0]xS
+0.602 0 0.199 1 scol N 1673 1222 M 1673 1279 I K
+N 1541 1234 255 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1541 1261 M (<<Class attribute>>)[17 17 21 7 16 15 15 8 16 8 8 10 7 16 16 8 16 17 0]xS
+0.602 0 0.199 1 scol N 2187 1222 M 2187 1279 I K
+N 2068 1234 255 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 2068 1261 M (<<Class attribute>>)[17 17 21 7 16 15 15 8 16 8 8 10 7 16 16 8 16 17 0]xS
+0.602 0 0.199 1 scol N 638 1222 M 638 1279 I K
+N 536 1233 245 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 536 1260 M (<<Field attribute>>)[17 17 18 7 16 7 16 8 16 8 8 10 7 16 16 8 16 17 0]xS
+: N 1130 845 233 126 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 1363 844 M 1129 844 I 1129 971 I 1363 971 I C
+K
+0 0 0 1 scol
+%%IncludeResource: font Helvetica-Oblique
+F /F1 0 /256 T /Helvetica-Oblique mF
+/F1S1C F1 [28.75 0 0 -28.75 0 0 ] mFS
+F1S1C Ji
+1150 880 M (FieldOrMethod)[18 7 16 7 16 23 10 24 16 8 16 16 0]xS
+0.602 0 0.199 1 scol N 1363 894 M 1129 894 I 1129 971 I 1363 971 I C
+K
+N 1363 911 M 1129 911 I 1129 971 I 1363 971 I C
+K
+0 0 0 1 scol 1174 960 M (getName\(\))[16 16 8 21 16 24 16 10 0]xS
+: N 571 845 214 126 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 785 844 M 570 844 I 570 971 I 785 971 I C
+K
+0 0 0 1 scol 594 880 M (AccessFlags)[19 15 15 16 15 15 18 7 16 16 0]xS
+0.602 0 0.199 1 scol N 785 894 M 570 894 I 570 971 I 785 971 I C
+K
+N 785 911 M 570 911 I 570 971 I 785 971 I C
+K
+0 0 0 1 scol 614 960 M (isPublic\(\))[7 15 19 16 16 7 7 15 10 0]xS
+0.602 0 0.199 1 scol N 1128 908 M 786 908 I K
+N 786 908 M 831 925 I 831 891 I C
+: 1 1 1 1 scol O ; K
+N 1237 1043 M 1237 972 I K
+N 992 1043 M 1497 1043 I K
+N 1237 972 M 1253 1017 I 1220 1017 I C
+: 1 1 1 1 scol O ; K
+: N 1494 1023 134 84 rp C
+1 1 0.801 1 scol L ; N 1628 1022 M 1493 1022 I 1493 1107 I 1628 1107 I C
+K
+0 0 0 1 scol F0S1C Ji
+1513 1058 M (Method)[23 16 8 16 16 0]xS
+0.602 0 0.199 1 scol N 1628 1074 M 1493 1074 I 1493 1107 I 1628 1107 I C
+K
+N 1628 1090 M 1493 1090 I 1493 1107 I 1628 1107 I C
+K
+N 1409 1111 M 1492 1085 I K
+N 1488 1110 16 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1488 1137 M (1)S
+0.602 0 0.199 1 scol N 1492 1085 M 1476 1102 I 1454 1097 I 1470 1080 I 1492 1085 I C
+: 1 1 1 1 scol O ; K
+N 1409 1111 M 1326 1136 I K
+N 1341 1157 11 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1341 1184 M (*)S
+N 1488 1110 16 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1488 1137 M (1)S
+N 1341 1157 11 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1341 1184 M (*)S
+0.602 0 0.199 1 scol N 1497 1028 M 1497 1043 I K
+: N 1734 802 235 139 rp C
+1 1 0.801 1 scol L ; N 1969 801 M 1733 801 I 1733 941 I 1969 941 I C
+K
+0 0 0 1 scol 1764 837 M (ConstantPool)[21 16 16 15 8 16 16 8 19 16 16 0]xS
+0.602 0 0.199 1 scol N 1969 853 M 1733 853 I 1733 941 I 1969 941 I C
+K
+N 1969 869 M 1733 869 I 1733 941 I 1969 941 I C
+K
+0 0 0 1 scol 1777 918 M (getConstant\(\))[16 16 8 21 16 16 15 8 16 16 8 10 0]xS
+: N 1088 610 317 160 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 1405 609 M 1087 609 I 1087 770 I 1405 770 I C
+K
+0 0 0 1 scol 1179 645 M (JavaClass)[15 16 13 16 21 7 16 15 0]xS
+0.602 0 0.199 1 scol N 1405 659 M 1087 659 I 1087 770 I 1405 770 I C
+K
+N 1405 676 M 1087 676 I 1087 770 I 1405 770 I C
+K
+0 0 0 1 scol 1131 724 M (getInterfaceNames\(\))[16 16 8 7 16 8 16 10 8 16 15 16 21 16 25 16 15 10 0]xS
+1131 757 M (getSuperclassName\(\))[16 16 8 19 16 16 16 10 15 7 16 15 15 21 16 25 16 10 0]xS
+0.602 0 0.199 1 scol N 1419 896 M 1314 771 I K
+N 1287 794 16 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1287 821 M (1)S
+0.602 0 0.199 1 scol N 1314 771 M 1336 779 I 1340 802 I 1318 794 I 1314 771 I C
+: 1 1 1 1 scol O ; K
+N 1419 896 M 1524 1021 I K
+N 1539 966 11 34 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1539 993 M (*)S
+N 1287 794 16 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1287 821 M (1)S
+N 1539 966 11 34 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1539 993 M (*)S
+1 1 1 1 scol [ 72 24 ] 0 sd N 696 690 M 1086 690 I K
+0 0 0 1 scol [ 72 24 ] 0 sd N 696 690 M 1086 690 I K
+3 Lw solid N 1086 690 M 1059 701 I : 0.754 0.754 +S K
+; N 1086 690 M 1059 679 I : 0.754 0.754 +S K
+; N 847 641 164 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 847 668 M (<<creates>>)[17 17 15 10 16 16 8 16 15 17 0]xS
+0.602 0 0.199 1 scol 1 Lw solid N 1569 786 M 1406 737 I K
+N 1569 786 M 1732 835 I K
+N 1086 751 M 786 866 I K
+N 786 866 M 834 866 I 822 834 I C
+: 1 1 1 1 scol O ; K
+: N 865 1023 134 84 rp C
+1 1 0.801 1 scol L ; N 999 1022 M 864 1022 I 864 1107 I 999 1107 I C
+K
+0 0 0 1 scol 899 1058 M (Field)[18 7 16 7 0]xS
+0.602 0 0.199 1 scol N 999 1072 M 864 1072 I 864 1107 I 999 1107 I C
+K
+N 999 1089 M 864 1089 I 864 1107 I 999 1107 I C
+K
+N 1083 1111 M 1000 1086 I K
+N 990 1111 16 34 rp C
+1 1 1 1 scol L 0 0 0 1 scol 990 1138 M (1)S
+0.602 0 0.199 1 scol N 1000 1086 M 1023 1081 I 1039 1098 I 1017 1102 I 1000 1086 I C
+: 1 1 1 1 scol O ; K
+N 1083 1111 M 1166 1136 I K
+N 1165 1079 11 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1165 1106 M (*)S
+N 990 1111 16 34 rp C
+1 1 1 1 scol L 0 0 0 1 scol 990 1138 M (1)S
+N 1165 1079 11 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1165 1106 M (*)S
+0.602 0 0.199 1 scol N 992 1067 M 992 1043 I K
+N 1072 896 M 1177 771 I K
+N 1190 794 16 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1190 821 M (1)S
+0.602 0 0.199 1 scol N 1177 771 M 1173 794 I 1150 802 I 1155 779 I 1177 771 I C
+: 1 1 1 1 scol O ; K
+N 1072 896 M 967 1021 I K
+N 1004 1018 11 34 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1004 1045 M (*)S
+N 1190 794 16 33 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1190 821 M (1)S
+N 1004 1018 11 34 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1004 1045 M (*)S
+LH
+%%PageTrailer
+
+%%Trailer
+%%DocumentNeededResources:
+%%+ font Helvetica-Oblique
+%%+ font Helvetica
+%%DocumentSuppliedResources:
+Pscript_WinNT_Incr dup /terminate get exec
+%%EOF
+grestore
+
+%%EndDocument
+ @endspecial 990 5316 a Fq(Figur)n(e)26 b(3:)31 b(UML)24
+b(diagram)i(for)f(the)h Fo(BCEL)i Fq(API)1863 5712 y(11)p
+eop
+%%Page: 12 12
+12 11 bop 146 407 a Ft(As)17 b(mentioned)f(in)h(section)g(2.1)g(alr)n
+(eady)-10 b(,)19 b(several)e(components)e(may)j(contain)f
+Fs(attribute)i Ft(objects:)25 b(classes,)0 520 y(\002elds,)43
+b(methods,)f(and)e Ff(Code)e Ft(objects)h(\(intr)n(oduced)g(in)h
+(section)f(2.3\).)81 b(The)39 b(latter)g(is)h(an)g(attribute)g(it-)0
+633 y(self)f(that)h(contains)f(the)g(actual)h(byte)f(code)f(array)-10
+b(,)44 b(the)39 b(maximum)i(stack)e(size,)k(the)c(number)g(of)h(local)0
+746 y(variables,)c(a)d(table)f(of)h(handled)e(exceptions,)i(and)f(some)
+g(optional)g(debugging)e(information)j(coded)e(as)0 858
+y Ff(LineNumberTable)23 b Ft(and)29 b Ff(LocalVariableTa)o(bl)o(e)24
+b Ft(attributes.)47 b(Attributes)27 b(ar)n(e)j(in)g(general)f
+(speci\002c)0 971 y(to)c(some)g(data)g(str)o(uctur)n(e,)g(i.e.)37
+b(no)25 b(two)g(components)f(shar)n(e)h(the)g(same)g(kind)h(of)f
+(attribute,)h(though)e(this)h(is)0 1084 y(not)h(explicitly)h
+(forbidden.)40 b(In)26 b(the)g(\002gur)n(e)g(the)g Ff(Attribute)d
+Ft(classes)j(ar)n(e)i(marked)e(with)g(the)g(component)0
+1197 y(they)21 b(belong)h(to.)0 1482 y Fm(3.2)119 b(Class)30
+b(repository)0 1659 y Ft(Using)35 b(the)g(pr)n(ovided)g
+Ff(Repository)c Ft(class,)39 b(r)n(eading)d(class)g(\002les)g(into)f(a)
+h Ff(JavaClass)c Ft(object)k(is)g(quite)0 1772 y(simple:)109
+1970 y Ff(JavaClass)51 b(clazz)h(=)i(Repository.look)o(up)o(Cl)o(as)o
+(s\()o("ja)o(va)o(.l)o(an)o(g.)o(Str)o(in)o(g")o(\);)146
+2168 y Ft(The)19 b(r)n(epository)e(also)i(contains)g(methods)f(pr)n
+(oviding)h(the)f(dynamic)i(equivalent)f(of)g(the)g Ff(instanceof)0
+2281 y Ft(operator)-7 b(,)21 b(and)i(other)e(useful)h(r)n(outines:)109
+2479 y Ff(if\(Repository.i)o(ns)o(ta)o(nce)o(Of)o(\(c)o(la)o(zz)o(,)49
+b(super_class\))g({)218 2592 y(...)109 2705 y(})0 2961
+y Fg(3.2.1)99 b(Accessing)25 b(class)h(\002le)f(data)0
+3138 y Ft(Information)39 b(within)g(the)f(class)i(\002le)f(components)e
+(may)j(be)e(accessed)g(like)i(Java)g(Beans)e(via)j(intuitive)0
+3251 y(set/get)19 b(methods.)26 b(All)c(of)g(them)f(also)h(de\002ne)e
+(a)i Ff(toString\(\))17 b Ft(method)j(so)h(that)h(implementing)f(a)h
+(simple)0 3364 y(class)h(viewer)f(is)h(very)f(easy)-10
+b(.)27 b(In)22 b(fact)i(all)g(of)f(the)e(examples)i(used)e(her)n(e)h
+(have)h(been)f(pr)n(oduced)f(this)h(way:)109 3562 y Ff(System.out.prin)
+o(tl)o(n\()o(cla)o(zz)o(\);)109 3675 y(printCode\(clazz)o(.g)o(et)o
+(Met)o(ho)o(ds)o(\(\))o(\);)109 3788 y(...)109 3901 y(public)52
+b(static)g(void)g(printCode\(Method)o([])c(methods\))j({)218
+4014 y(for\(int)h(i=0;)g(i)i(<)g(methods.length;)48 b(i++\))53
+b({)327 4127 y(System.out.prin)o(tln)o(\(m)o(et)o(ho)o(ds)o([i])o(\);)
+327 4352 y(Code)g(code)g(=)h(methods[i].get)o(Cod)o(e\()o(\);)327
+4465 y(if\(code)e(!=)h(null\))g(//)g(Non-abstract)c(method)436
+4578 y(System.out.print)o(ln)o(\(c)o(od)o(e\))o(;)218
+4691 y(})109 4804 y(})0 5060 y Fg(3.2.2)99 b(Analyzing)25
+b(class)g(data)0 5237 y Ft(Last)g(but)h(not)f(least,)h
+Fe(BCEL)i Ft(supports)23 b(the)i Fs(V)-7 b(isitor)28
+b Ft(design)d(pattern)g([GHJV95)q(],)h(so)g(one)f(can)i(write)e
+(visitor)0 5350 y(objects)e(to)h(traverse)f(and)h(analyze)h(the)e
+(contents)f(of)i(a)h(class)f(\002le.)32 b(Included)23
+b(in)h(the)g(distribution)f(is)h(a)h(class)0 5463 y Ff(JasminVisitor)17
+b Ft(that)22 b(converts)g(class)h(\002les)f(into)h(the)e(Jasmin)j
+(assembler)e(language)h([MD97)q(].)1863 5712 y Fq(12)p
+eop
+%%Page: 13 13
+13 12 bop 0 407 a Fm(3.3)119 b(ClassGen)0 587 y Ft(This)26
+b(part)g(of)g(the)g(API)g(\(package)g Ff(de.fub.bytecod)o(e.)o(gen)o
+(er)o(ic)o Ft(\))21 b(supplies)k(an)i(abstraction)f(level)h(for)0
+700 y(cr)n(eating)c(or)f(transforming)g(class)h(\002les)f(dynamically)
+-10 b(.)29 b(It)22 b(makes)g(the)g(static)g(constraints)g(of)g(Java)j
+(class)d(\002les)0 813 y(like)35 b(the)e(har)n(d-coded)h(byte)f(code)h
+(addr)n(esses)e(generic.)63 b(The)34 b(generic)f(constant)h(pool,)j
+(for)d(example,)j(is)0 926 y(implemented)23 b(by)h(the)f(class)h
+Ff(ConstantPoolGen)18 b Ft(which)24 b(of)n(fers)g(methods)e(for)i
+(adding)f(dif)n(fer)n(ent)h(types)0 1039 y(of)h(constants.)34
+b(Accor)n(dingly)-10 b(,)25 b Ff(ClassGen)d Ft(of)n(fers)i(an)i
+(interface)f(to)f(add)h(methods,)f(\002elds,)g(and)h(attributes.)0
+1152 y(Figur)n(e)d(4)h(gives)f(an)h(overview)g(of)f(this)h(part)f(of)h
+(the)e(API.)0 1422 y Fg(3.3.1)99 b(T)-9 b(ypes)0 1603
+y Ft(W)h(e)28 b(abstract)i(fr)n(om)f(the)g(concr)n(ete)f(details)h(of)g
+(the)g(type)e(signatur)n(e)i(syntax)f(\(see)g(2.5\))i(by)f(intr)n
+(oducing)g(the)0 1716 y Ff(Type)23 b Ft(class,)k(which)e(is)h(used,)e
+(for)h(example,)g(by)g(methods)f(to)g(de\002ne)g(their)h(r)n(eturn)f
+(and)i(ar)n(gument)e(types.)0 1829 y(Concr)n(ete)j(sub-classes)f(ar)n
+(e)i Ff(BasicType)p Ft(,)c Ff(ObjectType)p Ft(,)f(and)k
+Ff(ArrayType)d Ft(which)j(consists)f(of)h(the)g(el-)0
+1942 y(ement)33 b(type)f(and)i(the)f(number)g(of)h(dimensions.)60
+b(For)33 b(commonly)h(used)f(types)e(the)i(class)i(of)n(fers)e(some)0
+2055 y(pr)n(ede\002ned)23 b(constants.)36 b(For)25 b(example)h(the)f
+(method)f(signatur)n(e)h(of)h(the)f Ff(main)f Ft(method)h(as)g(shown)g
+(in)h(sec-)0 2168 y(tion)c(2.5)i(is)e(r)n(epr)n(esented)e(by:)109
+2403 y Ff(Type)162 b(return_type)49 b(=)55 b(Type.VOID;)109
+2516 y(Type[])d(arg_types)159 b(=)55 b(new)e(Type[])f({)i(new)f
+(ArrayType\(Type)o(.ST)o(RI)o(NG)o(,)48 b(1\))54 b(};)146
+2750 y(Type)18 b Ft(also)i(contains)g(methods)e(to)h(convert)h(types)d
+(into)j(textual)f(signatur)n(es)g(and)h(vice)g(versa.)27
+b(The)19 b(sub-)0 2863 y(classes)24 b(contain)g(implementations)g(of)g
+(the)f(r)n(outines)g(and)h(constraints)f(speci\002ed)g(by)h(the)f(Java)
+j(Language)0 2976 y(Speci\002cation)d([GJS96)q(].)0 3247
+y Fg(3.3.2)99 b(Generic)24 b(\002elds)h(and)g(methods)0
+3427 y Ft(Fields)f(ar)n(e)i(r)n(epr)n(esented)c(by)j
+Ff(FieldGen)c Ft(objects,)k(which)g(may)h(be)e(fr)n(eely)h(modi\002ed)f
+(by)h(the)f(user)-7 b(.)34 b(If)25 b(they)0 3540 y(have)e(the)g(access)
+g(rights)f Ff(static)52 b(final)p Ft(,)20 b(i.e.)29 b(ar)n(e)24
+b(constants)d(and)i(of)g(basic)i(type,)c(they)h(may)h(optionally)0
+3653 y(have)g(an)g(initializing)i(value.)146 3768 y(Generic)d(methods)e
+(contain)i(methods)e(to)h(add)h(exceptions)e(the)h(method)f(may)i(thr)n
+(ow)-8 b(,)21 b(local)i(variables,)0 3881 y(and)g(exception)e
+(handlers.)27 b(The)22 b(latter)g(two)g(ar)n(e)h(r)n(epr)n(esented)c
+(by)k(user)n(-con\002gurable)f(objects)g(as)g(well.)29
+b(Be-)0 3994 y(cause)20 b(exception)e(handlers)i(and)f(local)j
+(variables)f(contain)f(r)n(efer)n(ences)f(to)g(byte)g(code)h(addr)n
+(esses,)d(they)i(also)0 4107 y(take)j(the)g(r)n(ole)h(of)g(an)g
+Fs(instruction)h(tar)n(geter)i Ft(in)d(our)f(terminology)-10
+b(.)27 b(Instr)o(uction)22 b(tar)n(geters)f(contain)i(a)g(method)0
+4220 y Ff(updateTarget\(\))i Ft(to)31 b(r)n(edir)n(ect)g(a)h(r)n(efer)n
+(ence.)54 b(Generic)32 b(\(non-abstract\))g(methods)d(r)n(efer)i(to)g
+Fs(instruction)0 4332 y(lists)g Ft(that)e(consist)f(of)h(instr)o
+(uction)g(objects.)47 b(Refer)n(ences)28 b(to)g(byte)g(code)h(addr)n
+(esses)e(ar)n(e)i(implemented)f(by)0 4445 y(handles)22
+b(to)g(instr)o(uction)g(objects.)28 b(This)22 b(is)h(explained)f(in)h
+(mor)n(e)f(detail)h(in)g(the)f(following)h(sections.)146
+4560 y(The)32 b(maximum)h(stack)f(size)g(needed)e(by)i(the)f(method)g
+(and)h(the)f(maximum)j(number)e(of)g(local)i(vari-)0
+4673 y(ables)25 b(used)e(may)i(be)f(set)f(manually)j(or)e(computed)f
+(via)j(the)d Ff(setMaxStack\(\))c Ft(and)24 b Ff(setMaxLocals\(\))0
+4786 y Ft(methods)d(automatically)-10 b(.)0 5056 y Fg(3.3.3)99
+b(Instructions)0 5237 y Ft(Modeling)25 b(instr)o(uctions)g(as)h
+(objects)f(may)h(look)f(somewhat)g(odd)f(at)i(\002rst)f(sight,)g(but)h
+(in)g(fact)h(enables)e(pr)n(o-)0 5350 y(grammers)g(to)f(obtain)i(a)g
+(high-level)g(view)f(upon)f(contr)n(ol)i(\003ow)f(without)f(handling)h
+(details)g(like)h(concr)n(ete)0 5463 y(byte)c(code)h(of)n(fsets.)29
+b(Instr)o(uctions)22 b(consist)g(of)h(a)h(tag,)f(i.e.)30
+b(an)24 b(opcode,)d(their)i(length)g(in)h(bytes)e(and)h(an)h(of)n(fset)
+1863 5712 y Fq(13)p eop
+%%Page: 14 14
+14 13 bop 383 5113 a @beginspecial 13 @llx 12 @lly 535
+@urx 830 @ury 3671 @rwi @setspecial
+%%BeginDocument: eps/classgen.eps
+%!PS-Adobe-3.0 EPSF-3.0
+%%Title: Rose Diagram(s)
+%%Creator: AdobePS5.dll Version 5.0
+%%CreationDate: 7/7/1999 17:42:13
+%%Pages: 1
+%%Orientation: Portrait
+%%PageOrder: Ascend
+%%DocumentNeededResources: (atend)
+%%DocumentSuppliedResources: (atend)
+%%DocumentData: Clean7Bit
+%%TargetDevice: (HP LaserJet 5Si) (2014.108) 1
+%%LanguageLevel: 2
+%%BoundingBox: 13 12 535 830
+%%EndComments
+%%BeginProcSet: epsffit 1 0
+gsave
+1249.738 -7.476 translate
+90 rotate
+1.623 1.623 scale
+%%EndProcSet
+
+
+%%BeginDefaults
+%%PageBoundingBox: 13 12 582 830
+%%EndDefaults
+
+%%BeginProlog
+%%BeginResource: file Pscript_WinNT_ErrorHandler 5.0 0
+/currentpacking where{pop/oldpack currentpacking def/setpacking where{pop false
+setpacking}if}if/$brkpage 64 dict def $brkpage begin/prnt{dup type/stringtype
+ne{=string cvs}if dup length 6 mul/tx exch def/ty 10 def currentpoint/toy exch
+def/tox exch def 1 setgray newpath tox toy 2 sub moveto 0 ty rlineto tx 0
+rlineto 0 ty neg rlineto closepath fill tox toy moveto 0 setgray show}bind def
+/nl{currentpoint exch pop lmargin exch moveto 0 -10 rmoveto}def/=={/cp 0 def
+typeprint nl}def/typeprint{dup type exec}readonly def/lmargin 72 def/rmargin 72
+def/tprint{dup length cp add rmargin gt{nl/cp 0 def}if dup length cp add/cp
+exch def prnt}readonly def/cvsprint{=string cvs tprint( )tprint}readonly def
+/integertype{cvsprint}readonly def/realtype{cvsprint}readonly def/booleantype
+{cvsprint}readonly def/operatortype{(--)tprint =string cvs tprint(-- )tprint}
+readonly def/marktype{pop(-mark- )tprint}readonly def/dicttype{pop
+(-dictionary- )tprint}readonly def/nulltype{pop(-null- )tprint}readonly def
+/filetype{pop(-filestream- )tprint}readonly def/savetype{pop(-savelevel- )
+tprint}readonly def/fonttype{pop(-fontid- )tprint}readonly def/nametype{dup
+xcheck not{(/)tprint}if cvsprint}readonly def/stringtype{dup rcheck{(\()tprint
+tprint(\))tprint}{pop(-string- )tprint}ifelse}readonly def/arraytype{dup rcheck
+{dup xcheck{({)tprint{typeprint}forall(})tprint}{([)tprint{typeprint}forall(])
+tprint}ifelse}{pop(-array- )tprint}ifelse}readonly def/packedarraytype{dup
+rcheck{dup xcheck{({)tprint{typeprint}forall(})tprint}{([)tprint{typeprint}
+forall(])tprint}ifelse}{pop(-packedarray- )tprint}ifelse}readonly def/courier
+/Courier findfont 10 scalefont def end errordict/handleerror{systemdict begin
+$error begin $brkpage begin newerror{/newerror false store vmstatus pop pop 0
+ne{grestoreall}if showpage initgraphics courier setfont lmargin 720 moveto
+(ERROR: )prnt errorname prnt nl(OFFENDING COMMAND: )prnt/command load prnt
+$error/ostack known{nl nl(STACK:)prnt nl nl $error/ostack get aload length{==}
+repeat}if systemdict/showpage get exec(%%[ Error: )print errorname =print
+(; OffendingCommand: )print/command load =print( ]%%)= flush}if end end end}dup
+0 systemdict put dup 4 $brkpage put bind readonly put/currentpacking where{pop
+/setpacking where{pop oldpack setpacking}if}if
+%%EndResource
+userdict /Pscript_WinNT_Incr 230 dict dup begin put
+%%BeginResource: file Pscript_FatalError 5.0 0
+/FatalErrorIf{{initgraphics findfont exch scalefont setfont counttomark 3 div
+cvi{moveto show}repeat showpage quit}{cleartomark}ifelse}bind def
+%%EndResource
+/VM?{vmstatus exch sub exch pop gt{[
+(This job requires more memory than is available in this printer.)100 500
+(Try one or more of the following, and then print again:)100 485
+(For the output format, choose Optimize For Portability.)115 470
+(In the Device Settings page, make sure the Available PostScript Memory is accurate.)
+115 455(Reduce the number of fonts in the document.)115 440
+(Print the document in parts.)115 425 12/Times-Roman showpage
+(%%[ PrinterError: Low Printer VM ]%%)= true FatalErrorIf}if}bind def
+%%BeginResource: file Pscript_Win_Basic 5.0 0
+/d/def load def/,/load load d/~/exch , d/?/ifelse , d/!/pop , d/`/begin , d/^
+/index , d/@/dup , d/+/translate , d/$/roll , d/U/userdict , d/M/moveto , d/-
+/rlineto , d/&/currentdict , d/:/gsave , d/;/grestore , d/F/false , d/T/true ,
+d/N/newpath , d/E/end , d/Ac/arc , d/An/arcn , d/A/ashow , d/D/awidthshow , d/C
+/closepath , d/V/div , d/O/eofill , d/L/fill , d/I/lineto , d/-c/curveto , d/-M
+/rmoveto , d/+S/scale , d/Ji/setfont , d/Lc/setlinecap , d/Lj/setlinejoin , d
+/Lw/setlinewidth , d/Lm/setmiterlimit , d/sd/setdash , d/S/show , d/LH/showpage
+, d/K/stroke , d/W/widthshow , d/R/rotate , d/P/eoclip , d/L2? false
+/languagelevel where{pop languagelevel 2 ge{pop true}if}if d L2?{/xS/xshow , d
+/yS/yshow , d/zS/xyshow , d}if/b{bind d}bind d/bd{bind d}bind d/xd{~ d}bd/ld{,
+d}bd/lw/Lw ld/lc/Lc ld/lj/Lj ld/sg/setgray ld/ADO_mxRot null d/self & d/OrgMx
+matrix currentmatrix d/reinitialize{: OrgMx setmatrix[/TextInit/GraphInit
+/UtilsInit counttomark{@ where{self eq}{F}?{cvx exec}{!}?}repeat cleartomark ;}
+b/initialize{`{/ADO_mxRot ~ d/TextInitialised? F d reinitialize E}{U
+/Pscript_Win_Data 230 dict @ ` put/ADO_mxRot ~ d/TextInitialised? F d
+reinitialize}?}b/terminate{!{& self eq{exit}{E}?}loop E}b/suspend/terminate , d
+/resume{` Pscript_Win_Data `}b/snap{transform 0.25 sub round 0.25 add ~ 0.25
+sub round 0.25 add ~ itransform}b/dsnap{dtransform round ~ round ~ idtransform}
+b<04>cvn{}d/rr{1 ^ 0 - 0 ~ - neg 0 - C}b/rp{4 2 $ M 1 ^ 0 - 0 ~ - neg 0 -}b
+/solid{[]0 sd}b/g{@ not{U/DefIf_save save put}if U/DefIf_bool 2 ^ put}b
+/DefIf_El{if U/DefIf_bool get not @{U/DefIf_save get restore}if}b/e{DefIf_El !}
+b/UDF{L2?{undefinefont}{!}?}b/UDR{L2?{undefineresource}{! !}?}b
+%%EndResource
+%%BeginResource: file Pscript_Win_Utils_L2 5.0 0
+/rf/rectfill , d/fx{1 1 dtransform @ 0 ge{1 sub 0.5}{1 add -0.5}? 3 -1 $ @ 0 ge
+{1 sub 0.5}{1 add -0.5}? 3 1 $ 4 1 $ idtransform 4 -2 $ idtransform}b/BZ{4 -2 $
+snap + +S fx rf}b/rs/rectstroke , d/rc/rectclip , d/UtilsInit{currentglobal{F
+setglobal}if}b/scol{! setcolor}b/colspA/DeviceGray d/colspABC/DeviceRGB d
+/colspRefresh{colspABC setcolorspace}b/SetColSpace{colspABC setcolorspace}b
+%%EndResource
+end
+%%EndProlog
+
+%%BeginSetup
+[ 1 0 0 1 0 0 ] false Pscript_WinNT_Incr dup /initialize get exec
+1 setlinecap 1 setlinejoin
+/mysetup [ 0.24 0 0 -0.24 13.43905 829.74047 ] def
+%%EndSetup
+
+%%Page: 1 1
+%%PageBoundingBox: 13 12 582 830
+%%EndPageComments
+%%BeginPageSetup
+/DeviceRGB dup setcolorspace /colspABC exch def mysetup concat colspRefresh
+%%EndPageSetup
+
+Pscript_WinNT_Incr begin
+%%BeginResource: file Pscript_Win_GdiObject 5.0 0
+/SavedCTM null d/CTMsave{/SavedCTM SavedCTM currentmatrix d}b/CTMrestore
+{SavedCTM setmatrix}b/mp null d/ADO_mxRot null d/GDIHMatrix null d
+/GDIHPatternDict 22 dict d GDIHPatternDict `/PatternType 1 d/PaintType 2 d/Reps
+L2?{1}{5}? d/XStep 8 Reps mul d/YStep XStep d/BBox[0 0 XStep YStep]d/TilingType
+1 d/PaintProc{` 1 Lw[]0 sd PaintData , exec E}b/FGnd null d/BGnd null d
+/HS_Horizontal{horiz}b/HS_Vertical{vert}b/HS_FDiagonal{fdiag}b/HS_BDiagonal
+{biag}b/HS_Cross{horiz vert}b/HS_DiagCross{fdiag biag}b/MaxXYStep XStep YStep
+gt{XStep}{YStep}? d/horiz{Reps{0 4 M XStep 0 - 0 8 +}repeat 0 -8 Reps mul + K}b
+/vert{Reps{4 0 M 0 YStep - 8 0 +}repeat 0 -8 Reps mul + K}b/biag{Reps{0 0 M
+MaxXYStep @ - 0 YStep neg M MaxXYStep @ - 0 8 +}repeat 0 -8 Reps mul + 0 YStep
+M 8 8 - K}b/fdiag{Reps{0 0 M MaxXYStep @ neg - 0 YStep M MaxXYStep @ neg - 0 8
++}repeat 0 -8 Reps mul + MaxXYStep @ M 8 -8 - K}b E/makehatch{4 -2 $/yOrg ~ d
+/xOrg ~ d GDIHPatternDict/PaintData 3 -1 $ put CTMsave GDIHMatrix setmatrix
+GDIHPatternDict matrix xOrg yOrg + mp CTMrestore ~ U ~ 2 ^ put}b/h0{/h0
+/HS_Horizontal makehatch}b/h1{/h1/HS_Vertical makehatch}b/h2{/h2/HS_FDiagonal
+makehatch}b/h3{/h3/HS_BDiagonal makehatch}b/h4{/h4/HS_Cross makehatch}b/h5{/h5
+/HS_DiagCross makehatch}b/GDIBWPatternDict 25 dict @ `/PatternType 1 d
+/PaintType L2?{1}{2}? d/RepsV L2?{1}{6}? d/RepsH L2?{1}{5}? d/BBox[0 0 RepsH 1]
+d/TilingType 1 d/XStep 1 d/YStep 1 d/Height 8 RepsV mul d/Width 8 d/mx[Width 0
+0 Height neg 0 Height]d/FGnd null d/BGnd null d/SetBGndFGnd L2?{{FGnd null ne
+{FGnd aload ! scol BBox aload ! 2 ^ sub ~ 3 ^ sub ~ rf}if BGnd null ne{BGnd
+aload ! scol}if}}{{}}? b/PaintProc{` SetBGndFGnd RepsH{Width Height F mx
+PaintData imagemask Width 0 +}repeat E}b E d/GDIBWPatternMx null d/pfprep{save
+8 1 $/PatternOfTheDay 8 1 $ GDIBWPatternDict `/yOrg ~ d/xOrg ~ d/PaintData ~ d
+/yExt ~ d/Width ~ d/FGnd ~ d/BGnd ~ d/Height yExt RepsV mul d/mx[Width 0 0
+Height 0 0]d E : GDIBWPatternDict ` Width Height E dsnap +S/GDIBWPatternMx
+matrix currentmatrix d ; CTMsave GDIBWPatternMx setmatrix GDIBWPatternDict @ `
+xOrg yOrg E matrix + mp CTMrestore ~ !}b/pfbf{/fEOFill ~ d pfprep hbf fEOFill
+{O}{L}? restore}b/GraphInit{GDIHMatrix null eq{/SavedCTM matrix d : ADO_mxRot
+concat 0 0 snap + : 0.48 @ GDIHPatternDict ` YStep mul ~ XStep mul ~ dsnap
+YStep V ~ XStep V ~ E +S/GDIHMatrix matrix currentmatrix readonly d ; : 0.24
+-0.24 +S GDIBWPatternDict ` Width Height E dsnap +S/GDIBWPatternMx matrix
+currentmatrix readonly d ; ;}if}b
+%%EndResource
+%%BeginResource: file Pscript_Win_GdiObject_L2 5.0 0
+/mp/makepattern , d/hbf{setpattern}b/hf{:/fEOFill ~ d ~ ! setpattern fEOFill{O}
+{L}? ;}b/pbf{: !/fEOFill ~ d GDIBWPatternDict `/yOrg ~ d/xOrg ~ d/PaintData ~ d
+/OutputBPP ~ d/Height ~ d/Width ~ d/PaintType 1 d/PatternType 1 d/TilingType 1
+d/BBox[0 0 Width Height]d/XStep Width d/YStep Height d/mx xOrg yOrg matrix + d
+20 dict @ `/ImageType 1 d/Width Width d/Height Height d/ImageMatrix mx d
+/BitsPerComponent 8 d OutputBPP 24 eq{/Decode[0 1 0 1 0 1]d}{OutputBPP 8 eq{
+/Decode[0 1]d}{/Decode[0 1 0 1 0 1 0 1]d}?}?/DataSource{PaintData}d E/ImageDict
+~ d/PaintProc{` ImageDict image E}b & mx makepattern setpattern E fEOFill{O}{L}
+? ;}b
+%%EndResource
+end reinitialize
+: N 234 594 236 124 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol 1 Lw N 470 593 M 233 593 I 233 718 I 470 718 I C
+K
+0 0 0 1 scol Pscript_WinNT_Incr begin
+%%BeginResource: file Pscript_Text 5.0 0
+/TextInit{TextInitialised? not{/Pscript_Windows_Font & d/TextInitialised? T d
+/fM[1 0 0 1 0 0]d/mFM matrix d/iMat[1 0 0.212557 1 0 0]d}if}b/copyfont{1 ^
+length add dict `{1 ^/FID ne{d}{! !}?}forall & E}b/EncodeDict 11 dict d/bullets
+{{/bullet}repeat}b/rF{3 copyfont @ ` ~ EncodeDict ~ get/Encoding ~ 3 ^/0 eq{&
+/CharStrings known{CharStrings/Eth known not{! EncodeDict/ANSIEncodingOld get}
+if}if}if d E}b/mF{@ 7 1 $ findfont ~{@/Encoding get @ StandardEncoding eq{! T}{
+{ISOLatin1Encoding}stopped{! F}{eq}?{T}{@ ` T 32 1 127{Encoding 1 ^ get
+StandardEncoding 3 -1 $ get eq and}for E}?}?}{F}?{1 ^ ~ rF}{0 copyfont}? 6 -2 $
+{T pd_AddEm87 ~ !}{! ~ !/pd_charset @ where{~ get 128 eq{@ FDV 2 copy get @
+length array copy put pd_CoverFCRange}if}{!}?}? 2 ^ ~ definefont fM 5 4 -1 $
+put fM 4 0 put fM makefont Pscript_Windows_Font 3 1 $ put}b/sLT{: Lw -M
+currentpoint snap M 0 - 0 Lc K ;}b/xUP null d/yUP null d/uW null d/xSP null d
+/ySP null d/sW null d/sSU{N/uW ~ d/yUP ~ d/xUP ~ d}b/sU{xUP yUP uW sLT}b/sST{N
+/sW ~ d/ySP ~ d/xSP ~ d}b/sT{xSP ySP sW sLT}b/sR{: + R 0 0 M}b/sRxy{: matrix
+astore concat 0 0 M}b/eR/; , d/AddOrigFP{{&/FontInfo known{&/FontInfo get
+length 6 add}{6}? dict `/WinPitchAndFamily ~ d/WinCharSet ~ d/OrigFontType ~ d
+/OrigFontStyle ~ d/OrigFontName ~ d & E/FontInfo ~ d}{! ! ! ! !}?}b/mFS
+{makefont Pscript_Windows_Font 3 1 $ put}b/mF42D{0 copyfont `/FontName ~ d 2
+copy ~ sub 1 add dict `/.notdef 0 d 2 copy 1 ~{@ 3 ^ sub Encoding ~ get ~ d}for
+& E/CharStrings ~ d ! ! & @ E/FontName get ~ definefont}bind d/mF42{15 dict ` @
+4 1 $/FontName ~ d/FontType 0 d/FMapType 2 d/FontMatrix[1 0 0 1 0 0]d 1 ^ 254
+add 255 idiv @ array/Encoding ~ d 0 1 3 -1 $ 1 sub{@ Encoding 3 1 $ put}for
+/FDepVector Encoding length array d/CharStrings 2 dict `/.notdef 0 d & E d 0 1
+Encoding length 1 sub{@ @ 10 lt{! FontName length 1 add string}{100 lt{FontName
+length 2 add string}{FontName length 3 add string}?}? @ 0 FontName @ length
+string cvs putinterval @ 3 -1 $ @ 4 1 $ 3 string cvs FontName length ~
+putinterval cvn 1 ^ 256 mul @ 255 add 3 -1 $ 4 ^ findfont mF42D FDepVector 3 1
+$ put}for & @ E/FontName get ~ definefont ! ! ! mF}b/UmF{L2?
+{Pscript_Windows_Font ~ undef}{!}?}b/UmF42{@ findfont/FDepVector get{/FontName
+get undefinefont}forall undefinefont}b
+%%EndResource
+end reinitialize
+Pscript_WinNT_Incr begin
+%%BeginResource: file Pscript_Encoding256 5.0 0
+/CharCol256Encoding[/.notdef/breve/caron/dotaccent/dotlessi/fi/fl/fraction
+/hungarumlaut/Lslash/lslash/minus/ogonek/ring/Zcaron/zcaron/.notdef/.notdef
+/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
+/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/exclam/quotedbl/numbersign
+/dollar/percent/ampersand/quotesingle/parenleft/parenright/asterisk/plus/comma
+/hyphen/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon
+/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S
+/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/asciicircum/underscore/grave
+/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright
+/asciitilde/.notdef/.notdef/.notdef/quotesinglbase/florin/quotedblbase/ellipsis
+/dagger/daggerdbl/circumflex/perthousand/Scaron/guilsinglleft/OE/.notdef
+/.notdef/.notdef/.notdef/quoteleft/quoteright/quotedblleft/quotedblright/bullet
+/endash/emdash/tilde/trademark/scaron/guilsinglright/oe/.notdef/.notdef
+/Ydieresis/.notdef/exclamdown/cent/sterling/currency/yen/brokenbar/section
+/dieresis/copyright/ordfeminine/guillemotleft/logicalnot/.notdef/registered
+/macron/degree/plusminus/twosuperior/threesuperior/acute/mu/paragraph
+/periodcentered/cedilla/onesuperior/ordmasculine/guillemotright/onequarter
+/onehalf/threequarters/questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis
+/Aring/AE/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute
+/Icircumflex/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
+/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls
+/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla/egrave/eacute
+/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis/eth/ntilde/ograve
+/oacute/ocircumflex/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex
+/udieresis/yacute/thorn/ydieresis]def EncodeDict/256 CharCol256Encoding put
+%%EndResource
+end reinitialize
+
+%%IncludeResource: font Helvetica
+F /F0 0 /256 T /Helvetica mF
+/F0S29 F0 [41 0 0 -41 0 0 ] mFS
+F0S29 Ji
+257 643 M (BasicType)[27 23 20 8 21 26 19 23 0]xS
+0.602 0 0.199 1 scol N 470 659 M 233 659 I 233 718 I 470 718 I C
+K
+N 470 682 M 233 682 I 233 718 I 470 718 I C
+K
+: N 252 292 360 184 rp C
+1 1 0.801 1 scol L ; N 612 291 M 251 291 I 251 476 I 612 476 I C
+K
+0 0 0 1 scol 326 341 M (ObjectType)[32 23 10 23 21 11 26 19 23 0]xS
+0.602 0 0.199 1 scol N 612 357 M 251 357 I 251 476 I 612 476 I C
+K
+N 612 380 M 251 380 I 251 476 I 612 476 I C
+K
+0 0 0 1 scol 310 448 M (getClassName\(\))[23 23 11 30 10 23 20 20 30 23 36 23 14 0]xS
+: N 699 292 362 184 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 1061 291 M 698 291 I 698 476 I 1061 476 I C
+K
+0 0 0 1 scol 786 341 M (ArrayType)[27 14 14 23 19 26 19 23 0]xS
+0.602 0 0.199 1 scol N 1061 357 M 698 357 I 698 476 I 1061 476 I C
+K
+N 1061 380 M 698 380 I 698 476 I 1061 476 I C
+K
+0 0 0 1 scol 757 448 M (getDimensions\(\))[23 23 11 30 8 36 23 23 20 8 23 23 20 14 0]xS
+: N 532 594 312 124 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 844 593 M 531 593 I 531 718 I 844 718 I C
+K
+0 0 0 1 scol 546 643 M (ReferenceType)[30 23 12 23 14 23 23 21 23 26 19 23 0]xS
+0.602 0 0.199 1 scol N 844 659 M 531 659 I 531 718 I 844 718 I C
+K
+N 844 682 M 531 682 I 531 718 I 844 718 I C
+K
+: N 1202 295 284 178 rp C
+1 1 0.801 1 scol L ; N 1486 294 M 1201 294 I 1201 473 I 1486 473 I C
+K
+0 0 0 1 scol
+%%IncludeResource: font Helvetica-Oblique
+F /F1 0 /256 T /Helvetica-Oblique mF
+/F1S29 F1 [41 0 0 -41 0 0 ] mFS
+F1S29 Ji
+1226 343 M (AccessFlags)[27 21 21 23 21 21 25 9 23 23 0]xS
+0.602 0 0.199 1 scol N 1486 360 M 1201 360 I 1201 473 I 1486 473 I C
+K
+N 1486 383 M 1201 383 I 1201 473 I 1486 473 I C
+K
+0 0 0 1 scol 1260 450 M (isPublic\(\))[9 21 27 23 23 9 9 21 14 0]xS
+0.602 0 0.199 1 scol N 1344 602 M 1344 474 I K
+N 1059 602 M 1634 602 I K
+N 1344 474 M 1366 534 I 1322 534 I C
+: 1 1 1 1 scol O ; K
+N 678 500 M 678 593 I K
+N 369 500 M 881 500 I K
+N 678 593 M 700 533 I 656 533 I C
+: 1 1 1 1 scol O ; K
+N 369 477 M 369 500 I K
+N 881 477 M 881 500 I K
+: N 919 683 306 234 rp C
+1 1 0.801 1 scol L ; N 1225 682 M 918 682 I 918 917 I 1225 917 I C
+K
+0 0 0 1 scol F0S29 Ji
+988 732 M (FieldGen)[25 8 23 10 23 32 23 0]xS
+0.602 0 0.199 1 scol N 1225 748 M 918 748 I 918 917 I 1225 917 I C
+K
+N 1225 771 M 918 771 I 918 917 I 1225 917 I C
+K
+0 0 0 1 scol 977 839 M (getField\(\))[23 23 11 25 8 23 10 23 14 0]xS
+977 886 M (setInitValue\(\))[20 23 11 10 23 8 11 27 23 10 23 23 14 0]xS
+0.602 0 0.199 1 scol N 1059 682 M 1059 602 I K
+: N 543 1283 386 122 rp C
+1 1 0.801 1 scol L ; N 929 1282 M 542 1282 I 542 1405 I 929 1405 I C
+K
+0 0 0 1 scol 571 1332 M (LocalVariableGen)[23 23 21 23 10 27 23 14 8 23 23 10 23 32 23 0]xS
+0.602 0 0.199 1 scol N 929 1348 M 542 1348 I 542 1405 I 929 1405 I C
+K
+N 929 1371 M 542 1371 I 542 1405 I 929 1405 I C
+K
+: N 538 1106 396 124 rp C
+1 1 0.801 1 scol L ; N 934 1105 M 537 1105 I 537 1230 I 934 1230 I C
+K
+0 0 0 1 scol 559 1155 M (CodeExceptionGen)[30 23 23 23 27 18 21 23 23 11 8 23 23 32 23 0]xS
+0.602 0 0.199 1 scol N 934 1171 M 537 1171 I 537 1230 I 934 1230 I C
+K
+N 934 1194 M 537 1194 I 537 1230 I 934 1230 I C
+K
+: N 351 836 322 184 rp C
+1 1 0.801 1 scol L ; N 673 835 M 350 835 I 350 1020 I 673 1020 I C
+K
+0 0 0 1 scol 466 885 M (Type)[26 19 23 0]xS
+0.602 0 0.199 1 scol N 673 901 M 350 901 I 350 1020 I 673 1020 I C
+K
+N 673 924 M 350 924 I 350 1020 I 673 1020 I C
+K
+0 0 0 1 scol 409 992 M (getSignature\(\))[23 23 11 27 8 23 23 23 11 23 14 23 14 0]xS
+0.602 0 0.199 1 scol N 512 745 M 512 835 I K
+N 347 745 M 669 745 I K
+N 512 835 M 534 775 I 490 775 I C
+: 1 1 1 1 scol O ; K
+N 795 862 M 674 889 I K
+N 795 862 M 917 833 I K
+N 347 719 M 347 745 I K
+N 669 719 M 669 745 I K
+: N 538 1457 364 126 rp C
+1 1 0.801 1 scol L ; N 902 1456 M 537 1456 I 537 1583 I 902 1583 I C
+K
+0 0 0 1 scol 561 1506 M (BranchInstruction)[27 14 23 23 21 23 10 23 20 11 14 23 21 11 8 23 0]xS
+0.602 0 0.199 1 scol N 902 1522 M 537 1522 I 537 1583 I 902 1583 I C
+K
+N 902 1545 M 537 1545 I 537 1583 I 902 1583 I C
+K
+: N 1157 1012 342 184 rp C
+1 1 0.801 1 scol L ; N 1499 1011 M 1156 1011 I 1156 1196 I 1499 1196 I C
+K
+0 0 0 1 scol 1221 1061 M (MethodGen)[33 23 11 23 23 23 32 23 0]xS
+0.602 0 0.199 1 scol N 1499 1077 M 1156 1077 I 1156 1196 I 1499 1196 I C
+K
+N 1499 1100 M 1156 1100 I 1156 1196 I 1499 1196 I C
+K
+0 0 0 1 scol 1215 1168 M (addException\(\))[23 23 23 27 18 21 23 23 11 8 23 23 14 0]xS
+0.602 0 0.199 1 scol N 1022 1227 M 1155 1172 I K
+N 1155 1172 M 1136 1196 I 1105 1193 I 1124 1168 I 1155 1172 I C
+: 1 1 1 1 scol O ; K
+N 1022 1227 M 886 1281 I K
+N 913 1302 16 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 913 1340 M (*)S
+N 913 1302 16 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 913 1340 M (*)S
+0.602 0 0.199 1 scol N 1045 1134 M 1155 1121 I K
+N 1155 1121 M 1130 1139 I 1101 1127 I 1126 1109 I 1155 1121 I C
+: 1 1 1 1 scol O ; K
+N 1045 1134 M 935 1145 I K
+N 934 1068 16 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 934 1106 M (*)S
+N 934 1068 16 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 934 1106 M (*)S
+0.602 0 0.199 1 scol N 914 1014 M 674 962 I K
+N 914 1014 M 1155 1066 I K
+N 1344 1011 M 1344 602 I K
+: N 1751 1012 306 184 rp C
+1 1 0.801 1 scol L ; N 2057 1011 M 1750 1011 I 1750 1196 I 2057 1196 I C
+K
+0 0 0 1 scol 1779 1061 M (InstructionList)[10 23 20 11 14 23 21 11 8 23 23 23 8 20 0]xS
+0.602 0 0.199 1 scol N 2057 1077 M 1750 1077 I 1750 1196 I 2057 1196 I C
+K
+N 2057 1100 M 1750 1100 I 1750 1196 I 2057 1196 I C
+K
+0 0 0 1 scol 1809 1168 M (append\(\))[23 23 23 23 23 23 14 0]xS
+0.602 0 0.199 1 scol N 1624 1104 M 1749 1104 I K
+N 1624 1104 M 1500 1104 I K
+: N 1201 1313 222 190 rp C
+1 1 0.801 1 scol L ; N 1423 1312 M 1200 1312 I 1200 1503 I 1423 1503 I C
+K
+0 0 0 1 scol 1219 1362 M (Instruction)[10 23 20 11 14 23 21 11 8 23 0]xS
+0.602 0 0.199 1 scol N 1423 1378 M 1200 1378 I 1200 1503 I 1423 1503 I C
+K
+N 1423 1495 M 1200 1495 I 1200 1503 I 1423 1503 I C
+K
+0 0 0 1 scol 1259 1422 M (tag)[11 23 0]xS
+1259 1469 M (length)[10 23 23 23 11 0]xS
+0.602 0 0.199 1 scol N 903 1485 M 1199 1429 I K
+N 1199 1429 M 1144 1462 I 1136 1418 I C
+: 1 1 1 1 scol O ; K
+: N 1722 1345 364 126 rp C
+1 1 0.801 1 scol L ; N 2086 1344 M 1721 1344 I 1721 1471 I 2086 1471 I C
+K
+0 0 0 1 scol 1744 1394 M (InstructionHandle)[10 23 20 11 14 23 21 11 8 23 23 30 23 23 23 10 0]xS
+0.602 0 0.199 1 scol N 2086 1410 M 1721 1410 I 1721 1471 I 2086 1471 I C
+K
+N 2086 1433 M 1721 1433 I 1721 1471 I 2086 1471 I C
+K
+N 1904 1270 M 1904 1197 I K
+N 1947 1181 23 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1947 1219 M (1)S
+0.602 0 0.199 1 scol N 1904 1197 M 1919 1224 I 1904 1251 I 1889 1224 I 1904 1197 I C
+: 1 1 1 1 scol O ; K
+N 1904 1270 M 1904 1343 I K
+N 1950 1313 16 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1950 1351 M (*)S
+N 1947 1181 23 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1947 1219 M (1)S
+N 1950 1313 16 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1950 1351 M (*)S
+0.602 0 0.199 1 scol N 1572 1408 M 1424 1408 I K
+N 1429 1439 23 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1429 1477 M (1)S
+0.602 0 0.199 1 scol N 1572 1408 M 1720 1408 I K
+N 1693 1439 23 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1693 1477 M (1)S
+N 1429 1439 23 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1429 1477 M (1)S
+N 1693 1439 23 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1693 1477 M (1)S
+: N 0 1224 384 240 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol : 0 1223 385 242 rc N 384 1223 M -1 1223 I -1 1464 I 384 1464 I C
+K
+; 0 0 0 1 scol 20 1323 M (InstructionTargeter)[10 23 20 11 14 23 21 11 8 23 23 26 23 14 23 23 11 23 0]xS
+0.602 0 0.199 1 scol : 0 1339 385 126 rc N 384 1339 M -1 1339 I -1 1464 I 384 1464 I C
+K
+; : 0 1362 385 103 rc N 384 1362 M -1 1362 I -1 1464 I 384 1464 I C
+K
+; 0 0 0 1 scol 58 1430 M (updateTarget\(\))[23 23 23 23 11 23 26 23 14 23 23 11 14 0]xS
+64 1273 M (<<Interface>>)[24 24 10 23 11 23 14 12 23 21 23 24 0]xS
+1 1 1 1 scol [ 72 24 ] 0 sd N 540 1231 M 385 1280 I K
+0 0 0 1 scol [ 72 24 ] 0 sd N 540 1231 M 385 1280 I K
+0.602 0 0.199 1 scol solid N 385 1280 M 449 1283 I 435 1241 I C
+: 1 1 1 1 scol O ; K
+1 1 1 1 scol [ 72 24 ] 0 sd N 541 1344 M 385 1344 I K
+0 0 0 1 scol [ 72 24 ] 0 sd N 541 1344 M 385 1344 I K
+0.602 0 0.199 1 scol solid N 385 1344 M 445 1366 I 445 1322 I C
+: 1 1 1 1 scol O ; K
+N 1043 1616 M 1903 1616 I K
+N 1903 1616 M 1903 1472 I K
+N 1949 1550 16 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1949 1588 M (*)S
+0.602 0 0.199 1 scol N 1043 1616 M 191 1616 I K
+N 191 1616 M 191 1465 I K
+N 237 1542 16 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 237 1580 M (*)S
+N 1949 1550 16 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1949 1588 M (*)S
+N 237 1542 16 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 237 1580 M (*)S
+N 1186 1556 221 47 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1186 1594 M (<<targets>>)[24 24 11 23 14 23 23 11 20 24 0]xS
+: N 1707 306 362 284 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 2069 305 M 1706 305 I 1706 590 I 2069 590 I C
+K
+0 0 0 1 scol 1725 355 M (ConstantPoolGen)[30 23 23 20 11 23 23 11 27 23 23 10 32 23 0]xS
+0.602 0 0.199 1 scol N 2069 371 M 1706 371 I 1706 590 I 2069 590 I C
+K
+N 2069 394 M 1706 394 I 1706 590 I 2069 590 I C
+K
+0 0 0 1 scol 1765 462 M (addClass\(\))[23 23 23 30 10 23 20 20 14 0]xS
+1765 509 M (addMethodRef\(\))[23 23 23 33 23 11 23 23 23 30 23 12 14 0]xS
+1765 556 M (addInteger\(\))[23 23 23 10 23 11 23 23 23 14 14 0]xS
+: N 1475 683 314 234 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 1789 682 M 1474 682 I 1474 917 I 1789 917 I C
+K
+0 0 0 1 scol 1541 732 M (ClassGen)[30 10 23 20 20 32 23 0]xS
+0.602 0 0.199 1 scol N 1789 748 M 1474 748 I 1474 917 I 1789 917 I C
+K
+N 1789 771 M 1474 771 I 1474 917 I 1789 917 I C
+K
+0 0 0 1 scol 1533 839 M (addInterface\(\))[23 23 23 10 23 11 23 14 12 23 21 23 14 0]xS
+1533 886 M (addMethod\(\))[23 23 23 33 23 11 23 23 23 14 0]xS
+0.602 0 0.199 1 scol N 1634 682 M 1634 602 I K
+N 1751 636 M 1782 591 I K
+N 1751 636 M 1717 681 I K
+1 1 1 1 scol [ 72 24 ] 0 sd N 536 1458 M 385 1408 I K
+0 0 0 1 scol [ 72 24 ] 0 sd N 536 1458 M 385 1408 I K
+0.602 0 0.199 1 scol solid N 385 1408 M 449 1406 I 435 1448 I C
+: 1 1 1 1 scol O ; K
+LH
+%%PageTrailer
+
+%%Trailer
+%%DocumentNeededResources:
+%%+ font Helvetica-Oblique
+%%+ font Helvetica
+%%DocumentSuppliedResources:
+Pscript_WinNT_Incr dup /terminate get exec
+%%EOF
+grestore
+
+%%EndDocument
+ @endspecial 934 5316 a Fq(Figur)n(e)26 b(4:)k(UML)25
+b(diagram)g(of)g(the)h(ClassGen)e(API)1863 5712 y(14)p
+eop
+%%Page: 15 15
+15 14 bop 0 407 a Ft(\(or)17 b(index\))g(within)g(the)g(byte)f(code.)25
+b(Since)18 b(many)f(instr)o(uctions)f(ar)n(e)i(immutable,)h(the)e
+Ff(InstructionCon)o(st)o(an)o(ts)0 520 y Ft(interface)23
+b(of)n(fers)f(shar)n(eable)h(pr)n(ede\002ned)e(\223\003y-weight\224)h
+(constants)g(to)g(use.)146 633 y(Instr)o(uctions)28 b(ar)n(e)h(gr)n
+(ouped)e(via)k(sub-classing,)f(the)f(type)e(hierar)n(chy)j(of)f(instr)o
+(uction)f(classes)h(is)g(illus-)0 746 y(trated)d(by)h(\(incomplete\))g
+(\002gur)n(e)f(9)h(in)h(the)e(appendix.)39 b(The)27 b(most)f(important)
+g(family)j(of)e(instr)o(uctions)f(ar)n(e)0 858 y(the)h
+Fs(branch)h(instructions)p Ft(,)i(e.g.)42 b Ff(goto)p
+Ft(,)27 b(that)h(branch)g(to)f(tar)n(gets)g(somewher)n(e)e(within)j
+(the)f(byte)g(code.)42 b(Ob-)0 971 y(viously)-10 b(,)24
+b(this)f(makes)g(them)g(candidates)h(for)f(playing)h(an)g
+Ff(InstructionTarge)o(te)o(r)18 b Ft(r)n(ole,)23 b(too.)31
+b(Instr)o(uc-)0 1084 y(tions)16 b(ar)n(e)i(further)e(gr)n(ouped)g(by)h
+(the)f(interfaces)h(they)f(implement,)i(ther)n(e)e(ar)n(e,)i(e.g.,)f
+Ff(TypedInstructi)o(on)p Ft(s)0 1197 y(that)24 b(ar)n(e)h(associated)f
+(with)h(a)g(speci\002c)g(type)e(like)i Ff(ldc)p Ft(,)f(or)g
+Ff(ExceptionThrowe)o(r)18 b Ft(instr)o(uctions)24 b(that)h(may)0
+1310 y(raise)e(exceptions)e(when)g(executed.)146 1423
+y(All)i(instr)o(uctions)f(can)h(be)f(traversed)f(via)i
+Ff(accept\(Visitor)48 b(v\))22 b Ft(methods,)e(i.e.,)h(the)h(V)-5
+b(isitor)21 b(design)0 1536 y(pattern.)53 b(Ther)n(e)31
+b(is)g(however)f(some)h(special)h(trick)f(in)h(these)e(methods)f(that)i
+(allows)h(to)f(mer)n(ge)g(the)f(han-)0 1649 y(dling)21
+b(of)g(certain)g(instr)o(uction)g(gr)n(oups.)26 b(The)20
+b Ff(accept\(\))d Ft(do)j(not)h(only)f(call)j(the)d(corr)n(esponding)f
+Ff(visit\(\))0 1762 y Ft(method,)34 b(but)g(call)h Ff(visit\(\))30
+b Ft(methods)i(of)h(their)g(r)n(espective)f(super)g(classes)h(and)h
+(implemented)e(inter)n(-)0 1875 y(faces)27 b(\002rst,)g(i.e.)40
+b(the)26 b(most)g(speci\002c)h Ff(visit\(\))d Ft(call)29
+b(is)e(last.)40 b(Thus)26 b(one)g(can)i(gr)n(oup)e(the)g(handling)h
+(of,)h(say)-10 b(,)0 1988 y(all)24 b Ff(BranchInstructi)o(on)o
+Ft(s)17 b(into)22 b(one)g(single)g(method.)146 2100 y(For)30
+b(debugging)f(purposes)f(it)j(may)g(even)g(make)f(sense)f(to)h
+(\223invent\224)i(your)e(own)g(instr)o(uctions.)51 b(In)31
+b(a)0 2213 y(sophisticated)23 b(code)h(generator)f(like)i(the)e(one)h
+(used)g(as)g(a)i(backend)e(of)h(the)f(Barat)g(framework)g([BS98)q(])h
+(one)0 2326 y(often)h(has)g(to)h(insert)e(temporary)h
+Ff(nop)f Ft(\(No)h(operation\))g(instr)o(uctions.)39
+b(When)27 b(examining)g(the)f(pr)n(oduced)0 2439 y(code)34
+b(it)g(may)h(be)f(very)g(dif)n(\002cult)i(to)d(track)i(back)g(wher)n(e)
+f(the)f Ff(nop)g Ft(was)i(actually)g(inserted.)62 b(One)34
+b(could)0 2552 y(think)24 b(of)h(a)h(derived)e Ff(nop2)f
+Ft(instr)o(uction)h(that)h(contains)g(additional)g(debugging)e
+(information.)36 b(When)24 b(the)0 2665 y(instr)o(uction)e(list)h(is)g
+(dumped)e(to)h(byte)g(code,)f(the)h(extra)g(data)h(is)g(simply)f(dr)n
+(opped.)146 2778 y(One)j(could)g(also)g(think)g(of)g(new)f(byte)g(code)
+g(instr)o(uctions)g(operating)g(on)h(complex)g(numbers)f(that)h(ar)n(e)
+0 2891 y(r)n(eplaced)e(by)f(normal)h(byte)f(code)g(upon)g(load-time)h
+(or)f(ar)n(e)h(r)n(ecognized)f(by)h(a)g(new)f(JVM.)0
+3147 y Fg(3.3.4)99 b(Instruction)25 b(lists)0 3324 y
+Ft(An)18 b Fs(instruction)i(list)g Ft(is)e(implemented)g(by)g(a)h(list)
+g(of)g Fs(instruction)g(handles)h Ft(encapsulating)f(instr)o(uction)f
+(objects.)0 3437 y(Refer)n(ences)k(to)g(instr)o(uctions)h(in)h(the)e
+(list)i(ar)n(e)g(thus)e(not)h(implemented)f(by)h(dir)n(ect)g(pointers)f
+(to)h(instr)o(uctions)0 3549 y(but)31 b(by)f(pointers)f(to)h(instr)o
+(uction)h Fs(handles)p Ft(.)53 b(This)31 b(makes)f(appending,)h
+(inserting)f(and)h(deleting)e(ar)n(eas)i(of)0 3662 y(code)25
+b(very)h(simple.)38 b(Since)27 b(we)e(use)h(symbolic)g(r)n(efer)n
+(ences,)g(computation)g(of)g(concr)n(ete)g(byte)f(code)g(of)n(fsets)0
+3775 y(does)19 b(not)h(need)f(to)h(occur)h(until)f(\002nalization,)j
+(i.e.)k(until)21 b(the)f(user)f(has)i(\002nished)e(the)h(pr)n(ocess)f
+(of)i(generating)0 3888 y(or)29 b(transforming)f(code.)46
+b(W)-8 b(e)28 b(will)i(use)e(the)g(term)h(instr)o(uction)f(handle)h
+(and)g(instr)o(uction)g(synonymously)0 4001 y(thr)n(oughout)23
+b(the)h(r)n(est)g(of)h(the)f(paper)-7 b(.)35 b(Instr)o(uction)23
+b(handles)i(may)g(contain)h(additional)f(user)n(-de\002ned)e(data)0
+4114 y(using)f(the)g Ff(addAttribute\(\))16 b Ft(method.)0
+4362 y Fg(Appending.)90 b Ft(One)29 b(can)g(append)e(instr)o(uctions)h
+(or)g(other)g(instr)o(uction)g(lists)g(anywher)n(e)g(to)g(an)h
+(existing)0 4475 y(list.)63 b(The)34 b(instr)o(uctions)g(ar)n(e)h
+(appended)d(after)i(the)g(given)g(instr)o(uction)g(handle.)63
+b(All)36 b(append)d(methods)0 4588 y(r)n(eturn)27 b(a)h(new)g(instr)o
+(uction)f(handle)h(which)g(may)h(then)d(be)i(used)f(as)h(the)f(tar)n
+(get)g(of)h(a)g(branch)h(instr)o(uction,)0 4701 y(e.g..)109
+4898 y Ff(InstructionList)48 b(il)53 b(=)i(new)e(InstructionLis)o(t\()o
+(\);)109 5011 y(...)109 5124 y(GOTO)g(g)h(=)g(new)f(GOTO\(null\);)109
+5237 y(il.append\(g\);)109 5350 y(...)109 5463 y(InstructionHand)o(le)
+48 b(ih)54 b(=)g(il.append\(Inst)o(ru)o(ct)o(ion)o(Co)o(ns)o(ta)o(nt)o
+(s.A)o(CO)o(NS)o(T_)o(NU)o(LL\))o(;)1863 5712 y Fq(15)p
+eop
+%%Page: 16 16
+16 15 bop 109 407 a Ff(g.setTarget\(ih\))o(;)0 662 y
+Fg(Inserting.)91 b Ft(Instr)o(uctions)24 b(may)j(be)f(inserted)e
+(anywher)n(e)i(into)g(an)g(existing)f(list.)39 b(They)25
+b(ar)n(e)i(inserted)d(be-)0 775 y(for)n(e)19 b(the)f(given)g(instr)o
+(uction)h(handle.)26 b(All)20 b(insert)e(methods)f(r)n(eturn)h(a)h(new)
+f(instr)o(uction)h(handle)f(which)i(may)0 888 y(then)i(be)g(used)f(as)i
+(the)f(start)g(addr)n(ess)f(of)i(an)g(exception)e(handler)-7
+b(,)23 b(for)f(example.)109 1114 y Ff(InstructionHand)o(le)48
+b(start)k(=)i(il.insert\(inser)o(tio)o(n_)o(po)o(in)o(t,)2073
+1227 y(InstructionCon)o(st)o(ant)o(s.)o(NO)o(P\))o(;)109
+1339 y(...)109 1452 y(mg.addException)o(Ha)o(nd)o(ler)o(\(s)o(ta)o(rt)o
+(,)48 b(end,)53 b(handler,)e("java.io.IOExce)o(pt)o(io)o(n"\))o(;)0
+1708 y Fg(Deleting.)91 b Ft(Deletion)34 b(of)f(instr)o(uctions)g(is)h
+(also)g(very)f(straightforwar)n(d;)38 b(all)e(instr)o(uction)d(handles)
+g(and)0 1820 y(the)28 b(contained)g(instr)o(uctions)f(within)i(a)g
+(given)g(range)f(ar)n(e)g(r)n(emoved)g(fr)n(om)h(the)f(instr)o(uction)g
+(list)h(and)f(dis-)0 1933 y(posed.)e(The)c Ff(delete\(\))d
+Ft(method)i(may)i(however)e(thr)n(ow)h(a)h Ff(TargetLostExcep)o(tio)o
+(n)16 b Ft(when)22 b(ther)n(e)g(ar)n(e)0 2046 y(instr)o(uction)e(tar)n
+(geters)e(still)j(r)n(efer)n(encing)f(one)f(of)h(the)f(deleted)f(instr)
+o(uctions.)26 b(The)20 b(user)f(is)h(for)n(ced)g(to)f(handle)0
+2159 y(such)30 b(exceptions)f(in)i(a)g Ff(try-catch)c
+Ft(block)k(and)f(r)n(edir)n(ect)g(these)f(r)n(efer)n(ences)h(elsewher)n
+(e.)49 b(The)30 b Fs(peep)j(hole)0 2272 y Ft(optimizer)23
+b(described)e(in)i(section)f(A.3)h(gives)f(a)h(detailed)f(example)h
+(for)f(this.)109 2498 y Ff(try)53 b({)218 2611 y(il.delete\(first)o(,)
+48 b(last\);)109 2724 y(})54 b(catch\(TargetLos)o(tE)o(xce)o(pt)o(io)o
+(n)48 b(e\))54 b({)218 2837 y(InstructionHand)o(le)o([])48
+b(targets)j(=)k(e.getTargets\(\))o(;)218 2949 y(for\(int)d(i=0;)g(i)i
+(<)g(targets.length;)48 b(i++\))53 b({)327 3062 y(InstructionTarg)o
+(ete)o(r[)o(])48 b(targeters)j(=)j(targets[i].get)o(Tar)o(ge)o(te)o(rs)
+o(\(\))o(;)327 3175 y(for\(int)e(j=0;)g(j)i(<)h(targeters.leng)o(th)o
+(;)48 b(j++\))491 3288 y(targeters[j].up)o(da)o(te)o(Ta)o(rg)o(et\()o
+(ta)o(rg)o(et)o(s[)o(i],)g(new_target\);)218 3401 y(})109
+3514 y(})0 3769 y Fg(Finalizing.)92 b Ft(When)27 b(the)g(instr)o
+(uction)h(list)g(is)g(r)n(eady)g(to)f(be)h(dumped)f(to)g(pur)n(e)h
+(byte)f(code,)h(all)h(symbolic)0 3882 y(r)n(efer)n(ences)35
+b(must)g(be)h(mapped)g(to)f(r)n(eal)i(byte)e(code)h(of)n(fsets.)67
+b(This)36 b(is)g(done)f(by)h(the)f Ff(getByteCode\(\))0
+3995 y Ft(method)23 b(which)i(is)f(called)h(by)f(default)g(by)g
+Ff(MethodGen.getMe)o(th)o(od)o(\(\))o Ft(.)j(Afterwar)n(ds)c(you)g
+(should)g(call)0 4108 y Ff(dispose\(\))c Ft(so)j(that)h(the)f(instr)o
+(uction)h(handles)f(can)i(be)f(r)n(eused)e(internally)-10
+b(.)29 b(This)23 b(helps)f(to)g(r)n(educe)h(mem-)0 4221
+y(ory)f(usage.)109 4447 y Ff(InstructionList)48 b(il)53
+b(=)i(new)e(InstructionLis)o(t\()o(\);)109 4672 y(ClassGen)106
+b(cg)53 b(=)h(new)f(ClassGen\("HelloW)o(or)o(ld)o(",)48
+b("java.lang.Obje)o(ct)o(",)1636 4785 y("<generated>",)h(ACC_PUBLIC)h
+(|)k(ACC_SUPER,)1636 4898 y(null\);)109 5011 y(MethodGen)d(mg)i(=)h
+(new)f(MethodGen\(ACC_ST)o(AT)o(IC)48 b(|)54 b(ACC_PUBLIC,)1691
+5124 y(Type.VOID,)c(new)j(Type[])f({)1800 5237 y(new)h
+(ArrayType\(Type.)o(ST)o(RIN)o(G,)48 b(1\))1691 5350
+y(},)54 b(new)f(String[])e({)j("argv")e(},)1691 5463
+y("main",)f("HelloWorld",)e(il,)k(cp\);)1863 5712 y Fq(16)p
+eop
+%%Page: 17 17
+17 16 bop 109 407 a Ff(...)109 520 y(cg.addMethod\(mg)o(.g)o(et)o(Met)o
+(ho)o(d\()o(\)\))o(;)109 633 y(il.dispose\(\);)49 b(//)k(Reuse)g
+(instruction)c(handles)j(of)h(list)0 887 y Fg(3.3.5)99
+b(Code)25 b(example)f(revisited)0 1063 y Ft(Using)h(instr)o(uction)g
+(lists)h(gives)f(us)g(a)i(generic)e(view)h(upon)e(the)h(code:)34
+b(In)25 b(Figur)n(e)g(5)h(we)f(again)i(pr)n(esent)d(the)0
+1176 y(code)e(chunk)h(of)g(the)f Ff(readInt\(\))d Ft(method)i(of)i(the)
+f(faculty)i(example)e(in)i(section)e(2.6:)29 b(The)22
+b(local)j(variables)0 1289 y Ff(n)k Ft(and)g Ff(e1)g
+Ft(both)g(hold)g(two)g(r)n(efer)n(ences)f(to)h(instr)o(uctions,)h
+(de\002ning)e(their)h(scope.)47 b(Ther)n(e)29 b(ar)n(e)h(two)e
+Ff(goto)p Ft(s)0 1402 y(branching)g(to)e(the)g Ff(iload)f
+Ft(at)j(the)e(end)g(of)h(the)f(method.)40 b(One)27 b(of)g(the)f
+(exception)g(handlers)g(is)i(displayed,)0 1515 y(too:)f(it)c(r)n(efer)n
+(ences)e(the)h(start)g(and)h(the)e(end)h(of)h(the)f Ff(try)f
+Ft(block)i(and)g(also)f(the)g(exception)g(handler)g(code.)0
+4170 y @beginspecial 0 @llx 0 @lly 583 @urx 386 @ury
+4590 @rwi @setspecial
+%%BeginDocument: eps/il.eps
+%!PS-Adobe-2.0 EPSF-2.0
+%%Title: il.eps
+%%Creator: fig2dev Version 3.2 Patchlevel 1
+%%CreationDate: Wed Dec 2 15:26:46 1998
+%%For: dahm@che (Markus Dahm,,,,,)
+%%Orientation: Portrait
+%%BoundingBox: 0 0 583 386
+%%Pages: 0
+%%BeginSetup
+%%EndSetup
+%%Magnification: 1.0000
+%%EndComments
+/$F2psDict 200 dict def
+$F2psDict begin
+$F2psDict /mtrx matrix put
+/col-1 {0 setgray} bind def
+/col0 {0.000 0.000 0.000 srgb} bind def
+/col1 {0.000 0.000 1.000 srgb} bind def
+/col2 {0.000 1.000 0.000 srgb} bind def
+/col3 {0.000 1.000 1.000 srgb} bind def
+/col4 {1.000 0.000 0.000 srgb} bind def
+/col5 {1.000 0.000 1.000 srgb} bind def
+/col6 {1.000 1.000 0.000 srgb} bind def
+/col7 {1.000 1.000 1.000 srgb} bind def
+/col8 {0.000 0.000 0.560 srgb} bind def
+/col9 {0.000 0.000 0.690 srgb} bind def
+/col10 {0.000 0.000 0.820 srgb} bind def
+/col11 {0.530 0.810 1.000 srgb} bind def
+/col12 {0.000 0.560 0.000 srgb} bind def
+/col13 {0.000 0.690 0.000 srgb} bind def
+/col14 {0.000 0.820 0.000 srgb} bind def
+/col15 {0.000 0.560 0.560 srgb} bind def
+/col16 {0.000 0.690 0.690 srgb} bind def
+/col17 {0.000 0.820 0.820 srgb} bind def
+/col18 {0.560 0.000 0.000 srgb} bind def
+/col19 {0.690 0.000 0.000 srgb} bind def
+/col20 {0.820 0.000 0.000 srgb} bind def
+/col21 {0.560 0.000 0.560 srgb} bind def
+/col22 {0.690 0.000 0.690 srgb} bind def
+/col23 {0.820 0.000 0.820 srgb} bind def
+/col24 {0.500 0.190 0.000 srgb} bind def
+/col25 {0.630 0.250 0.000 srgb} bind def
+/col26 {0.750 0.380 0.000 srgb} bind def
+/col27 {1.000 0.500 0.500 srgb} bind def
+/col28 {1.000 0.630 0.630 srgb} bind def
+/col29 {1.000 0.750 0.750 srgb} bind def
+/col30 {1.000 0.880 0.880 srgb} bind def
+/col31 {1.000 0.840 0.000 srgb} bind def
+
+end
+save
+-84.0 526.0 translate
+1 -1 scale
+
+/cp {closepath} bind def
+/ef {eofill} bind def
+/gr {grestore} bind def
+/gs {gsave} bind def
+/sa {save} bind def
+/rs {restore} bind def
+/l {lineto} bind def
+/m {moveto} bind def
+/rm {rmoveto} bind def
+/n {newpath} bind def
+/s {stroke} bind def
+/sh {show} bind def
+/slc {setlinecap} bind def
+/slj {setlinejoin} bind def
+/slw {setlinewidth} bind def
+/srgb {setrgbcolor} bind def
+/rot {rotate} bind def
+/sc {scale} bind def
+/sd {setdash} bind def
+/ff {findfont} bind def
+/sf {setfont} bind def
+/scf {scalefont} bind def
+/sw {stringwidth} bind def
+/tr {translate} bind def
+/tnt {dup dup currentrgbcolor
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
+ bind def
+/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
+ 4 -2 roll mul srgb} bind def
+/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
+/$F2psEnd {$F2psEnteredState restore end} def
+%%EndProlog
+
+$F2psBegin
+10 setmiterlimit
+n -1000 9337 m -1000 -1000 l 11587 -1000 l 11587 9337 l cp clip
+ 0.06299 0.06299 sc
+% Polyline
+7.500 slw
+ [60] 0 sd
+gs clippath
+5205 7530 m 5175 7650 l 5145 7530 l 5145 7665 l 5205 7665 l cp
+clip
+n 5175 6975 m 5175 7650 l gs col0 s gr gr
+ [] 0 sd
+% arrowhead
+n 5205 7530 m 5175 7650 l 5145 7530 l col0 s
+% Polyline
+ [60] 0 sd
+gs clippath
+5595 7095 m 5625 6975 l 5655 7095 l 5655 6960 l 5595 6960 l cp
+clip
+n 5625 7650 m 5625 6975 l gs col0 s gr gr
+ [] 0 sd
+% arrowhead
+n 5595 7095 m 5625 6975 l 5655 7095 l col0 s
+% Polyline
+ [60] 0 sd
+gs clippath
+5205 3930 m 5175 4050 l 5145 3930 l 5145 4065 l 5205 4065 l cp
+clip
+n 5175 3375 m 5175 4050 l gs col0 s gr gr
+ [] 0 sd
+% arrowhead
+n 5205 3930 m 5175 4050 l 5145 3930 l col0 s
+% Polyline
+ [60] 0 sd
+gs clippath
+5595 3495 m 5625 3375 l 5655 3495 l 5655 3360 l 5595 3360 l cp
+clip
+n 5625 4050 m 5625 3375 l gs col0 s gr gr
+ [] 0 sd
+% arrowhead
+n 5595 3495 m 5625 3375 l 5655 3495 l col0 s
+% Polyline
+n 4380 6750 m 4275 6750 4275 6870 105 arcto 4 {pop} repeat
+ 4275 6975 6420 6975 105 arcto 4 {pop} repeat
+ 6525 6975 6525 6855 105 arcto 4 {pop} repeat
+ 6525 6750 4380 6750 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+4500 6930 m
+gs 1 -1 sc (goto) col0 sh gr
+% Polyline
+n 4380 6300 m 4275 6300 4275 6420 105 arcto 4 {pop} repeat
+ 4275 6525 6420 6525 105 arcto 4 {pop} repeat
+ 6525 6525 6525 6405 105 arcto 4 {pop} repeat
+ 6525 6300 4380 6300 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+4455 6480 m
+gs 1 -1 sc (invokevirtual) col0 sh gr
+% Polyline
+n 4380 5850 m 4275 5850 4275 5970 105 arcto 4 {pop} repeat
+ 4275 6075 6420 6075 105 arcto 4 {pop} repeat
+ 6525 6075 6525 5955 105 arcto 4 {pop} repeat
+ 6525 5850 4380 5850 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+4500 6030 m
+gs 1 -1 sc (aload) col0 sh gr
+% Polyline
+n 4380 5400 m 4275 5400 4275 5520 105 arcto 4 {pop} repeat
+ 4275 5625 6420 5625 105 arcto 4 {pop} repeat
+ 6525 5625 6525 5505 105 arcto 4 {pop} repeat
+ 6525 5400 4380 5400 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+4500 5580 m
+gs 1 -1 sc (getstatic) col0 sh gr
+% Polyline
+n 4380 4950 m 4275 4950 4275 5070 105 arcto 4 {pop} repeat
+ 4275 5175 6420 5175 105 arcto 4 {pop} repeat
+ 6525 5175 6525 5055 105 arcto 4 {pop} repeat
+ 6525 4950 4380 4950 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+4500 5130 m
+gs 1 -1 sc (astore) col0 sh gr
+% Polyline
+n 4380 4500 m 4275 4500 4275 4620 105 arcto 4 {pop} repeat
+ 4275 4725 6420 4725 105 arcto 4 {pop} repeat
+ 6525 4725 6525 4605 105 arcto 4 {pop} repeat
+ 6525 4500 4380 4500 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+4500 4680 m
+gs 1 -1 sc (goto) col0 sh gr
+% Polyline
+n 4380 4050 m 4275 4050 4275 4170 105 arcto 4 {pop} repeat
+ 4275 4275 6420 4275 105 arcto 4 {pop} repeat
+ 6525 4275 6525 4155 105 arcto 4 {pop} repeat
+ 6525 4050 4380 4050 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+4455 4230 m
+gs 1 -1 sc (istore) col0 sh gr
+% Polyline
+gs clippath
+5595 4395 m 5625 4275 l 5655 4395 l 5655 4260 l 5595 4260 l cp
+clip
+n 5625 4500 m 5625 4275 l gs col0 s gr gr
+
+% arrowhead
+n 5595 4395 m 5625 4275 l 5655 4395 l col0 s
+% Polyline
+gs clippath
+5205 4380 m 5175 4500 l 5145 4380 l 5145 4515 l 5205 4515 l cp
+clip
+n 5175 4275 m 5175 4500 l gs col0 s gr gr
+
+% arrowhead
+n 5205 4380 m 5175 4500 l 5145 4380 l col0 s
+% Polyline
+gs clippath
+5595 4845 m 5625 4725 l 5655 4845 l 5655 4710 l 5595 4710 l cp
+clip
+n 5625 4950 m 5625 4725 l gs col0 s gr gr
+
+% arrowhead
+n 5595 4845 m 5625 4725 l 5655 4845 l col0 s
+% Polyline
+gs clippath
+5205 4830 m 5175 4950 l 5145 4830 l 5145 4965 l 5205 4965 l cp
+clip
+n 5175 4725 m 5175 4950 l gs col0 s gr gr
+
+% arrowhead
+n 5205 4830 m 5175 4950 l 5145 4830 l col0 s
+% Polyline
+gs clippath
+5595 5295 m 5625 5175 l 5655 5295 l 5655 5160 l 5595 5160 l cp
+clip
+n 5625 5400 m 5625 5175 l gs col0 s gr gr
+
+% arrowhead
+n 5595 5295 m 5625 5175 l 5655 5295 l col0 s
+% Polyline
+gs clippath
+5205 5280 m 5175 5400 l 5145 5280 l 5145 5415 l 5205 5415 l cp
+clip
+n 5175 5175 m 5175 5400 l gs col0 s gr gr
+
+% arrowhead
+n 5205 5280 m 5175 5400 l 5145 5280 l col0 s
+% Polyline
+gs clippath
+5595 5745 m 5625 5625 l 5655 5745 l 5655 5610 l 5595 5610 l cp
+clip
+n 5625 5850 m 5625 5625 l gs col0 s gr gr
+
+% arrowhead
+n 5595 5745 m 5625 5625 l 5655 5745 l col0 s
+% Polyline
+gs clippath
+5205 5730 m 5175 5850 l 5145 5730 l 5145 5865 l 5205 5865 l cp
+clip
+n 5175 5625 m 5175 5850 l gs col0 s gr gr
+
+% arrowhead
+n 5205 5730 m 5175 5850 l 5145 5730 l col0 s
+% Polyline
+gs clippath
+5595 6195 m 5625 6075 l 5655 6195 l 5655 6060 l 5595 6060 l cp
+clip
+n 5625 6300 m 5625 6075 l gs col0 s gr gr
+
+% arrowhead
+n 5595 6195 m 5625 6075 l 5655 6195 l col0 s
+% Polyline
+gs clippath
+5205 6180 m 5175 6300 l 5145 6180 l 5145 6315 l 5205 6315 l cp
+clip
+n 5175 6075 m 5175 6300 l gs col0 s gr gr
+
+% arrowhead
+n 5205 6180 m 5175 6300 l 5145 6180 l col0 s
+% Polyline
+gs clippath
+5595 6645 m 5625 6525 l 5655 6645 l 5655 6510 l 5595 6510 l cp
+clip
+n 5625 6750 m 5625 6525 l gs col0 s gr gr
+
+% arrowhead
+n 5595 6645 m 5625 6525 l 5655 6645 l col0 s
+% Polyline
+gs clippath
+5205 6630 m 5175 6750 l 5145 6630 l 5145 6765 l 5205 6765 l cp
+clip
+n 5175 6525 m 5175 6750 l gs col0 s gr gr
+
+% arrowhead
+n 5205 6630 m 5175 6750 l 5145 6630 l col0 s
+% Polyline
+n 4380 7650 m 4275 7650 4275 7770 105 arcto 4 {pop} repeat
+ 4275 7875 6420 7875 105 arcto 4 {pop} repeat
+ 6525 7875 6525 7755 105 arcto 4 {pop} repeat
+ 6525 7650 4380 7650 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+4455 7830 m
+gs 1 -1 sc (iload) col0 sh gr
+% Polyline
+n 4380 8100 m 4275 8100 4275 8220 105 arcto 4 {pop} repeat
+ 4275 8325 6420 8325 105 arcto 4 {pop} repeat
+ 6525 8325 6525 8205 105 arcto 4 {pop} repeat
+ 6525 8100 4380 8100 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+4455 8280 m
+gs 1 -1 sc (ireturn) col0 sh gr
+% Polyline
+gs clippath
+5595 7995 m 5625 7875 l 5655 7995 l 5655 7860 l 5595 7860 l cp
+clip
+n 5625 8100 m 5625 7875 l gs col0 s gr gr
+
+% arrowhead
+n 5595 7995 m 5625 7875 l 5655 7995 l col0 s
+% Polyline
+gs clippath
+5205 7980 m 5175 8100 l 5145 7980 l 5145 8115 l 5205 8115 l cp
+clip
+n 5175 7875 m 5175 8100 l gs col0 s gr gr
+
+% arrowhead
+n 5205 7980 m 5175 8100 l 5145 7980 l col0 s
+% Polyline
+gs clippath
+5595 2595 m 5625 2475 l 5655 2595 l 5655 2460 l 5595 2460 l cp
+clip
+n 5625 2700 m 5625 2475 l gs col0 s gr gr
+
+% arrowhead
+n 5595 2595 m 5625 2475 l 5655 2595 l col0 s
+% Polyline
+gs clippath
+5205 2580 m 5175 2700 l 5145 2580 l 5145 2715 l 5205 2715 l cp
+clip
+n 5175 2475 m 5175 2700 l gs col0 s gr gr
+
+% arrowhead
+n 5205 2580 m 5175 2700 l 5145 2580 l col0 s
+% Polyline
+n 4380 3150 m 4275 3150 4275 3270 105 arcto 4 {pop} repeat
+ 4275 3375 6420 3375 105 arcto 4 {pop} repeat
+ 6525 3375 6525 3255 105 arcto 4 {pop} repeat
+ 6525 3150 4380 3150 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+4500 3330 m
+gs 1 -1 sc (getstatic) col0 sh gr
+% Polyline
+n 4380 2700 m 4275 2700 4275 2820 105 arcto 4 {pop} repeat
+ 4275 2925 6420 2925 105 arcto 4 {pop} repeat
+ 6525 2925 6525 2805 105 arcto 4 {pop} repeat
+ 6525 2700 4380 2700 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+4455 2880 m
+gs 1 -1 sc (istore) col0 sh gr
+% Polyline
+n 4380 2250 m 4275 2250 4275 2370 105 arcto 4 {pop} repeat
+ 4275 2475 6420 2475 105 arcto 4 {pop} repeat
+ 6525 2475 6525 2355 105 arcto 4 {pop} repeat
+ 6525 2250 4380 2250 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+4500 2430 m
+gs 1 -1 sc (sipush) col0 sh gr
+% Polyline
+gs clippath
+5595 3045 m 5625 2925 l 5655 3045 l 5655 2910 l 5595 2910 l cp
+clip
+n 5625 3150 m 5625 2925 l gs col0 s gr gr
+
+% arrowhead
+n 5595 3045 m 5625 2925 l 5655 3045 l col0 s
+% Polyline
+gs clippath
+5205 3030 m 5175 3150 l 5145 3030 l 5145 3165 l 5205 3165 l cp
+clip
+n 5175 2925 m 5175 3150 l gs col0 s gr gr
+
+% arrowhead
+n 5205 3030 m 5175 3150 l 5145 3030 l col0 s
+% Polyline
+n 1350 5175 m 3600 5175 l 3600 5625 l 1350 5625 l cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+1575 5400 m
+gs 1 -1 sc (IOException e1) col0 sh gr
+% Polyline
+n 1575 5175 m 1575 4950 l 3825 4950 l 3825 5400 l 3600 5400 l 3600 5175 l
+ 1575 5175 l cp gs 0.00 setgray ef gr gs col0 s gr
+% Polyline
+n 1350 3600 m 3600 3600 l 3600 4050 l 1350 4050 l cp gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+1575 3825 m
+gs 1 -1 sc (int n) col0 sh gr
+% Polyline
+n 1575 3600 m 1575 3375 l 3825 3375 l 3825 3825 l 3600 3825 l 3600 3600 l
+ 1575 3600 l cp gs 0.00 setgray ef gr gs col0 s gr
+% Polyline
+n 7200 4050 m 10350 4050 l 10350 4500 l 7200 4500 l cp gs col0 s gr
+% Polyline
+n 7425 4050 m 7425 3825 l 10575 3825 l 10575 4275 l 10350 4275 l 10350 4050 l
+ 8325 4050 l gs 0.00 setgray ef gr gs col0 s gr
+/Courier-Bold ff 210.00 scf sf
+7425 4275 m
+gs 1 -1 sc (Exception handler 1) col0 sh gr
+% Polyline
+gs clippath
+4152 5071 m 4275 5085 l 4160 5131 l 4294 5113 l 4286 5053 l cp
+clip
+n 3600 5175 m 4275 5085 l gs col0 s gr gr
+
+% arrowhead
+n 4152 5071 m 4275 5085 l 4160 5131 l 4156 5101 l 4152 5071 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+4190 2475 m 4275 2385 l 4243 2504 l 4309 2386 l 4256 2357 l cp
+clip
+n 3600 3600 m 4275 2385 l gs col0 s gr gr
+
+% arrowhead
+n 4190 2475 m 4275 2385 l 4243 2504 l 4217 2490 l 4190 2475 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+4221 6324 m 4275 6435 l 4175 6362 l 4262 6466 l 4308 6427 l cp
+clip
+n 3600 5625 m 4275 6435 l gs col0 s gr gr
+
+% arrowhead
+n 4221 6324 m 4275 6435 l 4175 6362 l 4198 6343 l 4221 6324 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+6635 5029 m 6525 5085 l 6596 4984 l 6494 5072 l 6533 5117 l cp
+clip
+n 7200 4500 m 6525 5085 l gs col0 s gr gr
+
+% arrowhead
+n 6635 5029 m 6525 5085 l 6596 4984 l 6616 5006 l 6635 5029 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+6645 4215 m 6525 4185 l 6645 4155 l 6510 4155 l 6510 4215 l cp
+clip
+n 7200 4185 m 6525 4185 l gs col0 s gr gr
+
+% arrowhead
+n 6645 4215 m 6525 4185 l 6645 4155 l 6645 4185 l 6645 4215 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+6582 3395 m 6525 3285 l 6627 3355 l 6538 3254 l 6493 3294 l cp
+clip
+n 7200 4050 m 6525 3285 l gs col0 s gr gr
+
+% arrowhead
+n 6582 3395 m 6525 3285 l 6627 3355 l 6604 3375 l 6582 3395 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+4329 7977 m 4320 8100 l 4269 7987 l 4293 8120 l 4352 8110 l cp
+clip
+n 3600 4050 m 4320 8100 l gs col0 s gr gr
+
+% arrowhead
+n 4329 7977 m 4320 8100 l 4269 7987 l 4299 7982 l 4329 7977 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+6649 7784 m 6525 7785 l 6633 7726 l 6503 7760 l 6518 7818 l cp
+clip
+n 6525 4635 m 6527 4636 l 6532 4640 l 6542 4646 l 6556 4655 l 6575 4667 l
+ 6600 4683 l 6628 4702 l 6661 4723 l 6695 4746 l 6731 4771 l
+ 6768 4796 l 6804 4821 l 6838 4845 l 6871 4869 l 6902 4892 l
+ 6931 4915 l 6958 4936 l 6983 4957 l 7005 4977 l 7026 4996 l
+ 7045 5015 l 7063 5034 l 7080 5054 l 7095 5073 l 7110 5093 l
+ 7124 5113 l 7137 5133 l 7150 5154 l 7162 5176 l 7174 5199 l
+ 7185 5223 l 7196 5247 l 7207 5273 l 7216 5299 l 7226 5326 l
+ 7235 5353 l 7243 5381 l 7251 5409 l 7258 5438 l 7265 5467 l
+ 7271 5496 l 7276 5525 l 7281 5554 l 7286 5582 l 7290 5611 l
+ 7293 5639 l 7296 5667 l 7299 5694 l 7301 5721 l 7303 5748 l
+ 7305 5775 l 7306 5802 l 7308 5829 l 7309 5857 l 7310 5885 l
+ 7310 5914 l 7311 5944 l 7311 5974 l 7311 6004 l 7311 6035 l
+ 7310 6067 l 7310 6099 l 7309 6131 l 7308 6163 l 7307 6195 l
+ 7306 6227 l 7305 6258 l 7304 6289 l 7302 6320 l 7301 6350 l
+ 7299 6379 l 7298 6407 l 7296 6435 l 7295 6462 l 7293 6489 l
+ 7292 6514 l 7290 6540 l 7288 6567 l 7287 6595 l 7285 6622 l
+ 7283 6650 l 7281 6677 l 7279 6706 l 7277 6734 l 7275 6762 l
+ 7273 6791 l 7270 6820 l 7268 6848 l 7265 6877 l 7263 6905 l
+ 7260 6932 l 7257 6959 l 7255 6986 l 7252 7011 l 7249 7036 l
+ 7246 7060 l 7243 7084 l 7240 7106 l 7237 7128 l 7233 7149 l
+ 7230 7170 l 7226 7195 l 7221 7219 l 7216 7243 l 7211 7268 l
+ 7205 7292 l 7198 7317 l 7191 7342 l 7183 7366 l 7174 7390 l
+ 7165 7414 l 7155 7436 l 7144 7459 l 7133 7480 l 7121 7500 l
+ 7108 7519 l 7095 7537 l 7081 7553 l 7066 7569 l 7051 7584 l
+ 7035 7598 l 7020 7609 l 7003 7621 l 6985 7632 l 6966 7642 l
+ 6945 7653 l 6921 7663 l 6895 7674 l 6867 7684 l 6836 7695 l
+ 6803 7706 l 6767 7717 l 6730 7728 l 6693 7739 l 6656 7750 l
+ 6622 7759 l 6592 7767 l 6567 7774 l 6525 7785 l gs col0 s gr gr
+
+% arrowhead
+n 6649 7784 m 6525 7785 l 6633 7726 l 6641 7755 l 6649 7784 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+6619 7615 m 6525 7695 l 6570 7580 l 6492 7690 l 6541 7725 l cp
+clip
+n 6525 6840 m 6526 6843 l 6529 6850 l 6533 6863 l 6540 6882 l 6549 6908 l
+ 6560 6938 l 6572 6973 l 6585 7010 l 6598 7048 l 6610 7086 l
+ 6622 7122 l 6632 7157 l 6642 7189 l 6650 7219 l 6657 7246 l
+ 6663 7271 l 6667 7294 l 6671 7315 l 6673 7335 l 6675 7354 l
+ 6675 7373 l 6674 7394 l 6672 7415 l 6669 7435 l 6663 7455 l
+ 6656 7476 l 6648 7498 l 6637 7520 l 6624 7544 l 6610 7568 l
+ 6595 7593 l 6579 7617 l 6564 7640 l 6550 7660 l 6525 7695 l gs col0 s gr gr
+
+% arrowhead
+n 6619 7615 m 6525 7695 l 6570 7580 l 6595 7597 l 6619 7615 l cp gs 0.00 setgray ef gr col0 s
+$F2psEnd
+rs
+
+%%EndDocument
+ @endspecial 844 4373 a Fq(Figur)n(e)k(5:)31 b(Instr)o(uction)26
+b(list)g(for)g Fh(readInt\(\))d Fq(method)0 4834 y Fg(3.3.6)99
+b(Instruction)25 b(factories)0 5011 y Ft(T)-8 b(o)16
+b(simplify)i(the)f(cr)n(eation)g(of)g(certain)h(instr)o(uctions)e(the)h
+(user)f(can)i(use)e(the)g(supplied)g Ff(InstructionFact)o(or)o(y)0
+5124 y Ft(class)28 b(which)f(of)n(fers)g(a)h(lot)f(of)g(useful)g
+(methods)e(to)i(cr)n(eate)g(instr)o(uctions)f(fr)n(om)i(scratch.)42
+b(Alternatively)-10 b(,)28 b(he)0 5237 y(can)j(also)g(use)e
+Fs(compound)i(instructions)p Ft(:)45 b(When)29 b(pr)n(oducing)h(byte)f
+(code,)j(some)d(patterns)g(typically)i(occur)0 5350 y(very)25
+b(fr)n(equently)-10 b(,)24 b(for)h(instance)g(the)g(compilation)h(of)f
+(arithmetic)h(or)f(comparison)g(expr)n(essions.)34 b(Y)-8
+b(ou)24 b(cer)n(-)0 5463 y(tainly)k(do)f(not)g(want)h(to)f(r)n(ewrite)g
+(the)g(code)g(that)g(translates)g(such)g(expr)n(essions)f(into)h(byte)g
+(code)g(in)h(every)1863 5712 y Fq(17)p eop
+%%Page: 18 18
+18 17 bop 0 407 a Ft(place)26 b(they)f(may)h(appear)-7
+b(.)36 b(In)26 b(or)n(der)e(to)h(support)f(this,)i(the)e
+Fe(BCEL)j Ft(API)e(includes)h(a)g Fs(compound)g(instruction)0
+520 y Ft(\(an)k(interface)f(with)f(a)i(single)e Ff(getInstructionL)o
+(is)o(t\()o(\))23 b Ft(method\).)45 b(Instances)27 b(of)i(this)g(class)
+g(may)g(be)0 633 y(used)21 b(in)i(any)g(place)g(wher)n(e)f(normal)h
+(instr)o(uctions)f(would)g(occur)-7 b(,)23 b(particularly)h(in)f
+(append)e(operations.)0 898 y Fg(Example:)43 b(Pushing)32
+b(constants.)92 b Ft(Pushing)28 b(constants)g(onto)f(the)h(operand)g
+(stack)g(may)h(be)g(coded)f(in)0 1011 y(dif)n(fer)n(ent)g(ways.)44
+b(As)27 b(explained)h(in)g(section)g(2.2)h(ther)n(e)e(ar)n(e)h(some)f
+(\223short-cut\224)h(instr)o(uctions)f(that)h(can)h(be)0
+1124 y(used)20 b(to)h(make)g(the)f(pr)n(oduced)g(byte)g(code)h(mor)n(e)
+g(compact.)28 b(The)20 b(smallest)i(instr)o(uction)f(to)f(push)h(a)h
+(single)e Ff(1)0 1237 y Ft(onto)h(the)h(stack)g(is)g
+Ff(iconst)p 1002 1237 28 4 v 30 w(1)p Ft(,)g(other)f(possibilities)i
+(ar)n(e)f Ff(bipush)e Ft(\(can)k(be)e(used)f(to)h(push)f(values)i
+(between)0 1350 y(-128)h(and)f(127\),)h Ff(sipush)c Ft(\(between)h
+(-32768)26 b(and)c(32767\),)j(or)e Ff(ldc)e Ft(\(load)i(constant)f(fr)n
+(om)h(constant)f(pool\).)146 1465 y(Instead)28 b(of)i(r)n(epeatedly)d
+(selecting)i(the)g(most)f(compact)i(instr)o(uction)f(in,)j(say)-10
+b(,)30 b(a)g(switch,)h(one)e(can)h(use)0 1578 y(the)20
+b(compound)g Ff(PUSH)g Ft(instr)o(uction)h(whenever)f(pushing)g(a)h
+(constant)g(number)g(or)g(string.)26 b(It)21 b(will)h(pr)n(oduce)0
+1691 y(the)g(appr)n(opriate)g(byte)g(code)f(instr)o(uction)i(and)f
+(insert)g(entries)f(into)i(to)f(constant)f(pool)h(if)i(necessary)-10
+b(.)109 1929 y Ff(il.append\(new)49 b(PUSH\(cp,)i("Hello,)g
+(world"\)\);)109 2042 y(il.append\(new)e(PUSH\(cp,)i(4711\)\);)0
+2315 y Fg(3.3.7)99 b(Code)25 b(patterns)f(using)i(regular)e
+(expressions)0 2496 y Ft(When)j(transforming)g(code,)g(for)g(instance)g
+(during)g(optimization)h(or)f(when)f(inserting)h(analysis)g(method)0
+2609 y(calls,)35 b(one)c(typically)h(sear)n(ches)f(for)g(certain)h
+(patterns)e(of)i(code)e(to)h(perform)g(the)g(transformation)g(at.)55
+b(T)-8 b(o)0 2722 y(simplify)27 b(handling)g(such)f(situations)g
+Fe(BCEL)i Ft(intr)n(oduces)e(a)h(special)g(featur)n(e:)35
+b(One)27 b(can)g(sear)n(ch)g(for)f(given)0 2835 y(code)17
+b(patterns)e(within)j(an)g(instr)o(uction)f(list)h(using)e
+Fs(r)n(egular)k(expr)n(essions)p Ft(.)30 b(In)17 b(such)g(expr)n
+(essions,)f(instr)o(uctions)0 2948 y(ar)n(e)26 b(r)n(epr)n(esented)e
+(by)i(symbolic)g(names,)h(e.g.)37 b(\224)p Ff(`IfInstruction')p
+Ft(\224.)32 b(Meta)26 b(characters)g(like)g Ff(+)p Ft(,)h
+Ff(*)p Ft(,)f(and)0 3061 y Ff(\(..|..\))20 b Ft(have)j(their)f(usual)h
+(meanings.)k(Thus,)22 b(the)f(expr)n(ession)109 3300
+y Ff("`NOP'+\(`ILOAD_)o(_')o(|`)o(ALO)o(AD)o(__)o('\))o(*")146
+3536 y Ft(r)n(epr)n(esents)28 b(a)i(piece)f(of)h(code)f(consisting)g
+(of)h(at)g(least)f(one)g Ff(NOP)g Ft(followed)g(by)h(a)g(possibly)f
+(empty)g(se-)0 3649 y(quence)22 b(of)g Ff(ILOAD)f Ft(and)i
+Ff(ALOAD)d Ft(instr)o(uctions.)146 3764 y(The)j Ff(search\(\))d
+Ft(method)j(of)g(class)i Ff(FindPattern)18 b Ft(gets)k(an)i(instr)o
+(uction)g(list)g(and)f(a)i(r)n(egular)e(expr)n(es-)0
+3877 y(sion)g(as)g(ar)n(guments)f(and)h(r)n(eturns)f(an)i(array)f
+(describing)g(the)g(ar)n(ea)h(of)f(matched)g(instr)o(uctions.)28
+b(Additional)0 3990 y(constraints)d(to)h(the)f(matching)i(ar)n(ea)g(of)
+g(instr)o(uctions,)f(which)g(can)h(not)f(be)g(implemented)f(via)j(r)n
+(egular)e(ex-)0 4103 y(pr)n(essions,)21 b(may)i(be)f(expr)n(essed)e
+(via)k Fs(code)g(constraints)p Ft(.)0 4376 y Fg(3.3.8)99
+b(Example:)30 b(Optimizing)25 b(boolean)g(expressions.)0
+4557 y Ft(In)17 b(Java,)j(boolean)d(values)h(ar)n(e)f(mapped)g(to)g(1)h
+(and)f(to)g(0,)h(r)n(espectively)-10 b(.)25 b(Thus,)18
+b(the)e(simplest)h(way)g(to)g(evaluate)0 4670 y(boolean)k(expr)n
+(essions)e(is)j(to)f(push)f(a)i(1)g(or)f(a)h(0)g(onto)f(the)f(operand)g
+(stack)h(depending)f(on)h(the)f(tr)o(uth)h(value)h(of)0
+4783 y(the)i(expr)n(ession.)31 b(But)23 b(this)h(way)-10
+b(,)25 b(the)e(subsequent)f(combination)k(of)e(boolean)h(expr)n
+(essions)d(\(with)i Ff(&&)p Ft(,)g(e.g\))0 4896 y(yields)e(long)g
+(chunks)g(of)h(code)e(that)i(push)e(lots)h(of)h(1s)g(and)f(0s)h(onto)f
+(the)f(stack.)146 5011 y(When)i(the)f(code)g(has)h(been)f(\002nalized)i
+(these)d(chunks)h(can)h(be)g(optimized)g(with)g(a)g Fs(peep)i(hole)f
+Ft(algorithm:)0 5124 y(An)i Ff(IfInstruction)20 b Ft(\(e.g.)38
+b(the)26 b(comparison)g(of)g(two)g(integers:)33 b Ff(if)p
+2529 5124 V 32 w(icmpeq)p Ft(\))24 b(that)h(either)h(pr)n(oduces)f(a)0
+5237 y(1)32 b(or)f(a)g(0)h(on)f(the)f(stack)h(and)g(is)h(followed)e(by)
+h(an)h Ff(ifne)e Ft(instr)o(uction)g(\(branch)j(if)f(stack)f(value)h
+Fd(6)p Fc(=)f Ft(0\))h(may)0 5350 y(be)d(r)n(eplaced)f(by)h(the)f
+Ff(IfInstruction)23 b Ft(with)29 b(its)f(branch)i(tar)n(get)e(r)n
+(eplaced)g(by)h(the)f(tar)n(get)g(of)h(the)f Ff(ifne)0
+5463 y Ft(instr)o(uction:)1863 5712 y Fq(18)p eop
+%%Page: 19 19
+19 18 bop 109 407 a Ff(InstructionList)48 b(il)53 b(=)i(new)e
+(InstructionLis)o(t\()o(\);)109 520 y(...)109 633 y(CodeConstraint)48
+b(constraint)i(=)k(new)g(CodeConstraint)o(\(\))48 b({)218
+746 y(public)k(boolean)f(checkCode\(Instru)o(ct)o(io)o(nH)o(an)o(dle)o
+([])d(match\))k({)327 858 y(IfInstruction)d(if1)k(=)h
+(\(IfInstruction\))o(ma)o(tch)o([0)o(].)o(ge)o(tI)o(nst)o(ru)o(ct)o(io)
+o(n\()o(\);)327 971 y(GOTO)544 b(g)163 b(=)54 b(\(GOTO\)match[2].)o(ge)
+o(tIn)o(st)o(ru)o(ct)o(io)o(n\(\))o(;)327 1084 y(return)e
+(\(if1.getTarget\()o(\))c(==)54 b(match[3]\))c(&&)709
+1197 y(\(g.getTarget\(\))e(==)54 b(match[4]\);)218 1310
+y(})109 1423 y(};)109 1536 y(FindPattern)c(f)163 b(=)54
+b(new)f(FindPattern\(il\))o(;)109 1649 y(String)325 b(pat)53
+b(=)h("`IfInstruction)o('`)o(IC)o(ON)o(ST)o(_0')o(`G)o(OT)o(O')o(`I)o
+(CON)o(ST)o(_1)o('")48 b(+)1091 1762 y("`NOP'\(`IFEQ'|`)o(IF)o(NE)o
+('\))o(";)109 1875 y(InstructionHand)o(le)o([])g(match;)109
+1988 y(for\(Instruction)o(Ha)o(nd)o(le)g(ih)54 b(=)g(f.search\(pat,)48
+b(constraint\);)327 2100 y(ih)54 b(!=)g(null;)e(ih)h(=)i
+(f.search\(pat,)48 b(match[0],)j(constraint\)\))e({)218
+2213 y(match)j(=)j(f.getMatch\(\);)48 b(//)54 b(Constraint)c(already)h
+(checked)218 2326 y(...)218 2439 y(match[0].setTar)o(ge)o(t\(m)o(at)o
+(ch)o([5)o(].)o(get)o(Ta)o(rg)o(et)o(\(\))o(\);)d(//)54
+b(Update)e(target)218 2552 y(...)218 2665 y(try)h({)327
+2778 y(il.delete\(match)o([1])o(,)48 b(match[5]\);)218
+2891 y(})54 b(catch\(TargetLos)o(tEx)o(ce)o(pt)o(io)o(n)48
+b(e\))54 b({)g(...)f(})109 3004 y(})146 3325 y Ft(The)26
+b(applied)g(code)f(constraint)h(object)g(ensur)n(es)f(that)h(the)f
+(matched)h(code)f(r)n(eally)i(corr)n(esponds)d(to)i(the)0
+3437 y(tar)n(geted)e(expr)n(ession)g(pattern.)35 b(Subsequent)24
+b(application)j(of)e(this)h(algorithm)g(r)n(emoves)f(all)i(unnecessary)
+0 3550 y(stack)g(operations)e(and)i(branch)h(instr)o(uctions)e(fr)n(om)
+h(the)f(byte)g(code.)40 b(If)27 b(any)g(of)g(the)f(deleted)f(instr)o
+(uctions)0 3663 y(is)g(still)h(r)n(efer)n(enced)d(by)i(an)h
+Ff(InstructionTar)o(ge)o(te)o(r)19 b Ft(object,)25 b(the)f(r)n(efer)n
+(ence)g(has)h(to)g(be)f(updated)g(in)h(the)0 3776 y Ff(catch)p
+Ft(-clause.)146 3903 y(Code)g(example)h(A.1)g(gives)f(a)h(verbose)f
+(example)h(of)f(how)h(to)f(cr)n(eate)h(a)g(class)g(\002le,)g(while)g
+(example)g(A.3)0 4016 y(shows)e(how)i(to)f(implement)h(a)g(simple)g
+(peephole)e(optimizer)i(and)g(how)g(to)f(deal)h(with)g
+Ff(TargetLost)21 b Ft(ex-)0 4129 y(ceptions.)0 4468 y
+Fg(Example)j(application:)91 b Ft(The)22 b(expr)n(ession)109
+4803 y Ff(if\(\(a)52 b(==)i(null\))e(||)i(\(i)g(<)g(2\)\))218
+4916 y(System.out.prin)o(tl)o(n\(")o(Oo)o(op)o(s")o(\);)146
+5237 y Ft(can)31 b(be)f(mapped)f(to)h(both)f(of)h(the)g(chunks)f(of)h
+(byte)f(code)g(shown)g(in)i(\002gur)n(e)e(3.3.8.)51 b(The)29
+b(left)i(column)0 5350 y(r)n(epr)n(esents)18 b(the)i(unoptimized)g
+(code)g(while)h(the)f(right)g(column)h(displays)f(the)g(same)g(code)g
+(after)h(an)g(aggr)n(es-)0 5463 y(sively)i(optimizing)g(peep)e(hole)h
+(algorithm)h(has)g(been)f(applied:)1863 5712 y Fq(19)p
+eop
+%%Page: 20 20
+20 19 bop 0 1311 a Ff(5:)108 b(aload_0)0 1424 y(6:)g(ifnull)434
+b(#13)0 1537 y(9:)108 b(iconst_0)0 1649 y(10:)53 b(goto)544
+b(#14)0 1762 y(13:)53 b(iconst_1)0 1875 y(14:)g(nop)0
+1988 y(15:)g(ifne)544 b(#36)0 2101 y(18:)53 b(iload_1)0
+2214 y(19:)g(iconst_2)0 2327 y(20:)g(if_icmplt)269 b(#27)0
+2440 y(23:)53 b(iconst_0)0 2553 y(24:)g(goto)544 b(#28)0
+2666 y(27:)53 b(iconst_1)0 2779 y(28:)g(nop)0 2891 y(29:)g(ifne)544
+b(#36)0 3004 y(32:)53 b(iconst_0)0 3117 y(33:)g(goto)544
+b(#37)0 3230 y(36:)53 b(iconst_1)0 3343 y(37:)g(nop)0
+3456 y(38:)g(ifeq)544 b(#52)0 3569 y(41:)53 b(getstatic)269
+b(System.out)0 3682 y(44:)53 b(ldc)599 b("Ooops")0 3795
+y(46:)53 b(invokevirtual)c(println)0 3908 y(52:)k(return)1899
+1311 y(10:)g(aload_0)1899 1424 y(11:)g(ifnull)434 b(#19)1899
+1537 y(14:)53 b(iload_1)1899 1650 y(15:)g(iconst_2)1899
+1763 y(16:)g(if_icmpge)269 b(#27)1899 1876 y(19:)53 b(getstatic)269
+b(System.out)1899 1989 y(22:)53 b(ldc)599 b("Ooops")1899
+2102 y(24:)53 b(invokevirtual)c(println)1899 2215 y(27:)k(return)995
+4181 y Fq(Figur)n(e)26 b(6:)31 b(Optimizing)25 b(boolean)h(expr)n
+(essions)1863 5712 y(20)p eop
+%%Page: 21 21
+21 20 bop 0 410 a Fr(4)143 b(Application)33 b(areas)0
+662 y Ft(Ther)n(e)20 b(ar)n(e)i(many)f(possible)g(application)h(ar)n
+(eas)f(for)g Fe(BCEL)i Ft(ranging)e(fr)n(om)g(class)h(br)n(owsers,)e
+(pr)n(o\002lers,)g(byte)0 774 y(code)30 b(optimizers,)i(and)e
+(compilers)g(to)g(sophisticated)f(r)o(un-time)i(analysis)g(tools)e(and)
+i(extensions)d(to)i(the)0 887 y(Java)24 b(language)f([AFM97,)g(MBL97].)
+146 1020 y(Compilers)33 b(like)g(the)f(Barat)h(compiler)g([BS98])g(use)
+f Fe(BCEL)j Ft(to)d(implement)h(a)g(byte)f(code)g(generating)0
+1133 y(back)22 b(end.)27 b(Other)21 b(possible)g(application)i(ar)n
+(eas)f(ar)n(e)f(the)g(static)h(analysis)g(of)g(byte)e(code)h([TK98)q(])
+h(or)f(examin-)0 1246 y(ing)e(the)f(r)o(un-time)i(behavior)f(of)g
+(classes)g(by)g(inserting)f(calls)i(to)f(pr)n(o\002ling)g(methods)e
+(into)i(the)f(code.)26 b(Further)0 1359 y(examples)h(ar)n(e)h
+(extending)e(Java)k(with)e(Eif)n(fel-like)h(assertions)d([FM98],)k
+(automated)d(delegation)f([Cos98)q(],)0 1472 y(or)c(with)h(the)f
+(concepts)f(of)i(\223Aspect-Oriented)e(Pr)n(ogramming\224)i([KLM)2542
+1439 y Fb(+)2601 1472 y Ft(97)q(].)0 1882 y Fm(4.1)119
+b(Class)30 b(loaders)0 2099 y Ft(Class)d(loaders)f(ar)n(e)h(r)n
+(esponsible)f(for)h(loading)g(class)g(\002les)f(fr)n(om)i(the)e(\002le)
+h(system)e(or)h(other)g(r)n(esour)n(ces)f(and)0 2212
+y(passing)k(the)g(byte)h(code)f(to)g(the)g(V)-5 b(irtual)31
+b(Machine)g([LB98].)50 b(A)30 b(custom)g Ff(ClassLoader)25
+b Ft(object)30 b(may)g(be)0 2325 y(used)h(to)h(inter)n(cept)g(the)g
+(standar)n(d)g(pr)n(ocedur)n(e)f(of)i(loading)f(a)i(class,)h(i.e.)58
+b(the)31 b(system)g(class)i(loader)-7 b(,)35 b(and)0
+2438 y(perform)22 b(some)g(transformations)g(befor)n(e)g(actually)i
+(passing)e(the)f(byte)h(code)g(to)g(the)g(JVM.)146 2571
+y(A)28 b(possible)f(scenario)h(is)g(described)f(in)h(\002gur)n(e)g(7:)
+39 b(During)28 b(r)o(un-time)g(the)f(V)-5 b(irtual)28
+b(Machine)h(r)n(equests)0 2683 y(a)d(custom)g(class)g(loader)g(to)f
+(load)h(a)g(given)g(class.)38 b(But)25 b(befor)n(e)h(the)f(JVM)h
+(actually)h(sees)d(the)h(byte)g(code,)h(the)0 2796 y(class)h(loader)f
+(makes)f(a)i(\223side-step\224)e(and)h(performs)f(some)g
+(transformation)h(to)g(the)f(class.)39 b(T)-8 b(o)26
+b(make)g(sur)n(e)0 2909 y(that)21 b(the)f(modi\002ed)g(byte)g(code)g
+(is)i(still)f(valid)i(and)e(does)e(not)h(violate)i(any)f(of)g(the)f
+(JVM's)h(r)o(ules)g(it)g(is)g(checked)0 3022 y(by)i(the)e(veri\002er)i
+(befor)n(e)f(the)g(JVM)h(\002nally)g(executes)e(it.)0
+4050 y @beginspecial 0 @llx 0 @lly 683 @urx 144 @ury
+4590 @rwi @setspecial
+%%BeginDocument: eps/classloader.eps
+%!PS-Adobe-2.0 EPSF-2.0
+%%Title: classloader.eps
+%%Creator: fig2dev Version 3.2 Patchlevel 0-beta3
+%%CreationDate: Thu Mar 18 16:45:56 1999
+%%For: dahm@gromit (Markus Dahm)
+%%Orientation: Portrait
+%%BoundingBox: 0 0 683 144
+%%Pages: 0
+%%BeginSetup
+%%EndSetup
+%%Magnification: 1.0000
+%%EndComments
+/$F2psDict 200 dict def
+$F2psDict begin
+$F2psDict /mtrx matrix put
+/col-1 {0 setgray} bind def
+/col0 {0.000 0.000 0.000 srgb} bind def
+/col1 {0.000 0.000 1.000 srgb} bind def
+/col2 {0.000 1.000 0.000 srgb} bind def
+/col3 {0.000 1.000 1.000 srgb} bind def
+/col4 {1.000 0.000 0.000 srgb} bind def
+/col5 {1.000 0.000 1.000 srgb} bind def
+/col6 {1.000 1.000 0.000 srgb} bind def
+/col7 {1.000 1.000 1.000 srgb} bind def
+/col8 {0.000 0.000 0.560 srgb} bind def
+/col9 {0.000 0.000 0.690 srgb} bind def
+/col10 {0.000 0.000 0.820 srgb} bind def
+/col11 {0.530 0.810 1.000 srgb} bind def
+/col12 {0.000 0.560 0.000 srgb} bind def
+/col13 {0.000 0.690 0.000 srgb} bind def
+/col14 {0.000 0.820 0.000 srgb} bind def
+/col15 {0.000 0.560 0.560 srgb} bind def
+/col16 {0.000 0.690 0.690 srgb} bind def
+/col17 {0.000 0.820 0.820 srgb} bind def
+/col18 {0.560 0.000 0.000 srgb} bind def
+/col19 {0.690 0.000 0.000 srgb} bind def
+/col20 {0.820 0.000 0.000 srgb} bind def
+/col21 {0.560 0.000 0.560 srgb} bind def
+/col22 {0.690 0.000 0.690 srgb} bind def
+/col23 {0.820 0.000 0.820 srgb} bind def
+/col24 {0.500 0.190 0.000 srgb} bind def
+/col25 {0.630 0.250 0.000 srgb} bind def
+/col26 {0.750 0.380 0.000 srgb} bind def
+/col27 {1.000 0.500 0.500 srgb} bind def
+/col28 {1.000 0.630 0.630 srgb} bind def
+/col29 {1.000 0.750 0.750 srgb} bind def
+/col30 {1.000 0.880 0.880 srgb} bind def
+/col31 {1.000 0.840 0.000 srgb} bind def
+
+end
+save
+-55.0 171.0 translate
+1 -1 scale
+
+/cp {closepath} bind def
+/ef {eofill} bind def
+/gr {grestore} bind def
+/gs {gsave} bind def
+/sa {save} bind def
+/rs {restore} bind def
+/l {lineto} bind def
+/m {moveto} bind def
+/rm {rmoveto} bind def
+/n {newpath} bind def
+/s {stroke} bind def
+/sh {show} bind def
+/slc {setlinecap} bind def
+/slj {setlinejoin} bind def
+/slw {setlinewidth} bind def
+/srgb {setrgbcolor} bind def
+/rot {rotate} bind def
+/sc {scale} bind def
+/sd {setdash} bind def
+/ff {findfont} bind def
+/sf {setfont} bind def
+/scf {scalefont} bind def
+/sw {stringwidth} bind def
+/tr {translate} bind def
+/tnt {dup dup currentrgbcolor
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
+ bind def
+/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
+ 4 -2 roll mul srgb} bind def
+/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
+/$F2psEnd {$F2psEnteredState restore end} def
+%%EndProlog
+
+$F2psBegin
+10 setmiterlimit
+n -1000 3712 m -1000 -1000 l 12712 -1000 l 12712 3712 l cp clip
+ 0.06299 0.06299 sc
+% Polyline
+7.500 slw
+n 1005 450 m 900 450 900 1020 105 arcto 4 {pop} repeat
+ 900 1125 3045 1125 105 arcto 4 {pop} repeat
+ 3150 1125 3150 555 105 arcto 4 {pop} repeat
+ 3150 450 1005 450 105 arcto 4 {pop} repeat
+ cp gs col0 s gr
+/Helvetica ff 210.00 scf sf
+1350 900 m
+gs 1 -1 sc (Java class file) col0 sh gr
+% Polyline
+n 3600 450 m 5850 450 l 5850 1125 l 3600 1125 l cp gs col0 s gr
+/Helvetica ff 210.00 scf sf
+4140 855 m
+gs 1 -1 sc (Class loader) col0 sh gr
+% Polyline
+n 6750 450 m 9000 450 l 9000 1125 l 6750 1125 l cp gs col0 s gr
+/Helvetica ff 210.00 scf sf
+7020 855 m
+gs 1 -1 sc (Byte code verifier) col0 sh gr
+% Polyline
+n 9450 450 m 11700 450 l 11700 1125 l 9450 1125 l cp gs col0 s gr
+/Helvetica ff 210.00 scf sf
+9900 900 m
+gs 1 -1 sc (Interpreter/JIT) col0 sh gr
+% Polyline
+n 4950 1575 m 7875 1575 l 7875 2700 l 4950 2700 l cp gs col0 s gr
+/Helvetica ff 210.00 scf sf
+5175 2475 m
+gs 1 -1 sc (Byte code transformations) col0 sh gr
+/Courier-Bold ff 210.00 scf sf
+5850 2025 m
+gs 1 -1 sc (JavaClass) col0 sh gr
+% Polyline
+gs clippath
+3453 735 m 3573 765 l 3453 795 l 3615 795 l 3615 735 l cp
+clip
+n 3150 765 m 3600 765 l gs col0 s gr gr
+
+% arrowhead
+n 3453 735 m 3573 765 l 3453 795 l 3453 765 l 3453 735 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+9303 735 m 9423 765 l 9303 795 l 9465 795 l 9465 735 l cp
+clip
+n 9000 765 m 9450 765 l gs col0 s gr gr
+
+% arrowhead
+n 9303 735 m 9423 765 l 9303 795 l 9303 765 l 9303 735 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+6105 1428 m 6075 1548 l 6045 1428 l 6045 1590 l 6105 1590 l cp
+clip
+n 5850 765 m 6075 765 l 6075 1575 l gs col0 s gr gr
+
+% arrowhead
+n 6105 1428 m 6075 1548 l 6045 1428 l 6075 1428 l 6105 1428 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+gs clippath
+6603 735 m 6723 765 l 6603 795 l 6765 795 l 6765 735 l cp
+clip
+n 6525 1575 m 6525 765 l 6750 765 l gs col0 s gr gr
+
+% arrowhead
+n 6603 735 m 6723 765 l 6603 795 l 6603 765 l 6603 735 l cp gs 0.00 setgray ef gr col0 s
+$F2psEnd
+rs
+
+%%EndDocument
+ @endspecial 1414 4253 a Fq(Figur)n(e)26 b(7:)k(Class)25
+b(loaders)146 4672 y Ft(Using)i(class)h(loaders)f(is)g(an)h(elegant)f
+(way)g(of)h(extending)d(the)i(Java)i(V)-5 b(irtual)28
+b(Machine)g(with)g(new)e(fea-)0 4785 y(tur)n(es)20 b(without)g
+(actually)i(modifying)f(it.)27 b(This)21 b(concept)f(enables)h
+(developers)e(to)h(use)g Fs(load-time)j(r)n(e\003ection)g
+Ft(to)0 4898 y(implement)28 b(their)f(ideas)h(as)g(opposed)d(to)j(the)f
+(static)h(r)n(e\003ection)g(supported)d(by)j(the)f(Java)j(Re\003ection)
+d(API)0 5011 y([Jav98)r(].)45 b(Load-time)28 b(transformations)g
+(supply)f(the)g(user)g(with)h(a)h(new)f(level)h(of)f(abstraction.)45
+b(He)27 b(is)i(not)0 5124 y(strictly)24 b(tied)f(to)h(the)f(static)h
+(constraints)f(of)h(the)g(original)h(authors)e(of)h(the)f(classes)h
+(but)g(may)g(customize)g(the)0 5237 y(applications)i(with)f(thir)n
+(d-party)g(code)g(in)g(or)n(der)g(to)f(bene\002t)h(fr)n(om)h(new)e
+(featur)n(es.)36 b(Such)25 b(transformations)0 5350 y(may)j(be)g
+(executed)d(on)j(demand)f(and)h(neither)e(interfer)n(e)h(with)h(other)e
+(users,)h(nor)h(alter)f(the)g(original)i(byte)0 5463
+y(code.)e(In)22 b(fact,)h(class)h(loaders)d(may)i(even)f(cr)n(eate)h
+(classes)f Fs(ad)i(hoc)f Ft(without)f(loading)h(a)g(\002le)g(at)f(all.)
+1863 5712 y Fq(21)p eop
+%%Page: 22 22
+22 21 bop 0 407 a Fg(4.1.1)99 b(Example:)30 b(Poor)25
+b(Man')-5 b(s)24 b(Genericity)0 587 y Ft(The)17 b(\223Poor)g(Man's)h
+(Genericity\224)g(pr)n(oject)f([BD98)r(])h(that)f(extends)f(Java)j
+(with)f(parameterized)f(classes,)h(for)f(ex-)0 700 y(ample,)j(uses)e
+Fe(BCEL)i Ft(in)f(two)g(places)g(to)g(generate)e(instances)i(of)g
+(parameterized)f(classes:)26 b(During)19 b(compile-)0
+813 y(time)36 b(\(the)f(standar)n(d)g Ff(javac)f Ft(with)i(some)f
+(slightly)g(changed)g(classes\))h(and)g(at)g(r)o(un-time)f(using)h(a)g
+(cus-)0 926 y(tom)28 b(class)g(loader)-7 b(.)43 b(The)28
+b(compiler)g(puts)f(some)g(additional)h(type)e(information)j(into)f
+(class)g(\002les)g(which)g(is)0 1039 y(evaluated)e(at)h(load-time)f(by)
+g(the)g(class)h(loader)-7 b(.)38 b(The)26 b(class)h(loader)e(performs)h
+(some)f(transformations)g(on)0 1152 y(the)i(loaded)g(class)i(and)e
+(passes)g(them)g(to)g(the)g(VM.)h(The)f(following)h(algorithm)g
+(illustrates)g(how)f(the)g(load)0 1264 y(method)21 b(of)i(the)f(class)h
+(loader)f(ful\002lls)i(the)e(r)n(equest)f(for)h(a)h(parameterized)f
+(class,)h(e.g.)k Ff(Stack<String>)127 1487 y Ft(1.)49
+b(Sear)n(ch)19 b(for)g(class)g Ff(Stack)p Ft(,)f(load)h(it,)g(and)g
+(check)g(for)g(a)g(certain)g(class)h(attribute)e(containing)h
+(additional)244 1600 y(type)i(information.)28 b(I.e.)f(the)22
+b(attribute)g(de\002nes)f(the)h(\223r)n(eal\224)i(name)f(of)g(the)e
+(class,)i(i.e.)28 b Ff(Stack<A>)p Ft(.)127 1794 y(2.)49
+b(Replace)28 b(all)h(occurr)n(ences)e(and)h(r)n(efer)n(ences)f(to)g
+(the)g(formal)i(type)d Ff(A)i Ft(with)g(r)n(efer)n(ences)f(to)g(the)g
+(actual)244 1907 y(type)21 b Ff(String)p Ft(.)k(For)d(example)g(the)g
+(method)353 2168 y Ff(void)53 b(push\(A)f(obj\))g({)i(...)g(})244
+2429 y Ft(becomes)353 2690 y Ff(void)f(push\(String)c(obj\))k({)h(...)f
+(})127 2952 y Ft(3.)c(Return)21 b(the)h(r)n(esulting)g(class)h(to)f
+(the)g(V)-5 b(irtual)23 b(Machine.)0 3293 y Fr(References)0
+3508 y Ft([AFM97])109 b(O.)29 b(Agesen,)f(S.)h(N.)f(Fr)n(eund,)h(and)g
+(J.)h(C.)f(Mitchell.)54 b(Adding)27 b(T)-8 b(ype)28 b(Parameterization)
+i(to)e(the)467 3621 y(Java)c(Language.)31 b(In)23 b Fs(Pr)n(oceedings)i
+(OOPSLA)-5 b('97)p Ft(,)21 b(Atlanta,)i(GA,)f(1997.)0
+3815 y([AP98])191 b(D.)24 b(Antonioli)f(and)h(M.)g(Pilz.)37
+b(Statistische)23 b(Analyse)g(von)h(Java-Class\002les.)38
+b(In)23 b(Clemens)h(Cap,)467 3928 y(editor)-7 b(,)21
+b Fs(Pr)n(oceedings)k(JIT'98)p Ft(.)f(Springer)-7 b(,)22
+b(1998.)0 4122 y([BD98])191 b(B.)21 b(Bokowski)f(and)i(M.)f(Dahm.)32
+b(Poor)21 b(Man's)h(Genericity)g(for)f(Java.)33 b(In)21
+b(Clemens)h(Cap,)g(editor)-7 b(,)467 4235 y Fs(Pr)n(oceedings)25
+b(JIT'98)p Ft(.)f(Springer)-7 b(,)21 b(1998.)0 4429 y([BS98])213
+b(B.)28 b(Bokowski)f(and)i(A.)f(Spiegel.)51 b(Barat)29
+b(\226)h(A)e(Fr)n(ont-End)f(for)i(Java.)54 b(T)-8 b(echnical)30
+b(r)n(eport,)f(Fr)n(eie)467 4542 y(Universit)8 b(\250)-38
+b(at)22 b(Berlin,)g(1998.)0 4736 y([CCK98])123 b(Geof)n(f)24
+b(Cohen,)f(Jef)n(f)h(Chase,)g(and)f(David)i(Kaminsky)-10
+b(.)35 b(Automatic)24 b(Pr)n(ogram)f(T)-8 b(ransformation)467
+4849 y(with)22 b(JOIE.)33 b(In)22 b Fs(Pr)n(oceedings)j(USENIX)c
+(Annual)h(T)-10 b(echnical)23 b(Symposium)p Ft(,)g(1998.)0
+5043 y([CCZ97])128 b(Suzanne)34 b(Collin,)39 b(Dominique)d(Colnet,)h
+(and)e(Olivier)h(Zendra.)70 b(T)-8 b(ype)33 b(Infer)n(ence)h(for)h
+(Late)467 5156 y(Binding.)22 b(The)g(SmallEif)n(fel)j(Compiler.)32
+b(In)23 b Fs(Pr)n(oceedings)i(JMLC'97)p Ft(,)e(1997.)0
+5350 y([Cos98])164 b(Pascal)42 b(Costanza.)90 b Fs(The)41
+b(ClassFilters)i(package)p Ft(.)91 b(Universit)8 b(\250)-38
+b(at)41 b(Bonn,)i Ff(http://www.cs.)467 5463 y(uni-)t(bonn.de/\230co)o
+(st)o(an)o(za)o(/Cl)o(as)o(sF)o(il)o(te)o(rs/)o Ft(,)17
+b(1998.)1863 5712 y Fq(22)p eop
+%%Page: 23 23
+23 22 bop 0 407 a Ft([FM98])180 b(C.)29 b(Fischer)f(and)g(D.)h
+(Meemken.)50 b(JaW)-8 b(a:)41 b(Java)30 b(with)f(Assertions.)49
+b(In)28 b(Clemens)h(Cap,)h(editor)-7 b(,)467 520 y Fs(Pr)n(oceedings)25
+b(JIT'98)p Ft(.)f(Springer)-7 b(,)21 b(1998.)0 707 y([GHJV95])76
+b(E.)17 b(Gamma,)k(R.)d(Helm,)h(R.)f(Johnson,)g(and)g(J.)g(Vlissides.)k
+Fs(Design)d(Patterns:)27 b(Elements)19 b(of)g(Reusable)467
+820 y(Object-Oriented)25 b(Softwar)n(e)p Ft(.)34 b(Addison-W)-8
+b(esley)e(,)19 b(1995.)0 1008 y([GJS96])170 b(J.)32 b(Gosling,)j(B.)d
+(Joy)-10 b(,)34 b(and)f(G.)f(Steele.)63 b Fs(The)33 b(Java)h(Language)f
+(Speci\002cation)p Ft(.)66 b(Addison-W)-8 b(esley)e(,)467
+1121 y(1996.)0 1308 y([Jav98])191 b(JavaSoft.)71 b Fs(Re\003ection)35
+b(API)p Ft(.)70 b Ff(http://java.sun)o(.c)o(om)o(/pr)o(od)o(uc)o(ts)o
+(/j)o(dk/)o(1.)o(1/)o(do)o(cs)o(/)467 1421 y(guide/reflecti)o(on/)o
+Ft(,)17 b(1998.)0 1609 y([KH98])175 b(Ralph)33 b(Keller)f(and)h(Urs)f
+(H)10 b(\250)-40 b(olzle.)65 b(Binary)32 b(Component)g(Adaptation.)63
+b(In)33 b(Eric)g(Jul,)i(editor)-7 b(,)467 1722 y Fs(Pr)n(oceedings)25
+b(ECOOP'98)p Ft(.)d(Springer)-7 b(,)21 b(1998.)0 1910
+y([KLM)238 1877 y Fb(+)297 1910 y Ft(97])50 b(Gr)n(egor)27
+b(Kiczales,)i(John)e(Lamping,)h(Anurag)f(Mendhekar)-7
+b(,)27 b(Chris)h(Maeda,)g(Cristina)g(Lopes,)467 2022
+y(Jean-Mar)n(c)f(Loingtier)-7 b(,)26 b(and)g(John)g(Irwin.)43
+b(Aspect-Oriented)24 b(Pr)n(ogramming.)43 b(T)-8 b(echnical)27
+b(r)n(e-)467 2135 y(port,)21 b(Xer)n(ox)h(Palo)h(Alto)f(Resear)n(ch)g
+(Center)-7 b(,)22 b(1997.)0 2323 y([LB98])205 b(Sheng)23
+b(Lian)i(and)g(Gilad)h(Bracha.)39 b(Dynamic)26 b(Class)g(Loading)d(in)i
+(the)f(Java)j(V)-5 b(irtual)25 b(Machine.)467 2436 y(In)d
+Fs(Pr)n(oceedings)j(OOPSLA)-5 b('98)p Ft(,)22 b(1998.)0
+2623 y([L)-8 b(Y97])208 b(T)-5 b(im)35 b(Lindholm)f(and)g(Frank)g(Y)-8
+b(ellin.)69 b Fs(The)35 b(Java)h(V)-7 b(irtual)35 b(Machine)g
+(Speci\002cation)p Ft(.)71 b(Addison-)467 2736 y(W)-8
+b(esley)e(,)20 b(1997.)0 2924 y([LZ98])200 b(Han)25 b(Bok)f(Lee)f(and)i
+(Benjamin)h(G.)f(Zorn.)38 b(BIT)-5 b(:)24 b(A)h(T)-8
+b(ool)24 b(for)h(Instr)o(umenting)e(Java)j(Bytecodes.)467
+3037 y(In)c Fs(Pr)n(oceedings)j(USENIX)c(Symposium)j(on)e(Internet)i(T)
+-10 b(echnologies)25 b(and)e(Systems)p Ft(,)h(1998.)0
+3225 y([MBL97])119 b(A.C.)24 b(Myers,)g(J.)h(A.)g(Bank,)f(and)h(B.)f
+(Liskov)-10 b(.)39 b(Parameterized)24 b(T)-8 b(ypes)23
+b(for)i(Java.)41 b(In)25 b Fs(Pr)n(oceedings)467 3337
+y(POPL)m('97)p Ft(,)c(Paris,)i(France,)f(1997.)0 3525
+y([MD97])161 b(J.)23 b(Meyer)e(and)h(T)-7 b(.)23 b(Downing.)32
+b Fs(Java)24 b(V)-7 b(irtual)24 b(Machine)p Ft(.)33 b(O'Reilly)-10
+b(,)23 b(1997.)0 3713 y([Sil98])217 b(Shawn)28 b(Silverman.)51
+b Fs(The)28 b(class\002le)i(API)p Ft(.)50 b(University)27
+b(of)h(Manitoba,)i Ff(http://Meurrens)o(.)467 3826 y(ML.org/ip-)t
+(Links)o(/j)o(av)o(a/)o(cod)o(eE)o(ng)o(in)o(ee)o(rin)o(g/)o(vi)o(ew)o
+(er)o(s.h)o(tm)o(l)p Ft(,)16 b(1998.)0 4013 y([T)-8 b(af96])194
+b(T)-8 b(ucker)23 b(T)-8 b(aft.)37 b(Pr)n(ogramming)25
+b(the)e(Internet)f(in)j(Ada95.)38 b(In)24 b Fs(Pr)n(oceedings)j
+(Ada-Eur)n(ope)f(Interna-)467 4126 y(tional)e(Confer)n(ence)g(on)e
+(Reliable)j(Softwar)n(e)f(T)-10 b(echnologies)p Ft(,)25
+b(1996.)0 4314 y([TK98])195 b(M.)35 b(Thies)f(and)h(U.)f(Kastens.)71
+b(Statische)34 b(Analyse)g(von)h(Bibliotheken)f(als)i(Gr)o(undlage)f
+(dy-)467 4427 y(namischer)23 b(Optimier)o(ung.)32 b(In)23
+b(Clemens)f(Cap,)h(editor)-7 b(,)21 b Fs(Pr)n(oceedings)26
+b(JIT'98)p Ft(.)d(Springer)-7 b(,)22 b(1998.)0 4614 y([Y)-8
+b(ou98])159 b(Matt)42 b(T)-7 b(.)42 b(Y)-8 b(ourst.)92
+b Fs(Inside)44 b(Java)f(Class)g(Files)p Ft(.)96 b(Laserstars)40
+b(T)-8 b(echnologies,)45 b Ff(http://www.)467 4727 y(laserstars.com)o
+(/ar)o(ti)o(cl)o(es)o(/d)o(dj/)o(in)o(si)o(de)o(jc)o(f/)p
+Ft(,)16 b(1998.)1863 5712 y Fq(23)p eop
+%%Page: 24 24
+24 23 bop 0 410 a Fr(A)143 b(Code)35 b(examples)e(for)i(the)g(ClassGen)
+f(API)0 658 y Fm(A.1)119 b(HelloW)-9 b(orldBuilder)i(.java)0
+835 y Ft(The)18 b(following)h(Java)i(pr)n(ogram)e(r)n(eads)f(a)i(name)f
+(fr)n(om)g(the)g(standar)n(d)f(input)g(and)h(prints)f(a)i(friendly)f
+(\223Hello\224.)0 948 y(Since)31 b(the)f Ff(readLine\(\))d
+Ft(method)j(may)h(thr)n(ow)g(an)g Ff(IOException)26 b
+Ft(it)32 b(is)f(enclosed)e(by)i(a)h Ff(try-catch)0 1060
+y Ft(block.)0 1268 y Ff(import)52 b(java.io.*;)0 1494
+y(public)g(class)g(HelloWorld)e({)109 1607 y(public)i(static)g(void)g
+(main\(String[])d(argv\))j({)218 1720 y(BufferedReader)c(in)54
+b(=)g(new)f(BufferedReader\()o(new)1418 1833 y(InputStreamRead)o(er)o
+(\(Sy)o(st)o(em)o(.i)o(n\))o(\);)218 1946 y(String)f(name)h(=)h(null;)
+218 2172 y(try)f({)327 2284 y(System.out.prin)o(t\(")o(Pl)o(ea)o(se)48
+b(enter)k(your)h(name>)f("\);)327 2397 y(name)h(=)h(in.readLine\(\);)
+218 2510 y(})g(catch\(IOExcepti)o(on)48 b(e\))54 b({)g(return;)d(})218
+2736 y(System.out.prin)o(tl)o(n\(")o(He)o(ll)o(o,)d(")54
+b(+)g(name\);)109 2849 y(})0 2962 y(})0 3343 y Fm(A.2)119
+b(HelloW)-9 b(orldBuilder)i(.java)0 3520 y Ft(W)f(e)28
+b(will)i(sketch)e(her)n(e)g(how)g(the)g(above)h(Java)i(class)e(can)h
+(be)f(cr)n(eated)f(fr)n(om)h(the)f(scratch)h(using)g(the)f
+Fe(BCEL)0 3633 y Ft(API.)h(For)g(ease)g(of)h(r)n(eading)g(we)f(will)i
+(use)e(textual)g(signatur)n(es)g(and)h(not)f(cr)n(eate)h(them)f
+(dynamically)-10 b(.)51 b(For)0 3746 y(example,)22 b(the)g(signatur)n
+(e)109 3954 y Ff("\(Ljava/lang/St)o(ri)o(ng)o(;\)L)o(ja)o(va)o(/l)o(an)
+o(g/S)o(tr)o(in)o(gB)o(uf)o(fer)o(;")146 4161 y Ft(would)g(actually)i
+(be)f(cr)n(eated)f(with)109 4369 y Ff(Type.getMethodS)o(ig)o(na)o(tur)o
+(e\()o(Ty)o(pe)o(.S)o(TRI)o(NG)o(BU)o(FF)o(ER)o(,)49
+b(new)k(Type[])f({)i(Type.STRING)49 b(}\);)0 4627 y Fg(A.2.1)99
+b(Initialization:)0 4803 y Ft(First)22 b(we)g(cr)n(eate)g(an)i(empty)d
+(class)i(and)g(an)g(instr)o(uction)f(list:)109 5011 y
+Ff(ClassGen)106 b(cg)53 b(=)h(new)f(ClassGen\("HelloW)o(or)o(ld)o(",)48
+b("java.lang.Obje)o(ct)o(",)1636 5124 y("<generated>",)h(ACC_PUBLIC)h
+(|)k(ACC_SUPER,)1636 5237 y(null\);)109 5350 y(ConstantPoolGen)48
+b(cp)53 b(=)i(cg.getConstant)o(Po)o(ol)o(\(\))o(;)49
+b(//)k(cg)h(creates)d(constant)g(pool)109 5463 y(InstructionList)d(il)
+53 b(=)i(new)e(InstructionLis)o(t\()o(\);)p eop
+%%Page: 25 25
+25 24 bop 146 407 a Ft(W)-8 b(e)26 b(then)f(cr)n(eate)i(the)e(main)j
+(method,)d(supplying)g(the)h(method's)f(name)h(and)h(the)e(symbolic)i
+(type)e(sig-)0 520 y(natur)n(e)d(encoded)f(with)i Ff(Type)e
+Ft(objects.)109 705 y Ff(MethodGen)105 b(mg)54 b(=)g(new)f
+(MethodGen\(ACC_S)o(TA)o(TI)o(C)48 b(|)55 b(ACC_PUBLIC,//)48
+b(access)k(flags)1745 818 y(Type.VOID,)760 b(//)53 b(return)f(type)1745
+931 y(new)i(Type[])d({)655 b(//)53 b(argument)e(types)1855
+1044 y(new)i(ArrayType\(Type)o(.S)o(TRI)o(NG)o(,)48 b(1\))54
+b(},)1745 1156 y(new)g(String[])d({)j("argv")d(},)j(//)g(arg)f(names)
+1745 1269 y("main",)f("HelloWorld",)212 b(//)54 b(method,)d(class)1745
+1382 y(il,)j(cp\);)109 1495 y(InstructionFact)o(or)o(y)48
+b(factory)k(=)i(new)f(InstructionFact)o(or)o(y\()o(cg\))o(;)146
+1680 y Ft(W)-8 b(e)22 b(de\002ne)f(some)h(often)g(use)f(types:)109
+1865 y Ff(ObjectType)50 b(i_stream)h(=)j(new)f(ObjectType\("jav)o(a.i)o
+(o.)o(In)o(pu)o(tS)o(tre)o(am)o("\))o(;)109 1978 y(ObjectType)d
+(p_stream)h(=)j(new)f(ObjectType\("jav)o(a.i)o(o.)o(Pr)o(in)o(tS)o(tre)
+o(am)o("\))o(;)0 2233 y Fg(A.2.2)99 b(Create)24 b(variables)h
+Fa(in)f Fg(and)h Fa(name)p Fg(:)0 2410 y Ft(W)-8 b(e)16
+b(call)j(the)e(constr)o(uctors,)f(i.e.)26 b(execute)15
+b Ff(BufferedReader\(I)o(np)o(ut)o(St)o(rea)o(mR)o(ea)o(de)o(r\()o(Sys)
+o(te)o(m.)o(in)o(\)\))o Ft(.)0 2522 y(The)j(r)n(efer)n(ence)h(to)g(the)
+f Ff(BufferedReader)13 b Ft(object)19 b(stays)f(on)h(top)f(of)h(the)g
+(stack)g(and)g(is)g(stor)n(ed)f(in)h(the)g(newly)0 2635
+y(allocated)k Ff(in)f Ft(variable.)109 2820 y Ff(il.append\(facto)o(ry)
+o(.c)o(rea)o(te)o(Ne)o(w\()o("j)o(ava)o(.i)o(o.)o(Bu)o(ff)o(ere)o(dR)o
+(ea)o(de)o(r")o(\)\);)109 2933 y(il.append\(Instr)o(uc)o(ti)o(onC)o(on)
+o(st)o(an)o(ts)o(.DU)o(P\))o(;)48 b(//)54 b(Use)f(predefined)d
+(constant)109 3046 y(il.append\(facto)o(ry)o(.c)o(rea)o(te)o(Ne)o(w\()o
+("j)o(ava)o(.i)o(o.)o(In)o(pu)o(tSt)o(re)o(am)o(Re)o(ad)o(er")o(\)\))o
+(;)109 3159 y(il.append\(Instr)o(uc)o(ti)o(onC)o(on)o(st)o(an)o(ts)o
+(.DU)o(P\))o(;)109 3272 y(il.append\(facto)o(ry)o(.c)o(rea)o(te)o(Fi)o
+(el)o(dA)o(cce)o(ss)o(\(")o(ja)o(va)o(.la)o(ng)o(.S)o(ys)o(te)o(m",)e
+("in",)k(i_stream,)2073 3385 y(Constants.GETS)o(TA)o(TIC)o(\)\))o(;)109
+3498 y(il.append\(facto)o(ry)o(.c)o(rea)o(te)o(In)o(vo)o(ke)o(\("j)o
+(av)o(a.)o(io)o(.I)o(npu)o(tS)o(tr)o(ea)o(mR)o(ead)o(er)o(",)c
+("<init>",)1800 3611 y(Type.VOID,)i(new)j(Type[])f({)i(i_stream)d(},)
+1800 3724 y(Constants.INVOK)o(ES)o(PE)o(CI)o(AL\))o(\);)109
+3837 y(il.append\(facto)o(ry)o(.c)o(rea)o(te)o(In)o(vo)o(ke)o(\("j)o
+(av)o(a.)o(io)o(.B)o(uff)o(er)o(ed)o(Re)o(ad)o(er")o(,)d("<init>",)j
+(Type.VOID,)1800 3950 y(new)i(Type[])f({new)h(ObjectType\("ja)o(va)o
+(.io)o(.R)o(ea)o(de)o(r")o(\)},)1800 4062 y(Constants.INVOK)o(ES)o(PE)o
+(CI)o(AL\))o(\);)109 4288 y(LocalVariableGe)o(n)48 b(lg)54
+b(=)218 4401 y(mg.addLocalVari)o(ab)o(le\()o("i)o(n")o(,)1309
+4514 y(new)f(ObjectType\("jav)o(a.i)o(o.)o(Bu)o(ff)o(er)o(edR)o(ea)o
+(de)o(r")o(\),)48 b(null,)k(null\);)109 4627 y(int)h(in)h(=)g
+(lg.getIndex\(\);)109 4740 y(lg.setStart\(il.)o(ap)o(pe)o(nd\()o(ne)o
+(w)48 b(ASTORE\(in\)\)\);)h(//)54 b(`i')f(valid)f(from)h(here)146
+4925 y Ft(Cr)n(eate)23 b(local)h(variable)h Ff(name)c
+Ft(and)h(initialize)j(it)e(to)f Ff(null)p Ft(.)109 5110
+y Ff(lg)54 b(=)g(mg.addLocalVar)o(iab)o(le)o(\(")o(na)o(me)o(",)48
+b(Type.STRING,)h(null,)j(null\);)109 5223 y(int)h(name)g(=)h
+(lg.getIndex\(\);)109 5336 y(il.append\(Instr)o(uc)o(ti)o(onC)o(on)o
+(st)o(an)o(ts)o(.AC)o(ON)o(ST)o(_N)o(UL)o(L\);)109 5449
+y(lg.setStart\(il.)o(ap)o(pe)o(nd\()o(ne)o(w)48 b(ASTORE\(name\)\)\);)g
+(//)54 b(`name')d(valid)i(from)f(here)p eop
+%%Page: 26 26
+26 25 bop 0 407 a Fg(A.2.3)99 b(Create)24 b(try-catch)i(block)0
+584 y Ft(W)-8 b(e)31 b(r)n(emember)g(the)g(start)g(of)h(the)f(block,)j
+(r)n(ead)e(a)g(line)g(fr)n(om)h(the)e(standar)n(d)g(input)g(and)h(stor)
+n(e)e(it)i(into)g(the)0 697 y(variable)25 b Ff(name)p
+Ft(.)109 913 y Ff(InstructionHand)o(le)48 b(try_start)i(=)218
+1026 y(il.append\(facto)o(ry)o(.cr)o(ea)o(te)o(Fi)o(el)o(dAc)o(ce)o(ss)
+o(\(")o(ja)o(va.)o(la)o(ng)o(.S)o(ys)o(tem)o(",)e("out",)k(p_stream,)
+2182 1139 y(Constants.GETS)o(TAT)o(IC)o(\)\))o(;)109
+1365 y(il.append\(new)d(PUSH\(cp,)i("Please)g(enter)h(your)h(name>)f
+("\)\);)109 1478 y(il.append\(facto)o(ry)o(.c)o(rea)o(te)o(In)o(vo)o
+(ke)o(\("j)o(av)o(a.)o(io)o(.P)o(rin)o(tS)o(tr)o(ea)o(m")o(,)d
+("print",)h(Type.VOID,)1800 1591 y(new)j(Type[])f({)i(Type.STRING)c(},)
+1800 1704 y(Constants.INVOK)o(EV)o(IR)o(TU)o(AL\))o(\);)109
+1817 y(il.append\(new)f(ALOAD\(in\)\);)109 1930 y(il.append\(facto)o
+(ry)o(.c)o(rea)o(te)o(In)o(vo)o(ke)o(\("j)o(av)o(a.)o(io)o(.B)o(uff)o
+(er)o(ed)o(Re)o(ad)o(er")o(,)f("readLine",)1800 2042
+y(Type.STRING,)h(Type.NO_ARGS,)1800 2155 y(Constants.INVOK)o(EV)o(IR)o
+(TU)o(AL\))o(\);)109 2268 y(il.append\(new)g(ASTORE\(name\)\);)146
+2485 y Ft(Upon)22 b(normal)h(execution)f(we)g(jump)g(behind)h
+(exception)e(handler)-7 b(,)22 b(the)g(tar)n(get)g(addr)n(ess)f(is)h
+(not)g(known)0 2598 y(yet.)109 2815 y Ff(GOTO)53 b(g)h(=)g(new)f
+(GOTO\(null\);)109 2928 y(InstructionHand)o(le)48 b(try_end)j(=)j
+(il.append\(g\);)146 3144 y Ft(W)-8 b(e)22 b(add)g(the)g(exception)g
+(handler)g(which)h(simply)g(r)n(eturns)e(fr)n(om)i(the)f(method.)109
+3361 y Ff(InstructionHand)o(le)48 b(handler)j(=)j(il.append\(Instru)o
+(ct)o(io)o(nC)o(on)o(sta)o(nt)o(s.)o(RE)o(TU)o(RN\))o(;)109
+3474 y(mg.addException)o(Ha)o(nd)o(ler)o(\(t)o(ry)o(_s)o(ta)o(rt,)48
+b(try_end,)j(handler,)f("java.io.IOExcep)o(ti)o(on)o("\))o(;)146
+3691 y Ft(\223Normal\224)24 b(code)e(continues,)f(now)h(we)g(can)i(set)
+d(the)h(branch)i(tar)n(get)e(of)g(the)g(GOT)n(O.)109
+3908 y Ff(InstructionHand)o(le)48 b(ih)54 b(=)218 4020
+y(il.append\(facto)o(ry)o(.cr)o(ea)o(te)o(Fi)o(el)o(dAc)o(ce)o(ss)o
+(\(")o(ja)o(va.)o(la)o(ng)o(.S)o(ys)o(tem)o(",)48 b("out",)k(p_stream,)
+2182 4133 y(Constants.GETS)o(TAT)o(IC)o(\)\))o(;)109
+4246 y(g.setTarget\(ih\))o(;)0 4505 y Fg(A.2.4)99 b(Printing)25
+b(\224Hello\224)0 4682 y Ft(String)d(concatenation)h(compiles)f(to)g
+Ff(StringBuffer)17 b Ft(operations.)109 4898 y Ff(il.append\(facto)o
+(ry)o(.c)o(rea)o(te)o(Ne)o(w\()o(Ty)o(pe.)o(ST)o(RI)o(NG)o(BU)o(FFE)o
+(R\))o(\);)109 5011 y(il.append\(Instr)o(uc)o(ti)o(onC)o(on)o(st)o(an)o
+(ts)o(.DU)o(P\))o(;)109 5124 y(il.append\(new)49 b(PUSH\(cp,)i("Hello,)
+g("\)\);)109 5237 y(il.append\(facto)o(ry)o(.c)o(rea)o(te)o(In)o(vo)o
+(ke)o(\("j)o(av)o(a.)o(la)o(ng)o(.St)o(ri)o(ng)o(Bu)o(ff)o(er")o(,)d
+("<init>",)1800 5350 y(Type.VOID,)i(new)j(Type[])f({)i(Type.STRING)c
+(},)1800 5463 y(Constants.INVOK)o(ES)o(PE)o(CI)o(AL\))o(\);)p
+eop
+%%Page: 27 27
+27 26 bop 109 407 a Ff(il.append\(new)49 b(ALOAD\(name\)\);)109
+520 y(il.append\(facto)o(ry)o(.c)o(rea)o(te)o(In)o(vo)o(ke)o(\("j)o(av)
+o(a.)o(la)o(ng)o(.St)o(ri)o(ng)o(Bu)o(ff)o(er")o(,)f("append",)1800
+633 y(Type.STRINGBUFF)o(ER)o(,)g(new)54 b(Type[])d({)j(Type.STRING)c
+(},)1800 746 y(Constants.INVOK)o(EV)o(IR)o(TU)o(AL\))o(\);)109
+858 y(il.append\(facto)o(ry)o(.c)o(rea)o(te)o(In)o(vo)o(ke)o(\("j)o(av)
+o(a.)o(la)o(ng)o(.St)o(ri)o(ng)o(Bu)o(ff)o(er")o(,)e("toString",)1800
+971 y(Type.STRING,)h(Type.NO_ARGS,)1800 1084 y(Constants.INVOK)o(EV)o
+(IR)o(TU)o(AL\))o(\);)109 1310 y(il.append\(facto)o(ry)o(.c)o(rea)o(te)
+o(In)o(vo)o(ke)o(\("j)o(av)o(a.)o(io)o(.P)o(rin)o(tS)o(tr)o(ea)o(m")o
+(,)g("println",)1800 1423 y(Type.VOID,)h(new)j(Type[])f({)i
+(Type.STRING)c(},)1800 1536 y(Constants.INVOK)o(EV)o(IR)o(TU)o(AL\))o
+(\);)109 1649 y(il.append\(Instr)o(uc)o(ti)o(onC)o(on)o(st)o(an)o(ts)o
+(.RE)o(TU)o(RN)o(\);)0 1908 y Fg(A.2.5)99 b(Finalization)0
+2085 y Ft(Finally)-10 b(,)26 b(we)e(have)i(to)e(set)g(the)g(stack)g
+(size,)i(which)f(normally)h(would)e(be)h(computed)f(on)g(the)g(\003y)h
+(and)g(add)g(a)0 2197 y(default)d(constr)o(uctor)g(method)f(to)h(the)g
+(class,)h(which)g(is)g(empty)e(in)i(this)f(case.)109
+2418 y Ff(mg.setMaxStack\()o(5\))o(;)109 2531 y(cg.addMethod\(mg)o(.g)o
+(et)o(Met)o(ho)o(d\()o(\)\))o(;)109 2644 y(il.dispose\(\);)49
+b(//)k(Allow)g(instruction)c(handles)j(to)h(be)h(reused)109
+2756 y(cg.addEmptyCons)o(tr)o(uc)o(tor)o(\(A)o(CC)o(_P)o(UB)o(LIC)o
+(\);)146 2977 y Ft(Last)22 b(but)h(not)f(least)g(we)g(dump)g(the)g
+Ff(JavaClass)c Ft(object)23 b(to)f(a)h(\002le.)109 3197
+y Ff(try)53 b({)218 3310 y(cg.getJavaClass)o(\(\))o(.du)o(mp)o(\(")o
+(He)o(ll)o(oWo)o(rl)o(d.)o(cl)o(as)o(s"\))o(;)109 3423
+y(})h(catch\(java.io.I)o(OE)o(xce)o(pt)o(io)o(n)48 b(e\))54
+b({)g(System.err.prin)o(tl)o(n\()o(e\);)48 b(})0 3711
+y Fm(A.3)119 b(Peephole.java)0 3888 y Ft(This)20 b(class)h(implements)e
+(a)i(simple)f(peephole)e(optimizer)j(that)f(r)n(emoves)f(any)h(NOP)h
+(instr)o(uctions)e(fr)n(om)i(the)0 4001 y(given)i(class.)0
+4221 y Ff(import)52 b(java.io.*;)0 4334 y(import)g(de.fub.bytecod)o
+(e.c)o(la)o(ss)o(fi)o(le)o(.*;)0 4447 y(import)g(de.fub.bytecod)o(e.g)o
+(en)o(er)o(ic)o(.*)o(;)0 4560 y(import)g(de.fub.bytecod)o(e.R)o(ep)o
+(os)o(it)o(or)o(y;)0 4785 y(public)g(class)g(Peephole)f({)109
+4898 y(public)h(static)g(void)g(main\(String[])d(argv\))j({)218
+5011 y(try)h({)327 5124 y(/*)h(Load)f(the)g(class)f(from)h(CLASSPATH.)
+382 5237 y(*/)327 5350 y(JavaClass)378 b(clazz)161 b(=)54
+b(Repository.looku)o(pC)o(la)o(ss)o(\(ar)o(gv)o([0)o(]\))o(;)327
+5463 y(Method[])433 b(methods)51 b(=)j(clazz.getMethods)o(\(\))o(;)p
+eop
+%%Page: 28 28
+28 27 bop 327 407 a Ff(ConstantPoolGen)48 b(cp)326 b(=)54
+b(new)g(ConstantPoolGe)o(n\()o(cl)o(azz)o(.g)o(et)o(Co)o(ns)o(tan)o(tP)
+o(oo)o(l\()o(\)\))o(;)327 633 y(for\(int)e(i=0;)g(i)i(<)h
+(methods.length)o(;)48 b(i++\))53 b({)436 746 y(MethodGen)e(mg)381
+b(=)54 b(new)f(MethodGen\(metho)o(ds)o([i)o(],)2345 858
+y(clazz.getClassNa)o(me)o(\(\))o(,)48 b(cp\);)436 971
+y(Method)216 b(stripped)51 b(=)j(removeNOPs\(mg\))o(;)436
+1197 y(if\(stripped)c(!=)k(null\))270 b(//)54 b(Any)f(NOPs)g(stripped?)
+545 1310 y(methods[i])d(=)55 b(stripped;)50 b(//)k(Overwrite)c(with)j
+(stripped)e(method)327 1423 y(})327 1649 y(/*)j(Dump)f(the)g(class)f
+(to)i(<class)e(name>_.class)382 1762 y(*/)327 1875 y(clazz.setConsta)o
+(ntP)o(oo)o(l\()o(cp)o(.g)o(etF)o(in)o(al)o(Co)o(ns)o(tan)o(tP)o(oo)o
+(l\()o(\)\))o(;)327 1988 y(clazz.dump\(claz)o(z.g)o(et)o(Cl)o(as)o(sN)o
+(ame)o(\(\))c(+)54 b("_.class"\);)218 2100 y(})g(catch\(Exception)48
+b(e\))54 b({)g(e.printStackTr)o(ac)o(e\(\))o(;)48 b(})109
+2213 y(})109 2439 y(private)j(static)h(final)h(Method)e
+(removeNOPs\(Metho)o(dG)o(en)d(mg\))53 b({)218 2552 y(InstructionList)
+157 b(il)217 b(=)54 b(mg.getInstructio)o(nL)o(is)o(t\()o(\);)218
+2665 y(FindPattern)377 b(f)272 b(=)54 b(new)g(FindPattern\(il)o(\);)218
+2778 y(String)652 b(pat)162 b(=)54 b("\(`NOP'\)+";)c(//)k(Find)e(at)i
+(least)e(one)h(NOP)218 2891 y(InstructionHand)o(le)48
+b(next)107 b(=)54 b(null;)218 3004 y(int)817 b(count)52
+b(=)i(0;)218 3230 y(for\(Instruction)o(Ha)o(ndl)o(e)48
+b(ih)54 b(=)g(f.search\(pat\);)48 b(//)54 b(Search)e(with)g(regular)g
+(expression)436 3342 y(ih)i(!=)g(null;)436 3455 y(ih)g(=)g
+(f.search\(pat,)49 b(next\)\))j({)327 3681 y(InstructionHand)o(le[)o(])
+c(match)k(=)j(f.getMatch\(\);)327 3794 y(InstructionHand)o(le)157
+b(first)52 b(=)j(match[0];)327 3907 y(InstructionHand)o(le)157
+b(last)107 b(=)55 b(match[match.le)o(ng)o(th)48 b(-)54
+b(1];)327 4133 y(/*)g(Some)f(nasty)f(Java)h(compilers)d(may)j(add)g
+(NOP)h(at)f(end)g(of)h(method.)382 4246 y(*/)327 4359
+y(if\(\(next)d(=)j(last.getNext\(\)\))48 b(==)54 b(null\))436
+4472 y(break;)327 4697 y(count)f(+=)g(match.length;)327
+4923 y(/*)h(Delete)e(NOPs)g(and)i(redirect)d(any)i(references)d(to)j
+(them)g(to)h(the)f(following)382 5036 y(*)h(\(non-nop\))c(instruction.)
+382 5149 y(*/)327 5262 y(try)j({)436 5375 y(il.delete\(first,)48
+b(last\);)p eop
+%%Page: 29 29
+29 28 bop 327 407 a Ff(})54 b(catch\(TargetLost)o(Ex)o(ce)o(pt)o(io)o
+(n)49 b(e\))k({)436 520 y(InstructionHandl)o(e[)o(])48
+b(targets)k(=)i(e.getTargets\(\))o(;)436 633 y(for\(int)e(i=0;)g(i)j(<)
+f(targets.length)o(;)48 b(i++\))53 b({)545 746 y(InstructionTarge)o(te)
+o(r[)o(])48 b(targeters)j(=)j(targets[i].getT)o(ar)o(ge)o(te)o(rs\()o
+(\);)545 971 y(for\(int)e(j=0;)h(j)h(<)g(targeters.leng)o(th)o(;)49
+b(j++\))655 1084 y(targeters[j].u)o(pd)o(at)o(eT)o(arg)o(et)o(\(t)o(ar)
+o(ge)o(ts[)o(i])o(,)f(next\);)436 1197 y(})327 1310 y(})218
+1423 y(})218 1649 y(Method)k(m)i(=)g(null;)218 1875 y(if\(count)d(>)j
+(0\))g({)327 1988 y(System.out.prin)o(tln)o(\(")o(Re)o(mo)o(ve)o(d)49
+b(")54 b(+)g(count)e(+)i(")g(NOP)f(instructions)c(from)k(method)f(")i
+(+)1364 2100 y(mg.getName\(\)\);)327 2213 y(m)g(=)109
+b(mg.getMethod\(\);)218 2326 y(})218 2552 y(il.dispose\(\);)49
+b(//)k(Reuse)g(instruction)c(handles)218 2665 y(return)j(m;)109
+2778 y(})0 2891 y(})p eop
+%%Page: 30 30
+30 29 bop 828 5113 a @beginspecial 13 @llx 12 @lly 383
+@urx 830 @ury 2602 @rwi @setspecial
+%%BeginDocument: eps/constantpool.eps
+%!PS-Adobe-3.0 EPSF-3.0
+%%Title: Rose Diagram(s)
+%%Creator: AdobePS5.dll Version 5.0
+%%CreationDate: 7/7/1999 17:45:21
+%%Pages: 1
+%%Orientation: Portrait
+%%PageOrder: Ascend
+%%DocumentNeededResources: (atend)
+%%DocumentSuppliedResources: (atend)
+%%DocumentData: Clean7Bit
+%%TargetDevice: (HP LaserJet 5Si) (2014.108) 1
+%%LanguageLevel: 2
+%%BoundingBox: 13 12 383 830
+%%EndComments
+%%BeginProcSet: epsffit 1 0
+gsave
+1677.488 -356.303 translate
+90 rotate
+2.035 2.035 scale
+%%EndProcSet
+
+
+%%BeginDefaults
+%%PageBoundingBox: 13 12 582 830
+%%EndDefaults
+
+%%BeginProlog
+%%BeginResource: file Pscript_WinNT_ErrorHandler 5.0 0
+/currentpacking where{pop/oldpack currentpacking def/setpacking where{pop false
+setpacking}if}if/$brkpage 64 dict def $brkpage begin/prnt{dup type/stringtype
+ne{=string cvs}if dup length 6 mul/tx exch def/ty 10 def currentpoint/toy exch
+def/tox exch def 1 setgray newpath tox toy 2 sub moveto 0 ty rlineto tx 0
+rlineto 0 ty neg rlineto closepath fill tox toy moveto 0 setgray show}bind def
+/nl{currentpoint exch pop lmargin exch moveto 0 -10 rmoveto}def/=={/cp 0 def
+typeprint nl}def/typeprint{dup type exec}readonly def/lmargin 72 def/rmargin 72
+def/tprint{dup length cp add rmargin gt{nl/cp 0 def}if dup length cp add/cp
+exch def prnt}readonly def/cvsprint{=string cvs tprint( )tprint}readonly def
+/integertype{cvsprint}readonly def/realtype{cvsprint}readonly def/booleantype
+{cvsprint}readonly def/operatortype{(--)tprint =string cvs tprint(-- )tprint}
+readonly def/marktype{pop(-mark- )tprint}readonly def/dicttype{pop
+(-dictionary- )tprint}readonly def/nulltype{pop(-null- )tprint}readonly def
+/filetype{pop(-filestream- )tprint}readonly def/savetype{pop(-savelevel- )
+tprint}readonly def/fonttype{pop(-fontid- )tprint}readonly def/nametype{dup
+xcheck not{(/)tprint}if cvsprint}readonly def/stringtype{dup rcheck{(\()tprint
+tprint(\))tprint}{pop(-string- )tprint}ifelse}readonly def/arraytype{dup rcheck
+{dup xcheck{({)tprint{typeprint}forall(})tprint}{([)tprint{typeprint}forall(])
+tprint}ifelse}{pop(-array- )tprint}ifelse}readonly def/packedarraytype{dup
+rcheck{dup xcheck{({)tprint{typeprint}forall(})tprint}{([)tprint{typeprint}
+forall(])tprint}ifelse}{pop(-packedarray- )tprint}ifelse}readonly def/courier
+/Courier findfont 10 scalefont def end errordict/handleerror{systemdict begin
+$error begin $brkpage begin newerror{/newerror false store vmstatus pop pop 0
+ne{grestoreall}if showpage initgraphics courier setfont lmargin 720 moveto
+(ERROR: )prnt errorname prnt nl(OFFENDING COMMAND: )prnt/command load prnt
+$error/ostack known{nl nl(STACK:)prnt nl nl $error/ostack get aload length{==}
+repeat}if systemdict/showpage get exec(%%[ Error: )print errorname =print
+(; OffendingCommand: )print/command load =print( ]%%)= flush}if end end end}dup
+0 systemdict put dup 4 $brkpage put bind readonly put/currentpacking where{pop
+/setpacking where{pop oldpack setpacking}if}if
+%%EndResource
+userdict /Pscript_WinNT_Incr 230 dict dup begin put
+%%BeginResource: file Pscript_FatalError 5.0 0
+/FatalErrorIf{{initgraphics findfont exch scalefont setfont counttomark 3 div
+cvi{moveto show}repeat showpage quit}{cleartomark}ifelse}bind def
+%%EndResource
+/VM?{vmstatus exch sub exch pop gt{[
+(This job requires more memory than is available in this printer.)100 500
+(Try one or more of the following, and then print again:)100 485
+(For the output format, choose Optimize For Portability.)115 470
+(In the Device Settings page, make sure the Available PostScript Memory is accurate.)
+115 455(Reduce the number of fonts in the document.)115 440
+(Print the document in parts.)115 425 12/Times-Roman showpage
+(%%[ PrinterError: Low Printer VM ]%%)= true FatalErrorIf}if}bind def
+%%BeginResource: file Pscript_Win_Basic 5.0 0
+/d/def load def/,/load load d/~/exch , d/?/ifelse , d/!/pop , d/`/begin , d/^
+/index , d/@/dup , d/+/translate , d/$/roll , d/U/userdict , d/M/moveto , d/-
+/rlineto , d/&/currentdict , d/:/gsave , d/;/grestore , d/F/false , d/T/true ,
+d/N/newpath , d/E/end , d/Ac/arc , d/An/arcn , d/A/ashow , d/D/awidthshow , d/C
+/closepath , d/V/div , d/O/eofill , d/L/fill , d/I/lineto , d/-c/curveto , d/-M
+/rmoveto , d/+S/scale , d/Ji/setfont , d/Lc/setlinecap , d/Lj/setlinejoin , d
+/Lw/setlinewidth , d/Lm/setmiterlimit , d/sd/setdash , d/S/show , d/LH/showpage
+, d/K/stroke , d/W/widthshow , d/R/rotate , d/P/eoclip , d/L2? false
+/languagelevel where{pop languagelevel 2 ge{pop true}if}if d L2?{/xS/xshow , d
+/yS/yshow , d/zS/xyshow , d}if/b{bind d}bind d/bd{bind d}bind d/xd{~ d}bd/ld{,
+d}bd/lw/Lw ld/lc/Lc ld/lj/Lj ld/sg/setgray ld/ADO_mxRot null d/self & d/OrgMx
+matrix currentmatrix d/reinitialize{: OrgMx setmatrix[/TextInit/GraphInit
+/UtilsInit counttomark{@ where{self eq}{F}?{cvx exec}{!}?}repeat cleartomark ;}
+b/initialize{`{/ADO_mxRot ~ d/TextInitialised? F d reinitialize E}{U
+/Pscript_Win_Data 230 dict @ ` put/ADO_mxRot ~ d/TextInitialised? F d
+reinitialize}?}b/terminate{!{& self eq{exit}{E}?}loop E}b/suspend/terminate , d
+/resume{` Pscript_Win_Data `}b/snap{transform 0.25 sub round 0.25 add ~ 0.25
+sub round 0.25 add ~ itransform}b/dsnap{dtransform round ~ round ~ idtransform}
+b<04>cvn{}d/rr{1 ^ 0 - 0 ~ - neg 0 - C}b/rp{4 2 $ M 1 ^ 0 - 0 ~ - neg 0 -}b
+/solid{[]0 sd}b/g{@ not{U/DefIf_save save put}if U/DefIf_bool 2 ^ put}b
+/DefIf_El{if U/DefIf_bool get not @{U/DefIf_save get restore}if}b/e{DefIf_El !}
+b/UDF{L2?{undefinefont}{!}?}b/UDR{L2?{undefineresource}{! !}?}b
+%%EndResource
+%%BeginResource: file Pscript_Win_Utils_L2 5.0 0
+/rf/rectfill , d/fx{1 1 dtransform @ 0 ge{1 sub 0.5}{1 add -0.5}? 3 -1 $ @ 0 ge
+{1 sub 0.5}{1 add -0.5}? 3 1 $ 4 1 $ idtransform 4 -2 $ idtransform}b/BZ{4 -2 $
+snap + +S fx rf}b/rs/rectstroke , d/rc/rectclip , d/UtilsInit{currentglobal{F
+setglobal}if}b/scol{! setcolor}b/colspA/DeviceGray d/colspABC/DeviceRGB d
+/colspRefresh{colspABC setcolorspace}b/SetColSpace{colspABC setcolorspace}b
+%%EndResource
+end
+%%EndProlog
+
+%%BeginSetup
+[ 1 0 0 1 0 0 ] false Pscript_WinNT_Incr dup /initialize get exec
+1 setlinecap 1 setlinejoin
+/mysetup [ 0.24 0 0 -0.24 13.43905 829.74047 ] def
+%%EndSetup
+
+%%Page: 1 1
+%%PageBoundingBox: 13 12 582 830
+%%EndPageComments
+%%BeginPageSetup
+/DeviceRGB dup setcolorspace /colspABC exch def mysetup concat colspRefresh
+%%EndPageSetup
+
+Pscript_WinNT_Incr begin
+%%BeginResource: file Pscript_Win_GdiObject 5.0 0
+/SavedCTM null d/CTMsave{/SavedCTM SavedCTM currentmatrix d}b/CTMrestore
+{SavedCTM setmatrix}b/mp null d/ADO_mxRot null d/GDIHMatrix null d
+/GDIHPatternDict 22 dict d GDIHPatternDict `/PatternType 1 d/PaintType 2 d/Reps
+L2?{1}{5}? d/XStep 8 Reps mul d/YStep XStep d/BBox[0 0 XStep YStep]d/TilingType
+1 d/PaintProc{` 1 Lw[]0 sd PaintData , exec E}b/FGnd null d/BGnd null d
+/HS_Horizontal{horiz}b/HS_Vertical{vert}b/HS_FDiagonal{fdiag}b/HS_BDiagonal
+{biag}b/HS_Cross{horiz vert}b/HS_DiagCross{fdiag biag}b/MaxXYStep XStep YStep
+gt{XStep}{YStep}? d/horiz{Reps{0 4 M XStep 0 - 0 8 +}repeat 0 -8 Reps mul + K}b
+/vert{Reps{4 0 M 0 YStep - 8 0 +}repeat 0 -8 Reps mul + K}b/biag{Reps{0 0 M
+MaxXYStep @ - 0 YStep neg M MaxXYStep @ - 0 8 +}repeat 0 -8 Reps mul + 0 YStep
+M 8 8 - K}b/fdiag{Reps{0 0 M MaxXYStep @ neg - 0 YStep M MaxXYStep @ neg - 0 8
++}repeat 0 -8 Reps mul + MaxXYStep @ M 8 -8 - K}b E/makehatch{4 -2 $/yOrg ~ d
+/xOrg ~ d GDIHPatternDict/PaintData 3 -1 $ put CTMsave GDIHMatrix setmatrix
+GDIHPatternDict matrix xOrg yOrg + mp CTMrestore ~ U ~ 2 ^ put}b/h0{/h0
+/HS_Horizontal makehatch}b/h1{/h1/HS_Vertical makehatch}b/h2{/h2/HS_FDiagonal
+makehatch}b/h3{/h3/HS_BDiagonal makehatch}b/h4{/h4/HS_Cross makehatch}b/h5{/h5
+/HS_DiagCross makehatch}b/GDIBWPatternDict 25 dict @ `/PatternType 1 d
+/PaintType L2?{1}{2}? d/RepsV L2?{1}{6}? d/RepsH L2?{1}{5}? d/BBox[0 0 RepsH 1]
+d/TilingType 1 d/XStep 1 d/YStep 1 d/Height 8 RepsV mul d/Width 8 d/mx[Width 0
+0 Height neg 0 Height]d/FGnd null d/BGnd null d/SetBGndFGnd L2?{{FGnd null ne
+{FGnd aload ! scol BBox aload ! 2 ^ sub ~ 3 ^ sub ~ rf}if BGnd null ne{BGnd
+aload ! scol}if}}{{}}? b/PaintProc{` SetBGndFGnd RepsH{Width Height F mx
+PaintData imagemask Width 0 +}repeat E}b E d/GDIBWPatternMx null d/pfprep{save
+8 1 $/PatternOfTheDay 8 1 $ GDIBWPatternDict `/yOrg ~ d/xOrg ~ d/PaintData ~ d
+/yExt ~ d/Width ~ d/FGnd ~ d/BGnd ~ d/Height yExt RepsV mul d/mx[Width 0 0
+Height 0 0]d E : GDIBWPatternDict ` Width Height E dsnap +S/GDIBWPatternMx
+matrix currentmatrix d ; CTMsave GDIBWPatternMx setmatrix GDIBWPatternDict @ `
+xOrg yOrg E matrix + mp CTMrestore ~ !}b/pfbf{/fEOFill ~ d pfprep hbf fEOFill
+{O}{L}? restore}b/GraphInit{GDIHMatrix null eq{/SavedCTM matrix d : ADO_mxRot
+concat 0 0 snap + : 0.48 @ GDIHPatternDict ` YStep mul ~ XStep mul ~ dsnap
+YStep V ~ XStep V ~ E +S/GDIHMatrix matrix currentmatrix readonly d ; : 0.24
+-0.24 +S GDIBWPatternDict ` Width Height E dsnap +S/GDIBWPatternMx matrix
+currentmatrix readonly d ; ;}if}b
+%%EndResource
+%%BeginResource: file Pscript_Win_GdiObject_L2 5.0 0
+/mp/makepattern , d/hbf{setpattern}b/hf{:/fEOFill ~ d ~ ! setpattern fEOFill{O}
+{L}? ;}b/pbf{: !/fEOFill ~ d GDIBWPatternDict `/yOrg ~ d/xOrg ~ d/PaintData ~ d
+/OutputBPP ~ d/Height ~ d/Width ~ d/PaintType 1 d/PatternType 1 d/TilingType 1
+d/BBox[0 0 Width Height]d/XStep Width d/YStep Height d/mx xOrg yOrg matrix + d
+20 dict @ `/ImageType 1 d/Width Width d/Height Height d/ImageMatrix mx d
+/BitsPerComponent 8 d OutputBPP 24 eq{/Decode[0 1 0 1 0 1]d}{OutputBPP 8 eq{
+/Decode[0 1]d}{/Decode[0 1 0 1 0 1 0 1]d}?}?/DataSource{PaintData}d E/ImageDict
+~ d/PaintProc{` ImageDict image E}b & mx makepattern setpattern E fEOFill{O}{L}
+? ;}b
+%%EndResource
+end reinitialize
+: N 1409 506 185 84 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol 1 Lw N 1594 505 M 1408 505 I 1408 590 I 1594 590 I C
+K
+0 0 0 1 scol Pscript_WinNT_Incr begin
+%%BeginResource: file Pscript_Text 5.0 0
+/TextInit{TextInitialised? not{/Pscript_Windows_Font & d/TextInitialised? T d
+/fM[1 0 0 1 0 0]d/mFM matrix d/iMat[1 0 0.212557 1 0 0]d}if}b/copyfont{1 ^
+length add dict `{1 ^/FID ne{d}{! !}?}forall & E}b/EncodeDict 11 dict d/bullets
+{{/bullet}repeat}b/rF{3 copyfont @ ` ~ EncodeDict ~ get/Encoding ~ 3 ^/0 eq{&
+/CharStrings known{CharStrings/Eth known not{! EncodeDict/ANSIEncodingOld get}
+if}if}if d E}b/mF{@ 7 1 $ findfont ~{@/Encoding get @ StandardEncoding eq{! T}{
+{ISOLatin1Encoding}stopped{! F}{eq}?{T}{@ ` T 32 1 127{Encoding 1 ^ get
+StandardEncoding 3 -1 $ get eq and}for E}?}?}{F}?{1 ^ ~ rF}{0 copyfont}? 6 -2 $
+{T pd_AddEm87 ~ !}{! ~ !/pd_charset @ where{~ get 128 eq{@ FDV 2 copy get @
+length array copy put pd_CoverFCRange}if}{!}?}? 2 ^ ~ definefont fM 5 4 -1 $
+put fM 4 0 put fM makefont Pscript_Windows_Font 3 1 $ put}b/sLT{: Lw -M
+currentpoint snap M 0 - 0 Lc K ;}b/xUP null d/yUP null d/uW null d/xSP null d
+/ySP null d/sW null d/sSU{N/uW ~ d/yUP ~ d/xUP ~ d}b/sU{xUP yUP uW sLT}b/sST{N
+/sW ~ d/ySP ~ d/xSP ~ d}b/sT{xSP ySP sW sLT}b/sR{: + R 0 0 M}b/sRxy{: matrix
+astore concat 0 0 M}b/eR/; , d/AddOrigFP{{&/FontInfo known{&/FontInfo get
+length 6 add}{6}? dict `/WinPitchAndFamily ~ d/WinCharSet ~ d/OrigFontType ~ d
+/OrigFontStyle ~ d/OrigFontName ~ d & E/FontInfo ~ d}{! ! ! ! !}?}b/mFS
+{makefont Pscript_Windows_Font 3 1 $ put}b/mF42D{0 copyfont `/FontName ~ d 2
+copy ~ sub 1 add dict `/.notdef 0 d 2 copy 1 ~{@ 3 ^ sub Encoding ~ get ~ d}for
+& E/CharStrings ~ d ! ! & @ E/FontName get ~ definefont}bind d/mF42{15 dict ` @
+4 1 $/FontName ~ d/FontType 0 d/FMapType 2 d/FontMatrix[1 0 0 1 0 0]d 1 ^ 254
+add 255 idiv @ array/Encoding ~ d 0 1 3 -1 $ 1 sub{@ Encoding 3 1 $ put}for
+/FDepVector Encoding length array d/CharStrings 2 dict `/.notdef 0 d & E d 0 1
+Encoding length 1 sub{@ @ 10 lt{! FontName length 1 add string}{100 lt{FontName
+length 2 add string}{FontName length 3 add string}?}? @ 0 FontName @ length
+string cvs putinterval @ 3 -1 $ @ 4 1 $ 3 string cvs FontName length ~
+putinterval cvn 1 ^ 256 mul @ 255 add 3 -1 $ 4 ^ findfont mF42D FDepVector 3 1
+$ put}for & @ E/FontName get ~ definefont ! ! ! mF}b/UmF{L2?
+{Pscript_Windows_Font ~ undef}{!}?}b/UmF42{@ findfont/FDepVector get{/FontName
+get undefinefont}forall undefinefont}b
+%%EndResource
+end reinitialize
+Pscript_WinNT_Incr begin
+%%BeginResource: file Pscript_Encoding256 5.0 0
+/CharCol256Encoding[/.notdef/breve/caron/dotaccent/dotlessi/fi/fl/fraction
+/hungarumlaut/Lslash/lslash/minus/ogonek/ring/Zcaron/zcaron/.notdef/.notdef
+/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
+/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/exclam/quotedbl/numbersign
+/dollar/percent/ampersand/quotesingle/parenleft/parenright/asterisk/plus/comma
+/hyphen/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon
+/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S
+/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/asciicircum/underscore/grave
+/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright
+/asciitilde/.notdef/.notdef/.notdef/quotesinglbase/florin/quotedblbase/ellipsis
+/dagger/daggerdbl/circumflex/perthousand/Scaron/guilsinglleft/OE/.notdef
+/.notdef/.notdef/.notdef/quoteleft/quoteright/quotedblleft/quotedblright/bullet
+/endash/emdash/tilde/trademark/scaron/guilsinglright/oe/.notdef/.notdef
+/Ydieresis/.notdef/exclamdown/cent/sterling/currency/yen/brokenbar/section
+/dieresis/copyright/ordfeminine/guillemotleft/logicalnot/.notdef/registered
+/macron/degree/plusminus/twosuperior/threesuperior/acute/mu/paragraph
+/periodcentered/cedilla/onesuperior/ordmasculine/guillemotright/onequarter
+/onehalf/threequarters/questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis
+/Aring/AE/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute
+/Icircumflex/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
+/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls
+/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla/egrave/eacute
+/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis/eth/ntilde/ograve
+/oacute/ocircumflex/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex
+/udieresis/yacute/thorn/ydieresis]def EncodeDict/256 CharCol256Encoding put
+%%EndResource
+end reinitialize
+
+%%IncludeResource: font Helvetica
+F /F0 0 /256 T /Helvetica mF
+/F0S18 F0 [24.66 0 0 -24.66 0 0 ] mFS
+F0S18 Ji
+1433 537 M (ConstantCP)[18 14 14 13 7 14 14 7 18 0]xS
+0.602 0 0.199 1 scol N 1594 551 M 1408 551 I 1408 590 I 1594 590 I C
+K
+N 1594 565 M 1408 565 I 1408 590 I 1594 590 I C
+K
+: N 1292 714 375 85 rp C
+1 1 0.801 1 scol L ; N 1667 713 M 1291 713 I 1291 799 I 1667 799 I C
+K
+0 0 0 1 scol 1324 745 M (ConstantInterfaceMethodref)[18 14 14 13 7 14 14 7 6 14 7 14 8 7 14 13 14 21 14 7 14 14 14 8 14 0]xS
+0.602 0 0.199 1 scol N 1667 759 M 1291 759 I 1291 799 I 1667 799 I C
+K
+N 1667 773 M 1291 773 I 1291 799 I 1667 799 I C
+K
+: N 1710 714 262 85 rp C
+1 1 0.801 1 scol L ; N 1972 713 M 1709 713 I 1709 799 I 1972 799 I C
+K
+0 0 0 1 scol 1734 745 M (ConstantMethodref)[18 14 14 13 7 14 14 7 21 14 7 14 14 14 8 14 0]xS
+0.602 0 0.199 1 scol N 1972 759 M 1709 759 I 1709 799 I 1972 799 I C
+K
+N 1972 773 M 1709 773 I 1709 799 I 1972 799 I C
+K
+: N 1011 714 235 85 rp C
+1 1 0.801 1 scol L ; N 1246 713 M 1010 713 I 1010 799 I 1246 799 I C
+K
+0 0 0 1 scol 1036 745 M (ConstantFieldref)[18 14 14 13 7 14 14 7 15 6 14 6 14 8 14 0]xS
+0.602 0 0.199 1 scol N 1246 759 M 1010 759 I 1010 799 I 1246 799 I C
+K
+N 1246 773 M 1010 773 I 1010 799 I 1246 799 I C
+K
+: N 1516 58 213 125 rp C
+1 1 0.801 1 scol L ; N 1729 57 M 1515 57 I 1515 183 I 1729 183 I C
+K
+0 0 0 1 scol 1546 89 M (ConstantPool)[18 14 14 13 7 14 14 7 17 14 14 0]xS
+0.602 0 0.199 1 scol N 1729 103 M 1515 103 I 1515 183 I 1729 183 I C
+K
+N 1729 116 M 1515 116 I 1515 183 I 1729 183 I C
+K
+0 0 0 1 scol 1555 158 M (getConstant\(\))[14 14 7 18 14 14 13 7 14 14 7 8 0]xS
+: N 1550 265 144 84 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 1694 264 M 1549 264 I 1549 349 I 1694 349 I C
+K
+0 0 0 1 scol 1571 296 M (Constant)[18 14 14 13 7 14 14 0]xS
+0.602 0 0.199 1 scol N 1694 310 M 1549 310 I 1549 349 I 1694 349 I C
+K
+N 1694 323 M 1549 323 I 1549 349 I 1694 349 I C
+K
+N 1622 223 M 1622 184 I K
+N 1652 175 14 29 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1652 198 M (1)S
+0.602 0 0.199 1 scol N 1622 184 M 1632 203 I 1622 221 I 1612 203 I 1622 184 I C
+: 1 1 1 1 scol O ; K
+N 1622 223 M 1622 263 I K
+N 1654 245 11 28 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1654 268 M (*)S
+N 1652 175 14 29 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1652 198 M (1)S
+N 1654 245 11 28 rp C
+1 1 1 1 scol L 0 0 0 1 scol 1654 268 M (*)S
+0.602 0 0.199 1 scol N 1494 655 M 1494 591 I K
+N 1123 655 M 1828 655 I K
+N 1494 591 M 1509 632 I 1479 632 I C
+: 1 1 1 1 scol O ; K
+N 1123 713 M 1123 655 I K
+: N 1743 506 219 84 rp C
+1 1 0.801 1 scol L ; N 1962 505 M 1742 505 I 1742 590 I 1962 590 I C
+K
+0 0 0 1 scol 1769 537 M (ConstantString)[18 14 14 13 7 14 14 7 17 7 8 6 14 0]xS
+0.602 0 0.199 1 scol N 1962 551 M 1742 551 I 1742 590 I 1962 590 I C
+K
+N 1962 565 M 1742 565 I 1742 590 I 1962 590 I C
+K
+: N 822 506 219 84 rp C
+1 1 0.801 1 scol L ; N 1041 505 M 821 505 I 821 590 I 1041 590 I C
+K
+0 0 0 1 scol 849 537 M (ConstantClass)[18 14 14 13 7 14 14 7 18 6 14 13 0]xS
+0.602 0 0.199 1 scol N 1041 551 M 821 551 I 821 590 I 1041 590 I C
+K
+N 1041 565 M 821 565 I 821 590 I 1041 590 I C
+K
+: N 1236 254 224 84 rp C
+1 1 0.801 1 scol L ; N 1460 253 M 1235 253 I 1235 338 I 1460 338 I C
+K
+0 0 0 1 scol 1259 285 M (ConstantInteger)[18 14 14 13 7 14 14 7 6 14 7 14 14 14 0]xS
+0.602 0 0.199 1 scol N 1460 299 M 1235 299 I 1235 338 I 1460 338 I C
+K
+N 1460 312 M 1235 312 I 1235 338 I 1460 338 I C
+K
+: N 958 254 232 84 rp C
+1 1 0.801 1 scol L ; N 1190 253 M 957 253 I 957 338 I 1190 338 I C
+K
+0 0 0 1 scol 984 285 M (ConstantDouble)[18 14 14 13 7 14 14 7 18 14 14 14 6 0]xS
+0.602 0 0.199 1 scol N 1190 299 M 957 299 I 957 338 I 1190 338 I C
+K
+N 1190 312 M 957 312 I 957 338 I 1190 338 I C
+K
+: N 1102 506 207 84 rp C
+1 1 0.801 1 scol L ; N 1309 505 M 1101 505 I 1101 590 I 1309 590 I C
+K
+0 0 0 1 scol 1127 537 M (ConstantFloat)[18 14 14 13 7 14 14 7 15 6 14 14 0]xS
+0.602 0 0.199 1 scol N 1309 551 M 1101 551 I 1101 590 I 1309 590 I C
+K
+N 1309 565 M 1101 565 I 1101 590 I 1309 590 I C
+K
+: N 708 254 206 84 rp C
+1 1 0.801 1 scol L ; N 914 253 M 707 253 I 707 338 I 914 338 I C
+K
+0 0 0 1 scol 732 285 M (ConstantLong)[18 14 14 13 7 14 14 7 14 14 14 0]xS
+0.602 0 0.199 1 scol N 914 299 M 707 299 I 707 338 I 914 338 I C
+K
+N 914 312 M 707 312 I 707 338 I 914 338 I C
+K
+: N 2025 506 246 84 rp C
+1 1 0.801 1 scol L ; N 2271 505 M 2024 505 I 2024 590 I 2271 590 I C
+K
+0 0 0 1 scol 2051 537 M (ConstantUnicode)[18 14 14 13 7 14 14 7 18 14 6 13 14 14 0]xS
+0.602 0 0.199 1 scol N 2271 545 M 2024 545 I 2024 590 I 2271 590 I C
+K
+N 2271 558 M 2024 558 I 2024 590 I 2271 590 I C
+K
+: N 1790 254 322 84 rp C
+1 1 0.801 1 scol L ; N 2112 253 M 1789 253 I 1789 338 I 2112 338 I C
+K
+0 0 0 1 scol 1817 285 M (ConstantNameAndType)[18 14 14 13 7 14 14 7 18 14 22 14 17 14 14 14 12 14 0]xS
+0.602 0 0.199 1 scol N 2112 299 M 1789 299 I 1789 338 I 2112 338 I C
+K
+N 2112 312 M 1789 312 I 1789 338 I 2112 338 I C
+K
+: N 2172 254 194 84 rp C
+1 1 0.801 1 scol L ; N 2366 253 M 2171 253 I 2171 338 I 2366 338 I C
+K
+0 0 0 1 scol 2195 285 M (ConstantUtf8)[18 14 14 13 7 14 14 7 18 7 7 0]xS
+0.602 0 0.199 1 scol N 2366 293 M 2171 293 I 2171 338 I 2366 338 I C
+K
+N 2366 306 M 2171 306 I 2171 338 I 2366 338 I C
+K
+N 1626 428 M 1626 350 I K
+N 809 428 M 2269 428 I K
+N 1626 350 M 1641 391 I 1611 391 I C
+: 1 1 1 1 scol O ; K
+N 933 505 M 933 428 I K
+N 1848 505 M 1848 428 I K
+N 1068 339 M 1068 428 I K
+N 2146 505 M 2146 428 I K
+N 809 339 M 809 428 I K
+N 2269 339 M 2269 428 I K
+N 1500 505 M 1500 428 I K
+N 1336 339 M 1336 428 I K
+N 1201 505 M 1201 428 I K
+N 1926 339 M 1926 428 I K
+N 1468 713 M 1468 655 I K
+N 1828 713 M 1828 655 I K
+LH
+%%PageTrailer
+
+%%Trailer
+%%DocumentNeededResources:
+%%+ font Helvetica
+%%DocumentSuppliedResources:
+Pscript_WinNT_Incr dup /terminate get exec
+%%EOF
+grestore
+
+%%EndDocument
+ @endspecial 824 5316 a Fq(Figur)n(e)26 b(8:)k(UML)25
+b(diagram)g(for)h(the)f(ConstantPool)i(API)p eop
+%%Page: 31 31
+31 30 bop 749 5113 a @beginspecial 13 @llx 12 @lly 410
+@urx 830 @ury 2792 @rwi @setspecial
+%%BeginDocument: eps/instructions.eps
+%!PS-Adobe-3.0 EPSF-3.0
+%%Title: Rose Diagram(s)
+%%Creator: AdobePS5.dll Version 5.0
+%%CreationDate: 7/7/1999 17:43:39
+%%Pages: 1
+%%Orientation: Portrait
+%%PageOrder: Ascend
+%%DocumentNeededResources: (atend)
+%%DocumentSuppliedResources: (atend)
+%%DocumentData: Clean7Bit
+%%TargetDevice: (HP LaserJet 5Si) (2014.108) 1
+%%LanguageLevel: 2
+%%BoundingBox: 13 12 410 830
+%%EndComments
+%%BeginProcSet: epsffit 1 0
+gsave
+1409.418 -167.686 translate
+90 rotate
+1.711 1.711 scale
+%%EndProcSet
+
+
+%%BeginDefaults
+%%PageBoundingBox: 13 12 582 830
+%%EndDefaults
+
+%%BeginProlog
+%%BeginResource: file Pscript_WinNT_ErrorHandler 5.0 0
+/currentpacking where{pop/oldpack currentpacking def/setpacking where{pop false
+setpacking}if}if/$brkpage 64 dict def $brkpage begin/prnt{dup type/stringtype
+ne{=string cvs}if dup length 6 mul/tx exch def/ty 10 def currentpoint/toy exch
+def/tox exch def 1 setgray newpath tox toy 2 sub moveto 0 ty rlineto tx 0
+rlineto 0 ty neg rlineto closepath fill tox toy moveto 0 setgray show}bind def
+/nl{currentpoint exch pop lmargin exch moveto 0 -10 rmoveto}def/=={/cp 0 def
+typeprint nl}def/typeprint{dup type exec}readonly def/lmargin 72 def/rmargin 72
+def/tprint{dup length cp add rmargin gt{nl/cp 0 def}if dup length cp add/cp
+exch def prnt}readonly def/cvsprint{=string cvs tprint( )tprint}readonly def
+/integertype{cvsprint}readonly def/realtype{cvsprint}readonly def/booleantype
+{cvsprint}readonly def/operatortype{(--)tprint =string cvs tprint(-- )tprint}
+readonly def/marktype{pop(-mark- )tprint}readonly def/dicttype{pop
+(-dictionary- )tprint}readonly def/nulltype{pop(-null- )tprint}readonly def
+/filetype{pop(-filestream- )tprint}readonly def/savetype{pop(-savelevel- )
+tprint}readonly def/fonttype{pop(-fontid- )tprint}readonly def/nametype{dup
+xcheck not{(/)tprint}if cvsprint}readonly def/stringtype{dup rcheck{(\()tprint
+tprint(\))tprint}{pop(-string- )tprint}ifelse}readonly def/arraytype{dup rcheck
+{dup xcheck{({)tprint{typeprint}forall(})tprint}{([)tprint{typeprint}forall(])
+tprint}ifelse}{pop(-array- )tprint}ifelse}readonly def/packedarraytype{dup
+rcheck{dup xcheck{({)tprint{typeprint}forall(})tprint}{([)tprint{typeprint}
+forall(])tprint}ifelse}{pop(-packedarray- )tprint}ifelse}readonly def/courier
+/Courier findfont 10 scalefont def end errordict/handleerror{systemdict begin
+$error begin $brkpage begin newerror{/newerror false store vmstatus pop pop 0
+ne{grestoreall}if showpage initgraphics courier setfont lmargin 720 moveto
+(ERROR: )prnt errorname prnt nl(OFFENDING COMMAND: )prnt/command load prnt
+$error/ostack known{nl nl(STACK:)prnt nl nl $error/ostack get aload length{==}
+repeat}if systemdict/showpage get exec(%%[ Error: )print errorname =print
+(; OffendingCommand: )print/command load =print( ]%%)= flush}if end end end}dup
+0 systemdict put dup 4 $brkpage put bind readonly put/currentpacking where{pop
+/setpacking where{pop oldpack setpacking}if}if
+%%EndResource
+userdict /Pscript_WinNT_Incr 230 dict dup begin put
+%%BeginResource: file Pscript_FatalError 5.0 0
+/FatalErrorIf{{initgraphics findfont exch scalefont setfont counttomark 3 div
+cvi{moveto show}repeat showpage quit}{cleartomark}ifelse}bind def
+%%EndResource
+/VM?{vmstatus exch sub exch pop gt{[
+(This job requires more memory than is available in this printer.)100 500
+(Try one or more of the following, and then print again:)100 485
+(For the output format, choose Optimize For Portability.)115 470
+(In the Device Settings page, make sure the Available PostScript Memory is accurate.)
+115 455(Reduce the number of fonts in the document.)115 440
+(Print the document in parts.)115 425 12/Times-Roman showpage
+(%%[ PrinterError: Low Printer VM ]%%)= true FatalErrorIf}if}bind def
+%%BeginResource: file Pscript_Win_Basic 5.0 0
+/d/def load def/,/load load d/~/exch , d/?/ifelse , d/!/pop , d/`/begin , d/^
+/index , d/@/dup , d/+/translate , d/$/roll , d/U/userdict , d/M/moveto , d/-
+/rlineto , d/&/currentdict , d/:/gsave , d/;/grestore , d/F/false , d/T/true ,
+d/N/newpath , d/E/end , d/Ac/arc , d/An/arcn , d/A/ashow , d/D/awidthshow , d/C
+/closepath , d/V/div , d/O/eofill , d/L/fill , d/I/lineto , d/-c/curveto , d/-M
+/rmoveto , d/+S/scale , d/Ji/setfont , d/Lc/setlinecap , d/Lj/setlinejoin , d
+/Lw/setlinewidth , d/Lm/setmiterlimit , d/sd/setdash , d/S/show , d/LH/showpage
+, d/K/stroke , d/W/widthshow , d/R/rotate , d/P/eoclip , d/L2? false
+/languagelevel where{pop languagelevel 2 ge{pop true}if}if d L2?{/xS/xshow , d
+/yS/yshow , d/zS/xyshow , d}if/b{bind d}bind d/bd{bind d}bind d/xd{~ d}bd/ld{,
+d}bd/lw/Lw ld/lc/Lc ld/lj/Lj ld/sg/setgray ld/ADO_mxRot null d/self & d/OrgMx
+matrix currentmatrix d/reinitialize{: OrgMx setmatrix[/TextInit/GraphInit
+/UtilsInit counttomark{@ where{self eq}{F}?{cvx exec}{!}?}repeat cleartomark ;}
+b/initialize{`{/ADO_mxRot ~ d/TextInitialised? F d reinitialize E}{U
+/Pscript_Win_Data 230 dict @ ` put/ADO_mxRot ~ d/TextInitialised? F d
+reinitialize}?}b/terminate{!{& self eq{exit}{E}?}loop E}b/suspend/terminate , d
+/resume{` Pscript_Win_Data `}b/snap{transform 0.25 sub round 0.25 add ~ 0.25
+sub round 0.25 add ~ itransform}b/dsnap{dtransform round ~ round ~ idtransform}
+b<04>cvn{}d/rr{1 ^ 0 - 0 ~ - neg 0 - C}b/rp{4 2 $ M 1 ^ 0 - 0 ~ - neg 0 -}b
+/solid{[]0 sd}b/g{@ not{U/DefIf_save save put}if U/DefIf_bool 2 ^ put}b
+/DefIf_El{if U/DefIf_bool get not @{U/DefIf_save get restore}if}b/e{DefIf_El !}
+b/UDF{L2?{undefinefont}{!}?}b/UDR{L2?{undefineresource}{! !}?}b
+%%EndResource
+%%BeginResource: file Pscript_Win_Utils_L2 5.0 0
+/rf/rectfill , d/fx{1 1 dtransform @ 0 ge{1 sub 0.5}{1 add -0.5}? 3 -1 $ @ 0 ge
+{1 sub 0.5}{1 add -0.5}? 3 1 $ 4 1 $ idtransform 4 -2 $ idtransform}b/BZ{4 -2 $
+snap + +S fx rf}b/rs/rectstroke , d/rc/rectclip , d/UtilsInit{currentglobal{F
+setglobal}if}b/scol{! setcolor}b/colspA/DeviceGray d/colspABC/DeviceRGB d
+/colspRefresh{colspABC setcolorspace}b/SetColSpace{colspABC setcolorspace}b
+%%EndResource
+end
+%%EndProlog
+
+%%BeginSetup
+[ 1 0 0 1 0 0 ] false Pscript_WinNT_Incr dup /initialize get exec
+1 setlinecap 1 setlinejoin
+/mysetup [ 0.24 0 0 -0.24 13.43905 829.74047 ] def
+%%EndSetup
+
+%%Page: 1 1
+%%PageBoundingBox: 13 12 582 830
+%%EndPageComments
+%%BeginPageSetup
+/DeviceRGB dup setcolorspace /colspABC exch def mysetup concat colspRefresh
+%%EndPageSetup
+
+Pscript_WinNT_Incr begin
+%%BeginResource: file Pscript_Win_GdiObject 5.0 0
+/SavedCTM null d/CTMsave{/SavedCTM SavedCTM currentmatrix d}b/CTMrestore
+{SavedCTM setmatrix}b/mp null d/ADO_mxRot null d/GDIHMatrix null d
+/GDIHPatternDict 22 dict d GDIHPatternDict `/PatternType 1 d/PaintType 2 d/Reps
+L2?{1}{5}? d/XStep 8 Reps mul d/YStep XStep d/BBox[0 0 XStep YStep]d/TilingType
+1 d/PaintProc{` 1 Lw[]0 sd PaintData , exec E}b/FGnd null d/BGnd null d
+/HS_Horizontal{horiz}b/HS_Vertical{vert}b/HS_FDiagonal{fdiag}b/HS_BDiagonal
+{biag}b/HS_Cross{horiz vert}b/HS_DiagCross{fdiag biag}b/MaxXYStep XStep YStep
+gt{XStep}{YStep}? d/horiz{Reps{0 4 M XStep 0 - 0 8 +}repeat 0 -8 Reps mul + K}b
+/vert{Reps{4 0 M 0 YStep - 8 0 +}repeat 0 -8 Reps mul + K}b/biag{Reps{0 0 M
+MaxXYStep @ - 0 YStep neg M MaxXYStep @ - 0 8 +}repeat 0 -8 Reps mul + 0 YStep
+M 8 8 - K}b/fdiag{Reps{0 0 M MaxXYStep @ neg - 0 YStep M MaxXYStep @ neg - 0 8
++}repeat 0 -8 Reps mul + MaxXYStep @ M 8 -8 - K}b E/makehatch{4 -2 $/yOrg ~ d
+/xOrg ~ d GDIHPatternDict/PaintData 3 -1 $ put CTMsave GDIHMatrix setmatrix
+GDIHPatternDict matrix xOrg yOrg + mp CTMrestore ~ U ~ 2 ^ put}b/h0{/h0
+/HS_Horizontal makehatch}b/h1{/h1/HS_Vertical makehatch}b/h2{/h2/HS_FDiagonal
+makehatch}b/h3{/h3/HS_BDiagonal makehatch}b/h4{/h4/HS_Cross makehatch}b/h5{/h5
+/HS_DiagCross makehatch}b/GDIBWPatternDict 25 dict @ `/PatternType 1 d
+/PaintType L2?{1}{2}? d/RepsV L2?{1}{6}? d/RepsH L2?{1}{5}? d/BBox[0 0 RepsH 1]
+d/TilingType 1 d/XStep 1 d/YStep 1 d/Height 8 RepsV mul d/Width 8 d/mx[Width 0
+0 Height neg 0 Height]d/FGnd null d/BGnd null d/SetBGndFGnd L2?{{FGnd null ne
+{FGnd aload ! scol BBox aload ! 2 ^ sub ~ 3 ^ sub ~ rf}if BGnd null ne{BGnd
+aload ! scol}if}}{{}}? b/PaintProc{` SetBGndFGnd RepsH{Width Height F mx
+PaintData imagemask Width 0 +}repeat E}b E d/GDIBWPatternMx null d/pfprep{save
+8 1 $/PatternOfTheDay 8 1 $ GDIBWPatternDict `/yOrg ~ d/xOrg ~ d/PaintData ~ d
+/yExt ~ d/Width ~ d/FGnd ~ d/BGnd ~ d/Height yExt RepsV mul d/mx[Width 0 0
+Height 0 0]d E : GDIBWPatternDict ` Width Height E dsnap +S/GDIBWPatternMx
+matrix currentmatrix d ; CTMsave GDIBWPatternMx setmatrix GDIBWPatternDict @ `
+xOrg yOrg E matrix + mp CTMrestore ~ !}b/pfbf{/fEOFill ~ d pfprep hbf fEOFill
+{O}{L}? restore}b/GraphInit{GDIHMatrix null eq{/SavedCTM matrix d : ADO_mxRot
+concat 0 0 snap + : 0.48 @ GDIHPatternDict ` YStep mul ~ XStep mul ~ dsnap
+YStep V ~ XStep V ~ E +S/GDIHMatrix matrix currentmatrix readonly d ; : 0.24
+-0.24 +S GDIBWPatternDict ` Width Height E dsnap +S/GDIBWPatternMx matrix
+currentmatrix readonly d ; ;}if}b
+%%EndResource
+%%BeginResource: file Pscript_Win_GdiObject_L2 5.0 0
+/mp/makepattern , d/hbf{setpattern}b/hf{:/fEOFill ~ d ~ ! setpattern fEOFill{O}
+{L}? ;}b/pbf{: !/fEOFill ~ d GDIBWPatternDict `/yOrg ~ d/xOrg ~ d/PaintData ~ d
+/OutputBPP ~ d/Height ~ d/Width ~ d/PaintType 1 d/PatternType 1 d/TilingType 1
+d/BBox[0 0 Width Height]d/XStep Width d/YStep Height d/mx xOrg yOrg matrix + d
+20 dict @ `/ImageType 1 d/Width Width d/Height Height d/ImageMatrix mx d
+/BitsPerComponent 8 d OutputBPP 24 eq{/Decode[0 1 0 1 0 1]d}{OutputBPP 8 eq{
+/Decode[0 1]d}{/Decode[0 1 0 1 0 1 0 1]d}?}?/DataSource{PaintData}d E/ImageDict
+~ d/PaintProc{` ImageDict image E}b & mx makepattern setpattern E fEOFill{O}{L}
+? ;}b
+%%EndResource
+end reinitialize
+: N 1432 65 209 154 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol 1 Lw N 1641 64 M 1431 64 I 1431 219 I 1641 219 I C
+K
+0 0 0 1 scol Pscript_WinNT_Incr begin
+%%BeginResource: file Pscript_Text 5.0 0
+/TextInit{TextInitialised? not{/Pscript_Windows_Font & d/TextInitialised? T d
+/fM[1 0 0 1 0 0]d/mFM matrix d/iMat[1 0 0.212557 1 0 0]d}if}b/copyfont{1 ^
+length add dict `{1 ^/FID ne{d}{! !}?}forall & E}b/EncodeDict 11 dict d/bullets
+{{/bullet}repeat}b/rF{3 copyfont @ ` ~ EncodeDict ~ get/Encoding ~ 3 ^/0 eq{&
+/CharStrings known{CharStrings/Eth known not{! EncodeDict/ANSIEncodingOld get}
+if}if}if d E}b/mF{@ 7 1 $ findfont ~{@/Encoding get @ StandardEncoding eq{! T}{
+{ISOLatin1Encoding}stopped{! F}{eq}?{T}{@ ` T 32 1 127{Encoding 1 ^ get
+StandardEncoding 3 -1 $ get eq and}for E}?}?}{F}?{1 ^ ~ rF}{0 copyfont}? 6 -2 $
+{T pd_AddEm87 ~ !}{! ~ !/pd_charset @ where{~ get 128 eq{@ FDV 2 copy get @
+length array copy put pd_CoverFCRange}if}{!}?}? 2 ^ ~ definefont fM 5 4 -1 $
+put fM 4 0 put fM makefont Pscript_Windows_Font 3 1 $ put}b/sLT{: Lw -M
+currentpoint snap M 0 - 0 Lc K ;}b/xUP null d/yUP null d/uW null d/xSP null d
+/ySP null d/sW null d/sSU{N/uW ~ d/yUP ~ d/xUP ~ d}b/sU{xUP yUP uW sLT}b/sST{N
+/sW ~ d/ySP ~ d/xSP ~ d}b/sT{xSP ySP sW sLT}b/sR{: + R 0 0 M}b/sRxy{: matrix
+astore concat 0 0 M}b/eR/; , d/AddOrigFP{{&/FontInfo known{&/FontInfo get
+length 6 add}{6}? dict `/WinPitchAndFamily ~ d/WinCharSet ~ d/OrigFontType ~ d
+/OrigFontStyle ~ d/OrigFontName ~ d & E/FontInfo ~ d}{! ! ! ! !}?}b/mFS
+{makefont Pscript_Windows_Font 3 1 $ put}b/mF42D{0 copyfont `/FontName ~ d 2
+copy ~ sub 1 add dict `/.notdef 0 d 2 copy 1 ~{@ 3 ^ sub Encoding ~ get ~ d}for
+& E/CharStrings ~ d ! ! & @ E/FontName get ~ definefont}bind d/mF42{15 dict ` @
+4 1 $/FontName ~ d/FontType 0 d/FMapType 2 d/FontMatrix[1 0 0 1 0 0]d 1 ^ 254
+add 255 idiv @ array/Encoding ~ d 0 1 3 -1 $ 1 sub{@ Encoding 3 1 $ put}for
+/FDepVector Encoding length array d/CharStrings 2 dict `/.notdef 0 d & E d 0 1
+Encoding length 1 sub{@ @ 10 lt{! FontName length 1 add string}{100 lt{FontName
+length 2 add string}{FontName length 3 add string}?}? @ 0 FontName @ length
+string cvs putinterval @ 3 -1 $ @ 4 1 $ 3 string cvs FontName length ~
+putinterval cvn 1 ^ 256 mul @ 255 add 3 -1 $ 4 ^ findfont mF42D FDepVector 3 1
+$ put}for & @ E/FontName get ~ definefont ! ! ! mF}b/UmF{L2?
+{Pscript_Windows_Font ~ undef}{!}?}b/UmF42{@ findfont/FDepVector get{/FontName
+get undefinefont}forall undefinefont}b
+%%EndResource
+end reinitialize
+Pscript_WinNT_Incr begin
+%%BeginResource: file Pscript_Encoding256 5.0 0
+/CharCol256Encoding[/.notdef/breve/caron/dotaccent/dotlessi/fi/fl/fraction
+/hungarumlaut/Lslash/lslash/minus/ogonek/ring/Zcaron/zcaron/.notdef/.notdef
+/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
+/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/exclam/quotedbl/numbersign
+/dollar/percent/ampersand/quotesingle/parenleft/parenright/asterisk/plus/comma
+/hyphen/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon
+/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S
+/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/asciicircum/underscore/grave
+/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright
+/asciitilde/.notdef/.notdef/.notdef/quotesinglbase/florin/quotedblbase/ellipsis
+/dagger/daggerdbl/circumflex/perthousand/Scaron/guilsinglleft/OE/.notdef
+/.notdef/.notdef/.notdef/quoteleft/quoteright/quotedblleft/quotedblright/bullet
+/endash/emdash/tilde/trademark/scaron/guilsinglright/oe/.notdef/.notdef
+/Ydieresis/.notdef/exclamdown/cent/sterling/currency/yen/brokenbar/section
+/dieresis/copyright/ordfeminine/guillemotleft/logicalnot/.notdef/registered
+/macron/degree/plusminus/twosuperior/threesuperior/acute/mu/paragraph
+/periodcentered/cedilla/onesuperior/ordmasculine/guillemotright/onequarter
+/onehalf/threequarters/questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis
+/Aring/AE/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute
+/Icircumflex/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
+/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls
+/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla/egrave/eacute
+/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis/eth/ntilde/ograve
+/oacute/ocircumflex/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex
+/udieresis/yacute/thorn/ydieresis]def EncodeDict/256 CharCol256Encoding put
+%%EndResource
+end reinitialize
+
+%%IncludeResource: font Helvetica
+F /F0 0 /256 T /Helvetica mF
+/F0S21 F0 [33.09 0 0 -33.09 0 0 ] mFS
+F0S21 Ji
+1461 104 M (Instruction)[9 18 17 9 11 18 17 9 7 17 0]xS
+0.602 0 0.199 1 scol N 1641 117 M 1431 117 I 1431 219 I 1641 219 I C
+K
+N 1641 212 M 1431 212 I 1431 219 I 1641 219 I C
+K
+0 0 0 1 scol 1478 153 M (tag)[9 17 0]xS
+1478 191 M (length)[7 17 18 18 9 0]xS
+: N 575 326 321 98 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 896 325 M 574 325 I 574 424 I 896 424 I C
+K
+0 0 0 1 scol 609 365 M (BranchInstruction)[22 11 17 18 17 18 9 18 17 9 11 18 17 9 7 17 0]xS
+0.602 0 0.199 1 scol N 896 378 M 574 378 I 574 424 I 896 424 I C
+K
+N 896 396 M 574 396 I 574 424 I 896 424 I C
+K
+: N 822 556 164 154 rp C
+1 1 0.801 1 scol L ; N 986 555 M 821 555 I 821 710 I 986 710 I C
+K
+0 0 0 1 scol 859 595 M (Select)[22 17 7 17 17 0]xS
+0.602 0 0.199 1 scol N 986 608 M 821 608 I 821 710 I 986 710 I C
+K
+N 986 702 M 821 702 I 821 710 I 986 710 I C
+K
+0 0 0 1 scol 868 644 M (targets)[9 17 11 18 17 9 0]xS
+868 682 M (keys)[16 17 15 0]xS
+: N 584 815 303 100 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 887 814 M 583 814 I 583 915 I 887 915 I C
+K
+0 0 0 1 scol 599 855 M (LOOKUPSWITCH)[18 26 26 22 24 22 22 34 9 21 24 0]xS
+0.602 0 0.199 1 scol N 887 868 M 583 868 I 583 915 I 887 915 I C
+K
+N 887 886 M 583 886 I 583 915 I 887 915 I C
+K
+: N 964 815 267 100 rp C
+1 1 0.801 1 scol L ; N 1231 814 M 963 814 I 963 915 I 1231 915 I C
+K
+0 0 0 1 scol 978 855 M (TABLESWITCH)[21 22 22 18 22 22 34 9 21 24 0]xS
+0.602 0 0.199 1 scol N 1231 868 M 963 868 I 963 915 I 1231 915 I C
+K
+N 1231 886 M 963 886 I 963 915 I 1231 915 I C
+K
+: N 567 557 208 100 rp C
+1 1 0.801 1 scol L ; N 775 556 M 566 556 I 566 657 I 775 657 I C
+K
+0 0 0 1 scol 587 597 M (IfInstruction)[9 10 9 18 17 9 11 18 17 9 7 17 0]xS
+0.602 0 0.199 1 scol N 775 609 M 566 609 I 566 657 I 775 657 I C
+K
+N 775 628 M 566 628 I 566 657 I 775 657 I C
+K
+: N 393 557 143 100 rp C
+1 1 0.801 1 scol L ; N 536 556 M 392 556 I 392 657 I 536 657 I C
+K
+0 0 0 1 scol 415 597 M (GOTO)[26 26 21 0]xS
+0.602 0 0.199 1 scol N 536 609 M 392 609 I 392 657 I 536 657 I C
+K
+N 536 628 M 392 628 I 392 657 I 536 657 I C
+K
+N 730 499 M 730 425 I K
+N 469 499 M 910 499 I K
+N 730 425 M 748 473 I 712 473 I C
+: 1 1 1 1 scol O ; K
+N 469 556 M 469 499 I K
+: N 1843 118 290 100 rp C
+1 1 0.801 1 scol L ; N 2133 117 M 1842 117 I 1842 218 I 2133 218 I C
+K
+0 0 0 1 scol 1865 158 M (ReturnInstruction)[24 17 9 18 11 18 9 18 17 9 11 18 17 9 7 17 0]xS
+0.602 0 0.199 1 scol N 2133 168 M 1842 168 I 1842 218 I 2133 218 I C
+K
+N 2133 186 M 1842 186 I 1842 218 I 2133 218 I C
+K
+: N 1004 325 264 99 rp C
+1 1 0.801 1 scol L ; N 1268 324 M 1003 324 I 1003 424 I 1268 424 I C
+K
+0 0 0 1 scol 1023 364 M (ArrayInstruction)[22 11 11 17 15 9 18 17 9 11 18 17 9 7 17 0]xS
+0.602 0 0.199 1 scol N 1268 377 M 1003 377 I 1003 424 I 1268 424 I C
+K
+N 1268 396 M 1003 396 I 1003 424 I 1268 424 I C
+K
+: N 1704 332 232 188 rp C
+1 1 0.801 1 scol L ; N 1936 331 M 1703 331 I 1703 520 I 1936 520 I C
+K
+0 0 0 1 scol 1722 372 M (CPInstruction)[24 22 9 18 17 9 11 18 17 9 7 17 0]xS
+0.602 0 0.199 1 scol N 1936 382 M 1703 382 I 1703 520 I 1936 520 I C
+K
+N 1936 438 M 1703 438 I 1703 520 I 1936 520 I C
+K
+0 0 0 1 scol 1751 418 M (index)[7 18 18 17 0]xS
+1751 494 M (getType\(\))[18 17 9 21 15 18 17 11 0]xS
+: N 1038 118 274 100 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 1312 117 M 1037 117 I 1037 218 I 1312 218 I C
+K
+0 0 0 1 scol 1059 158 M (StackInstruction)[22 9 17 17 16 9 18 17 9 11 18 17 9 7 17 0]xS
+0.602 0 0.199 1 scol N 1312 170 M 1037 170 I 1037 218 I 1312 218 I C
+K
+N 1312 189 M 1037 189 I 1037 218 I 1312 218 I C
+K
+: N 1312 325 345 99 rp C
+1 1 0.801 1 scol L ; N 1657 324 M 1311 324 I 1311 424 I 1657 424 I C
+K
+0 0 0 1 scol 1329 364 M (ConversionInstruction)[24 17 18 15 17 11 17 7 17 18 9 18 17 9 11 18 17 9 7 17 0]xS
+0.602 0 0.199 1 scol N 1657 377 M 1311 377 I 1311 424 I 1657 424 I C
+K
+N 1657 396 M 1311 396 I 1311 424 I 1657 424 I C
+K
+N 675 556 M 675 499 I K
+: N 619 118 337 100 rp C
+1 1 0.801 1 scol L ; N 956 117 M 618 117 I 618 218 I 956 218 I C
+K
+0 0 0 1 scol 641 158 M (ArithmeticInstruction)[22 11 7 9 18 27 17 9 7 17 9 18 17 9 11 18 17 9 7 17 0]xS
+0.602 0 0.199 1 scol N 956 170 M 618 170 I 618 218 I 956 218 I C
+K
+N 956 189 M 618 189 I 618 218 I 956 218 I C
+K
+: N 1974 326 390 148 rp C
+1 1 0.801 1 scol L ; N 2364 325 M 1973 325 I 1973 474 I 2364 474 I C
+K
+0 0 0 1 scol 1998 366 M (LocalVariableInstruction)[18 17 17 17 7 22 17 11 7 17 18 7 17 9 18 17 9 11 18 17 9 7 17 0]xS
+0.602 0 0.199 1 scol N 2364 376 M 1973 376 I 1973 474 I 2364 474 I C
+K
+N 2364 433 M 1973 433 I 1973 474 I 2364 474 I C
+K
+0 0 0 1 scol 2020 412 M (index)[7 18 18 17 0]xS
+: N 1392 869 263 148 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 1655 868 M 1391 868 I 1391 1017 I 1655 1017 I C
+K
+0 0 0 1 scol 1414 908 M (FieldInstruction)[20 7 17 7 18 9 18 17 9 11 18 17 9 7 17 0]xS
+0.602 0 0.199 1 scol N 1655 921 M 1391 921 I 1391 1017 I 1655 1017 I C
+K
+N 1655 940 M 1391 940 I 1391 1017 I 1655 1017 I C
+K
+0 0 0 1 scol 1439 995 M (getFieldType\(\))[18 17 9 20 7 17 7 18 21 15 18 17 11 0]xS
+: N 1735 869 351 148 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 2086 868 M 1734 868 I 1734 1017 I 2086 1017 I C
+K
+0 0 0 1 scol 1790 908 M (InvokeInstruction)[9 18 15 17 16 17 9 18 17 9 11 18 17 9 7 17 0]xS
+0.602 0 0.199 1 scol N 2086 919 M 1734 919 I 1734 1017 I 2086 1017 I C
+K
+N 2086 937 M 1734 937 I 1734 1017 I 2086 1017 I C
+K
+0 0 0 1 scol 1781 992 M (getArgumentTypes\(\))[18 17 9 22 11 18 18 27 17 18 9 21 15 18 17 17 11 0]xS
+0.602 0 0.199 1 scol N 1539 293 M 1539 220 I K
+N 703 293 M 2171 293 I K
+N 1539 220 M 1557 269 I 1522 269 I C
+: 1 1 1 1 scol O ; K
+N 2171 325 M 2171 293 I K
+N 1826 331 M 1826 293 I K
+N 898 784 M 898 711 I K
+N 737 784 M 1069 784 I K
+N 898 711 M 916 760 I 880 760 I C
+: 1 1 1 1 scol O ; K
+N 737 814 M 737 784 I K
+N 1116 324 M 1116 293 I K
+N 792 219 M 792 293 I K
+N 1487 324 M 1487 293 I K
+N 1984 219 M 1984 293 I K
+N 1166 219 M 1166 293 I K
+: N 1554 623 248 148 rp C
+1 1 0.801 1 scol L ; N 1802 622 M 1553 622 I 1553 771 I 1802 771 I C
+K
+0 0 0 1 scol 1572 663 M (FieldOrMethod)[20 7 17 7 18 26 11 27 17 9 18 17 0]xS
+0.602 0 0.199 1 scol N 1802 676 M 1553 676 I 1553 771 I 1802 771 I C
+K
+N 1802 694 M 1553 694 I 1553 771 I 1802 771 I C
+K
+0 0 0 1 scol 1601 749 M (getName\(\))[18 17 9 24 17 27 17 11 0]xS
+: N 2179 635 186 99 rp C
+1 1 0.801 1 scol L ; 0.602 0 0.199 1 scol N 2365 634 M 2178 634 I 2178 734 I 2365 734 I C
+K
+0 0 0 1 scol 2232 674 M (NEW)[24 22 0]xS
+0.602 0 0.199 1 scol N 2365 684 M 2178 684 I 2178 734 I 2365 734 I C
+K
+N 2365 703 M 2178 703 I 2178 734 I 2365 734 I C
+K
+N 703 325 M 703 293 I K
+N 1820 594 M 1820 521 I K
+N 1657 594 M 2249 594 I K
+N 1820 521 M 1838 570 I 1802 570 I C
+: 1 1 1 1 scol O ; K
+: N 1889 635 250 99 rp C
+1 1 0.801 1 scol L ; N 2139 634 M 1888 634 I 1888 734 I 2139 734 I C
+K
+0 0 0 1 scol 1907 674 M (INSTANCEOF)[9 24 22 21 22 24 24 22 26 0]xS
+0.602 0 0.199 1 scol N 2139 684 M 1888 684 I 1888 734 I 2139 734 I C
+K
+N 2139 703 M 1888 703 I 1888 734 I 2139 734 I C
+K
+N 2014 634 M 2014 594 I K
+N 2249 634 M 2249 594 I K
+N 1657 622 M 1657 594 I K
+N 1069 814 M 1069 784 I K
+N 1677 845 M 1677 772 I K
+N 1511 845 M 1907 845 I K
+N 1677 772 M 1695 821 I 1660 821 I C
+: 1 1 1 1 scol O ; K
+N 1907 868 M 1907 845 I K
+N 1511 868 M 1511 845 I K
+N 910 555 M 910 499 I K
+LH
+%%PageTrailer
+
+%%Trailer
+%%DocumentNeededResources:
+%%+ font Helvetica
+%%DocumentSuppliedResources:
+Pscript_WinNT_Incr dup /terminate get exec
+%%EOF
+grestore
+
+%%EndDocument
+ @endspecial 880 5316 a Fq(Figur)n(e)26 b(9:)31 b(UML)25
+b(diagram)g(for)g(the)h(Instr)o(uction)g(API)p eop
+%%Trailer
+end
+userdict /end-hook known{end-hook}if
+%%EOF
diff --git a/docs/manual.tex b/docs/manual.tex
new file mode 100644
index 00000000..a79ce572
--- /dev/null
+++ b/docs/manual.tex
@@ -0,0 +1,1079 @@
+\documentclass[12pt,twoside]{article}
+
+\usepackage{epsf,a4wide,moreverb,url}
+\usepackage{palatino}
+
+\newcommand\jc{{\sffamily BCEL }}
+\newcommand\cp{{constant pool }}
+\newcommand\cpe{constant pool}
+\newcommand\jvm{{Java Virtual Machine }}
+\newcommand\jvme{{Java Virtual Machine}}
+\newcommand\vm{{Virtual Machine }}
+\newcommand\href[2]{#2}
+
+\begin{document}
+
+\title{Byte Code Engineering Library (BCEL)\\
+ Description and usage manual\\
+ {\small \textbf{Version 1.0}}}
+
+\author{{\Large Markus Dahm}\\\\
+ \href{mailto:markus.dahm@inf.fu-berlin.de}{\texttt{markus.dahm@berlin.de}}}
+
+\maketitle
+
+%\tableofcontents
+
+\begin{abstract}
+Extensions and improvements of the programming language Java and its
+related execution environment (Java Virtual Machine, JVM) are the
+subject of a large number of research projects and proposals. There
+are projects, for instance, to add parameterized types to Java, to
+implement ``Aspect-Oriented Programming'', to perform sophisticated
+static analysis, and to improve the run-time performance.
+
+Since Java classes are compiled into portable binary class files
+(called \emph{byte code}), it is the most convenient and
+platform-independent way to implement these improvements not by
+writing a new compiler or changing the JVM, but by transforming the
+byte code. These transformations can either be performed after
+compile-time, or at load-time. Many programmers are doing this by
+implementing their own specialized byte code manipulation tools, which
+are, however, restricted in the range of their re-usability.
+
+To deal with the necessary class file transformations, we introduce an
+API that helps developers to conveniently implement their
+transformations.
+\end{abstract}
+
+\section{Introduction}\label{sec:intro}
+
+The Java language \cite{gosling} has become very popular and many
+research projects deal with further improvements of the language or
+its run-time behavior. The possibility to extend a language with new
+concepts is surely a desirable feature, but implementation issues
+should be hidden from the user. Fortunately, the concepts of the \jvm
+permit the user-transparent implementation of such extensions with
+relatively little effort.
+
+Because the target language of Java is an interpreted language with a
+small and easy-to-understand set of instructions (the \emph{byte
+code}), developers can implement and test their concepts in a very
+elegant way. One can write a plug-in replacement for the system's
+class loader which is responsible for dynamically loading class files
+at run-time and passing the byte code to the \vm (see section
+\ref{sec:classloaders}). Class loaders may thus be used to intercept
+the loading process and transform classes before they get actually
+executed by the JVM \cite{classloader}. While the original class
+files always remain unaltered, the behavior of the class loader may be
+reconfigured for every execution or instrumented dynamically.
+
+The \jc API (Byte Code Engineering Library), formerly known as
+JavaClass, is a toolkit for the static analysis and dynamic creation
+or transformation of Java class files. It enables developers to
+implement the desired features on a high level of abstraction without
+handling all the internal details of the Java class file format and
+thus re-inventing the wheel every time. \jc is written entirely in
+Java and freely available under the terms of the Apache Software
+License. \footnote{The distribution is available at
+ \url{http://jakarta.apache.org/bcel/}, including several code
+ examples and javadoc manuals. }
+
+This paper is structured as follows: We give a brief description of
+the \jvm and the class file format in section \ref{sec:jvm}. Section
+\ref{sec:api} introduces the \jc API. Section \ref{sec:application}
+describes some typical application areas and example projects. The
+appendix contains code examples that are to long to be presented in
+the main part of this paper. All examples are included in the
+down-loadable distribution.
+
+\subsection{Related work}
+
+There are a number of proposals and class libraries that have some
+similarities with \textsc{BCEL}: The JOIE \cite{joie} toolkit can
+be used to instrument class loaders with dynamic behavior. Similarly,
+``Binary Component Adaptation'' \cite{bca} allows components to be
+adapted and evolved on-the-fly. Han Lee's ``Byte-code Instrumenting
+Tool'' \cite{bit} allows the user to insert calls to analysis methods
+anywhere in the byte code. The Jasmin language \cite{jasmin} can be
+used to hand-write or generate pseudo-assembler code. D-Java
+\cite{classfile} and JCF \cite{inside} are class viewing tools.
+
+In contrast to these projects, \jc is intended to be a general purpose
+tool for ``byte code engineering''. It gives full control to the
+developer on a high level of abstraction and is not restricted to any
+particular application area.
+
+\section{The Java Virtual Machine}\label{sec:jvm}
+
+Readers already familiar with the \jvm and the Java class file format
+may want to skip this section and proceed with section \ref{sec:api}.
+
+Programs written in the Java language are compiled into a portable
+binary format called \emph{byte code}. Every class is represented by
+a single class file containing class related data and byte code
+instructions. These files are loaded dynamically into an interpreter
+(\jvme, JVM) and executed.
+
+Figure \ref{fig:jvm} illustrates the procedure of compiling and
+executing a Java class: The source file (\texttt{HelloWorld.java}) is
+compiled into a Java class file (\texttt{HelloWorld.class}), loaded by
+the byte code interpreter and executed. In order to implement
+additional features, researchers may want to transform class files
+(drawn with bold lines) before they get actually executed. This
+application area is one of the main issues of this article.
+
+\begin{figure}[htbp]
+ \begin{center}
+ \leavevmode
+ \epsfxsize\textwidth
+ \epsfbox{eps/jvm.eps}
+ \caption{Compilation and execution of Java classes}
+ \label{fig:jvm}
+ \end{center}
+\end{figure}
+
+Note that the use of the general term ``Java'' implies two meanings:
+on the one hand, Java as a programming language is meant, on the other
+hand, the Java Virtual Machine, which is not necessarily targeted by
+the Java language exclusively, but may be used by other languages as
+well (e.g. Eiffel \cite{eiffel}, or Ada \cite{ada}). We assume the
+reader to be familiar with the Java language and to have a general
+understanding of the Virtual Machine.
+
+\subsection{Java class file format}\label{sec:format}
+
+Giving a full overview of the design issues of the Java class file
+format and the associated byte code instructions is beyond the scope
+of this paper. We will just give a brief introduction covering the
+details that are necessary for understanding the rest of this
+paper. The format of class files and the byte code instruction set are
+described in more detail in the ``\jvm Specification'' \cite{jvm}
+\footnote{Also available online at
+\url{http://www.javasoft.com/docs/books/vmspec/index.html}}, and in
+\cite{jasmin}. Especially, we will not deal with the security
+constraints that the \jvm has to check at run-time, i.e. the byte code
+verifier.
+
+Figure \ref{fig:classfile} shows a simplified example of the contents
+of a Java class file: It starts with a header containing a ``magic
+number'' (\texttt{0xCAFEBABE}) and the version number, followed by the
+\emph{\cpe}, which can be roughly thought of as the text segment of an
+executable, the \emph{access rights} of the class encoded by a bit
+mask, a list of interfaces implemented by the class, lists containing
+the fields and methods of the class, and finally the \emph{class
+attributes}, e.g. the \texttt{SourceFile} attribute telling the name
+of the source file. Attributes are a way of putting additional,
+e.g. user-defined, information into class file data structures. For
+example, a custom class loader may evaluate such attribute data in
+order to perform its transformations. The JVM specification declares
+that unknown, i.e. user-defined attributes must be ignored by any \vm
+implementation.
+
+\begin{figure}[htbp]
+ \begin{center}
+ \leavevmode
+ \epsfxsize\textwidth
+ \epsfbox{eps/classfile.eps}
+ \caption{Java class file format}
+ \label{fig:classfile}
+ \end{center}
+\end{figure}
+
+Because all of the information needed to dynamically resolve the
+symbolic references to classes, fields and methods at run-time is
+coded with string constants, the \cp contains in fact the largest
+portion of an average class file, approximately 60\% \cite{statistic}.
+The byte code instructions themselves just make up 12\%.
+
+The right upper box shows a ``zoomed'' excerpt of the \cpe, while the
+rounded box below depicts some instructions that are contained within
+a method of the example class. These instructions represent the
+straightforward translation of the well-known statement:
+
+\begin{verbatim}
+ System.out.println("Hello, world");
+\end{verbatim}
+
+The first instruction loads the contents of the field \texttt{out} of
+class \texttt{java.lang.System} onto the operand stack. This is an
+instance of the class \texttt{java.io.PrintStream}. The \texttt{ldc}
+(``Load constant'') pushes a reference to the string "Hello world" on
+the stack. The next instruction invokes the instance method
+\texttt{println} which takes both values as parameters (Instance
+methods always implicitly take an instance reference as their first
+argument).
+
+Instructions, other data structures within the class file and
+constants themselves may refer to constants in the \cpe. Such
+references are implemented via fixed indexes encoded directly into the
+instructions. This is illustrated for some items of the figure
+emphasized with a surrounding box.
+
+For example, the \texttt{invokevirtual} instruction refers to a
+\texttt{MethodRef} constant that contains information about the name
+of the called method, the signature (i.e. the encoded argument and
+return types), and to which class the method belongs. In fact, as
+emphasized by the boxed value, the \texttt{MethodRef} constant itself
+just refers to other entries holding the real data, e.g. it refers to
+a \texttt{ConstantClass} entry containing a symbolic reference to the
+class \texttt{java.io.PrintStream}. To keep the class file compact,
+such constants are typically shared by different instructions.
+Similarly, a field is represented by a \texttt{Fieldref} constant that
+includes information about the name, the type and the containing class
+of the field.
+
+The \cp basically holds the following types of constants: References
+to methods, fields and classes, strings, integers, floats, longs, and
+doubles.
+
+\subsection{Byte code instruction set}\label{sec:code}
+
+The JVM is a stack-oriented interpreter that creates a local stack
+frame of fixed size for every method invocation. The size of the local
+stack has to be computed by the compiler. Values may also be stored
+intermediately in a frame area containing \emph{local variables} which
+can be used like a set of registers. These local variables are
+numbered from 0 to 65535, i.e. you have a maximum of 65536 of local
+variables. The stack frames of caller and callee method are
+overlapping, i.e. the caller pushes arguments onto the operand stack
+and the called method receives them in local variables.
+
+The byte code instruction set currently consists of 212 instructions,
+44 opcodes are marked as reserved and may be used for future
+extensions or intermediate optimizations within the Virtual
+Machine. The instruction set can be roughly grouped as follows:
+
+\begin{description}
+\item[Stack operations:] Constants can be pushed onto the stack either
+by loading them from the \cp with the \texttt{ldc} instruction or with
+special ``short-cut'' instructions where the operand is encoded into
+the instructions, e.g. \texttt{iconst\_0} or \texttt{bipush} (push
+byte value).
+
+\item[Arithmetic operations:] The instruction set of the \jvm
+distinguishes its operand types using different instructions to
+operate on values of specific type. Arithmetic operations starting
+with \texttt{i}, for example, denote an integer operation. E.g.,
+\texttt{iadd} that adds two integers and pushes the result back on the
+stack. The Java types \texttt{boolean}, \texttt{byte},
+\texttt{short}, and \texttt{char} are handled as integers by the JVM.
+
+\item[Control flow:] There are branch instructions like \texttt{goto}
+and \texttt{if\_icmpeq}, which compares two integers for
+equality. There is also a \texttt{jsr} (jump sub-routine) and
+\texttt{ret} pair of instructions that is used to implement the
+\texttt{finally} clause of \texttt{try-catch} blocks. Exceptions may
+be thrown with the \texttt{athrow} instruction.
+
+Branch targets are coded as offsets from the current byte code
+position, i.e. with an integer number.
+
+\item[Load and store operations] for local variables like
+\texttt{iload} and \texttt{istore}. There are also array operations
+like \texttt{iastore} which stores an integer value into an array.
+
+\item[Field access:] The value of an instance field may be retrieved
+with \texttt{getfield} and written with \texttt{putfield}. For static
+fields, there are \texttt{getstatic} and \texttt{putstatic}
+counterparts.
+
+\item[Method invocation:] Methods may either be called via static
+references with \texttt{invokesta\-tic} or be bound virtually with the
+\texttt{invokevirtual} instruction. Super class methods and private
+methods are invoked with \texttt{invokespecial}.
+
+\item[Object allocation:] Class instances are allocated with the
+\texttt{new} instruction, arrays of basic type like \texttt{int[]}
+with \texttt{newarray}, arrays of references like \texttt{String[][]}
+with \texttt{anewarray} or \texttt{multianewarray}.
+
+\item[Conversion and type checking:] For stack operands of basic type
+there exist casting operations like \texttt{f2i} which converts a
+float value into an integer. The validity of a type cast may be
+checked with \texttt{checkcast} and the \texttt{instanceof} operator
+can be directly mapped to the equally named instruction.
+\end{description}
+
+Most instructions have a fixed length, but there are also some
+variable-length instructions: In particular, the \texttt{lookupswitch}
+and \texttt{tableswitch} instructions, which are used to implement
+\texttt{switch()} statements. Since the number of \texttt{case}
+clauses may vary, these instructions contain a variable number of
+statements.
+
+We will not list all byte code instructions here, since these are
+explained in detail in the JVM specification. The opcode names are
+mostly self-explaining, so understanding the following code examples
+should be fairly intuitive.
+
+\subsection{Method code}\label{sec:code2}
+
+Non-abstract methods contain an attribute (\texttt{Code}) that holds
+the following data: The maximum size of the method's stack frame, the
+number of local variables and an array of byte code
+instructions. Optionally, it may also contain information about the
+names of local variables and source file line numbers that can be used
+by a debugger.
+
+Whenever an exception is thrown, the JVM performs exception handling
+by looking into a table of exception handlers. The table marks
+handlers, i.e. pieces of code, to be responsible for exceptions of
+certain types that are raised within a given area of the byte
+code. When there is no appropriate handler the exception is propagated
+back to the caller of the method. The handler information is itself
+stored in an attribute contained within the \texttt{Code} attribute.
+
+\subsection{Byte code offsets}\label{sec:offsets}
+
+Targets of branch instructions like \texttt{goto} are encoded as
+relative offsets in the array of byte codes. Exception handlers and
+local variables refer to absolute addresses within the byte code. The
+former contains references to the start and the end of the
+\texttt{try} block, and to the instruction handler code. The latter
+marks the range in which a local variable is valid, i.e. its scope.
+This makes it difficult to insert or delete code areas on this level
+of abstraction, since one has to recompute the offsets every time and
+update the referring objects. We will see in section \ref{sec:cgapi}
+how \jc remedies this restriction.
+
+\subsection{Type information}\label{sec:types}
+
+Java is a type-safe language and the information about the types of
+fields, local variables, and methods is stored in
+\emph{signatures}. These are strings stored in the \cp and encoded in
+a special format. For example the argument and return types of the
+\texttt{main} method
+
+\begin{verbatim}
+ public static void main(String[] argv)
+\end{verbatim}
+
+are represented by the signature
+
+\begin{verbatim}
+ ([java/lang/String;)V
+\end{verbatim}
+
+Classes and arrays are internally represented by strings like
+\texttt{"java/lang/String"}, basic types like \texttt{float} by an
+integer number. Within signatures they are represented by single
+characters, e.g., \texttt{"I"}, for integer.
+
+\subsection{Code example}\label{sec:fac}
+
+The following example program prompts for a number and prints the
+faculty of it. The \texttt{readLine()} method reading from the
+standard input may raise an \texttt{IOException} and if a misspelled
+number is passed to \texttt{parseInt()} it throws a
+\texttt{NumberFormatException}. Thus, the critical area of code must be
+encapsulated in a \texttt{try-catch} block.
+
+{\small \begin{verbatim}
+import java.io.*;
+public class Faculty {
+ private static BufferedReader in = new BufferedReader(new
+ InputStreamReader(System.in));
+ public static final int fac(int n) {
+ return (n == 0)? 1 : n * fac(n - 1);
+ }
+ public static final int readInt() {
+ int n = 4711;
+ try {
+ System.out.print("Please enter a number> ");
+ n = Integer.parseInt(in.readLine());
+ } catch(IOException e1) { System.err.println(e1); }
+ catch(NumberFormatException e2) { System.err.println(e2); }
+ return n;
+ }
+ public static void main(String[] argv) {
+ int n = readInt();
+ System.out.println("Faculty of " + n + " is " + fac(n));
+ }}
+\end{verbatim}}
+
+This code example typically compiles to the following chunks of byte
+code:
+
+\subsubsection{Method fac}
+
+{\small \begin{verbatim}
+0: iload_0
+1: ifne #8
+4: iconst_1
+5: goto #16
+8: iload_0
+9: iload_0
+10: iconst_1
+11: isub
+12: invokestatic Faculty.fac (I)I (12)
+15: imul
+16: ireturn
+
+LocalVariable(start_pc = 0, length = 16, index = 0:int n)
+\end{verbatim}}
+
+The method \texttt{fac} has only one local variable, the argument
+\texttt{n}, stored in slot 0. This variable's scope ranges from the
+start of the byte code sequence to the very end. If the value of
+\texttt{n} (stored in local variable 0, i.e. the value fetched with
+\texttt{iload\_0}) is not equal to 0, the \texttt{ifne} instruction
+branches to the byte code at offset 8, otherwise a 1 is pushed onto
+the operand stack and the control flow branches to the final return.
+For ease of reading, the offsets of the branch instructions, which are
+actually relative, are displayed as absolute addresses in these
+examples.
+
+If recursion has to continue, the arguments for the multiplication
+(\texttt{n} and \texttt{fac(n - 1)}) are evaluated and the results
+pushed onto the operand stack. After the multiplication operation has
+been performed the function returns the computed value from the top of
+the stack.
+
+\subsubsection{Method readInt}
+
+{\small \begin{verbatim}
+0: sipush 4711
+3: istore_0
+4: getstatic java.lang.System.out Ljava/io/PrintStream;
+7: ldc "Please enter a number> "
+9: invokevirtual java.io.PrintStream.print (Ljava/lang/String;)V
+12: getstatic Faculty.in Ljava/io/BufferedReader;
+15: invokevirtual java.io.BufferedReader.readLine ()Ljava/lang/String;
+18: invokestatic java.lang.Integer.parseInt (Ljava/lang/String;)I
+21: istore_0
+22: goto #44
+25: astore_1
+26: getstatic java.lang.System.err Ljava/io/PrintStream;
+29: aload_1
+30: invokevirtual java.io.PrintStream.println (Ljava/lang/Object;)V
+33: goto #44
+36: astore_1
+37: getstatic java.lang.System.err Ljava/io/PrintStream;
+40: aload_1
+41: invokevirtual java.io.PrintStream.println (Ljava/lang/Object;)V
+44: iload_0
+45: ireturn
+
+Exception handler(s) =
+From To Handler Type
+4 22 25 java.io.IOException(6)
+4 22 36 NumberFormatException(10)
+\end{verbatim}}
+
+First the local variable \texttt{n} (in slot 0) is initialized to the
+value 4711. The next instruction, \texttt{getstatic}, loads the
+static \texttt{System.out} field onto the stack. Then a string is
+loaded and printed, a number read from the standard input and
+assigned to \texttt{n}.
+
+If one of the called methods (\texttt{readLine()} and
+\texttt{parseInt()}) throws an exception, the \jvm calls one of the
+declared exception handlers, depending on the type of the exception.
+The \texttt{try}-clause itself does not produce any code, it merely
+defines the range in which the following handlers are active. In the
+example the specified source code area maps to a byte code area
+ranging from offset 4 (inclusive) to 22 (exclusive). If no exception
+has occurred (``normal'' execution flow) the \texttt{goto}
+instructions branch behind the handler code. There the value of
+\texttt{n} is loaded and returned.
+
+For example the handler for \texttt{java.io.IOException} starts at
+offset 25. It simply prints the error and branches back to the normal
+execution flow, i.e. as if no exception had occurred.
+
+\section{The BCEL API}\label{sec:api}
+
+The \jc API abstracts from the concrete circumstances of the \jvm and
+how to read and write binary Java class files. The API mainly
+consists of three parts:
+
+\begin{enumerate}
+
+\item A package that contains classes that describe ``static''
+ constraints of class files, i.e., reflect the class file format and
+ is not intended for byte code modifications. The classes may be
+ used to read and write class files from or to a file. This is
+ useful especially for analyzing Java classes without having the
+ source files at hand. The main data structure is called
+ \texttt{JavaClass} which contains methods, fields, etc..
+
+\item A package to dynamically generate or modify \texttt{JavaClass}
+objects. It may be used e.g. to insert analysis code, to strip
+unnecessary information from class files, or to implement the code
+generator back-end of a Java compiler.
+
+\item Various code examples and utilities like a class file viewer, a
+tool to convert class files into HTML, and a converter from class
+files to the Jasmin assembly language \cite{jasmin}.
+\end{enumerate}
+
+\subsection{JavaClass}\label{sec:javaclass}
+
+The ``static'' component of the \jc API resides in the package
+\path{de.fub.bytecode.classfile} and represents class files. All of the
+binary components and data structures declared in the JVM
+specification \cite{jvm} and described in section \ref{sec:jvm} are
+mapped to classes. Figure \ref{fig:umljc} shows an UML diagram of the
+hierarchy of classes of the \jc API. Figure \ref{fig:umlcp} in the
+appendix also shows a detailed diagram of the \texttt{ConstantPool}
+components.
+
+\begin{figure}[htbp]
+ \begin{center}
+ \leavevmode
+ \epsfysize0.93\textheight
+ \epsfbox{eps/javaclass.eps}
+ \caption{UML diagram for the \jc API}\label{fig:umljc}
+ \end{center}
+\end{figure}
+
+The top-level data structure is \texttt{JavaClass}, which in most
+cases is created by a \texttt{Class\-Par\-ser} object that is capable
+of parsing binary class files. A \texttt{JavaClass} object basically
+consists of fields, methods, symbolic references to the super class
+and to the implemented interfaces.
+
+The \cp serves as some kind of central repository and is thus of
+outstanding importance for all components. \texttt{ConstantPool}
+objects contain an array of fixed size of \texttt{Constant} entries,
+which may be retrieved via the \texttt{getConstant()} method taking an
+integer index as argument. Indexes to the \cp may be contained in
+instructions as well as in other components of a class file and in \cp
+entries themselves.
+
+Methods and fields contain a signature, symbolically defining their
+types. Access flags like \texttt{public static final} occur in
+several places and are encoded by an integer bit mask, e.g.
+\texttt{public static final} matches to the Java expression
+
+\begin{verbatim}
+ int access_flags = ACC_PUBLIC | ACC_STATIC | ACC_FINAL;
+\end{verbatim}
+
+As mentioned in section \ref{sec:format} already, several components
+may contain \emph{attribute} objects: classes, fields, methods, and
+\texttt{Code} objects (introduced in section \ref{sec:code2}). The
+latter is an attribute itself that contains the actual byte code
+array, the maximum stack size, the number of local variables, a table
+of handled exceptions, and some optional debugging information coded
+as \texttt{LineNumberTable} and \texttt{LocalVariableTable}
+attributes. Attributes are in general specific to some data structure,
+i.e. no two components share the same kind of attribute, though this
+is not explicitly forbidden. In the figure the \texttt{Attribute}
+classes are marked with the component they belong to.
+
+\subsection{Class repository}
+
+Using the provided \texttt{Repository} class, reading class files into
+a \texttt{JavaClass} object is quite simple:
+
+\begin{verbatim}
+ JavaClass clazz = Repository.lookupClass("java.lang.String");
+\end{verbatim}
+
+The repository also contains methods providing the dynamic equivalent
+of the \texttt{instanceof} operator, and other useful routines:
+
+\begin{verbatim}
+ if(Repository.instanceOf(clazz, super_class) {
+ ...
+ }
+\end{verbatim}
+
+\subsubsection{Accessing class file data}
+
+Information within the class file components may be accessed like Java
+Beans via intuitive set/get methods. All of them also define a
+\texttt{toString()} method so that implementing a simple class viewer
+is very easy. In fact all of the examples used here have been produced
+this way:
+
+{\small \begin{verbatim}
+ System.out.println(clazz);
+ printCode(clazz.getMethods());
+ ...
+ public static void printCode(Method[] methods) {
+ for(int i=0; i < methods.length; i++) {
+ System.out.println(methods[i]);
+
+ Code code = methods[i].getCode();
+ if(code != null) // Non-abstract method
+ System.out.println(code);
+ }
+ }
+\end{verbatim}}
+
+\subsubsection{Analyzing class data}
+
+Last but not least, \jc supports the \emph{Visitor} design
+pattern \cite{design}, so one can write visitor objects to traverse
+and analyze the contents of a class file. Included in the distribution
+is a class \texttt{JasminVisitor} that converts class files into the
+Jasmin assembler language \cite{jasmin}.
+
+\subsection{ClassGen}\label{sec:cgapi}
+
+This part of the API (package \path{ork.apache.bcel.generic}) supplies
+an abstraction level for creating or transforming class files
+dynamically. It makes the static constraints of Java class files like
+the hard-coded byte code addresses generic. The generic \cpe, for
+example, is implemented by the class \texttt{ConstantPoolGen} which
+offers methods for adding different types of constants. Accordingly,
+\texttt{ClassGen} offers an interface to add methods, fields, and
+attributes. Figure \ref{fig:umlcg} gives an overview of this part of
+the API.
+
+\begin{figure}[htbp]
+ \begin{center}
+ \leavevmode
+ \epsfysize0.93\textheight
+ \epsfbox{eps/classgen.eps}
+ \caption{UML diagram of the ClassGen API}\label{fig:umlcg}
+ \end{center}
+\end{figure}
+
+\subsubsection{Types}
+
+We abstract from the concrete details of the type signature syntax
+(see \ref{sec:types}) by introducing the \texttt{Type} class, which is
+used, for example, by methods to define their return and argument
+types. Concrete sub-classes are \texttt{BasicType},
+\texttt{ObjectType}, and \texttt{ArrayType} which consists of the
+element type and the number of dimensions. For commonly used types the
+class offers some predefined constants. For example the method
+signature of the \texttt{main} method as shown in section
+\ref{sec:types} is represented by:
+
+\begin{verbatim}
+ Type return_type = Type.VOID;
+ Type[] arg_types = new Type[] { new ArrayType(Type.STRING, 1) };
+\end{verbatim}
+
+\texttt{Type} also contains methods to convert types into textual
+signatures and vice versa. The sub-classes contain implementations of
+the routines and constraints specified by the Java Language
+Specification \cite{gosling}.
+
+\subsubsection{Generic fields and methods}
+
+Fields are represented by \texttt{FieldGen} objects, which may be
+freely modified by the user. If they have the access rights
+\texttt{static final}, i.e. are constants and of basic type, they may
+optionally have an initializing value.
+
+Generic methods contain methods to add exceptions the method may
+throw, local variables, and exception handlers. The latter two are
+represented by user-configurable objects as well. Because exception
+handlers and local variables contain references to byte code
+addresses, they also take the role of an \emph{instruction targeter}
+in our terminology. Instruction targeters contain a method
+\texttt{updateTarget()} to redirect a reference. Generic
+(non-abstract) methods refer to \emph{instruction lists} that consist
+of instruction objects. References to byte code addresses are
+implemented by handles to instruction objects. This is explained in
+more detail in the following sections.
+
+The maximum stack size needed by the method and the maximum number of
+local variables used may be set manually or computed via the
+\texttt{setMaxStack()} and \texttt{setMaxLocals()} methods
+automatically.
+
+\subsubsection{Instructions}
+
+Modeling instructions as objects may look somewhat odd at first sight,
+but in fact enables programmers to obtain a high-level view upon
+control flow without handling details like concrete byte code offsets.
+Instructions consist of a tag, i.e. an opcode, their length in bytes
+and an offset (or index) within the byte code. Since many instructions
+are immutable, the \texttt{InstructionConstants} interface offers
+shareable predefined ``fly-weight'' constants to use.
+
+Instructions are grouped via sub-classing, the type hierarchy of
+instruction classes is illustrated by (incomplete) figure
+\ref{fig:umlinstr} in the appendix. The most important family of
+instructions are the \emph{branch instructions}, e.g. \texttt{goto},
+that branch to targets somewhere within the byte code. Obviously,
+this makes them candidates for playing an \texttt{InstructionTargeter}
+role, too. Instructions are further grouped by the interfaces they
+implement, there are, e.g., \texttt{TypedInstruction}s that are
+associated with a specific type like \texttt{ldc}, or
+\texttt{ExceptionThrower} instructions that may raise exceptions when
+executed.
+
+All instructions can be traversed via \texttt{accept(Visitor v)} methods,
+i.e., the Visitor design pattern. There is however some special trick
+in these methods that allows to merge the handling of certain
+instruction groups. The \texttt{accept()} do not only call the
+corresponding \texttt{visit()} method, but call \texttt{visit()}
+methods of their respective super classes and implemented interfaces
+first, i.e. the most specific \texttt{visit()} call is last. Thus one
+can group the handling of, say, all \texttt{BranchInstruction}s into
+one single method.
+
+For debugging purposes it may even make sense to ``invent'' your own
+instructions. In a sophisticated code generator like the one used as a
+backend of the Barat framework \cite{barat} one often has to insert
+temporary \texttt{nop} (No operation) instructions. When examining
+the produced code it may be very difficult to track back where the
+\texttt{nop} was actually inserted. One could think of a derived
+\texttt{nop2} instruction that contains additional debugging
+information. When the instruction list is dumped to byte code, the
+extra data is simply dropped.
+
+One could also think of new byte code instructions operating on
+complex numbers that are replaced by normal byte code upon load-time
+or are recognized by a new JVM.
+
+\subsubsection{Instruction lists}\label{sec:il}
+
+An \emph{instruction list} is implemented by a list of
+\emph{instruction handles} encapsulating instruction objects.
+References to instructions in the list are thus not implemented by
+direct pointers to instructions but by pointers to instruction
+\emph{handles}. This makes appending, inserting and deleting areas of
+code very simple. Since we use symbolic references, computation of
+concrete byte code offsets does not need to occur until finalization,
+i.e. until the user has finished the process of generating or
+transforming code. We will use the term instruction handle and
+instruction synonymously throughout the rest of the paper.
+Instruction handles may contain additional user-defined data using the
+\texttt{addAttribute()} method.
+
+\paragraph{Appending.}
+One can append instructions or other instruction lists anywhere to an
+existing list. The instructions are appended after the given
+instruction handle. All append methods return a new instruction
+handle which may then be used as the target of a branch instruction,
+e.g..
+
+{\small \begin{verbatim}
+ InstructionList il = new InstructionList();
+ ...
+ GOTO g = new GOTO(null);
+ il.append(g);
+ ...
+ InstructionHandle ih = il.append(InstructionConstants.ACONST_NULL);
+ g.setTarget(ih);
+\end{verbatim}}
+
+\paragraph{Inserting.}
+Instructions may be inserted anywhere into an existing list. They are
+inserted before the given instruction handle. All insert methods
+return a new instruction handle which may then be used as the start
+address of an exception handler, for example.
+
+{\small \begin{verbatim}
+ InstructionHandle start = il.insert(insertion_point,
+ InstructionConstants.NOP);
+ ...
+ mg.addExceptionHandler(start, end, handler, "java.io.IOException");
+\end{verbatim}}
+
+
+\paragraph{Deleting.}
+Deletion of instructions is also very straightforward; all instruction
+handles and the contained instructions within a given range are
+removed from the instruction list and disposed. The \texttt{delete()}
+method may however throw a \texttt{TargetLostException} when there are
+instruction targeters still referencing one of the deleted
+instructions. The user is forced to handle such exceptions in a
+\texttt{try-catch} block and redirect these references elsewhere. The
+\emph{peep hole} optimizer described in section \ref{sec:nop} gives a
+detailed example for this.
+
+{\small \begin{verbatim}
+ try {
+ il.delete(first, last);
+ } catch(TargetLostException e) {
+ InstructionHandle[] targets = e.getTargets();
+ 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], new_target);
+ }
+ }
+\end{verbatim}}
+
+\paragraph{Finalizing.}
+When the instruction list is ready to be dumped to pure byte code, all
+symbolic references must be mapped to real byte code offsets. This is
+done by the \texttt{getByteCode()} method which is called by default
+by \texttt{MethodGen.getMethod()}. Afterwards you should call
+\texttt{dispose()} so that the instruction handles can be reused
+internally. This helps to reduce memory usage.
+
+\begin{verbatim}
+ InstructionList il = new InstructionList();
+
+ ClassGen cg = new ClassGen("HelloWorld", "java.lang.Object",
+ "<generated>", ACC_PUBLIC | ACC_SUPER,
+ null);
+ MethodGen mg = new MethodGen(ACC_STATIC | ACC_PUBLIC,
+ Type.VOID, new Type[] {
+ new ArrayType(Type.STRING, 1)
+ }, new String[] { "argv" },
+ "main", "HelloWorld", il, cp);
+ ...
+ cg.addMethod(mg.getMethod());
+ il.dispose(); // Reuse instruction handles of list
+\end{verbatim}
+
+\subsubsection{Code example revisited}
+
+Using instruction lists gives us a generic view upon the code: In
+Figure \ref{fig:il} we again present the code chunk of the
+\texttt{readInt()} method of the faculty example in section
+\ref{sec:fac}: The local variables \texttt{n} and \texttt{e1} both
+hold two references to instructions, defining their scope. There are
+two \texttt{goto}s branching to the \texttt{iload} at the end of the
+method. One of the exception handlers is displayed, too: it references
+the start and the end of the \texttt{try} block and also the exception
+handler code.
+
+\begin{figure}[htbp]
+ \begin{center}
+ \leavevmode
+ \epsfxsize\textwidth
+ \epsfbox{eps/il.eps}
+ \caption{Instruction list for \texttt{readInt()} method}
+ \label{fig:il}
+ \end{center}
+\end{figure}
+
+\subsubsection{Instruction factories}\label{sec:compound}
+
+To simplify the creation of certain instructions the user can use the
+supplied \texttt{InstructionFactory} class which offers a lot of
+useful methods to create instructions from scratch. Alternatively, he
+can also use \emph{compound instructions}: When producing byte code,
+some patterns typically occur very frequently, for instance the
+compilation of arithmetic or comparison expressions. You certainly do
+not want to rewrite the code that translates such expressions into
+byte code in every place they may appear. In order to support this,
+the \jc API includes a \emph{compound instruction} (an interface with
+a single \texttt{getInstructionList()} method). Instances of this
+class may be used in any place where normal instructions would occur,
+particularly in append operations.
+
+\paragraph{Example: Pushing constants.}
+Pushing constants onto the operand stack may be coded in different
+ways. As explained in section \ref{sec:code} there are some
+``short-cut'' instructions that can be used to make the produced byte
+code more compact. The smallest instruction to push a single
+\texttt{1} onto the stack is \texttt{iconst\_1}, other possibilities
+are \texttt{bipush} (can be used to push values between -128 and 127),
+\texttt{sipush} (between -32768 and 32767), or \texttt{ldc} (load
+constant from \cpe).
+
+Instead of repeatedly selecting the most compact instruction in, say,
+a switch, one can use the compound \texttt{PUSH} instruction whenever
+pushing a constant number or string. It will produce the appropriate
+byte code instruction and insert entries into to \cp if necessary.
+
+\begin{verbatim}
+ il.append(new PUSH(cp, "Hello, world"));
+ il.append(new PUSH(cp, 4711));
+\end{verbatim}
+
+\subsubsection{Code patterns using regular expressions}\label{sec:peephole}
+
+When transforming code, for instance during optimization or when
+inserting analysis method calls, one typically searches for certain
+patterns of code to perform the transformation at. To simplify
+handling such situations \jc introduces a special feature: One can
+search for given code patterns within an instruction list using
+\emph{regular expressions}. In such expressions, instructions are
+represented by symbolic names, e.g. "\texttt{`IfInstruction'}". Meta
+characters like \verb|+|, \verb|*|, and \verb@(..|..)@ have their
+usual meanings. Thus, the expression
+
+\begin{verbatim}
+ "`NOP'+(`ILOAD__'|`ALOAD__')*"
+\end{verbatim}
+
+represents a piece of code consisting of at least one \texttt{NOP}
+followed by a possibly empty sequence of \texttt{ILOAD} and
+\texttt{ALOAD} instructions.
+
+The \texttt{search()} method of class \texttt{FindPattern} gets an
+instruction list and a regular expression as arguments and returns an
+array describing the area of matched instructions. Additional
+constraints to the matching area of instructions, which can not be
+implemented via regular expressions, may be expressed via \emph{code
+constraints}.
+
+\subsubsection{Example: Optimizing boolean expressions.}
+
+In Java, boolean values are mapped to 1 and to 0, respectively. Thus,
+the simplest way to evaluate boolean expressions is to push a 1 or a 0
+onto the operand stack depending on the truth value of the expression.
+But this way, the subsequent combination of boolean expressions (with
+\verb|&&|, e.g) yields long chunks of code that push lots of 1s and
+0s onto the stack.
+
+When the code has been finalized these chunks can be optimized with a
+\emph{peep hole} algorithm: An \texttt{IfInstruction} (e.g. the
+comparison of two integers: \texttt{if\_icmpeq}) that either produces
+a 1 or a 0 on the stack and is followed by an \texttt{ifne}
+instruction (branch if stack value $\neq$ 0) may be replaced by the
+\texttt{IfInstruction} with its branch target replaced by the target
+of the \texttt{ifne} instruction:
+
+{\small \verbatimtabinput{bool.java}}
+
+The applied code constraint object ensures that the matched code
+really corresponds to the targeted expression pattern. Subsequent
+application of this algorithm removes all unnecessary stack operations
+and branch instructions from the byte code. If any of the deleted
+instructions is still referenced by an \texttt{InstructionTargeter}
+object, the reference has to be updated in the \texttt{catch}-clause.
+
+Code example \ref{sec:hello} gives a verbose example of how to create
+a class file, while example \ref{sec:nop} shows how to implement a
+simple peephole optimizer and how to deal with \texttt{TargetLost}
+exceptions.
+
+\paragraph{Example application:}
+The expression
+
+\begin{verbatim}
+ if((a == null) || (i < 2))
+ System.out.println("Ooops");
+\end{verbatim}
+
+can be mapped to both of the chunks of byte code shown in figure
+\ref{fig:code}. The left column represents the unoptimized code while
+the right column displays the same code after an aggressively
+optimizing peep hole algorithm has been applied:
+
+\begin{figure}[hpt]
+\begin{minipage}{0.49\textwidth}
+ {\small \verbatimtabinput{unopt}} \vfil
+\end{minipage}
+\begin{minipage}{0.49\textwidth}
+ {\small \verbatimtabinput{opt}} \vfil
+\end{minipage}\label{fig:code}\caption{Optimizing boolean expressions}
+\begin{center}
+
+
+\end{center}
+\end{figure}
+\section{Application areas}\label{sec:application}
+
+There are many possible application areas for \jc ranging from class
+browsers, profilers, byte code optimizers, and compilers to
+sophisticated run-time analysis tools and extensions to the Java
+language \cite{agesen, myers}.
+
+Compilers like the Barat compiler \cite{barat} use \jc to implement a
+byte code generating back end. Other possible application areas are
+the static analysis of byte code \cite{thies} or examining the
+run-time behavior of classes by inserting calls to profiling methods
+into the code. Further examples are extending Java with Eiffel-like
+assertions \cite{jawa}, automated delegation \cite{classfilters}, or
+with the concepts of ``Aspect-Oriented Programming'' \cite{aspect}.
+
+\subsection{Class loaders}\label{sec:classloaders}
+
+Class loaders are responsible for loading class files from the file
+system or other resources and passing the byte code to the \vm
+\cite{classloader}. A custom \texttt{ClassLoader} object may be used
+to intercept the standard procedure of loading a class, i.e. the
+system class loader, and perform some transformations before actually
+passing the byte code to the JVM.
+
+A possible scenario is described in figure \ref{fig:classloader}:
+During run-time the \vm requests a custom class loader to load a given
+class. But before the JVM actually sees the byte code, the class
+loader makes a ``side-step'' and performs some transformation to the
+class. To make sure that the modified byte code is still valid and
+does not violate any of the JVM's rules it is checked by the verifier
+before the JVM finally executes it.
+
+\begin{figure}[ht]
+ \begin{center}
+ \leavevmode
+ \epsfxsize\textwidth
+ \epsfbox{eps/classloader.eps}
+ \caption{Class loaders}\label{fig:classloader}
+ \end{center}
+\end{figure}
+
+Using class loaders is an elegant way of extending the \jvm with new
+features without actually modifying it. This concept enables
+developers to use \emph{load-time reflection} to implement their ideas
+as opposed to the static reflection supported by the Java Reflection
+API \cite{reflection}. Load-time transformations supply the user with
+a new level of abstraction. He is not strictly tied to the static
+constraints of the original authors of the classes but may customize
+the applications with third-party code in order to benefit from new
+features. Such transformations may be executed on demand and neither
+interfere with other users, nor alter the original byte code. In fact,
+class loaders may even create classes \emph{ad hoc} without loading a
+file at all.
+
+\subsubsection{Example: Poor Man's Genericity}
+
+The ``Poor Man's Genericity'' project \cite{pmg} that extends Java
+with parameterized classes, for example, uses \jc in two places to
+generate instances of parameterized classes: During compile-time (the
+standard \texttt{javac} with some slightly changed classes) and at
+run-time using a custom class loader. The compiler puts some
+additional type information into class files which is evaluated at
+load-time by the class loader. The class loader performs some
+transformations on the loaded class and passes them to the VM. The
+following algorithm illustrates how the load method of the class
+loader fulfills the request for a parameterized class,
+e.g. \verb|Stack<String>|
+
+\begin{enumerate}
+\item Search for class \texttt{Stack}, load it, and check for a
+certain class attribute containing additional type information. I.e.
+the attribute defines the ``real'' name of the class,
+i.e. \verb|Stack<A>|.
+
+\item Replace all occurrences and references to the formal type
+\texttt{A} with references to the actual type \texttt{String}. For
+example the method
+
+\begin{verbatim}
+ void push(A obj) { ... }
+\end{verbatim}
+
+becomes
+
+\begin{verbatim}
+ void push(String obj) { ... }
+\end{verbatim}
+
+\item Return the resulting class to the Virtual Machine.
+\end{enumerate}
+
+\bibliographystyle{alpha}\bibliography{manual}
+
+\newpage\appendix
+
+\pagestyle{empty}
+\include{appendix}
+\include{diagrams}
+
+\end{document}
+% LocalWords: Freie Universit Institut Informatik dahm inf fu berlin de JOIE
+% LocalWords: JCF HelloWorld Jasmin Eiffel SourceFile classfile lang io ldc ar
+% LocalWords: PrintStream invokevirtual MethodRef ConstantClass Fieldref dup
+% LocalWords: iconst bipush iadd cmpeq jsr athrow iload istore iastore er ic
+% LocalWords: getfield putfield getstatic putstatic invokestatic newarray nop
+% LocalWords: anewarray checkcast instanceof lookupswitch tableswitch Barat VM
+% LocalWords: ConstantPool getConstant LineNumberTable LocalvariableTable ifne
+% LocalWords: invokesta invokespecial multianewarray ConstantPoolGen MethodGen
+% LocalWords: BasicType ObjectType ArrayType InstructionTarge getByteCode bool
+% LocalWords: BranchInstruction InstructionTargeter InstructionHandle regex
+% LocalWords: TargetLostException codeconstraint CompoundInstruction sipush
+% LocalWords: getInstructionList FindPattern CodeConstraint IfInstruction fac
+% LocalWords: TargetLost javac readLine IOException parseInt readInt CLASSPATH
+% LocalWords: NumberFormatException toString JasminVisitor getSignature JVM's
+% LocalWords: FieldGen updateTarget LGPL BCEL LocalVariableTable setMaxStack
+% LocalWords: setMaxLocals InstructionConstants TypedInstruction addAttribute
+% LocalWords: ExceptionThrower getMethod InstructionFactory ALOAD
+
diff --git a/docs/opt b/docs/opt
new file mode 100644
index 00000000..fd57764f
--- /dev/null
+++ b/docs/opt
@@ -0,0 +1,24 @@
+10: aload_0
+11: ifnull #19
+14: iload_1
+15: iconst_2
+16: if_icmpge #27
+19: getstatic System.out
+22: ldc "Ooops"
+24: invokevirtual println
+27: return
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/unopt b/docs/unopt
new file mode 100644
index 00000000..c458bf40
--- /dev/null
+++ b/docs/unopt
@@ -0,0 +1,24 @@
+5: aload_0
+6: ifnull #13
+9: iconst_0
+10: goto #14
+13: iconst_1
+14: nop
+15: ifne #36
+18: iload_1
+19: iconst_2
+20: if_icmplt #27
+23: iconst_0
+24: goto #28
+27: iconst_1
+28: nop
+29: ifne #36
+32: iconst_0
+33: goto #37
+36: iconst_1
+37: nop
+38: ifeq #52
+41: getstatic System.out
+44: ldc "Ooops"
+46: invokevirtual println
+52: return
diff --git a/examples/HelloWorldBuilder.java b/examples/HelloWorldBuilder.java
new file mode 100644
index 00000000..c45a52be
--- /dev/null
+++ b/examples/HelloWorldBuilder.java
@@ -0,0 +1,157 @@
+import org.apache.bcel.generic.*;
+import org.apache.bcel.Constants;
+
+/**
+ * Create HelloWorld class:
+ * <PRE>
+ * import java.io.*;
+ *
+ * public class HelloWorld {
+ * public static void main(String[] argv) {
+ * BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+ * String name = null;
+ *
+ * try {
+ * System.out.print("Please enter your name> ");
+ * name = in.readLine();
+ * } catch(IOException e) { return; }
+ *
+ * System.out.println("Hello, " + name);
+ * }
+ * }
+ * </PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A>
+ */
+public class HelloWorldBuilder {
+ public static void main(String[] argv) {
+ ClassGen cg = new ClassGen("HelloWorld", "java.lang.Object",
+ "<generated>", Constants.ACC_PUBLIC |
+ Constants.ACC_SUPER,
+ null);
+ ConstantPoolGen cp = cg.getConstantPool(); // cg creates constant pool
+ InstructionList il = new InstructionList();
+ MethodGen mg = new MethodGen(Constants.ACC_STATIC |
+ Constants.ACC_PUBLIC,// access flags
+ Type.VOID, // return type
+ new Type[] { // argument types
+ new ArrayType(Type.STRING, 1)
+ },
+ new String[] { "argv" }, // arg names
+ "main", "HelloWorld", // method, class
+ il, cp);
+ InstructionFactory factory = new InstructionFactory(cg);
+
+ ObjectType i_stream = new ObjectType("java.io.InputStream");
+ ObjectType p_stream = new ObjectType("java.io.PrintStream");
+
+ /* Create BufferedReader object and store it in local variable `in'.
+ */
+ il.append(factory.createNew("java.io.BufferedReader"));
+ il.append(InstructionConstants.DUP); // Use predefined constant, i.e. flyweight
+ il.append(factory.createNew("java.io.InputStreamReader"));
+ il.append(InstructionConstants.DUP);
+ il.append(factory.createFieldAccess("java.lang.System", "in", i_stream,
+ Constants.GETSTATIC));
+
+ /* Call constructors, i.e. BufferedReader(InputStreamReader())
+ */
+ il.append(factory.createInvoke("java.io.InputStreamReader", "<init>",
+ Type.VOID, new Type[] { i_stream },
+ Constants.INVOKESPECIAL));
+ il.append(factory.createInvoke("java.io.BufferedReader", "<init>", Type.VOID,
+ new Type[] { new ObjectType("java.io.Reader") },
+ Constants.INVOKESPECIAL));
+
+ /* Create local variable `in'
+ */
+ LocalVariableGen lg = mg.addLocalVariable("in",
+ new ObjectType("java.io.BufferedReader"),
+ null, null);
+ int in = lg.getIndex();
+ lg.setStart(il.append(new ASTORE(in))); // `i' valid from here
+
+ /* Create local variable `name'
+ */
+ lg = mg.addLocalVariable("name", Type.STRING, null, null);
+ int name = lg.getIndex();
+ il.append(InstructionConstants.ACONST_NULL);
+ lg.setStart(il.append(new ASTORE(name))); // `name' valid from here
+
+ /* try { ...
+ */
+ InstructionHandle try_start =
+ il.append(factory.createFieldAccess("java.lang.System", "out", p_stream,
+ Constants.GETSTATIC));
+
+ il.append(new PUSH(cp, "Please enter your name> "));
+ il.append(factory.createInvoke("java.io.PrintStream", "print", Type.VOID,
+ new Type[] { Type.STRING }, Constants.INVOKEVIRTUAL));
+ il.append(new ALOAD(in));
+ il.append(factory.createInvoke("java.io.BufferedReader", "readLine",
+ Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
+ il.append(new ASTORE(name));
+
+ /* Upon normal execution we jump behind exception handler,
+ * the target address is not known yet.
+ */
+ GOTO g = new GOTO(null);
+ InstructionHandle try_end = il.append(g);
+
+ /* } catch() { ... }
+ * Add exception handler: simply return from method
+ */
+ InstructionHandle handler = il.append(InstructionConstants.RETURN);
+ mg.addExceptionHandler(try_start, try_end, handler,
+ new ObjectType("java.io.IOException"));
+
+ /* Normal code continues, now we can set the branch target of the GOTO
+ * that jumps over the handler code.
+ */
+ InstructionHandle ih =
+ il.append(factory.createFieldAccess("java.lang.System", "out", p_stream,
+ Constants.GETSTATIC));
+ g.setTarget(ih);
+
+ /* String concatenation compiles to StringBuffer operations.
+ */
+ il.append(factory.createNew(Type.STRINGBUFFER));
+ il.append(InstructionConstants.DUP);
+ il.append(new PUSH(cp, "Hello, "));
+ il.append(factory.createInvoke("java.lang.StringBuffer", "<init>",
+ Type.VOID, new Type[] { Type.STRING },
+ Constants.INVOKESPECIAL));
+ il.append(new ALOAD(name));
+
+ /* Concatenate strings using a StringBuffer and print them.
+ */
+ il.append(factory.createInvoke("java.lang.StringBuffer", "append",
+ Type.STRINGBUFFER, new Type[] { Type.STRING },
+ Constants.INVOKEVIRTUAL));
+ il.append(factory.createInvoke("java.lang.StringBuffer", "toString",
+ Type.STRING, Type.NO_ARGS,
+ Constants.INVOKEVIRTUAL));
+
+ il.append(factory.createInvoke("java.io.PrintStream", "println",
+ Type.VOID, new Type[] { Type.STRING },
+ Constants.INVOKEVIRTUAL));
+
+ il.append(InstructionConstants.RETURN);
+
+ mg.setMaxStack(5); // Needed stack size
+ cg.addMethod(mg.getMethod());
+
+ il.dispose(); // Reuse instruction handles
+
+ /* Add public <init> method, i.e. empty constructor
+ */
+ cg.addEmptyConstructor(Constants.ACC_PUBLIC);
+
+ /* Get JavaClass object and dump it to file.
+ */
+ try {
+ cg.getJavaClass().dump("HelloWorld.class");
+ } catch(java.io.IOException e) { System.err.println(e); }
+ }
+}
diff --git a/examples/JasminVisitor.java b/examples/JasminVisitor.java
new file mode 100644
index 00000000..f0f8fa9d
--- /dev/null
+++ b/examples/JasminVisitor.java
@@ -0,0 +1,281 @@
+import org.apache.bcel.classfile.Visitor;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.generic.*;
+import java.io.*;
+import java.util.*;
+import org.apache.bcel.Constants;
+import org.apache.bcel.Repository;
+
+/**
+ * Disassemble Java class object into the <A HREF="http://www.cat.nyu.edu/meyer/jasmin">
+ * JASMIN</A> format.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A>
+ */
+public class JasminVisitor extends org.apache.bcel.classfile.EmptyVisitor {
+ private JavaClass clazz;
+ private PrintWriter out;
+ private String class_name;
+ private ConstantPoolGen cp;
+
+ public JasminVisitor(JavaClass clazz, OutputStream out) {
+ this.clazz = clazz;
+ this.out = new PrintWriter(out);
+ class_name = clazz.getClassName();
+ cp = new ConstantPoolGen(clazz.getConstantPool());
+ }
+
+ /**
+ * Start traversal using DefaultVisitor pattern.
+ */
+ public void disassemble() {
+ new org.apache.bcel.classfile.DescendingVisitor(clazz, this).visit();
+ out.close();
+ }
+
+ public void visitJavaClass(JavaClass clazz) {
+ out.println(";; Produced by JasminVisitor (BCEL)");
+ out.println(";; http://jakarta.apache.org/bcel/");
+ out.println(";; " + new Date() + "\n");
+
+ out.println(".source " + clazz.getSourceFileName());
+ out.println("." + Utility.classOrInterface(clazz.getAccessFlags()) + " " +
+ Utility.accessToString(clazz.getAccessFlags(), true) +
+ " " + clazz.getClassName().replace('.', '/'));
+ out.println(".super " + clazz.getSuperclassName().replace('.', '/'));
+
+ String[] interfaces = clazz.getInterfaceNames();
+
+ for(int i=0; i < interfaces.length; i++)
+ out.println(".implements " + interfaces[i].replace('.', '/'));
+
+ out.print("\n");
+ }
+
+ public void visitField(Field field) {
+ out.print(".field " + Utility.accessToString(field.getAccessFlags()) +
+ " " + field.getName() + " " + field.getSignature());
+ if(field.getAttributes().length == 0)
+ out.print("\n");
+ }
+
+ public void visitConstantValue(ConstantValue cv) {
+ out.println(" = " + cv);
+ }
+
+ private Method method;
+
+ /**
+ * Unfortunately Jasmin expects ".end method" after each method. Thus we've to check
+ * for every of the method's attributes if it's the last one and print ".end method"
+ * then.
+ */
+ private final void printEndMethod(Attribute attr) {
+ Attribute[] attributes = method.getAttributes();
+
+ if(attr == attributes[attributes.length - 1])
+ out.println(".end method");
+ }
+
+ public void visitDeprecated(Deprecated attribute) { printEndMethod(attribute); }
+ public void visitSynthetic(Synthetic attribute) { printEndMethod(attribute); }
+
+ public void visitMethod(Method method) {
+ out.println("\n.method " + Utility.accessToString(method.getAccessFlags()) +
+ " " + method.getName() + method.getSignature());
+
+ this.method = method; // Remember for use in subsequent visitXXX calls
+
+ Attribute[] attributes = method.getAttributes();
+ if((attributes == null) || (attributes.length == 0))
+ out.println(".end method");
+ }
+
+ public void visitExceptionTable(ExceptionTable e) {
+ String[] names = e.getExceptionNames();
+ for(int i=0; i < names.length; i++)
+ out.println(".throws " + names[i].replace('.', '/'));
+
+ printEndMethod(e);
+ }
+
+ private Hashtable map;
+
+ public void visitCode(Code code) {
+ int label_counter = 0;
+
+ out.println(".limit stack " + code.getMaxStack());
+ out.println(".limit locals " + code.getMaxLocals());
+
+ MethodGen mg = new MethodGen(method, class_name, cp);
+ InstructionList il = mg.getInstructionList();
+ InstructionHandle[] ihs = il.getInstructionHandles();
+
+ /* Pass 1: Give all referenced instruction handles a symbolic name, i.e. a
+ * label.
+ */
+ map = new Hashtable();
+
+ for(int i=0; i < ihs.length; i++) {
+ if(ihs[i] instanceof BranchHandle) {
+ BranchInstruction bi = (BranchInstruction)ihs[i].getInstruction();
+
+ if(bi instanceof Select) { // Special cases LOOKUPSWITCH and TABLESWITCH
+ InstructionHandle[] targets = ((Select)bi).getTargets();
+
+ for(int j=0; j < targets.length; j++)
+ put(targets[j], "Label" + label_counter++ + ":");
+ }
+
+ InstructionHandle ih = bi.getTarget();
+ put(ih, "Label" + label_counter++ + ":");
+ }
+ }
+
+ LocalVariableGen[] lvs = mg.getLocalVariables();
+ for(int i=0; i < lvs.length; i++) {
+ InstructionHandle ih = lvs[i].getStart();
+ put(ih, "Label" + label_counter++ + ":");
+ ih = lvs[i].getEnd();
+ put(ih, "Label" + label_counter++ + ":");
+ }
+
+ CodeExceptionGen[] ehs = mg.getExceptionHandlers();
+ for(int i=0; i < ehs.length; i++) {
+ CodeExceptionGen c = ehs[i];
+ InstructionHandle ih = c.getStartPC();
+
+ put(ih, "Label" + label_counter++ + ":");
+ ih = c.getEndPC();
+ put(ih, "Label" + label_counter++ + ":");
+ ih = c.getHandlerPC();
+ put(ih, "Label" + label_counter++ + ":");
+ }
+
+ LineNumberGen[] lns = mg.getLineNumbers();
+ for(int i=0; i < lns.length; i++) {
+ InstructionHandle ih = lns[i].getInstruction();
+ put(ih, ".line " + lns[i].getSourceLine());
+ }
+
+ /* Pass 2: Output code.
+ */
+ for(int i=0; i < lvs.length; i++) {
+ LocalVariableGen l = lvs[i];
+ out.println(".var " + l.getIndex() + " is " + l.getName() + " " +
+ l.getType().getSignature() +
+ " from " + get(l.getStart()) +
+ " to " + get(l.getEnd()));
+ }
+
+ out.print("\n");
+
+ for(int i=0; i < ihs.length; i++) {
+ InstructionHandle ih = ihs[i];
+ Instruction inst = ih.getInstruction();
+ String str = (String)map.get(ih);
+
+ if(str != null)
+ out.println(str);
+
+ if(inst instanceof BranchInstruction) {
+ if(inst instanceof Select) { // Special cases LOOKUPSWITCH and TABLESWITCH
+ Select s = (Select)inst;
+ int[] matchs = s.getMatchs();
+ InstructionHandle[] targets = s.getTargets();
+
+ if(s instanceof TABLESWITCH) {
+ out.println("\ttableswitch " + matchs[0] + " " +
+ matchs[matchs.length - 1]);
+
+ for(int j=0; j < targets.length; j++)
+ out.println("\t\t" + get(targets[j]));
+
+ } else { // LOOKUPSWITCH
+ out.println("\tlookupswitch ");
+
+ for(int j=0; j < targets.length; j++)
+ out.println("\t\t" + matchs[j] + " : " + get(targets[j]));
+ }
+
+ out.println("\t\tdefault: " + get(s.getTarget())); // Applies for both
+ } else {
+ BranchInstruction bi = (BranchInstruction)inst;
+ ih = bi.getTarget();
+ str = get(ih);
+ out.println("\t" + Constants.OPCODE_NAMES[bi.getOpcode()] + " " + str);
+ }
+ }
+ else
+ out.println("\t" + inst.toString(cp.getConstantPool()));
+ }
+
+ out.print("\n");
+
+ for(int i=0; i < ehs.length; i++) {
+ CodeExceptionGen c = ehs[i];
+ ObjectType caught = c.getCatchType();
+ String class_name = (caught == null)? // catch any exception, used when compiling finally
+ "all" : caught.getClassName().replace('.', '/');
+
+ out.println(".catch " + class_name + " from " +
+ get(c.getStartPC()) + " to " + get(c.getEndPC()) +
+ " using " + get(c.getHandlerPC()));
+ }
+
+ printEndMethod(code);
+ }
+
+
+ private final String get(InstructionHandle ih) {
+ String str = new StringTokenizer((String)map.get(ih), "\n").nextToken();
+ return str.substring(0, str.length() - 1);
+ }
+
+ private final void put(InstructionHandle ih, String line) {
+ String str = (String)map.get(ih);
+
+ if(str == null)
+ map.put(ih, line);
+ else {
+ if(line.startsWith("Label") || str.endsWith(line)) // Already have a label in the map
+ return;
+
+ map.put(ih, str + "\n" + line); // append
+ }
+ }
+
+ public static void main(String[] argv) {
+ ClassParser parser=null;
+ JavaClass java_class;
+
+ try {
+ if(argv.length == 0)
+ System.err.println("disassemble: No input files specified");
+ else {
+ for(int i=0; i < argv.length; i++) {
+ if((java_class = Repository.lookupClass(argv[i])) == null)
+ java_class = new ClassParser(argv[i]).parse();
+
+ String class_name = java_class.getClassName();
+ int index = class_name.lastIndexOf('.');
+ String path = class_name.substring(0, index + 1).replace('.', File.separatorChar);
+ class_name = class_name.substring(index + 1);
+
+ if(!path.equals("")) {
+ File f = new File(path);
+ f.mkdirs();
+ }
+
+ String name = path + class_name + ".j";
+ FileOutputStream out = new FileOutputStream(name);
+ new JasminVisitor(java_class, out).disassemble();
+ System.out.println("File dumped to: " + name);
+ }
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/examples/Mini/ASCII_CharStream.java b/examples/Mini/ASCII_CharStream.java
new file mode 100644
index 00000000..4ddad520
--- /dev/null
+++ b/examples/Mini/ASCII_CharStream.java
@@ -0,0 +1,381 @@
+/* Generated By:JavaCC: Do not edit this line. ASCII_CharStream.java Version 0.7pre6 */
+package Mini;
+
+/**
+ * An implementation of interface CharStream, where the stream is assumed to
+ * contain only ASCII characters (without unicode processing).
+ */
+
+public final class ASCII_CharStream
+{
+ public static final boolean staticFlag = true;
+ static int bufsize;
+ static int available;
+ static int tokenBegin;
+ static public int bufpos = -1;
+ static private int bufline[];
+ static private int bufcolumn[];
+
+ static private int column = 0;
+ static private int line = 1;
+
+ static private boolean prevCharIsCR = false;
+ static private boolean prevCharIsLF = false;
+
+ static private java.io.Reader inputStream;
+
+ static private char[] buffer;
+ static private int maxNextCharInd = 0;
+ static private int inBuf = 0;
+
+ static private final void ExpandBuff(boolean wrapAround)
+ {
+ char[] newbuffer = new char[bufsize + 2048];
+ int newbufline[] = new int[bufsize + 2048];
+ int newbufcolumn[] = new int[bufsize + 2048];
+
+ try
+ {
+ if (wrapAround)
+ {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+ System.arraycopy(buffer, 0, newbuffer,
+ bufsize - tokenBegin, bufpos);
+ buffer = newbuffer;
+
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
+ System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
+ bufline = newbufline;
+
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
+ System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
+ bufcolumn = newbufcolumn;
+
+ maxNextCharInd = (bufpos += (bufsize - tokenBegin));
+ }
+ else
+ {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+ buffer = newbuffer;
+
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
+ bufline = newbufline;
+
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
+ bufcolumn = newbufcolumn;
+
+ maxNextCharInd = (bufpos -= tokenBegin);
+ }
+ }
+ catch (Throwable t)
+ {
+ throw new Error(t.getMessage());
+ }
+
+
+ bufsize += 2048;
+ available = bufsize;
+ tokenBegin = 0;
+ }
+
+ static private final void FillBuff() throws java.io.IOException
+ {
+ if (maxNextCharInd == available)
+ {
+ if (available == bufsize)
+ {
+ if (tokenBegin > 2048)
+ {
+ bufpos = maxNextCharInd = 0;
+ available = tokenBegin;
+ }
+ else if (tokenBegin < 0)
+ bufpos = maxNextCharInd = 0;
+ else
+ ExpandBuff(false);
+ }
+ else if (available > tokenBegin)
+ available = bufsize;
+ else if ((tokenBegin - available) < 2048)
+ ExpandBuff(true);
+ else
+ available = tokenBegin;
+ }
+
+ int i;
+ try {
+ if ((i = inputStream.read(buffer, maxNextCharInd,
+ available - maxNextCharInd)) == -1)
+ {
+ inputStream.close();
+ throw new java.io.IOException();
+ }
+ else
+ maxNextCharInd += i;
+ return;
+ }
+ catch(java.io.IOException e) {
+ --bufpos;
+ backup(0);
+ if (tokenBegin == -1)
+ tokenBegin = bufpos;
+ throw e;
+ }
+ }
+
+ static public final char BeginToken() throws java.io.IOException
+ {
+ tokenBegin = -1;
+ char c = readChar();
+ tokenBegin = bufpos;
+
+ return c;
+ }
+
+ static private final void UpdateLineColumn(char c)
+ {
+ column++;
+
+ if (prevCharIsLF)
+ {
+ prevCharIsLF = false;
+ line += (column = 1);
+ }
+ else if (prevCharIsCR)
+ {
+ prevCharIsCR = false;
+ if (c == '\n')
+ {
+ prevCharIsLF = true;
+ }
+ else
+ line += (column = 1);
+ }
+
+ switch (c)
+ {
+ case '\r' :
+ prevCharIsCR = true;
+ break;
+ case '\n' :
+ prevCharIsLF = true;
+ break;
+ case '\t' :
+ column--;
+ column += (8 - (column & 07));
+ break;
+ default :
+ break;
+ }
+
+ bufline[bufpos] = line;
+ bufcolumn[bufpos] = column;
+ }
+
+ static public final char readChar() throws java.io.IOException
+ {
+ if (inBuf > 0)
+ {
+ --inBuf;
+ return (char)((char)0xff & buffer[(bufpos == bufsize - 1) ? (bufpos = 0) : ++bufpos]);
+ }
+
+ if (++bufpos >= maxNextCharInd)
+ FillBuff();
+
+ char c = (char)((char)0xff & buffer[bufpos]);
+
+ UpdateLineColumn(c);
+ return (c);
+ }
+
+ /**
+ * @deprecated
+ * @see #getEndColumn
+ */
+
+ static public final int getColumn() {
+ return bufcolumn[bufpos];
+ }
+
+ /**
+ * @deprecated
+ * @see #getEndLine
+ */
+
+ static public final int getLine() {
+ return bufline[bufpos];
+ }
+
+ static public final int getEndColumn() {
+ return bufcolumn[bufpos];
+ }
+
+ static public final int getEndLine() {
+ return bufline[bufpos];
+ }
+
+ static public final int getBeginColumn() {
+ return bufcolumn[tokenBegin];
+ }
+
+ static public final int getBeginLine() {
+ return bufline[tokenBegin];
+ }
+
+ static public final void backup(int amount) {
+
+ inBuf += amount;
+ if ((bufpos -= amount) < 0)
+ bufpos += bufsize;
+ }
+
+ public ASCII_CharStream(java.io.Reader dstream, int startline,
+ int startcolumn, int buffersize)
+ {
+ if (inputStream != null)
+ throw new Error("\n ERROR: Second call to the constructor of a static ASCII_CharStream. You must\n" +
+ " either use ReInit() or set the JavaCC option STATIC to false\n" +
+ " during the generation of this class.");
+ inputStream = dstream;
+ line = startline;
+ column = startcolumn - 1;
+
+ available = bufsize = buffersize;
+ buffer = new char[buffersize];
+ bufline = new int[buffersize];
+ bufcolumn = new int[buffersize];
+ }
+
+ public ASCII_CharStream(java.io.Reader dstream, int startline,
+ int startcolumn)
+ {
+ this(dstream, startline, startcolumn, 4096);
+ }
+ static public void ReInit(java.io.Reader dstream, int startline,
+ int startcolumn, int buffersize)
+ {
+ inputStream = dstream;
+ line = startline;
+ column = startcolumn - 1;
+
+ if (buffer == null || buffersize != buffer.length)
+ {
+ available = bufsize = buffersize;
+ buffer = new char[buffersize];
+ bufline = new int[buffersize];
+ bufcolumn = new int[buffersize];
+ }
+ prevCharIsLF = prevCharIsCR = false;
+ tokenBegin = inBuf = maxNextCharInd = 0;
+ bufpos = -1;
+ }
+
+ static public void ReInit(java.io.Reader dstream, int startline,
+ int startcolumn)
+ {
+ ReInit(dstream, startline, startcolumn, 4096);
+ }
+ public ASCII_CharStream(java.io.InputStream dstream, int startline,
+ int startcolumn, int buffersize)
+ {
+ this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
+ }
+
+ public ASCII_CharStream(java.io.InputStream dstream, int startline,
+ int startcolumn)
+ {
+ this(dstream, startline, startcolumn, 4096);
+ }
+
+ static public void ReInit(java.io.InputStream dstream, int startline,
+ int startcolumn, int buffersize)
+ {
+ ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
+ }
+ static public void ReInit(java.io.InputStream dstream, int startline,
+ int startcolumn)
+ {
+ ReInit(dstream, startline, startcolumn, 4096);
+ }
+ static public final String GetImage()
+ {
+ if (bufpos >= tokenBegin)
+ return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
+ else
+ return new String(buffer, tokenBegin, bufsize - tokenBegin) +
+ new String(buffer, 0, bufpos + 1);
+ }
+
+ static public final char[] GetSuffix(int len)
+ {
+ char[] ret = new char[len];
+
+ if ((bufpos + 1) >= len)
+ System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
+ else
+ {
+ System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
+ len - bufpos - 1);
+ System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
+ }
+
+ return ret;
+ }
+
+ static public void Done()
+ {
+ buffer = null;
+ bufline = null;
+ bufcolumn = null;
+ }
+
+ /**
+ * Method to adjust line and column numbers for the start of a token.<BR>
+ */
+ static public void adjustBeginLineColumn(int newLine, int newCol)
+ {
+ int start = tokenBegin;
+ int len;
+
+ if (bufpos >= tokenBegin)
+ {
+ len = bufpos - tokenBegin + inBuf + 1;
+ }
+ else
+ {
+ len = bufsize - tokenBegin + bufpos + 1 + inBuf;
+ }
+
+ int i = 0, j = 0, k = 0;
+ int nextColDiff = 0, columnDiff = 0;
+
+ while (i < len &&
+ bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
+ {
+ bufline[j] = newLine;
+ nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
+ bufcolumn[j] = newCol + columnDiff;
+ columnDiff = nextColDiff;
+ i++;
+ }
+
+ if (i < len)
+ {
+ bufline[j] = newLine++;
+ bufcolumn[j] = newCol + columnDiff;
+
+ while (i++ < len)
+ {
+ if (bufline[j = start % bufsize] != bufline[++start % bufsize])
+ bufline[j] = newLine++;
+ else
+ bufline[j] = newLine;
+ }
+ }
+
+ line = bufline[j];
+ column = bufcolumn[j];
+ }
+
+}
diff --git a/examples/Mini/ASTExpr.java b/examples/Mini/ASTExpr.java
new file mode 100644
index 00000000..149c288a
--- /dev/null
+++ b/examples/Mini/ASTExpr.java
@@ -0,0 +1,292 @@
+/* Generated By:JJTree: Do not edit this line. ASTExpr.java */
+/* JJT: 0.3pre1 */
+
+package Mini;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.generic.*;
+
+/**
+ * Represents arithmetic expressions such as `(a + 12 == b) OR c'.
+ * The parse tree is built initially by the parser and modified, i.e.
+ * compacted with `traverse()'. Each (Expr, Term, Factor) node
+ * with kind == -1 is replaced which its successor node, which is
+ * converted to type `Expr'
+ *
+ * A node with kind == -1 denotes the fact that this expression
+ * node has just one child branch and thus may be replaced by this
+ * branch (or leaf) directly without altering the expression
+ * semantics. Term and Factor nodes are used only to build the parse tree
+ * obeying the aritmetical precedences (* stronger than +, etc.) and
+ * are discarded in the first pass.
+*/
+public class ASTExpr extends SimpleNode
+implements MiniParserConstants, MiniParserTreeConstants, org.apache.bcel.Constants {
+ protected int kind=-1; // Single twig to leaf?
+ private int unop=-1; // Special case: Unary operand applied
+ protected ASTExpr[] exprs; // Sub expressions
+ protected Environment env; // Needed in all passes
+ protected int line, column;
+ protected boolean is_simple; // true, if simple expression like `12 + f(a)'
+
+ /* Not all children shall inherit this, exceptions are ASTIdent and ASTFunAppl, which
+ * look up the type in the corresponding environment entry.
+ */
+ protected int type = T_UNKNOWN;
+
+ // Generated methods
+ ASTExpr(int id) {
+ super(id);
+ }
+
+ ASTExpr(MiniParser p, int id) {
+ super(p, id);
+ }
+
+ public static Node jjtCreate(MiniParser p, int id) {
+ return new ASTExpr(p, id);
+ }
+
+ ASTExpr(int line, int column, int id) {
+ super(id);
+ this.line = line;
+ this.column = column;
+ }
+
+ ASTExpr(int line, int column, int kind, int id) {
+ this(line, column, id);
+ this.kind = kind;
+ }
+
+ /* Special constructor, called from ASTTerm.traverse() and
+ * ASTFactor.traverse(), when traverse()ing the parse tree replace
+ * themselves with Expr nodes.
+ */
+ ASTExpr(ASTExpr[] children, int kind, int line, int column) {
+ this(line, column, kind, JJTEXPR);
+ exprs = children;
+ }
+
+ /**
+ * @return name of node, its kind and the number of children.
+ */
+ public String toString() {
+ String op="";
+ int len = (children != null)? children.length : 0;
+ if(unop != -1)
+ op = tokenImage[unop];
+ else if(kind != -1)
+ op = tokenImage[kind];
+
+ return jjtNodeName[id] + "(" + op + ")[" + len + "]<" +
+ TYPE_NAMES[type] + "> @" + line + ", " + column;
+ }
+
+ /**
+ * Overrides SimpleNode.closeNode(). Overridden by some subclasses.
+ *
+ * Called by the parser when the construction of this node is finished.
+ * Casts children Node[] to precise ASTExpr[] type.
+ */
+ public void closeNode() {
+ if(children != null) {
+ exprs = new ASTExpr[children.length];
+ System.arraycopy(children, 0, exprs, 0, children.length);
+ children=null; // Throw away old reference
+ }
+ }
+
+ /**
+ * First pass
+ * Overridden by subclasses. Traverse the whole parse tree recursively and
+ * drop redundant nodes.
+ */
+ public ASTExpr traverse(Environment env) {
+ this.env = env;
+
+ if((kind == -1) && (unop == -1)) // Redundant node (built thru op precedence) ?
+ return exprs[0].traverse(env); // --> Replaced by successor
+ else {
+ for(int i=0; i < exprs.length; i++) // Traverse children
+ exprs[i] = exprs[i].traverse(env); // References may change
+
+ return this;
+ }
+ }
+
+ /**
+ * Second and third pass
+ * @return type of expression
+ * @param expected type
+ */
+ public int eval(int expected) {
+ int child_type = T_UNKNOWN, t;
+
+ is_simple = true;
+
+ // Determine expected node type depending on used operator.
+ if(unop != -1) {
+ if(unop == MINUS)
+ child_type = type = T_INT; // -
+ else
+ child_type = type = T_BOOLEAN; // !
+ }
+ else {
+ // Compute expected type
+ if((kind == PLUS) || (kind == MINUS) || (kind == MULT) ||
+ (kind == MOD) || (kind == DIV))
+ child_type = type = T_INT;
+ else if((kind == AND) || (kind == OR))
+ child_type = type = T_BOOLEAN;
+ else { // LEQ, GT, etc.
+ child_type = T_INT;
+ type = T_BOOLEAN;
+ }
+ }
+
+ // Get type of subexpressions
+ for(int i=0; i < exprs.length; i++) {
+ t = exprs[i].eval(child_type);
+
+ if(t != child_type)
+ MiniC.addError(exprs[i].getLine(), exprs[i].getColumn(),
+ "Expression has not expected type " + TYPE_NAMES[child_type] +
+ " but " + TYPE_NAMES[t] + ".");
+
+ is_simple = is_simple && exprs[i].isSimple();
+ }
+
+ return type;
+ }
+
+ private static final String toBool(String i) {
+ return "(" + i + " != 0)";
+ }
+
+ private static final String toInt(String i) {
+ return "((" + i + ")? 1 : 0)";
+ }
+
+ /**
+ * Fourth pass, produce Java code.
+ */
+ public void code(StringBuffer buf) {
+ if(unop != -1) {
+ exprs[0].code(buf);
+ String top = ASTFunDecl.pop();
+ if(unop == MINUS)
+ ASTFunDecl.push(buf, "-" + top);
+ else
+ ASTFunDecl.push(buf, "(" + top + " == 1)? 0 : 1)");
+ }
+ else {
+ exprs[0].code(buf);
+ exprs[1].code(buf);
+ String _body_int2 = ASTFunDecl.pop();
+ String _body_int = ASTFunDecl.pop();
+
+ switch(kind) {
+ case PLUS: ASTFunDecl.push(buf, _body_int + " + " + _body_int2); break;
+ case MINUS: ASTFunDecl.push(buf, _body_int + " - " + _body_int2); break;
+ case MULT: ASTFunDecl.push(buf, _body_int + " * " + _body_int2); break;
+ case DIV: ASTFunDecl.push(buf, _body_int + " / " + _body_int2); break;
+
+ case AND: ASTFunDecl.push(buf, toInt(toBool(_body_int) + " && " +
+ toBool(_body_int2))); break;
+ case OR: ASTFunDecl.push(buf, toInt(toBool(_body_int) + " || " +
+ toBool(_body_int2))); break;
+
+ case EQ: ASTFunDecl.push(buf, toInt(_body_int + " == " + _body_int2));
+ break;
+ case LEQ: ASTFunDecl.push(buf, toInt(_body_int + " <= " + _body_int2));
+ break;
+ case GEQ: ASTFunDecl.push(buf, toInt(_body_int + " >= " + _body_int2));
+ break;
+ case NEQ: ASTFunDecl.push(buf, toInt(_body_int + " != " + _body_int2));
+ break;
+ case LT: ASTFunDecl.push(buf, toInt(_body_int + " < " + _body_int2));
+ break;
+ case GT: ASTFunDecl.push(buf, toInt(_body_int + " > " + _body_int2));
+ break;
+
+ default: System.err.println("Ooops");
+ }
+ }
+ }
+
+ /**
+ * Fifth pass, produce Java byte code.
+ */
+ public void byte_code(InstructionList il, MethodGen method, ConstantPoolGen cp) {
+ exprs[0].byte_code(il, method, cp);
+
+ if(unop != -1) { // Apply unary operand
+ if(unop == MINUS)
+ il.append(InstructionConstants.INEG);
+ else { // == NOT
+ il.append(new PUSH(cp, 1)); ASTFunDecl.push(); // Push TRUE
+ il.append(InstructionConstants.IXOR); ASTFunDecl.pop();
+ }
+ }
+ else { // Apply binary operand
+ BranchHandle bh=null;
+
+ exprs[1].byte_code(il, method, cp);
+
+ switch(kind) {
+ case PLUS: il.append(InstructionConstants.IADD); ASTFunDecl.pop(); break;
+ case MINUS: il.append(InstructionConstants.ISUB); ASTFunDecl.pop(); break;
+ case MULT: il.append(InstructionConstants.IMUL); ASTFunDecl.pop(); break;
+ case DIV: il.append(InstructionConstants.IDIV); ASTFunDecl.pop(); break;
+ case AND: il.append(InstructionConstants.IAND); ASTFunDecl.pop(); break;
+ case OR: il.append(InstructionConstants.IOR); ASTFunDecl.pop(); break;
+
+ /* Use negated operands */
+ case EQ: bh = il.append(new IF_ICMPNE(null)); ASTFunDecl.pop(2); break;
+ case LEQ: bh = il.append(new IF_ICMPGT(null)); ASTFunDecl.pop(2); break;
+ case GEQ: bh = il.append(new IF_ICMPLT(null)); ASTFunDecl.pop(2); break;
+ case NEQ: bh = il.append(new IF_ICMPEQ(null)); ASTFunDecl.pop(2); break;
+ case LT: bh = il.append(new IF_ICMPGE(null)); ASTFunDecl.pop(2); break;
+ case GT: bh = il.append(new IF_ICMPLE(null)); ASTFunDecl.pop(2); break;
+ default: System.err.println("Ooops");
+ }
+
+ switch(kind) {
+ case EQ: case LEQ: case GEQ: case NEQ: case LT: case GT:
+ BranchHandle g;
+
+ il.append(new PUSH(cp, 1));
+ g = il.append(new GOTO(null));
+ bh.setTarget(il.append(new PUSH(cp, 0)));
+ g.setTarget(il.append(InstructionConstants.NOP)); // May be optimized away later
+ ASTFunDecl.push();
+ break;
+
+ default: break;
+ }
+ }
+ }
+
+ public boolean isSimple() { return is_simple; }
+ public void setType(int type) { this.type = type; }
+ public int getType() { return type; }
+ public void setKind(int kind) { this.kind = kind; }
+ public int getKind() { return kind; }
+ public void setUnOp(int unop) { this.unop = unop; }
+ public int getUnOp() { return unop; }
+ public void setLine(int line) { this.line = line; }
+ public int getLine() { return line; }
+ public void setColumn(int column) { this.column = column; }
+ public int getColumn() { return column; }
+ public void setPosition(int line, int column) {
+ this.line = line;
+ this.column = column;
+ }
+
+ public void dump(String prefix) {
+ System.out.println(toString(prefix));
+
+ if(exprs != null) // Children may have no subchildren
+ for(int i=0; i < exprs.length; ++i)
+ exprs[i].dump(prefix + " ");
+ }
+}
diff --git a/examples/Mini/ASTFactor.java b/examples/Mini/ASTFactor.java
new file mode 100644
index 00000000..41c2bdcd
--- /dev/null
+++ b/examples/Mini/ASTFactor.java
@@ -0,0 +1,37 @@
+/* Generated By:JJTree: Do not edit this line. ASTFactor.java */
+/* JJT: 0.3pre1 */
+
+package Mini;
+
+/**
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A>
+ */
+public class ASTFactor extends ASTExpr {
+ // Generated methods
+ ASTFactor(int id) {
+ super(id);
+ }
+
+ ASTFactor(MiniParser p, int id) {
+ super(p, id);
+ }
+
+ public static Node jjtCreate(MiniParser p, int id) {
+ return new ASTFactor(p, id);
+ }
+
+ // Inherited closeNode(), dump()
+
+ /**
+ * Drop this node, if kind == -1, because then it has just one child node
+ * and may be safely replaced with it.
+ */
+ public ASTExpr traverse(Environment env) {
+ if(kind == -1) // Drop it
+ return exprs[0].traverse(env);
+ else // Or convert it to Expr node & copy children
+ return new ASTExpr(exprs, kind, line, column).traverse(env);
+ }
+}
diff --git a/examples/Mini/ASTFunAppl.java b/examples/Mini/ASTFunAppl.java
new file mode 100644
index 00000000..87c9a955
--- /dev/null
+++ b/examples/Mini/ASTFunAppl.java
@@ -0,0 +1,221 @@
+/* Generated By:JJTree: Do not edit this line. ASTFunAppl.java */
+/* JJT: 0.3pre1 */
+
+package Mini;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.generic.*;
+
+/**
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A>
+ */
+public class ASTFunAppl extends ASTExpr implements MiniParserTreeConstants,
+ org.apache.bcel.Constants {
+ private ASTIdent name;
+ private Function function; // Points to Function in environment
+
+ // Generated methods
+ ASTFunAppl(int id) {
+ super(id);
+ }
+
+ ASTFunAppl(MiniParser p, int id) {
+ super(p, id);
+ }
+
+ public static Node jjtCreate(MiniParser p, int id) {
+ return new ASTFunAppl(p, id);
+ }
+
+ ASTFunAppl(ASTIdent name, Function function, ASTExpr[] exprs) {
+ this(JJTFUNAPPL);
+
+ this.name = name;
+ this.function = function;
+ this.exprs = exprs;
+ }
+
+ public String toString() {
+ return jjtNodeName[id] + " " + name.getName();
+ }
+
+ /**
+ * Overrides ASTExpr.closeNode()
+ */
+ public void closeNode() {
+ name = (ASTIdent)children[0];
+
+ if(children.length > 1) {
+ exprs = new ASTExpr[children.length - 1];
+ System.arraycopy(children, 1, exprs, 0, children.length - 1);
+ }
+
+ children=null; // Throw away old reference
+ }
+
+ /**
+ * Overrides ASTExpr.traverse()
+ */
+ public ASTExpr traverse(Environment env) {
+ String fname = name.getName();
+ EnvEntry entry = env.get(fname);
+
+ this.env = env;
+
+ if(entry == null) // Applying unknown function
+ MiniC.addError(name.getLine(), name.getColumn(),
+ "Applying unknown function " + fname + ".");
+ else {
+ if(!(entry instanceof Function))
+ MiniC.addError(name.getLine(), name.getColumn(),
+ "Applying non-function " + fname + ".");
+ else {
+ int len = (exprs != null)? exprs.length : 0;
+ Function fun = (Function)entry;
+
+ if(len != fun.getNoArgs())
+ MiniC.addError(name.getLine(), name.getColumn(),
+ "Function " + fname + " expects " + fun.getNoArgs() +
+ " arguments, you supplied " + len + ".");
+ else { // Adjust references
+ function = fun;
+ name = fun.getName();
+ }
+ }
+ }
+
+ if(exprs != null) // Argument list may be empty
+ for(int i=0; i < exprs.length; i++)
+ exprs[i] = exprs[i].traverse(env);
+
+ return this;
+ }
+
+ /**
+ * Second pass
+ * Overrides AstExpr.eval()
+ * @return type of expression
+ * @param expected type
+ */
+ public int eval(int expected) {
+ String fname = name.getName();
+ Function f = function;
+ ASTIdent fun = f.getName();
+ ASTIdent[] args = f.getArgs();
+ int t = fun.getType();
+
+ is_simple = true; // Only true if all arguments are simple expressions
+
+ // Check arguments
+ if(exprs != null) {
+ for(int i=0; i < exprs.length; i++) { // length match checked in previous pass
+ int expect = args[i].getType(); // May be T_UNKNOWN
+ int t_e = exprs[i].eval(expect); // May be T_UNKNOWN
+
+ if((expect != T_UNKNOWN) && (t_e != expect))
+ MiniC.addError(exprs[i].getLine(), exprs[i].getColumn(),
+ "Argument " + (i + 1) + " in application of " + fname +
+ " is not of type " + TYPE_NAMES[expect] + " but " +
+ TYPE_NAMES[t_e]);
+ else
+ args[i].setType(t_e); // Update, may be identical
+
+ is_simple = is_simple && exprs[i].isSimple(); // Check condition
+ }
+ }
+
+ if(t == T_UNKNOWN) // Function type yet unknown
+ fun.setType(t = expected); // May be still T_UNKNOWN
+
+ return type = t;
+ }
+
+ /**
+ * Fourth pass, produce Java code.
+ */
+ public void code(StringBuffer buf) {
+ String fname = name.getName();
+ Function f = function;
+ ASTIdent[] args = f.getArgs();
+
+ if(fname.equals("READ"))
+ ASTFunDecl.push(buf, "_readInt()");
+ else if(fname.equals("WRITE")) {
+ exprs[0].code(buf);
+ ASTFunDecl.push(buf, "_writeInt(" + ASTFunDecl.pop() + ")");
+ }
+ else { // Normal function
+ if(exprs != null) { // Output in reverse odrder
+ for(int i = exprs.length - 1; i >= 0; i--)
+ exprs[i].code(buf);
+ }
+
+ StringBuffer call = new StringBuffer(fname + "(");
+ // Function call
+
+ if(exprs != null) {
+ for(int i=0; i < exprs.length; i++) {
+ call.append(ASTFunDecl.pop());
+ if(i < exprs.length - 1)
+ call.append(", ");
+ }
+ }
+ call.append(")");
+
+ ASTFunDecl.push(buf, call.toString());
+ }
+ }
+
+ /**
+ * Fifth pass, produce Java byte code.
+ */
+ public void byte_code(InstructionList il, MethodGen method, ConstantPoolGen cp) {
+ String fname = name.getName();
+ Function f = function;
+ //ASTIdent fun = f.getName();
+ ASTIdent[] args = f.getArgs();
+ String class_name = method.getClassName();
+
+ if(fname.equals("READ"))
+ il.append(new INVOKESTATIC(cp.addMethodref(class_name,
+ "_readInt",
+ "()I")));
+ else if(fname.equals("WRITE")) {
+ exprs[0].byte_code(il, method, cp);
+ ASTFunDecl.pop();
+ il.append(new INVOKESTATIC(cp.addMethodref(class_name,
+ "_writeInt",
+ "(I)I")));
+ }
+ else { // Normal function
+ int size = exprs.length;
+ Type[] argv = null;
+
+ if(exprs != null) {
+ argv = new Type[size];
+
+ for(int i=0; i < size; i++) {
+ argv[i] = Type.INT;
+ exprs[i].byte_code(il, method, cp);
+ }
+
+ //ASTFunDecl.push(size);
+ }
+
+ ASTFunDecl.pop(size);
+
+ // Function call
+ il.append(new INVOKESTATIC(cp.addMethodref(class_name,
+ fname,
+ Type.getMethodSignature(Type.INT,
+ argv))));
+ }
+
+ ASTFunDecl.push();
+ }
+
+ // dump() inherited
+ public ASTIdent getName() { return name; }
+ public Function getFunction() { return function; }
+}
diff --git a/examples/Mini/ASTFunDecl.java b/examples/Mini/ASTFunDecl.java
new file mode 100644
index 00000000..a008f74f
--- /dev/null
+++ b/examples/Mini/ASTFunDecl.java
@@ -0,0 +1,395 @@
+/* Generated By:JJTree: Do not edit this line. ASTFunDecl.java */
+/* JJT: 0.3pre1 */
+
+package Mini;
+import java.io.PrintWriter;
+import java.util.Iterator;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.generic.*;
+import org.apache.bcel.util.InstructionFinder;
+
+/**
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A>
+ */
+public class ASTFunDecl extends SimpleNode
+implements MiniParserTreeConstants, org.apache.bcel.Constants {
+ private ASTIdent name;
+ private ASTIdent[] argv;
+ private ASTExpr body;
+ private int type = T_UNKNOWN;
+ private int line, column;
+ private boolean is_simple; // true, if simple expression like `12 + f(a)'
+ private boolean is_recursive; // Not used yet, TODO
+ private int max_depth; // max. expression tree depth
+ private Environment env;
+
+ // Generated methods
+ ASTFunDecl(int id) {
+ super(id);
+ }
+
+ ASTFunDecl(MiniParser p, int id) {
+ super(p, id);
+ }
+
+ public static Node jjtCreate(MiniParser p, int id) {
+ return new ASTFunDecl(p, id);
+ }
+
+ ASTFunDecl(ASTIdent name, ASTIdent[] argv, ASTExpr body, int type) {
+ this(JJTFUNDECL);
+
+ this.name = name;
+ this.argv = argv;
+ this.body = body;
+ this.type = type;
+ }
+
+ /**
+ * Overrides SimpleNode.closeNode()
+ * Cast children to appropiate type.
+ */
+ public void closeNode() {
+ name = (ASTIdent)children[0];
+ body = (ASTExpr)children[children.length - 1];
+
+ argv = new ASTIdent[children.length - 2]; // May be 0-size array
+ for(int i = 1; i < children.length - 1; i++)
+ argv[i - 1] = (ASTIdent)children[i];
+
+ children=null; // Throw away old reference
+ }
+
+ /**
+ * First pass of parse tree.
+ */
+ public ASTFunDecl traverse(Environment env) {
+ this.env = env;
+
+ // Put arguments into hash table aka environment
+ for(int i=0; i < argv.length; i++) {
+ EnvEntry entry = env.get(argv[i].getName());
+
+ if(entry != null)
+ MiniC.addError(argv[i].getLine(), argv[i].getColumn(),
+ "Redeclaration of " + entry + ".");
+ else
+ env.put(new Variable(argv[i]));
+ }
+
+ /* Update entry of this function, i.e. set argument references.
+ * The entry is already in there by garantuee, but may be of wrong type,
+ * i.e. the user defined a function `TRUE', e.g. and `TRUE' is of type `Variable'.
+ */
+ try {
+ Function fun = (Function)env.get(name.getName());
+ fun.setArgs(argv);
+ } catch(ClassCastException e) {} // Who cares?
+
+ body = body.traverse(env); // Traverse expression body
+
+ return this;
+ }
+
+ /** Second pass
+ * @return type of expression
+ */
+ public int eval(int pass) {
+ int expected = name.getType(); // Maybe other function has already called us
+ type = body.eval(expected); // And updated the env
+
+ if((expected != T_UNKNOWN) && (type != expected))
+ MiniC.addError(line, column,
+ "Function f ist not of type " + TYPE_NAMES[expected] +
+ " as previously assumed, but " + TYPE_NAMES[type]);
+
+ name.setType(type);
+
+ is_simple = body.isSimple();
+
+ if(pass == 2 && type == T_UNKNOWN)
+ is_recursive = true;
+
+ return type;
+ }
+
+ /**
+ * Fourth pass, produce Java code.
+ */
+ public void code(PrintWriter out) {
+ String expr;
+ boolean main=false, ignore=false;
+
+ String fname = name.getName();
+
+ if(fname.equals("main")) {
+ out.println(" public static void main(String[] _argv) {");
+ main = true;
+ }
+ else if(fname.equals("READ") || fname.equals("WRITE")) { // Do nothing
+ ignore = true;
+ }
+ else {
+ out.print(" public static final " + "int" + // type_names[type] +
+ " " + fname + "(");
+
+ for(int i = 0; i < argv.length; i++) {
+ out.print("int " + argv[i].getName());
+
+ if(i < argv.length - 1)
+ out.print(", ");
+ }
+
+ out.println(")\n throws IOException\n {");
+ }
+
+ if(!ignore) {
+ StringBuffer buf = new StringBuffer();
+
+ body.code(buf);
+ out.println(getVarDecls());
+
+ expr = buf.toString();
+
+ if(main)
+ out.println(" try {");
+
+ out.println(expr);
+
+ if(main)
+ out.println(" } catch(Exception e) { System.err.println(e); }\n }\n");
+ else
+ out.println("\n return " + pop() + ";\n }\n");
+ }
+
+ reset();
+ }
+
+ /**
+ * Fifth pass, produce Java byte code.
+ */
+ public void byte_code(ClassGen class_gen, ConstantPoolGen cp) {
+ MethodGen method=null;
+ boolean main=false, ignore=false;
+ String class_name = class_gen.getClassName();
+ String fname = name.getName();
+ InstructionList il = new InstructionList();
+
+ Type[] args = { new ArrayType(Type.STRING, 1) }; // default for `main'
+ String[] arg_names = { "$argv" };
+
+ if(fname.equals("main")) {
+ method = new MethodGen(ACC_STATIC | ACC_PUBLIC,
+ Type.VOID, args, arg_names,
+ "main", class_name, il, cp);
+
+ main = true;
+ } else if(fname.equals("READ") || fname.equals("WRITE")) { // Do nothing
+ ignore = true;
+ } else {
+ int size = argv.length;
+
+ arg_names = new String[size];
+ args = new Type[size];
+
+ for(int i = 0; i < size; i++) {
+ args[i] = Type.INT;
+ arg_names[i] = argv[i].getName();
+ }
+
+ method = new MethodGen(ACC_STATIC | ACC_PRIVATE | ACC_FINAL,
+ Type.INT, args, arg_names,
+ fname, class_name, il, cp);
+
+ LocalVariableGen[] lv = method.getLocalVariables();
+ for(int i = 0; i < size; i++) {
+ Variable entry = (Variable)env.get(arg_names[i]);
+ entry.setLocalVariable(lv[i]);
+ }
+
+ method.addException("java.io.IOException");
+ }
+
+ if(!ignore) {
+ body.byte_code(il, method, cp);
+
+ if(main) {
+ ObjectType e_type = new ObjectType("java.lang.Exception");
+ InstructionHandle start = il.getStart(), end, handler, end_handler;
+ LocalVariableGen exc = method.addLocalVariable("$e",
+ e_type,
+ null, null);
+ int slot = exc.getIndex();
+
+ il.append(InstructionConstants.POP); pop(); // Remove last element on stack
+ end = il.append(InstructionConstants.RETURN); // Use instruction constants, if possible
+
+ // catch
+ handler = il.append(new ASTORE(slot)); // save exception object
+ il.append(new GETSTATIC(cp.addFieldref("java.lang.System", "err",
+ "Ljava/io/PrintStream;")));
+ il.append(new ALOAD(slot)); push(2);
+ il.append(new INVOKEVIRTUAL(cp.addMethodref("java.io.PrintStream",
+ "println",
+ "(Ljava/lang/Object;)V")));
+ pop(2);
+ end_handler = il.append(InstructionConstants.RETURN);
+ method.addExceptionHandler(start, end, handler, e_type);
+ exc.setStart(handler); exc.setEnd(end_handler);
+ }
+ else
+ il.append(InstructionConstants.IRETURN); // Reuse object to save memory
+
+ method.removeNOPs(); // First optimization pass, provided by MethodGen
+ optimizeIFs(il); // Second optimization pass, application-specific
+ method.setMaxStack(max_size);
+ class_gen.addMethod(method.getMethod());
+ }
+
+ il.dispose(); // Dispose instruction handles for better memory utilization
+
+ reset();
+ }
+
+ private static final InstructionFinder.CodeConstraint my_constraint =
+ new InstructionFinder.CodeConstraint() {
+ public boolean checkCode(InstructionHandle[] match) {
+ BranchInstruction if_icmp = (BranchInstruction)match[0].getInstruction();
+ GOTO goto_ = (GOTO)match[2].getInstruction();
+ return (if_icmp.getTarget() == match[3]) && (goto_.getTarget() == match[4]);
+ }
+ };
+
+ /**
+ * Replaces instruction sequences (typically generated by ASTIfExpr) of the form
+ *
+ * IF_ICMP__, ICONST_1, GOTO, ICONST_0, IFEQ, Instruction
+ *
+ * where the IF_ICMP__ branches to the ICONST_0 (else part) and the GOTO branches
+ * to the IFEQ with the simpler expression
+ *
+ * IF_ICMP__, Instruction
+ *
+ * where the IF_ICMP__ now branches to the target of the previous IFEQ instruction.
+ */
+ private static final void optimizeIFs(InstructionList il) {
+ InstructionFinder f = new InstructionFinder(il);
+ String pat = "IF_ICMP ICONST_1 GOTO ICONST_0 IFEQ Instruction";
+
+ for(Iterator it = f.search(pat, my_constraint); it.hasNext();) {
+ InstructionHandle[] match = (InstructionHandle[])it.next();
+ int len = match.length;
+
+ // Everything ok, update code
+ BranchInstruction ifeq = (BranchInstruction)(match[4].getInstruction());
+ BranchHandle if_icmp = (BranchHandle)match[0];
+
+ if_icmp.setTarget(ifeq.getTarget());
+
+ try {
+ il.delete(match[1], match[4]);
+ } catch(TargetLostException e) {
+ InstructionHandle[] targets = e.getTargets();
+
+ System.err.println(targets[0]);
+
+ for(int i=0; i < targets.length; i++) {
+ InstructionTargeter[] targeters = targets[i].getTargeters();
+
+ for(int j=0; j < targeters.length; j++)
+ if((targets[i] != match[4]) || (targeters[j] != match[2]))
+ System.err.println("Ooops: " + e);
+ }
+ }
+ }
+ }
+
+ /**
+ * Overrides SimpleNode.toString()
+ */
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+ buf.append(jjtNodeName[id] + " " + name + "(");
+
+ for(int i = 0; i < argv.length; i++) {
+ buf.append(argv[i].getName());
+ if(i < argv.length - 1)
+ buf.append(", ");
+ }
+
+ buf.append(")");
+ return buf.toString();
+ }
+
+ public boolean isrecursive() { return is_recursive; }
+ public boolean isSimple() { return is_simple; }
+ public ASTIdent getName() { return name; }
+ public int getNoArgs() { return argv.length; }
+ public ASTIdent[] getArgs() { return argv; }
+ public int getType() { return type; }
+ public void setType(int type) { this.type = type; }
+ public void setLine(int line) { this.line = line; }
+ public int getLine() { return line; }
+ public void setColumn(int column) { this.column = column; }
+ public int getColumn() { return column; }
+ public void setPosition(int line, int column) {
+ this.line = line;
+ this.column = column;
+ }
+
+ /**
+ * Overrides SimpleNode.dump()
+ */
+ public void dump(String prefix) {
+ System.out.println(toString(prefix));
+
+ for(int i = 0; i < argv.length; i++)
+ argv[i].dump(prefix + " ");
+
+ body.dump(prefix + " ");
+ }
+
+ /* Used to simpulate stack with local vars and compute maximum stack size.
+ */
+ static int size, max_size;
+
+ static final void reset() { size = max_size = 0; }
+
+ private static final String getVarDecls() {
+ StringBuffer buf = new StringBuffer(" int ");
+
+ for(int i=0; i < max_size; i++) {
+ buf.append("_s" + i);
+
+ if(i < max_size - 1)
+ buf.append(", ");
+ }
+
+ buf.append(";\n");
+ return buf.toString();
+ }
+
+ /** Used by byte_code()
+ */
+ static final void pop(int s) { size -= s; }
+ static final void push(int s) {
+ size += s;
+
+ if(size > max_size)
+ max_size = size;
+ }
+ static final void push() { push(1); }
+
+ /** Used byte code()
+ */
+ static final void push(StringBuffer buf, String str) {
+ buf.append(" _s" + size + " = " + str + ";\n");
+ push(1);
+ }
+
+ static final String pop() {
+ return "_s" + (--size);
+ }
+}
diff --git a/examples/Mini/ASTIdent.java b/examples/Mini/ASTIdent.java
new file mode 100644
index 00000000..3d223e9a
--- /dev/null
+++ b/examples/Mini/ASTIdent.java
@@ -0,0 +1,118 @@
+/* Generated By:JJTree: Do not edit this line. ASTIdent.java */
+/* JJT: 0.3pre1 */
+
+package Mini;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.generic.*;
+
+/**
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A>
+ */
+public class ASTIdent extends ASTExpr implements org.apache.bcel.Constants {
+ private String name;
+ private Variable reference; // Reference in environment to decl of this ident
+
+ // Generated methods
+ ASTIdent(int id) {
+ super(id);
+ }
+
+ ASTIdent(MiniParser p, int id) {
+ super(p, id);
+ }
+
+ public static Node jjtCreate(MiniParser p, int id) {
+ return new ASTIdent(p, id);
+ }
+
+ public ASTIdent(String name, int type, int line, int column) {
+ super(line, column, JJTIDENT);
+
+ this.name = name;
+ this.type = type;
+ }
+
+ // closeNode, dump inherited
+
+ /**
+ * @return identifier and line/column number of appearance
+ */
+ public String toString() {
+ return super.toString() + " = " + name;
+ }
+
+ /**
+ * Overrides ASTExpr.traverse()
+ */
+ public ASTExpr traverse(Environment env) {
+ EnvEntry entry = env.get(name);
+
+ if(entry == null)
+ MiniC.addError(line, column, "Undeclared identifier " + name);
+ else if(entry instanceof Function)
+ MiniC.addError(line, column,
+ "Function " + name + " used as an identifier.");
+ else
+ reference = (Variable)entry;
+
+ return this; // Nothing to reduce/traverse further here
+ }
+
+ /**
+ * Overrides AstExpr.eval()
+ */
+ public int eval(int expected) {
+ ASTIdent ident = reference.getName();
+ int t = ident.getType();
+
+ is_simple = true; // (Very) simple expression, always true
+
+ if((t == T_UNKNOWN) && (expected == T_UNKNOWN))
+ type = T_UNKNOWN;
+ else if((t == T_UNKNOWN) && (expected != T_UNKNOWN)) {
+ ident.setType(expected);
+ type = expected;
+ }
+ else if((t != T_UNKNOWN) && (expected == T_UNKNOWN)) {
+ ident.setType(t);
+ type = t;
+ }
+ else // (t != T_UNKNOWN) && (expected != T_UNKNOWN)
+ type = t; // Caller has to check for an error, i.e. t != expected
+
+ return type;
+ }
+
+ /**
+ * Fourth pass, produce Java code.
+ */
+ public void code(StringBuffer buf) {
+ if(name.equals("TRUE"))
+ ASTFunDecl.push(buf, "1");
+ else if(name.equals("FALSE"))
+ ASTFunDecl.push(buf, "0");
+ else
+ ASTFunDecl.push(buf, name);
+ }
+
+ /**
+ * Fifth pass, produce Java byte code.
+ */
+ public void byte_code(InstructionList il, MethodGen method, ConstantPoolGen cp) {
+ if(name.equals("TRUE"))
+ il.append(new PUSH(cp, 1));
+ else if(name.equals("FALSE"))
+ il.append(new PUSH(cp, 0));
+ else {
+ LocalVariableGen local_var = reference.getLocalVariable();
+ il.append(new ILOAD(local_var.getIndex()));
+ }
+ ASTFunDecl.push();
+ }
+
+
+ public void setName(String name) { this.name = name; }
+ public String getName() { return name; }
+}
diff --git a/examples/Mini/ASTIfExpr.java b/examples/Mini/ASTIfExpr.java
new file mode 100644
index 00000000..d554dcf0
--- /dev/null
+++ b/examples/Mini/ASTIfExpr.java
@@ -0,0 +1,156 @@
+/* Generated By:JJTree: Do not edit this line. ASTIfExpr.java */
+/* JJT: 0.3pre1 */
+
+package Mini;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.generic.*;
+
+/**
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A>
+ */
+public class ASTIfExpr extends ASTExpr implements org.apache.bcel.Constants {
+ private ASTExpr if_expr, then_expr, else_expr;
+
+ // Generated methods
+ ASTIfExpr(int id) {
+ super(id);
+ }
+
+ ASTIfExpr(MiniParser p, int id) {
+ super(p, id);
+ }
+
+ public static Node jjtCreate(MiniParser p, int id) {
+ return new ASTIfExpr(p, id);
+ }
+
+ /**
+ * Overrides ASTExpr.closeNode()
+ * Cast children nodes Node[] to appropiate type ASTExpr[]
+ */
+ public void closeNode() {
+ if_expr = (ASTExpr)children[0];
+ then_expr = (ASTExpr)children[1];
+
+ if(children.length == 3) // has else branch
+ else_expr = (ASTExpr)children[2];
+ else
+ MiniC.addError(if_expr.getLine(), if_expr.getColumn(),
+ "IF expression has no ELSE branch");
+
+ children=null; // Throw away
+ }
+
+ /**
+ * Overrides ASTExpr.traverse()
+ */
+ public ASTExpr traverse(Environment env) {
+ this.env = env;
+
+ if_expr = if_expr.traverse(env);
+ then_expr = then_expr.traverse(env);
+
+ if(else_expr != null)
+ else_expr = else_expr.traverse(env);
+
+ return this;
+ }
+
+ /**
+ * Second pass
+ * Overrides AstExpr.eval()
+ * @return type of expression
+ * @param expected type
+ */
+ public int eval(int expected) {
+ int then_type, else_type, if_type;
+
+ if((if_type=if_expr.eval(T_BOOLEAN)) != T_BOOLEAN)
+ MiniC.addError(if_expr.getLine(), if_expr.getColumn(),
+ "IF expression is not of type boolean, but " +
+ TYPE_NAMES[if_type] + ".");
+
+ then_type=then_expr.eval(expected);
+
+ if((expected != T_UNKNOWN) && (then_type != expected))
+ MiniC.addError(then_expr.getLine(), then_expr.getColumn(),
+ "THEN expression is not of expected type " +
+ TYPE_NAMES[expected] + " but " + TYPE_NAMES[then_type] + ".");
+
+ if(else_expr != null) {
+ else_type = else_expr.eval(expected);
+
+ if((expected != T_UNKNOWN) && (else_type != expected))
+ MiniC.addError(else_expr.getLine(), else_expr.getColumn(),
+ "ELSE expression is not of expected type " +
+ TYPE_NAMES[expected] + " but " + TYPE_NAMES[else_type] + ".");
+ else if(then_type == T_UNKNOWN) {
+ then_type = else_type;
+ then_expr.setType(else_type);
+ }
+ }
+ else {
+ else_type = then_type;
+ else_expr = then_expr;
+ }
+
+ if(then_type != else_type)
+ MiniC.addError(line, column,
+ "Type mismatch in THEN-ELSE: " +
+ TYPE_NAMES[then_type] + " vs. " + TYPE_NAMES[else_type] + ".");
+
+ type = then_type;
+
+ is_simple = if_expr.isSimple() && then_expr.isSimple() && else_expr.isSimple();
+
+ return type;
+ }
+
+ /**
+ * Fourth pass, produce Java code.
+ */
+ public void code(StringBuffer buf) {
+ if_expr.code(buf);
+
+ buf.append(" if(" + ASTFunDecl.pop() + " == 1) {\n");
+ int size = ASTFunDecl.size;
+ then_expr.code(buf);
+ ASTFunDecl.size = size; // reset stack
+ buf.append(" } else {\n");
+ else_expr.code(buf);
+ buf.append(" }\n");
+ }
+
+ /**
+ * Fifth pass, produce Java byte code.
+ */
+ public void byte_code(InstructionList il, MethodGen method, ConstantPoolGen cp) {
+ if_expr.byte_code(il, method, cp);
+
+ InstructionList then_code = new InstructionList();
+ InstructionList else_code = new InstructionList();
+
+ then_expr.byte_code(then_code, method, cp);
+ else_expr.byte_code(else_code, method, cp);
+
+ BranchHandle i, g;
+
+ i = il.append(new IFEQ(null)); // If POP() == FALSE(i.e. 0) then branch to ELSE
+ ASTFunDecl.pop();
+ il.append(then_code);
+ g = il.append(new GOTO(null));
+ i.setTarget(il.append(else_code));
+ g.setTarget(il.append(InstructionConstants.NOP)); // May be optimized away later
+ }
+
+ public void dump(String prefix) {
+ System.out.println(toString(prefix));
+
+ if_expr.dump(prefix + " ");
+ then_expr.dump(prefix + " ");
+ if(else_expr != null)
+ else_expr.dump(prefix + " ");
+ }
+}
diff --git a/examples/Mini/ASTInteger.java b/examples/Mini/ASTInteger.java
new file mode 100644
index 00000000..ee025ada
--- /dev/null
+++ b/examples/Mini/ASTInteger.java
@@ -0,0 +1,73 @@
+/* Generated By:JJTree: Do not edit this line. ASTInteger.java */
+/* JJT: 0.3pre1 */
+
+package Mini;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.generic.*;
+
+/**
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A>
+ */
+public class ASTInteger extends ASTExpr {
+ private int value;
+
+ // Generated methods
+ ASTInteger(int id) {
+ super(id);
+ }
+
+ ASTInteger(MiniParser p, int id) {
+ super(p, id);
+ }
+
+ public static Node jjtCreate(MiniParser p, int id) {
+ return new ASTInteger(p, id);
+ }
+
+ // closeNode, dump inherited from Expr
+
+ /**
+ * @return identifier and line/column number of appearance
+ */
+ public String toString() {
+ return super.toString() + " = " + value;
+ }
+
+ /**
+ * Overrides ASTExpr.traverse()
+ */
+ public ASTExpr traverse(Environment env) {
+ this.env = env;
+ return this; // Nothing to reduce/traverse here
+ }
+
+ /**
+ * Second pass
+ * Overrides AstExpr.eval()
+ * @return type of expression
+ */
+ public int eval(int expected) {
+ is_simple = true; // (Very) simple expression, always true
+
+ return type = T_INT;
+ }
+
+ /**
+ * Fourth pass, produce Java code.
+ */
+ public void code(StringBuffer buf) {
+ ASTFunDecl.push(buf, "" + value);
+ }
+
+ /**
+ * Fifth pass, produce Java byte code.
+ */
+ public void byte_code(InstructionList il, MethodGen method, ConstantPoolGen cp) {
+ il.append(new PUSH(cp, value)); ASTFunDecl.push();
+ }
+
+ void setValue(int value) { this.value = value; }
+ int getValue() { return value; }
+}
diff --git a/examples/Mini/ASTLetExpr.java b/examples/Mini/ASTLetExpr.java
new file mode 100644
index 00000000..f1d90c27
--- /dev/null
+++ b/examples/Mini/ASTLetExpr.java
@@ -0,0 +1,159 @@
+/* Generated By:JJTree: Do not edit this line. ASTLetExpr.java */
+/* JJT: 0.3pre1 */
+
+package Mini;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.generic.*;
+
+/**
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A>
+ */
+public class ASTLetExpr extends ASTExpr implements org.apache.bcel.Constants {
+ private ASTIdent[] idents;
+ private ASTExpr[] exprs;
+ private ASTExpr body;
+
+ // Generated methods
+ ASTLetExpr(int id) {
+ super(id);
+ }
+
+ ASTLetExpr(MiniParser p, int id) {
+ super(p, id);
+ }
+
+ public static Node jjtCreate(MiniParser p, int id) {
+ return new ASTLetExpr(p, id);
+ }
+
+
+ /**
+ * Overrides ASTExpr.closeNode()
+ * Cast children nodes to appropiate types.
+ */
+ public void closeNode() {
+ int i, len_2 = children.length / 2; /* length must be a multiple of
+ * two (ident = expr) + 1 (body expr) */
+ idents = new ASTIdent[len_2];
+ exprs = new ASTExpr[len_2];
+
+ // At least one assignment is enforced by the grammar
+ for(i=0; i < len_2; i++) {
+ idents[i] = (ASTIdent)children[i * 2];
+ exprs[i] = (ASTExpr)children[i * 2 + 1];
+ }
+
+ body = (ASTExpr)children[children.length - 1]; // Last expr is the body
+ children=null; // Throw away old reference
+ }
+
+ /**
+ * Overrides ASTExpr.traverse()
+ */
+ public ASTExpr traverse(Environment env) {
+ this.env = env;
+
+ // Traverse RHS exprs first, so no references to LHS vars are allowed
+ for(int i=0; i < exprs.length; i++)
+ exprs[i] = exprs[i].traverse((Environment)env.clone());
+
+ // Put argument names into hash table aka. environment
+ for(int i=0; i < idents.length; i++) {
+ ASTIdent id = idents[i];
+ String name = id.getName();
+ EnvEntry entry = env.get(name);
+
+ if(entry != null)
+ MiniC.addError(id.getLine(), id.getColumn(),
+ "Redeclaration of " + entry + ".");
+ else
+ env.put(new Variable(id));
+ }
+
+ body = body.traverse(env);
+
+ return this;
+ }
+
+ /**
+ * Second pass
+ * Overrides AstExpr.eval()
+ * @return type of expression
+ * @param expected type
+ */
+ public int eval(int expected) {
+ //is_simple = true;
+
+ for(int i=0; i < idents.length; i++) {
+ int t = exprs[i].eval(T_UNKNOWN);
+
+ idents[i].setType(t);
+ // is_simple = is_simple && exprs[i].isSimple();
+ }
+
+ return type = body.eval(expected);
+ }
+
+ /**
+ * Fifth pass, produce Java code.
+ */
+ public void code(StringBuffer buf) {
+ for(int i = 0; i < idents.length; i++) {
+ String ident = idents[i].getName();
+ int t = idents[i].getType(); // can only be int
+
+ /* Idents have to be declared at start of function for later use.
+ * Each name is unique, so there shouldn't be a problem in application.
+ */
+ exprs[i].code(buf);
+
+ buf.append(" " + TYPE_NAMES[t] + " " + ident + " = " +
+ ASTFunDecl.pop() + ";\n");
+ }
+
+ body.code(buf);
+ }
+
+ /**
+ * Fifth pass, produce Java byte code.
+ */
+ public void byte_code(InstructionList il, MethodGen method, ConstantPoolGen cp) {
+ int size = idents.length;
+ LocalVariableGen[] l = new LocalVariableGen[size];
+
+ for(int i=0; i < size; i++) {
+ String ident = idents[i].getName();
+ Variable entry = (Variable)env.get(ident);
+ Type t = BasicType.getType((byte)idents[i].getType());
+ LocalVariableGen lg = method.addLocalVariable(ident, t, null, null);
+ int slot = lg.getIndex();
+
+ entry.setLocalVariable(lg);
+ InstructionHandle start = il.getEnd();
+ exprs[i].byte_code(il, method, cp);
+ start = (start == null)? il.getStart() : start.getNext();
+ lg.setStart(start);
+ il.append(new ISTORE(slot)); ASTFunDecl.pop();
+ l[i] = lg;
+ }
+
+ body.byte_code(il, method, cp);
+ InstructionHandle end = il.getEnd();
+ for(int i=0; i < size; i++)
+ l[i].setEnd(end);
+ }
+
+ public void dump(String prefix) {
+ System.out.println(toString(prefix));
+
+ for(int i=0; i < idents.length; i++) {
+ idents[i].dump(prefix + " ");
+ exprs[i].dump(prefix + " ");
+ }
+
+ body.dump(prefix + " ");
+ }
+
+}
diff --git a/examples/Mini/ASTProgram.java b/examples/Mini/ASTProgram.java
new file mode 100644
index 00000000..7a2c3e7a
--- /dev/null
+++ b/examples/Mini/ASTProgram.java
@@ -0,0 +1,301 @@
+/* Generated By:JJTree: Do not edit this line. ASTProgram.java */
+/* JJT: 0.3pre1 */
+
+package Mini;
+import java.io.PrintWriter;
+import java.util.Vector;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.generic.*;
+
+/**
+ * Root node of everything, direct children are nodes of type FunDecl
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A>
+ */
+public class ASTProgram extends SimpleNode
+implements MiniParserConstants, MiniParserTreeConstants, org.apache.bcel.Constants {
+ private ASTFunDecl[] fun_decls; // Children: Function declarations
+ private Environment env; // Environment contains variables and functions
+
+ ASTProgram(int id) {
+ super(id);
+
+ env = new Environment();
+
+ /* Add predefined functions WRITE/READ.
+ * WRITE has one arg of type T_INT, both return T_INT.
+ */
+ ASTIdent ident = new ASTIdent("WRITE", T_INT, -1, -1);
+ ASTIdent[] args = { new ASTIdent("", T_INT, -1, -1) };
+ Function fun = new Function(ident, args, true);
+ env.put(fun);
+
+ ident = new ASTIdent("READ", T_INT, -1, -1);
+ args = new ASTIdent[0];
+ fun = new Function(ident, args, true);
+ env.put(fun);
+
+ /* Add predefined idents TRUE/FALSE of type T_BOOLEAN
+ */
+ ident = new ASTIdent("TRUE", T_BOOLEAN, -1, -1);
+ Variable var = new Variable(ident, true);
+ env.put(var);
+
+ ident = new ASTIdent("FALSE", T_BOOLEAN, -1, -1);
+ var = new Variable(ident, true);
+ env.put(var);
+ }
+
+ ASTProgram(MiniParser p, int id) {
+ super(p, id);
+ }
+
+ public static Node jjtCreate(MiniParser p, int id) {
+ return new ASTProgram(p, id);
+ }
+
+ /**
+ * Overrides SimpleNode.closeNode().
+ * Cast children to appropiate type.
+ */
+ public void closeNode() {
+ if(children != null) { // Non-empty program ?
+ fun_decls = new ASTFunDecl[children.length];
+ System.arraycopy(children, 0, fun_decls, 0, children.length);
+ children=null; // Throw away old reference
+ }
+ }
+
+ /**
+ * First pass of parse tree.
+ *
+ * Put everything into the environment, which is copied appropiately to each
+ * recursion level, i.e. each FunDecl gets its own copy that it can further
+ * manipulate.
+ *
+ * Checks for name clashes of function declarations.
+ */
+ public ASTProgram traverse() {
+ ASTFunDecl f;
+ ASTIdent name;
+ String fname;
+ EnvEntry fun;
+ Function main=null;
+
+ if(fun_decls != null) {
+ // Put function names into hash table aka. environment
+ for(int i=0; i < fun_decls.length; i++) {
+ f = fun_decls[i];
+ name = f.getName();
+ fname = name.getName();
+ fun = env.get(fname); // Lookup in env
+
+ if(fun != null)
+ MiniC.addError(f.getLine(), f.getColumn(),
+ "Redeclaration of " + fun + ".");
+ else
+ env.put(new Function(name, null)); // `args' will be set by FunDecl.traverse()
+
+
+ }
+
+ // Go for it
+ for(int i=0; i < fun_decls.length; i++) {
+ fun_decls[i] = fun_decls[i].traverse((Environment)env.clone());
+
+ // Look for `main' routine
+ fname = fun_decls[i].getName().getName();
+ if(fname.equals("main"))
+ main = (Function)env.get(fname);
+ }
+
+ if(main == null)
+ MiniC.addError(0, 0, "You didn't declare a `main' function.");
+ else if(main.getNoArgs() != 0)
+ MiniC.addError(main.getLine(), main.getColumn(),
+ "Main function has too many arguments declared.");
+ }
+
+ return this;
+ }
+
+ /**
+ * Second pass, determine type of each node, if possible.
+ * @return type of expression
+ */
+ public void eval(int pass) {
+
+ for(int i=0; i < fun_decls.length; i++) {
+ fun_decls[i].eval(pass);
+
+ if(pass == 3) { // Final check for unresolved types
+ ASTIdent name = fun_decls[i].getName();
+
+ if(name.getType() == T_UNKNOWN)
+ MiniC.addError(name.getColumn(), name.getLine(),
+ "Type of function " + name.getName() +
+ " can not be determined (infinite recursion?).");
+ }
+ }
+ }
+
+ /**
+ * Fifth pass, produce Java code.
+ */
+ public void code(PrintWriter out, String name) {
+ out.println("import java.io.BufferedReader;");
+ out.println("import java.io.InputStreamReader;");
+ out.println("import java.io.IOException;\n");
+
+ out.println("public final class " + name + " {");
+ out.println(" private static BufferedReader _in = new BufferedReader" +
+ "(new InputStreamReader(System.in));\n");
+
+ out.println(" private static final int _readInt() throws IOException {\n" +
+ " System.out.print(\"Please enter a number> \");\n" +
+ " return Integer.parseInt(_in.readLine());\n }\n");
+
+ out.println(" private static final int _writeInt(int n) {\n" +
+ " System.out.println(\"Result: \" + n);\n return 0;\n }\n");
+
+ for(int i=0; i < fun_decls.length; i++)
+ fun_decls[i].code(out);
+
+ out.println("}");
+ }
+
+ /**
+ * Fifth pass, produce Java byte code.
+ */
+ public void byte_code(ClassGen class_gen, ConstantPoolGen cp) {
+ /* private static BufferedReader _in;
+ */
+ class_gen.addField(new Field(ACC_PRIVATE | ACC_STATIC,
+ cp.addUtf8("_in"),
+ cp.addUtf8("Ljava/io/BufferedReader;"),
+ null, cp.getConstantPool()));
+
+ MethodGen method;
+ Method m;
+ InstructionList il = new InstructionList();
+ byte[] byte_code;
+ String class_name = class_gen.getClassName();
+
+ /* Often used constant pool entries
+ */
+ int _in = cp.addFieldref(class_name, "_in", "Ljava/io/BufferedReader;");
+
+ int out = cp.addFieldref("java.lang.System", "out",
+ "Ljava/io/PrintStream;");
+
+ il.append(new GETSTATIC(out));
+ il.append(new PUSH(cp, "Please enter a number> "));
+ il.append(new INVOKEVIRTUAL(cp.addMethodref("java.io.PrintStream",
+ "print",
+ "(Ljava/lang/String;)V")));
+ il.append(new GETSTATIC(_in));
+ il.append(new INVOKEVIRTUAL(cp.addMethodref("java.io.BufferedReader",
+ "readLine",
+ "()Ljava/lang/String;")));
+ il.append(new INVOKESTATIC(cp.addMethodref("java.lang.Integer",
+ "parseInt",
+ "(Ljava/lang/String;)I")));
+ il.append(InstructionConstants.IRETURN);
+
+ /* private static final int _readInt() throws IOException
+ */
+ method = new MethodGen(ACC_STATIC | ACC_PRIVATE | ACC_FINAL,
+ Type.INT, Type.NO_ARGS, null,
+ "_readInt", class_name, il, cp);
+
+ method.addException("java.io.IOException");
+
+ method.setMaxStack(2);
+ class_gen.addMethod(method.getMethod());
+
+ /* private static final int _writeInt(int i) throws IOException
+ */
+ Type[] args = { Type.INT };
+ String[] argv = { "i" } ;
+ il = new InstructionList();
+ il.append(new GETSTATIC(out));
+ il.append(new NEW(cp.addClass("java.lang.StringBuffer")));
+ il.append(InstructionConstants.DUP);
+ il.append(new PUSH(cp, "Result: "));
+ il.append(new INVOKESPECIAL(cp.addMethodref("java.lang.StringBuffer",
+ "<init>",
+ "(Ljava/lang/String;)V")));
+
+ il.append(new ILOAD(0));
+ il.append(new INVOKEVIRTUAL(cp.addMethodref("java.lang.StringBuffer",
+ "append",
+ "(I)Ljava/lang/StringBuffer;")));
+
+ il.append(new INVOKEVIRTUAL(cp.addMethodref("java.lang.StringBuffer",
+ "toString",
+ "()Ljava/lang/String;")));
+
+ il.append(new INVOKEVIRTUAL(cp.addMethodref("java.io.PrintStream",
+ "println",
+ "(Ljava/lang/String;)V")));
+ il.append(new PUSH(cp, 0));
+ il.append(InstructionConstants.IRETURN); // Reuse objects, if possible
+
+ method = new MethodGen(ACC_STATIC | ACC_PRIVATE | ACC_FINAL,
+ Type.INT, args, argv,
+ "_writeInt", class_name, il, cp);
+
+ method.setMaxStack(4);
+ class_gen.addMethod(method.getMethod());
+
+ /* public <init> -- constructor
+ */
+ il.dispose(); // Dispose instruction handles for better memory utilization
+
+ il = new InstructionList();
+ il.append(new ALOAD(0)); // Push `this'
+ il.append(new INVOKESPECIAL(cp.addMethodref("java.lang.Object",
+ "<init>", "()V")));
+ il.append(new RETURN());
+
+ method = new MethodGen(ACC_PUBLIC, Type.VOID, Type.NO_ARGS, null,
+ "<init>", class_name, il, cp);
+
+ method.setMaxStack(1);
+ class_gen.addMethod(method.getMethod());
+
+ /* class initializer
+ */
+ il.dispose(); // Dispose instruction handles for better memory utilization
+ il = new InstructionList();
+ il.append(new NEW(cp.addClass("java.io.BufferedReader")));
+ il.append(InstructionConstants.DUP);
+ il.append(new NEW(cp.addClass("java.io.InputStreamReader")));
+ il.append(InstructionConstants.DUP);
+ il.append(new GETSTATIC(cp.addFieldref("java.lang.System", "in",
+ "Ljava/io/InputStream;")));
+ il.append(new INVOKESPECIAL(cp.addMethodref("java.io.InputStreamReader",
+ "<init>", "(Ljava/io/InputStream;)V")));
+ il.append(new INVOKESPECIAL(cp.addMethodref("java.io.BufferedReader",
+ "<init>", "(Ljava/io/Reader;)V")));
+ il.append(new PUTSTATIC(_in));
+ il.append(InstructionConstants.RETURN); // Reuse instruction constants
+
+ method = new MethodGen(ACC_STATIC, Type.VOID, Type.NO_ARGS, null,
+ "<clinit>", class_name, il, cp);
+
+ method.setMaxStack(5);
+ class_gen.addMethod(method.getMethod());
+
+ for(int i=0; i < fun_decls.length; i++)
+ fun_decls[i].byte_code(class_gen, cp);
+ }
+
+ public void dump(String prefix) {
+ System.out.println(toString(prefix));
+
+ for(int i = 0; i < fun_decls.length; ++i)
+ fun_decls[i].dump(prefix + " ");
+ }
+}
diff --git a/examples/Mini/ASTTerm.java b/examples/Mini/ASTTerm.java
new file mode 100644
index 00000000..eed7c9bf
--- /dev/null
+++ b/examples/Mini/ASTTerm.java
@@ -0,0 +1,37 @@
+/* Generated By:JJTree: Do not edit this line. ASTTerm.java */
+/* JJT: 0.3pre1 */
+
+package Mini;
+
+/**
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A>
+ */
+public class ASTTerm extends ASTExpr {
+ // Generated methods
+ ASTTerm(int id) {
+ super(id);
+ }
+
+ ASTTerm(MiniParser p, int id) {
+ super(p, id);
+ }
+
+ public static Node jjtCreate(MiniParser p, int id) {
+ return new ASTTerm(p, id);
+ }
+
+ // Inherited closeNode(), dump()
+
+ /**
+ * Drop this node, if kind == -1, because then it has just one child node
+ * and may be safely replaced with it.
+ */
+ public ASTExpr traverse(Environment env) {
+ if(kind == -1) // Drop it
+ return exprs[0].traverse(env);
+ else // Or convert it to Expr node, copy children
+ return new ASTExpr(exprs, kind, line, column).traverse(env);
+ }
+}
diff --git a/examples/Mini/EnvEntry.java b/examples/Mini/EnvEntry.java
new file mode 100644
index 00000000..bc82cea9
--- /dev/null
+++ b/examples/Mini/EnvEntry.java
@@ -0,0 +1,13 @@
+package Mini;
+
+/**
+ * Entry in environment.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A>
+ */
+public interface EnvEntry {
+ public String getHashKey();
+ public int getLine();
+ public int getColumn();
+}
diff --git a/examples/Mini/Environment.java b/examples/Mini/Environment.java
new file mode 100644
index 00000000..9c30e025
--- /dev/null
+++ b/examples/Mini/Environment.java
@@ -0,0 +1,184 @@
+package Mini;
+
+import java.util.Vector;
+
+/**
+ * For efficiency and convenience reasons we want our own hash table. It does
+ * not conform to java.util.Dictionary(yet).
+ *
+ * That environment contains all function definitions and identifiers.
+ * Hash keys are Strings (identifiers), which are mapped to a table index.
+ *
+ * The table consists of `SIZE' fields which have `SLOTS' subfields. Thus
+ * the maximum number of storable items is `SLOTS' * `SIZE'.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A>
+ */
+public class Environment implements Cloneable {
+ private static final int SIZE = 127; // Prime number large enough for most cases
+ private static final int SLOTS = 3; // Number of slots of each field
+
+ private int size; // The table is an array of
+ private Vector[] table; // Vectors
+ private int elements=0;
+
+ public Environment(int size) {
+ this.size = size;
+ table = new Vector[size];
+ }
+
+ private Environment(Vector[] table) {
+ size = table.length;
+ this.table = table;
+ }
+
+ public Environment() {
+ this(SIZE);
+ }
+
+ private final int hashCode(String key) {
+ return Math.abs(key.hashCode()) % size;
+ }
+
+ /**
+ * Inserts macro into table or overwrite old contents if it
+ * was already stored.
+ */
+ public void put(EnvEntry obj) {
+ int hash;
+ Vector v;
+ String key = obj.getHashKey();
+
+ hash = hashCode(key);
+ v = table[hash];
+
+ elements++; // Count
+
+ if(v == null) // Not yet initialized
+ table[hash] = v = new Vector(SLOTS);
+ else {
+ try {
+ int index = lookup(v, key);
+
+ if(index >= 0) {
+ v.setElementAt(obj, index); // Overwrite
+ return;
+ }
+ } catch(ArrayIndexOutOfBoundsException e) {}
+ }
+
+ // Not found in Vector -> add it
+ v.addElement(obj);
+ }
+
+ /** Get entry from hash table.
+ */
+ public EnvEntry get(String key) {
+ int hash;
+ Vector v;
+ EnvEntry entry = null;
+
+ hash = hashCode(key);
+ v = table[hash];
+
+ if(v == null)
+ return null;
+
+ try {
+ int index = lookup(v, key);
+
+ if(index >= 0)
+ entry = (EnvEntry)v.elementAt(index);
+ } catch(ArrayIndexOutOfBoundsException e) {}
+
+ return entry;
+ }
+
+ /**
+ * Delete an object if it does exist.
+ */
+ public void delete(String key) {
+ int hash;
+ Vector v;
+
+ hash = hashCode(key);
+ v = table[hash];
+
+ if(v == null)
+ return;
+
+ try {
+ int index = lookup(v, key);
+
+ if(index >= 0) {
+ elements--; // Count
+ v.removeElementAt(index);
+ }
+ } catch(ArrayIndexOutOfBoundsException e) {}
+ }
+
+ private static final int lookup(Vector v, String key)
+ throws ArrayIndexOutOfBoundsException
+ {
+ int len = v.size();
+
+ for(int i=0; i < len; i++) {
+ EnvEntry entry = (EnvEntry)v.elementAt(i);
+
+ if(entry.getHashKey().equals(key)) // Found index
+ return i;
+ }
+
+ return -1;
+ }
+
+ public Object clone() {
+ Vector[] copy = new Vector[size];
+
+ for(int i=0; i < size; i++) {
+ if(table[i] != null) {
+ copy[i] = (Vector)table[i].clone(); // Copies references
+
+ /*
+ int len = table[i].size();
+
+ copy[i] = new Vector(len);
+ try {
+ for(int j=0; j < len; j++)
+ copy[i].addElement(table[i].elementAt(j));
+ } catch(ArrayIndexOutOfBoundsException e) {}*/
+ }
+ }
+
+ return new Environment(copy);
+ }
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+
+ for(int i=0; i < size; i++)
+ if(table[i] != null)
+ buf.append(table[i] + "\n");
+
+ return buf.toString();
+ }
+
+ public EnvEntry[] getEntries() {
+ EnvEntry[] entries = new EnvEntry[elements];
+ int k = 0;
+ Vector v;
+
+ for(int i=0; i < size; i++) {
+ if((v = table[i]) != null) {
+ int len = v.size();
+ try {
+ for(int j=0; j < len; j++)
+ entries[k++] = (EnvEntry)v.elementAt(j);
+ } catch(ArrayIndexOutOfBoundsException e) {}
+ }
+ }
+
+ return entries;
+ }
+}
diff --git a/examples/Mini/Function.java b/examples/Mini/Function.java
new file mode 100644
index 00000000..1ccc0d3e
--- /dev/null
+++ b/examples/Mini/Function.java
@@ -0,0 +1,63 @@
+package Mini;
+
+/**
+ * Represents a function declaration and its arguments. Type information is contained
+ * in the ASTIdent fields.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A>
+ */
+public class Function implements org.apache.bcel.Constants, EnvEntry {
+ private ASTIdent name; // Reference to the original declaration
+ private ASTIdent[] args; // Reference to argument identifiers
+ private ASTExpr body; // Reference to function expression body
+ private boolean reserved; // Is a key word?
+ private int line, column; // Short for name.getToken()
+ private String fun_name; // Short for name.getName()
+ private int no_args;
+
+ public Function(ASTIdent name, ASTIdent[] args) {
+ this(name, args, false);
+ }
+
+ public Function(ASTIdent name, ASTIdent[] args, boolean reserved) {
+ this.name = name;
+ this.args = args;
+ this.reserved = reserved;
+
+ fun_name = name.getName();
+ line = name.getLine();
+ column = name.getColumn();
+ setArgs(args);
+ }
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+
+ for(int i=0; i < no_args; i++) {
+ buf.append(args[i].getName());
+
+ if(i < no_args - 1)
+ buf.append(", ");
+ }
+
+ String prefix = "Function " + fun_name + "(" + buf.toString() + ")";
+
+ if(!reserved)
+ return prefix + " declared at line " + line + ", column " + column;
+ else
+ return prefix + " <predefined function>";
+ }
+
+ public int getNoArgs() { return no_args; }
+ public ASTIdent getName() { return name; }
+ public String getHashKey() { return fun_name; }
+ public int getLine() { return line; }
+ public int getColumn() { return column; }
+ public ASTIdent getArg(int i) { return args[i]; }
+ public ASTIdent[] getArgs() { return args; }
+ public void setArgs(ASTIdent[] args) {
+ this.args = args;
+ no_args = (args == null)? 0 : args.length;
+ }
+}
diff --git a/examples/Mini/JJTMiniParserState.java b/examples/Mini/JJTMiniParserState.java
new file mode 100644
index 00000000..dec0e0b1
--- /dev/null
+++ b/examples/Mini/JJTMiniParserState.java
@@ -0,0 +1,123 @@
+/* Generated By:JJTree: Do not edit this line. JJTMiniParserState.java */
+
+package Mini;
+
+class JJTMiniParserState {
+ private java.util.Stack nodes;
+ private java.util.Stack marks;
+
+ private int sp; // number of nodes on stack
+ private int mk; // current mark
+ private boolean node_created;
+
+ JJTMiniParserState() {
+ nodes = new java.util.Stack();
+ marks = new java.util.Stack();
+ sp = 0;
+ mk = 0;
+ }
+
+ /* Determines whether the current node was actually closed and
+ pushed. This should only be called in the final user action of a
+ node scope. */
+ boolean nodeCreated() {
+ return node_created;
+ }
+
+ /* Call this to reinitialize the node stack. It is called
+ automatically by the parser's ReInit() method. */
+ void reset() {
+ nodes.removeAllElements();
+ marks.removeAllElements();
+ sp = 0;
+ mk = 0;
+ }
+
+ /* Returns the root node of the AST. It only makes sense to call
+ this after a successful parse. */
+ Node rootNode() {
+ return (Node)nodes.elementAt(0);
+ }
+
+ /* Pushes a node on to the stack. */
+ void pushNode(Node n) {
+ nodes.push(n);
+ ++sp;
+ }
+
+ /* Returns the node on the top of the stack, and remove it from the
+ stack. */
+ Node popNode() {
+ if (--sp < mk) {
+ mk = ((Integer)marks.pop()).intValue();
+ }
+ return (Node)nodes.pop();
+ }
+
+ /* Returns the node currently on the top of the stack. */
+ Node peekNode() {
+ return (Node)nodes.peek();
+ }
+
+ /* Returns the number of children on the stack in the current node
+ scope. */
+ int nodeArity() {
+ return sp - mk;
+ }
+
+
+ void clearNodeScope(Node n) {
+ while (sp > mk) {
+ popNode();
+ }
+ mk = ((Integer)marks.pop()).intValue();
+ }
+
+
+ void openNodeScope(Node n) {
+ marks.push(new Integer(mk));
+ mk = sp;
+ n.jjtOpen();
+ }
+
+
+ /* A definite node is constructed from a specified number of
+ children. That number of nodes are popped from the stack and
+ made the children of the definite node. Then the definite node
+ is pushed on to the stack. */
+ void closeNodeScope(Node n, int num) {
+ mk = ((Integer)marks.pop()).intValue();
+ while (num-- > 0) {
+ Node c = popNode();
+ c.jjtSetParent(n);
+ n.jjtAddChild(c, num);
+ }
+ n.jjtClose();
+ pushNode(n);
+ node_created = true;
+ }
+
+
+ /* A conditional node is constructed if its condition is true. All
+ the nodes that have been pushed since the node was opened are
+ made children of the the conditional node, which is then pushed
+ on to the stack. If the condition is false the node is not
+ constructed and they are left on the stack. */
+ void closeNodeScope(Node n, boolean condition) {
+ if (condition) {
+ int a = nodeArity();
+ mk = ((Integer)marks.pop()).intValue();
+ while (a-- > 0) {
+ Node c = popNode();
+ c.jjtSetParent(n);
+ n.jjtAddChild(c, a);
+ }
+ n.jjtClose();
+ pushNode(n);
+ node_created = true;
+ } else {
+ mk = ((Integer)marks.pop()).intValue();
+ node_created = false;
+ }
+ }
+}
diff --git a/examples/Mini/Mini.bnf b/examples/Mini/Mini.bnf
new file mode 100644
index 00000000..5b460172
--- /dev/null
+++ b/examples/Mini/Mini.bnf
@@ -0,0 +1,75 @@
+Program:
+ (FunDecl)*
+
+FunDecl:
+ "FUN" Ident "=" Expr
+
+Expr:
+ "(" Expr ")"
+|
+ Expr AddOp Expr
+|
+ Expr MultOp Expr
+|
+ Expr CmpOp Expr
+|
+ Ident
+|
+ Number
+|
+ FunAppl
+|
+ UnOp Expr
+|
+ IfExpr
+
+IfExpr:
+ "IF" Expr "THEN" Expr ["ELSE" Expr] "FI"
+
+FunAppl:
+ Ident "(" [Expr ("," Expr)*] ")"
+
+AddOp:
+ ("+" | "-" | "OR")
+
+MultOp:
+ ("*" | "/" | "%" | "AND")
+
+CmpOp:
+ ("==" | "!=" | "<=" | ">=" | ">" | "<"")
+
+UnOp:
+ ("-" | "!")
+
+Ident:
+ LETTER (LETTER|DIGIT)*
+
+Number:
+ DIGIT+
+
+LETTER:
+ [a-zA-Z]
+
+DIGIT:
+ [0-9]
+
+---------------------------------------------------------
+Expr:
+ Term [AddOp Term]
+|
+ UnOp Expr
+|
+ FunAppl
+
+Term:
+ Factor [MultOp Factor]
+
+Factor:
+ Element [CmpOp Element]
+
+Element:
+ Ident
+|
+ Number
+|
+ "(" Expr ")"
diff --git a/examples/Mini/Mini.jj b/examples/Mini/Mini.jj
new file mode 100644
index 00000000..c84c8312
--- /dev/null
+++ b/examples/Mini/Mini.jj
@@ -0,0 +1,576 @@
+/*@bgen(jjtree) Generated By:JJTree: Do not edit this line. Mini.jj */
+/*@egen*/
+
+PARSER_BEGIN(MiniParser)
+package Mini;
+
+public class MiniParser/*@bgen(jjtree)*/implements MiniParserTreeConstants/*@egen*/ {/*@bgen(jjtree)*/
+ protected static JJTMiniParserState jjtree = new JJTMiniParserState();
+
+/*@egen*/
+ private static Token expr_token;
+
+ final static void jjtreeOpenNodeScope(Node n) {}
+ final static void jjtreeCloseNodeScope(Node n) {((SimpleNode)n).closeNode();}
+}
+
+PARSER_END(MiniParser)
+
+SKIP : /* WHITE SPACE */
+{
+ " "
+| "\t"
+| "\n"
+| "\r"
+| "\f"
+}
+
+/* Single-line Comments
+ */
+MORE :
+{
+ "--" : SINGLE_LINE_COMMENT_STATE
+}
+
+<SINGLE_LINE_COMMENT_STATE> SPECIAL_TOKEN :
+{
+ <SINGLE_LINE_COMMENT: "\n" | "\r" | "\r\n" > : DEFAULT
+}
+
+<SINGLE_LINE_COMMENT_STATE> MORE :
+{
+ < ~[] >
+}
+
+/* A program consists of a number of function declarations with a
+ * distinguished function `main' that starts the program.
+ */
+void Program() : {/*@bgen(jjtree) Program */
+ ASTProgram jjtn000 = new ASTProgram(JJTPROGRAM);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Program */
+ try {
+/*@egen*/
+ (FunDecl())*
+ <EOF>/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+/* "FUN" Ident() "(" NameList() ")" = Expr()
+ */
+void FunDecl() :
+{/*@bgen(jjtree) FunDecl */
+ ASTFunDecl jjtn000 = new ASTFunDecl(JJTFUNDECL);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/
+ String s;
+ Token t;
+}
+{/*@bgen(jjtree) FunDecl */
+ try {
+/*@egen*/
+ t = "FUN" { jjtn000.setPosition(t.beginLine, t.beginColumn); }
+
+ Ident()
+
+ <LPAREN>
+ [
+ Ident() (<COMMA> Ident())*
+ ]
+ <RPAREN>
+
+ <ASSIGN>
+
+ Expr()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/ /* Body expression */
+}
+
+void Expr() :
+{/*@bgen(jjtree) Expr */
+ ASTExpr jjtn000 = new ASTExpr(JJTEXPR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/
+ int kind=-1;
+ int un_op=-1;
+}
+{/*@bgen(jjtree) Expr */
+ try {
+/*@egen*/
+ IfExpr()
+|
+ LetExpr()
+|
+ Term() [kind = AddOp() Expr() { jjtn000.setKind(kind); }]
+|
+ un_op = UnOp() { jjtn000.setUnOp(un_op); } Expr()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+/*
+ * The disambiguating algorithm of JavaCC automatically binds dangling
+ * else's to the innermost if statement. The LOOKAHEAD specification
+ * is to tell JavaCC that we know what we are doing.
+ */
+void IfExpr() :
+{/*@bgen(jjtree) IfExpr */
+ ASTIfExpr jjtn000 = new ASTIfExpr(JJTIFEXPR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/
+ Token t=null;
+}
+{/*@bgen(jjtree) IfExpr */
+ try {
+/*@egen*/
+ t = "IF" { jjtn000.setPosition(t.beginLine, t.beginColumn); }
+ Expr() "THEN" Expr() [ LOOKAHEAD(1) "ELSE" Expr() ] "FI"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void LetExpr() :
+{/*@bgen(jjtree) LetExpr */
+ ASTLetExpr jjtn000 = new ASTLetExpr(JJTLETEXPR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/
+ Token t=null;
+}
+{/*@bgen(jjtree) LetExpr */
+ try {
+/*@egen*/
+ t = "LET" { jjtn000.setPosition(t.beginLine, t.beginColumn); }
+ (Ident() <ASSIGN> Expr())+ "IN" Expr()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+Token FunAppl() :
+{/*@bgen(jjtree) FunAppl */
+ ASTFunAppl jjtn000 = new ASTFunAppl(JJTFUNAPPL);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/
+ Token t=null;
+}
+{/*@bgen(jjtree) FunAppl */
+ try {
+/*@egen*/
+ t = Ident() { jjtn000.setPosition(t.beginLine, t.beginColumn); }
+ <LPAREN>
+ [Expr() (<COMMA> Expr())*] <RPAREN>/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/
+ { return t; }/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+
+}
+
+void Term():
+{/*@bgen(jjtree) Term */
+ ASTTerm jjtn000 = new ASTTerm(JJTTERM);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/
+ int kind=-1;
+}
+{/*@bgen(jjtree) Term */
+ try {
+/*@egen*/
+ Factor() [kind = MultOp() { jjtn000.setKind(kind); } Term()]/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/
+ { jjtn000.setPosition(expr_token.beginLine, expr_token.beginColumn); }/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void Factor() :
+{/*@bgen(jjtree) Factor */
+ ASTFactor jjtn000 = new ASTFactor(JJTFACTOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/
+ int kind=-1;
+}
+{/*@bgen(jjtree) Factor */
+ try {
+/*@egen*/
+ Element() [kind = CmpOp() { jjtn000.setKind(kind); } Factor()]/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/
+ { jjtn000.setPosition(expr_token.beginLine, expr_token.beginColumn); }/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void Element() : {}
+{
+/* expr_token is a global variable used to remember the position of an Expr() node
+*/
+ LOOKAHEAD(2)
+ expr_token = FunAppl()
+|
+ expr_token = Ident()
+|
+ expr_token = Integer()
+|
+ expr_token = <LPAREN> Expr() <RPAREN>
+}
+
+Token Integer() :
+{/*@bgen(jjtree) Integer */
+ ASTInteger jjtn000 = new ASTInteger(JJTINTEGER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/
+ int num;
+ Token t; // Contains lexem and line/column number
+}
+{/*@bgen(jjtree) Integer */
+ try {
+/*@egen*/
+ t = <INTEGER>/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/
+ {
+ jjtn000.setValue(Integer.parseInt(t.image));
+ jjtn000.setPosition(t.beginLine, t.beginColumn);
+ return t;
+ }/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+Token Ident() :
+{/*@bgen(jjtree) Ident */
+ ASTIdent jjtn000 = new ASTIdent(JJTIDENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/
+ String name;
+ Token t; // Contains lexem and line/column number
+}
+{/*@bgen(jjtree) Ident */
+ try {
+/*@egen*/
+ (t = <TRUE> | t = <FALSE> | t = <READ> | t = <WRITE> |
+ t = <IDENT>)/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/
+ {
+ jjtn000.setName(t.image);
+ jjtn000.setPosition(t.beginLine, t.beginColumn);
+ return t;
+ }/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+int AddOp() :
+{
+ Token t=null;
+}
+{
+ (t = <PLUS> | t = <MINUS> | t = <OR>)
+ {
+ return t.kind;
+ }
+}
+
+int MultOp() :
+{
+ Token t=null;
+}
+{
+ (t = <MULT> | t = <DIV> | t = <MOD> | t = <AND>)
+ {
+ return t.kind;
+ }
+}
+
+int CmpOp() :
+{
+ Token t=null;
+}
+{
+ (t = <EQ> | t = <NEQ> | t = <LEQ> | t = <GEQ> | t = <GT> | t = <LT>)
+ {
+ return t.kind;
+ }
+}
+
+int UnOp() :
+{
+ Token t=null;
+}
+{
+ (t = <MINUS> | t = <NOT>)
+ {
+ return t.kind;
+ }
+}
+
+
+TOKEN : /* Boolean and arithmetic operands */
+{
+ < GT : ">" >
+|
+ < LT : "<" >
+|
+ < GEQ : ">=" >
+|
+ < LEQ : "<=" >
+|
+ < EQ : "==" >
+|
+ < NEQ : "!=" >
+|
+ < NOT : "!" >
+|
+ < FALSE : "FALSE" >
+|
+ < TRUE : "TRUE" >
+|
+ < AND : "AND" >
+|
+ < OR : "OR" >
+|
+ < PLUS : "+">
+|
+ < MINUS : "-">
+|
+ < MULT : "*">
+|
+ < MOD : "%">
+|
+ < DIV : "/">
+|
+ < LPAREN : "(">
+|
+ < RPAREN : ")">
+|
+ < ASSIGN : "=">
+|
+ < COMMA : ",">
+|
+ < READ : "READ">
+|
+ < WRITE : "WRITE">
+}
+
+/* Has to be and the, otherwise every string wil become an <IDENT> token
+ * Who knows why ...
+ */
+TOKEN : /* LITERALS */
+{
+ < #DIGIT: ["0"-"9"] >
+|
+ < #LETTER: ["a"-"z", "A"-"Z"] >
+|
+ < IDENT: <LETTER> (<LETTER> | <DIGIT> | "_")* >
+|
+ < INTEGER: (<DIGIT>)+ >
+|
+ < STRING: "\"" (~["\"", "\n", "\r"])* "\"" >
+}
diff --git a/examples/Mini/Mini.jjt b/examples/Mini/Mini.jjt
new file mode 100644
index 00000000..568c0a49
--- /dev/null
+++ b/examples/Mini/Mini.jjt
@@ -0,0 +1,293 @@
+options {
+ MULTI=true;
+ NODE_SCOPE_HOOK=true; /* Call methods on entry/exit of node */
+}
+
+PARSER_BEGIN(MiniParser)
+package Mini;
+
+public class MiniParser {
+ private static Token expr_token;
+
+ final static void jjtreeOpenNodeScope(Node n) {}
+ final static void jjtreeCloseNodeScope(Node n) {((SimpleNode)n).closeNode();}
+}
+
+PARSER_END(MiniParser)
+
+SKIP : /* WHITE SPACE */
+{
+ " "
+| "\t"
+| "\n"
+| "\r"
+| "\f"
+}
+
+/* Single-line Comments
+ */
+MORE :
+{
+ "--" : SINGLE_LINE_COMMENT_STATE
+}
+
+<SINGLE_LINE_COMMENT_STATE> SPECIAL_TOKEN :
+{
+ <SINGLE_LINE_COMMENT: "\n" | "\r" | "\r\n" > : DEFAULT
+}
+
+<SINGLE_LINE_COMMENT_STATE> MORE :
+{
+ < ~[] >
+}
+
+/* A program consists of a number of function declarations with a
+ * distinguished function `main' that starts the program.
+ */
+void Program() : {}
+{
+ (FunDecl())*
+ <EOF>
+}
+
+/* "FUN" Ident() "(" NameList() ")" = Expr()
+ */
+void FunDecl() :
+{
+ String s;
+ Token t;
+}
+{
+ t = "FUN" { jjtThis.setPosition(t.beginLine, t.beginColumn); }
+
+ Ident()
+
+ <LPAREN>
+ [
+ Ident() (<COMMA> Ident())*
+ ]
+ <RPAREN>
+
+ <ASSIGN>
+
+ Expr() /* Body expression */
+}
+
+void Expr() :
+{
+ int kind=-1;
+ int un_op=-1;
+}
+{
+ IfExpr()
+|
+ LetExpr()
+|
+ Term() [kind = AddOp() Expr() { jjtThis.setKind(kind); }]
+|
+ un_op = UnOp() { jjtThis.setUnOp(un_op); } Expr()
+}
+
+/*
+ * The disambiguating algorithm of JavaCC automatically binds dangling
+ * else's to the innermost if statement. The LOOKAHEAD specification
+ * is to tell JavaCC that we know what we are doing.
+ */
+void IfExpr() :
+{
+ Token t=null;
+}
+{
+ t = "IF" { jjtThis.setPosition(t.beginLine, t.beginColumn); }
+ Expr() "THEN" Expr() [ LOOKAHEAD(1) "ELSE" Expr() ] "FI"
+}
+
+void LetExpr() :
+{
+ Token t=null;
+}
+{
+ t = "LET" { jjtThis.setPosition(t.beginLine, t.beginColumn); }
+ (Ident() <ASSIGN> Expr())+ "IN" Expr()
+}
+
+Token FunAppl() :
+{
+ Token t=null;
+}
+{
+ t = Ident() { jjtThis.setPosition(t.beginLine, t.beginColumn); }
+ <LPAREN>
+ [Expr() (<COMMA> Expr())*] <RPAREN>
+ { return t; }
+
+}
+
+void Term():
+{
+ int kind=-1;
+}
+{
+ Factor() [kind = MultOp() { jjtThis.setKind(kind); } Term()]
+ { jjtThis.setPosition(expr_token.beginLine, expr_token.beginColumn); }
+}
+
+void Factor() :
+{
+ int kind=-1;
+}
+{
+ Element() [kind = CmpOp() { jjtThis.setKind(kind); } Factor()]
+ { jjtThis.setPosition(expr_token.beginLine, expr_token.beginColumn); }
+}
+
+void Element() #void : {}
+{
+/* expr_token is a global variable used to remember the position of an Expr() node
+*/
+ LOOKAHEAD(2)
+ expr_token = FunAppl()
+|
+ expr_token = Ident()
+|
+ expr_token = Integer()
+|
+ expr_token = <LPAREN> Expr() <RPAREN>
+}
+
+Token Integer() :
+{
+ int num;
+ Token t; // Contains lexem and line/column number
+}
+{
+ t = <INTEGER>
+ {
+ jjtThis.setValue(Integer.parseInt(t.image));
+ jjtThis.setPosition(t.beginLine, t.beginColumn);
+ return t;
+ }
+}
+
+Token Ident() :
+{
+ String name;
+ Token t; // Contains lexem and line/column number
+}
+{
+ (t = <TRUE> | t = <FALSE> | t = <READ> | t = <WRITE> |
+ t = <IDENT>)
+ {
+ jjtThis.setName(t.image);
+ jjtThis.setPosition(t.beginLine, t.beginColumn);
+ return t;
+ }
+}
+
+int AddOp() #void :
+{
+ Token t=null;
+}
+{
+ (t = <PLUS> | t = <MINUS> | t = <OR>)
+ {
+ return t.kind;
+ }
+}
+
+int MultOp() #void :
+{
+ Token t=null;
+}
+{
+ (t = <MULT> | t = <DIV> | t = <MOD> | t = <AND>)
+ {
+ return t.kind;
+ }
+}
+
+int CmpOp() #void :
+{
+ Token t=null;
+}
+{
+ (t = <EQ> | t = <NEQ> | t = <LEQ> | t = <GEQ> | t = <GT> | t = <LT>)
+ {
+ return t.kind;
+ }
+}
+
+int UnOp() #void :
+{
+ Token t=null;
+}
+{
+ (t = <MINUS> | t = <NOT>)
+ {
+ return t.kind;
+ }
+}
+
+
+TOKEN : /* Boolean and arithmetic operands */
+{
+ < GT : ">" >
+|
+ < LT : "<" >
+|
+ < GEQ : ">=" >
+|
+ < LEQ : "<=" >
+|
+ < EQ : "==" >
+|
+ < NEQ : "!=" >
+|
+ < NOT : "!" >
+|
+ < FALSE : "FALSE" >
+|
+ < TRUE : "TRUE" >
+|
+ < AND : "AND" >
+|
+ < OR : "OR" >
+|
+ < PLUS : "+">
+|
+ < MINUS : "-">
+|
+ < MULT : "*">
+|
+ < MOD : "%">
+|
+ < DIV : "/">
+|
+ < LPAREN : "(">
+|
+ < RPAREN : ")">
+|
+ < ASSIGN : "=">
+|
+ < COMMA : ",">
+|
+ < READ : "READ">
+|
+ < WRITE : "WRITE">
+}
+
+/* Has to be and the, otherwise every string wil become an <IDENT> token
+ * Who knows why ...
+ */
+TOKEN : /* LITERALS */
+{
+ < #DIGIT: ["0"-"9"] >
+|
+ < #LETTER: ["a"-"z", "A"-"Z"] >
+|
+ < IDENT: <LETTER> (<LETTER> | <DIGIT> | "_")* >
+|
+ < INTEGER: (<DIGIT>)+ >
+|
+ < STRING: "\"" (~["\"", "\n", "\r"])* "\"" >
+}
diff --git a/examples/Mini/MiniC.java b/examples/Mini/MiniC.java
new file mode 100644
index 00000000..6052aca7
--- /dev/null
+++ b/examples/Mini/MiniC.java
@@ -0,0 +1,154 @@
+package Mini;
+import java.util.Vector;
+import java.io.*;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.generic.*;
+
+public class MiniC implements org.apache.bcel.Constants {
+ private static Vector errors = null;
+ private static Vector warnings = null;
+ private static String file = null;
+ private static int pass = 0;
+
+ public static void main(String[] argv) {
+ String[] file_name = new String[argv.length];
+ int files=0;
+ MiniParser parser=null;
+ String base_name=null;
+ boolean byte_code=true;
+
+ try {
+ /* Parse command line arguments.
+ */
+ for(int i=0; i < argv.length; i++) {
+ if(argv[i].charAt(0) == '-') { // command line switch
+ if(argv[i].equals("-java"))
+ byte_code=false;
+ else if(argv[i].equals("-bytecode"))
+ byte_code=true;
+ else
+ throw new Exception("Unknown option: " + argv[i]);
+ }
+ else { // add file name to list
+ file_name[files++] = argv[i];
+ }
+ }
+
+ if(files == 0)
+ System.err.println("Nothing to compile.");
+
+ for(int j=0; j < files; j++) {
+ errors = new Vector();
+ warnings = new Vector();
+ pass = 0;
+
+ if(j == 0)
+ parser = new MiniParser(new java.io.FileInputStream(file_name[0]));
+ else
+ parser.ReInit(new java.io.FileInputStream(file_name[j]));
+
+ int index = file_name[j].lastIndexOf('.');
+ if(index > 0)
+ base_name = file_name[j].substring(0, index);
+ else
+ base_name = file_name[j];
+
+ if((index = base_name.lastIndexOf(File.separatorChar)) > 0)
+ base_name = base_name.substring(index + 1);
+
+ file = file_name[j];
+
+ System.out.println("Parsing ...");
+ parser.Program();
+ ASTProgram program = (ASTProgram)parser.jjtree.rootNode();
+
+ System.out.println("Pass 1: Optimizing parse tree ...");
+ pass = 1;
+ program = program.traverse();
+ // program.dump(">");
+
+ if(errors.size() == 0) {
+ System.out.println("Pass 2: Type checking (I) ...");
+ program.eval(pass=2);
+ }
+
+ if(errors.size() == 0) {
+ System.out.println("Pass 3: Type checking (II) ...");
+ program.eval(pass=3);
+ }
+
+ for(int i=0; i < errors.size(); i++)
+ System.out.println(errors.elementAt(i));
+
+ for(int i=0; i < warnings.size(); i++)
+ System.out.println(warnings.elementAt(i));
+
+ if(errors.size() == 0) {
+ if(byte_code) {
+ System.out.println("Pass 5: Generating byte code ...");
+ ClassGen class_gen = new ClassGen(base_name, "java.lang.Object",
+ file_name[j],
+ ACC_PUBLIC | ACC_FINAL |
+ ACC_SUPER, null);
+ ConstantPoolGen cp = class_gen.getConstantPool();
+
+ program.byte_code(class_gen, cp);
+ JavaClass clazz = class_gen.getJavaClass();
+ clazz.dump(base_name + ".class");
+ }
+ else {
+ System.out.println("Pass 5: Generating Java code ...");
+ PrintWriter out = new PrintWriter(new FileOutputStream(base_name + ".java"));
+ program.code(out, base_name);
+ out.close();
+
+ System.out.println("Pass 6: Compiling Java code ...");
+
+ String[] args = { "javac", base_name + ".java" };
+ //sun.tools.javac.Main compiler = new sun.tools.javac.Main(System.err, "javac");
+ try {
+ Process p = Runtime.getRuntime().exec(args);
+ p.waitFor();
+ } catch(Exception e) {System.out.println(e); }
+
+ //compiler.compile(args);
+ }
+ }
+
+ if((errors.size() > 0) || (warnings.size() > 0))
+ System.out.println(errors.size() + " errors and " + warnings.size() +
+ " warnings.");
+ }
+ } catch(Exception e) { e.printStackTrace(); }
+ }
+
+
+ final static void addError(int line, int column, String err) {
+ if(pass != 2)
+ errors.addElement(file + ":" + fillup(line, 3) + "," + fillup(column, 2) +
+ ": " + err);
+ }
+
+ final static void addWarning(int line, int column, String err) {
+ warnings.addElement("Warning: " + file + ":" + fillup(line, 3) + "," +
+ fillup(column, 3) + ": " + err);
+ }
+
+ final static String fillup(int n, int len) {
+ String str = Integer.toString(n);
+ int diff = len - str.length();
+
+ if(diff > 0) {
+ char[] chs = new char[diff];
+
+ for(int i=0; i < diff; i++)
+ chs[i] = ' ';
+
+ return new String(chs) + str;
+ }
+ else
+ return str;
+ }
+
+ final static void addWarning(String err) { warnings.addElement(err); }
+}
diff --git a/examples/Mini/MiniParser$JJCalls b/examples/Mini/MiniParser$JJCalls
new file mode 100644
index 00000000..9f4981c7
--- /dev/null
+++ b/examples/Mini/MiniParser$JJCalls
Binary files differ
diff --git a/examples/Mini/MiniParser.java b/examples/Mini/MiniParser.java
new file mode 100644
index 00000000..d5a34672
--- /dev/null
+++ b/examples/Mini/MiniParser.java
@@ -0,0 +1,991 @@
+/* Generated By:JJTree&JavaCC: Do not edit this line. MiniParser.java */
+package Mini;
+
+public class MiniParser/*@bgen(jjtree)*/implements MiniParserTreeConstants, MiniParserConstants {/*@bgen(jjtree)*/
+ protected static JJTMiniParserState jjtree = new JJTMiniParserState();private static Token expr_token;
+
+ final static void jjtreeOpenNodeScope(Node n) {}
+ final static void jjtreeCloseNodeScope(Node n) {((SimpleNode)n).closeNode();}
+
+/* A program consists of a number of function declarations with a
+ * distinguished function `main' that starts the program.
+ */
+ static final public void Program() throws ParseException {
+ /*@bgen(jjtree) Program */
+ ASTProgram jjtn000 = new ASTProgram(JJTPROGRAM);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ label_1:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case 9:
+ ;
+ break;
+ default:
+ jj_la1[0] = jj_gen;
+ break label_1;
+ }
+ FunDecl();
+ }
+ jj_consume_token(0);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof ParseException) {
+ {if (true) throw (ParseException)jjte000;}
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {if (true) throw (RuntimeException)jjte000;}
+ }
+ {if (true) throw (Error)jjte000;}
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+/* "FUN" Ident() "(" NameList() ")" = Expr()
+ */
+ static final public void FunDecl() throws ParseException {
+ /*@bgen(jjtree) FunDecl */
+ ASTFunDecl jjtn000 = new ASTFunDecl(JJTFUNDECL);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);String s;
+ Token t;
+ try {
+ t = jj_consume_token(9);
+ jjtn000.setPosition(t.beginLine, t.beginColumn);
+ Ident();
+ jj_consume_token(LPAREN);
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case FALSE:
+ case TRUE:
+ case READ:
+ case WRITE:
+ case IDENT:
+ Ident();
+ label_2:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case COMMA:
+ ;
+ break;
+ default:
+ jj_la1[1] = jj_gen;
+ break label_2;
+ }
+ jj_consume_token(COMMA);
+ Ident();
+ }
+ break;
+ default:
+ jj_la1[2] = jj_gen;
+ ;
+ }
+ jj_consume_token(RPAREN);
+ jj_consume_token(ASSIGN);
+ Expr();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof ParseException) {
+ {if (true) throw (ParseException)jjte000;}
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {if (true) throw (RuntimeException)jjte000;}
+ }
+ {if (true) throw (Error)jjte000;}
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ static final public void Expr() throws ParseException {
+ /*@bgen(jjtree) Expr */
+ ASTExpr jjtn000 = new ASTExpr(JJTEXPR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);int kind=-1;
+ int un_op=-1;
+ try {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case 10:
+ IfExpr();
+ break;
+ case 14:
+ LetExpr();
+ break;
+ case FALSE:
+ case TRUE:
+ case LPAREN:
+ case READ:
+ case WRITE:
+ case IDENT:
+ case INTEGER:
+ Term();
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case OR:
+ case PLUS:
+ case MINUS:
+ kind = AddOp();
+ Expr();
+ jjtn000.setKind(kind);
+ break;
+ default:
+ jj_la1[3] = jj_gen;
+ ;
+ }
+ break;
+ case NOT:
+ case MINUS:
+ un_op = UnOp();
+ jjtn000.setUnOp(un_op);
+ Expr();
+ break;
+ default:
+ jj_la1[4] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof ParseException) {
+ {if (true) throw (ParseException)jjte000;}
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {if (true) throw (RuntimeException)jjte000;}
+ }
+ {if (true) throw (Error)jjte000;}
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+/*
+ * The disambiguating algorithm of JavaCC automatically binds dangling
+ * else's to the innermost if statement. The LOOKAHEAD specification
+ * is to tell JavaCC that we know what we are doing.
+ */
+ static final public void IfExpr() throws ParseException {
+ /*@bgen(jjtree) IfExpr */
+ ASTIfExpr jjtn000 = new ASTIfExpr(JJTIFEXPR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);Token t=null;
+ try {
+ t = jj_consume_token(10);
+ jjtn000.setPosition(t.beginLine, t.beginColumn);
+ Expr();
+ jj_consume_token(11);
+ Expr();
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case 12:
+ jj_consume_token(12);
+ Expr();
+ break;
+ default:
+ jj_la1[5] = jj_gen;
+ ;
+ }
+ jj_consume_token(13);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof ParseException) {
+ {if (true) throw (ParseException)jjte000;}
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {if (true) throw (RuntimeException)jjte000;}
+ }
+ {if (true) throw (Error)jjte000;}
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ static final public void LetExpr() throws ParseException {
+ /*@bgen(jjtree) LetExpr */
+ ASTLetExpr jjtn000 = new ASTLetExpr(JJTLETEXPR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);Token t=null;
+ try {
+ t = jj_consume_token(14);
+ jjtn000.setPosition(t.beginLine, t.beginColumn);
+ label_3:
+ while (true) {
+ Ident();
+ jj_consume_token(ASSIGN);
+ Expr();
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case FALSE:
+ case TRUE:
+ case READ:
+ case WRITE:
+ case IDENT:
+ ;
+ break;
+ default:
+ jj_la1[6] = jj_gen;
+ break label_3;
+ }
+ }
+ jj_consume_token(15);
+ Expr();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof ParseException) {
+ {if (true) throw (ParseException)jjte000;}
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {if (true) throw (RuntimeException)jjte000;}
+ }
+ {if (true) throw (Error)jjte000;}
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ static final public Token FunAppl() throws ParseException {
+ /*@bgen(jjtree) FunAppl */
+ ASTFunAppl jjtn000 = new ASTFunAppl(JJTFUNAPPL);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);Token t=null;
+ try {
+ t = Ident();
+ jjtn000.setPosition(t.beginLine, t.beginColumn);
+ jj_consume_token(LPAREN);
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case 10:
+ case 14:
+ case NOT:
+ case FALSE:
+ case TRUE:
+ case MINUS:
+ case LPAREN:
+ case READ:
+ case WRITE:
+ case IDENT:
+ case INTEGER:
+ Expr();
+ label_4:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case COMMA:
+ ;
+ break;
+ default:
+ jj_la1[7] = jj_gen;
+ break label_4;
+ }
+ jj_consume_token(COMMA);
+ Expr();
+ }
+ break;
+ default:
+ jj_la1[8] = jj_gen;
+ ;
+ }
+ jj_consume_token(RPAREN);
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ {if (true) return t;}
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof ParseException) {
+ {if (true) throw (ParseException)jjte000;}
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {if (true) throw (RuntimeException)jjte000;}
+ }
+ {if (true) throw (Error)jjte000;}
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public void Term() throws ParseException {
+ /*@bgen(jjtree) Term */
+ ASTTerm jjtn000 = new ASTTerm(JJTTERM);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);int kind=-1;
+ try {
+ Factor();
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case AND:
+ case MULT:
+ case MOD:
+ case DIV:
+ kind = MultOp();
+ jjtn000.setKind(kind);
+ Term();
+ break;
+ default:
+ jj_la1[9] = jj_gen;
+ ;
+ }
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ jjtn000.setPosition(expr_token.beginLine, expr_token.beginColumn);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof ParseException) {
+ {if (true) throw (ParseException)jjte000;}
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {if (true) throw (RuntimeException)jjte000;}
+ }
+ {if (true) throw (Error)jjte000;}
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ static final public void Factor() throws ParseException {
+ /*@bgen(jjtree) Factor */
+ ASTFactor jjtn000 = new ASTFactor(JJTFACTOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);int kind=-1;
+ try {
+ Element();
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case GT:
+ case LT:
+ case GEQ:
+ case LEQ:
+ case EQ:
+ case NEQ:
+ kind = CmpOp();
+ jjtn000.setKind(kind);
+ Factor();
+ break;
+ default:
+ jj_la1[10] = jj_gen;
+ ;
+ }
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ jjtn000.setPosition(expr_token.beginLine, expr_token.beginColumn);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof ParseException) {
+ {if (true) throw (ParseException)jjte000;}
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {if (true) throw (RuntimeException)jjte000;}
+ }
+ {if (true) throw (Error)jjte000;}
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ static final public void Element() throws ParseException {
+ if (jj_2_1(2)) {
+ expr_token = FunAppl();
+ } else {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case FALSE:
+ case TRUE:
+ case READ:
+ case WRITE:
+ case IDENT:
+ expr_token = Ident();
+ break;
+ case INTEGER:
+ expr_token = Integer();
+ break;
+ case LPAREN:
+ expr_token = jj_consume_token(LPAREN);
+ Expr();
+ jj_consume_token(RPAREN);
+ break;
+ default:
+ jj_la1[11] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ }
+
+ static final public Token Integer() throws ParseException {
+ /*@bgen(jjtree) Integer */
+ ASTInteger jjtn000 = new ASTInteger(JJTINTEGER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);int num;
+ Token t;
+ try {
+ t = jj_consume_token(INTEGER);
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ jjtn000.setValue(Integer.parseInt(t.image));
+ jjtn000.setPosition(t.beginLine, t.beginColumn);
+ {if (true) return t;}
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Token Ident() throws ParseException {
+ /*@bgen(jjtree) Ident */
+ ASTIdent jjtn000 = new ASTIdent(JJTIDENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);String name;
+ Token t;
+ try {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case TRUE:
+ t = jj_consume_token(TRUE);
+ break;
+ case FALSE:
+ t = jj_consume_token(FALSE);
+ break;
+ case READ:
+ t = jj_consume_token(READ);
+ break;
+ case WRITE:
+ t = jj_consume_token(WRITE);
+ break;
+ case IDENT:
+ t = jj_consume_token(IDENT);
+ break;
+ default:
+ jj_la1[12] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ jjtn000.setName(t.image);
+ jjtn000.setPosition(t.beginLine, t.beginColumn);
+ {if (true) return t;}
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public int AddOp() throws ParseException {
+ Token t=null;
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case PLUS:
+ t = jj_consume_token(PLUS);
+ break;
+ case MINUS:
+ t = jj_consume_token(MINUS);
+ break;
+ case OR:
+ t = jj_consume_token(OR);
+ break;
+ default:
+ jj_la1[13] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ {if (true) return t.kind;}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public int MultOp() throws ParseException {
+ Token t=null;
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case MULT:
+ t = jj_consume_token(MULT);
+ break;
+ case DIV:
+ t = jj_consume_token(DIV);
+ break;
+ case MOD:
+ t = jj_consume_token(MOD);
+ break;
+ case AND:
+ t = jj_consume_token(AND);
+ break;
+ default:
+ jj_la1[14] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ {if (true) return t.kind;}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public int CmpOp() throws ParseException {
+ Token t=null;
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case EQ:
+ t = jj_consume_token(EQ);
+ break;
+ case NEQ:
+ t = jj_consume_token(NEQ);
+ break;
+ case LEQ:
+ t = jj_consume_token(LEQ);
+ break;
+ case GEQ:
+ t = jj_consume_token(GEQ);
+ break;
+ case GT:
+ t = jj_consume_token(GT);
+ break;
+ case LT:
+ t = jj_consume_token(LT);
+ break;
+ default:
+ jj_la1[15] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ {if (true) return t.kind;}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public int UnOp() throws ParseException {
+ Token t=null;
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case MINUS:
+ t = jj_consume_token(MINUS);
+ break;
+ case NOT:
+ t = jj_consume_token(NOT);
+ break;
+ default:
+ jj_la1[16] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ {if (true) return t.kind;}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final private boolean jj_2_1(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ boolean retval = !jj_3_1();
+ jj_save(0, xla);
+ return retval;
+ }
+
+ static final private boolean jj_3R_8() {
+ if (jj_scan_token(FALSE)) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
+ static final private boolean jj_3R_11() {
+ if (jj_scan_token(IDENT)) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
+ static final private boolean jj_3R_7() {
+ if (jj_scan_token(TRUE)) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
+ static final private boolean jj_3R_6() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_7()) {
+ jj_scanpos = xsp;
+ if (jj_3R_8()) {
+ jj_scanpos = xsp;
+ if (jj_3R_9()) {
+ jj_scanpos = xsp;
+ if (jj_3R_10()) {
+ jj_scanpos = xsp;
+ if (jj_3R_11()) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
+ static final private boolean jj_3_1() {
+ if (jj_3R_5()) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
+ static final private boolean jj_3R_5() {
+ if (jj_3R_6()) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
+ static final private boolean jj_3R_10() {
+ if (jj_scan_token(WRITE)) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
+ static final private boolean jj_3R_9() {
+ if (jj_scan_token(READ)) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
+ static private boolean jj_initialized_once = false;
+ static public MiniParserTokenManager token_source;
+ static ASCII_CharStream jj_input_stream;
+ static public Token token, jj_nt;
+ static private int jj_ntk;
+ static private Token jj_scanpos, jj_lastpos;
+ static private int jj_la;
+ static public boolean lookingAhead = false;
+ static private boolean jj_semLA;
+ static private int jj_gen;
+ static final private int[] jj_la1 = new int[17];
+ static final private int[] jj_la1_0 = {0x200,0x0,0x1800000,0x1c000000,0x11c04400,0x1000,0x1800000,0x0,0x11c04400,0xe2000000,0x3f0000,0x1800000,0x1800000,0x1c000000,0xe2000000,0x3f0000,0x10400000,};
+ static final private int[] jj_la1_1 = {0x0,0x8,0x130,0x0,0x331,0x0,0x130,0x8,0x331,0x0,0x0,0x331,0x130,0x0,0x0,0x0,0x0,};
+ static final private JJCalls[] jj_2_rtns = new JJCalls[1];
+ static private boolean jj_rescan = false;
+ static private int jj_gc = 0;
+
+ public MiniParser(java.io.InputStream stream) {
+ if (jj_initialized_once) {
+ System.out.println("ERROR: Second call to constructor of static parser. You must");
+ System.out.println(" either use ReInit() or set the JavaCC option STATIC to false");
+ System.out.println(" during parser generation.");
+ throw new Error();
+ }
+ jj_initialized_once = true;
+ jj_input_stream = new ASCII_CharStream(stream, 1, 1);
+ token_source = new MiniParserTokenManager(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 17; i++) jj_la1[i] = -1;
+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
+ }
+
+ static public void ReInit(java.io.InputStream stream) {
+ jj_input_stream.ReInit(stream, 1, 1);
+ token_source.ReInit(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jjtree.reset();
+ jj_gen = 0;
+ for (int i = 0; i < 17; i++) jj_la1[i] = -1;
+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
+ }
+
+ public MiniParser(java.io.Reader stream) {
+ if (jj_initialized_once) {
+ System.out.println("ERROR: Second call to constructor of static parser. You must");
+ System.out.println(" either use ReInit() or set the JavaCC option STATIC to false");
+ System.out.println(" during parser generation.");
+ throw new Error();
+ }
+ jj_initialized_once = true;
+ jj_input_stream = new ASCII_CharStream(stream, 1, 1);
+ token_source = new MiniParserTokenManager(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 17; i++) jj_la1[i] = -1;
+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
+ }
+
+ static public void ReInit(java.io.Reader stream) {
+ jj_input_stream.ReInit(stream, 1, 1);
+ token_source.ReInit(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jjtree.reset();
+ jj_gen = 0;
+ for (int i = 0; i < 17; i++) jj_la1[i] = -1;
+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
+ }
+
+ public MiniParser(MiniParserTokenManager tm) {
+ if (jj_initialized_once) {
+ System.out.println("ERROR: Second call to constructor of static parser. You must");
+ System.out.println(" either use ReInit() or set the JavaCC option STATIC to false");
+ System.out.println(" during parser generation.");
+ throw new Error();
+ }
+ jj_initialized_once = true;
+ token_source = tm;
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 17; i++) jj_la1[i] = -1;
+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
+ }
+
+ public void ReInit(MiniParserTokenManager tm) {
+ token_source = tm;
+ token = new Token();
+ jj_ntk = -1;
+ jjtree.reset();
+ jj_gen = 0;
+ for (int i = 0; i < 17; i++) jj_la1[i] = -1;
+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
+ }
+
+ static final private Token jj_consume_token(int kind) throws ParseException {
+ Token oldToken;
+ if ((oldToken = token).next != null) token = token.next;
+ else token = token.next = token_source.getNextToken();
+ jj_ntk = -1;
+ if (token.kind == kind) {
+ jj_gen++;
+ if (++jj_gc > 100) {
+ jj_gc = 0;
+ for (int i = 0; i < jj_2_rtns.length; i++) {
+ JJCalls c = jj_2_rtns[i];
+ while (c != null) {
+ if (c.gen < jj_gen) c.first = null;
+ c = c.next;
+ }
+ }
+ }
+ return token;
+ }
+ token = oldToken;
+ jj_kind = kind;
+ throw generateParseException();
+ }
+
+ static final private boolean jj_scan_token(int kind) {
+ if (jj_scanpos == jj_lastpos) {
+ jj_la--;
+ if (jj_scanpos.next == null) {
+ jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
+ } else {
+ jj_lastpos = jj_scanpos = jj_scanpos.next;
+ }
+ } else {
+ jj_scanpos = jj_scanpos.next;
+ }
+ if (jj_rescan) {
+ int i = 0; Token tok = token;
+ while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }
+ if (tok != null) jj_add_error_token(kind, i);
+ }
+ return (jj_scanpos.kind != kind);
+ }
+
+ static final public Token getNextToken() {
+ if (token.next != null) token = token.next;
+ else token = token.next = token_source.getNextToken();
+ jj_ntk = -1;
+ jj_gen++;
+ return token;
+ }
+
+ static final public Token getToken(int index) {
+ Token t = lookingAhead ? jj_scanpos : token;
+ for (int i = 0; i < index; i++) {
+ if (t.next != null) t = t.next;
+ else t = t.next = token_source.getNextToken();
+ }
+ return t;
+ }
+
+ static final private int jj_ntk() {
+ if ((jj_nt=token.next) == null)
+ return (jj_ntk = (token.next=token_source.getNextToken()).kind);
+ else
+ return (jj_ntk = jj_nt.kind);
+ }
+
+ static private java.util.Vector jj_expentries = new java.util.Vector();
+ static private int[] jj_expentry;
+ static private int jj_kind = -1;
+ static private int[] jj_lasttokens = new int[100];
+ static private int jj_endpos;
+
+ static private void jj_add_error_token(int kind, int pos) {
+ if (pos >= 100) return;
+ if (pos == jj_endpos + 1) {
+ jj_lasttokens[jj_endpos++] = kind;
+ } else if (jj_endpos != 0) {
+ jj_expentry = new int[jj_endpos];
+ for (int i = 0; i < jj_endpos; i++) {
+ jj_expentry[i] = jj_lasttokens[i];
+ }
+ boolean exists = false;
+ for (java.util.Enumeration enum = jj_expentries.elements(); enum.hasMoreElements();) {
+ int[] oldentry = (int[])(enum.nextElement());
+ if (oldentry.length == jj_expentry.length) {
+ exists = true;
+ for (int i = 0; i < jj_expentry.length; i++) {
+ if (oldentry[i] != jj_expentry[i]) {
+ exists = false;
+ break;
+ }
+ }
+ if (exists) break;
+ }
+ }
+ if (!exists) jj_expentries.addElement(jj_expentry);
+ if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
+ }
+ }
+
+ static final public ParseException generateParseException() {
+ jj_expentries.removeAllElements();
+ boolean[] la1tokens = new boolean[43];
+ for (int i = 0; i < 43; i++) {
+ la1tokens[i] = false;
+ }
+ if (jj_kind >= 0) {
+ la1tokens[jj_kind] = true;
+ jj_kind = -1;
+ }
+ for (int i = 0; i < 17; i++) {
+ if (jj_la1[i] == jj_gen) {
+ for (int j = 0; j < 32; j++) {
+ if ((jj_la1_0[i] & (1<<j)) != 0) {
+ la1tokens[j] = true;
+ }
+ if ((jj_la1_1[i] & (1<<j)) != 0) {
+ la1tokens[32+j] = true;
+ }
+ }
+ }
+ }
+ for (int i = 0; i < 43; i++) {
+ if (la1tokens[i]) {
+ jj_expentry = new int[1];
+ jj_expentry[0] = i;
+ jj_expentries.addElement(jj_expentry);
+ }
+ }
+ jj_endpos = 0;
+ jj_rescan_token();
+ jj_add_error_token(0, 0);
+ int[][] exptokseq = new int[jj_expentries.size()][];
+ for (int i = 0; i < jj_expentries.size(); i++) {
+ exptokseq[i] = (int[])jj_expentries.elementAt(i);
+ }
+ return new ParseException(token, exptokseq, tokenImage);
+ }
+
+ static final public void enable_tracing() {
+ }
+
+ static final public void disable_tracing() {
+ }
+
+ static final private void jj_rescan_token() {
+ jj_rescan = true;
+ for (int i = 0; i < 1; i++) {
+ JJCalls p = jj_2_rtns[i];
+ do {
+ if (p.gen > jj_gen) {
+ jj_la = p.arg; jj_lastpos = jj_scanpos = p.first;
+ switch (i) {
+ case 0: jj_3_1(); break;
+ }
+ }
+ p = p.next;
+ } while (p != null);
+ }
+ jj_rescan = false;
+ }
+
+ static final private void jj_save(int index, int xla) {
+ JJCalls p = jj_2_rtns[index];
+ while (p.gen > jj_gen) {
+ if (p.next == null) { p = p.next = new JJCalls(); break; }
+ p = p.next;
+ }
+ p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla;
+ }
+
+ private static final class JJCalls {
+ int gen;
+ Token first;
+ int arg;
+ JJCalls next;
+ }
+
+}
diff --git a/examples/Mini/MiniParserConstants.java b/examples/Mini/MiniParserConstants.java
new file mode 100644
index 00000000..0986a4d2
--- /dev/null
+++ b/examples/Mini/MiniParserConstants.java
@@ -0,0 +1,85 @@
+/* Generated By:JJTree&JavaCC: Do not edit this line. MiniParserConstants.java */
+package Mini;
+
+public interface MiniParserConstants {
+
+ int EOF = 0;
+ int SINGLE_LINE_COMMENT = 7;
+ int GT = 16;
+ int LT = 17;
+ int GEQ = 18;
+ int LEQ = 19;
+ int EQ = 20;
+ int NEQ = 21;
+ int NOT = 22;
+ int FALSE = 23;
+ int TRUE = 24;
+ int AND = 25;
+ int OR = 26;
+ int PLUS = 27;
+ int MINUS = 28;
+ int MULT = 29;
+ int MOD = 30;
+ int DIV = 31;
+ int LPAREN = 32;
+ int RPAREN = 33;
+ int ASSIGN = 34;
+ int COMMA = 35;
+ int READ = 36;
+ int WRITE = 37;
+ int DIGIT = 38;
+ int LETTER = 39;
+ int IDENT = 40;
+ int INTEGER = 41;
+ int STRING = 42;
+
+ int DEFAULT = 0;
+ int SINGLE_LINE_COMMENT_STATE = 1;
+
+ String[] tokenImage = {
+ "<EOF>",
+ "\" \"",
+ "\"\\t\"",
+ "\"\\n\"",
+ "\"\\r\"",
+ "\"\\f\"",
+ "\"--\"",
+ "<SINGLE_LINE_COMMENT>",
+ "<token of kind 8>",
+ "\"FUN\"",
+ "\"IF\"",
+ "\"THEN\"",
+ "\"ELSE\"",
+ "\"FI\"",
+ "\"LET\"",
+ "\"IN\"",
+ "\">\"",
+ "\"<\"",
+ "\">=\"",
+ "\"<=\"",
+ "\"==\"",
+ "\"!=\"",
+ "\"!\"",
+ "\"FALSE\"",
+ "\"TRUE\"",
+ "\"AND\"",
+ "\"OR\"",
+ "\"+\"",
+ "\"-\"",
+ "\"*\"",
+ "\"%\"",
+ "\"/\"",
+ "\"(\"",
+ "\")\"",
+ "\"=\"",
+ "\",\"",
+ "\"READ\"",
+ "\"WRITE\"",
+ "<DIGIT>",
+ "<LETTER>",
+ "<IDENT>",
+ "<INTEGER>",
+ "<STRING>",
+ };
+
+}
diff --git a/examples/Mini/MiniParserTokenManager.java b/examples/Mini/MiniParserTokenManager.java
new file mode 100644
index 00000000..4a34dee1
--- /dev/null
+++ b/examples/Mini/MiniParserTokenManager.java
@@ -0,0 +1,721 @@
+/* Generated By:JJTree&JavaCC: Do not edit this line. MiniParserTokenManager.java */
+package Mini;
+
+public class MiniParserTokenManager implements MiniParserConstants
+{
+static private final int jjMoveStringLiteralDfa0_1()
+{
+ return jjMoveNfa_1(0, 0);
+}
+static private final void jjCheckNAdd(int state)
+{
+ if (jjrounds[state] != jjround)
+ {
+ jjstateSet[jjnewStateCnt++] = state;
+ jjrounds[state] = jjround;
+ }
+}
+static private final void jjAddStates(int start, int end)
+{
+ do {
+ jjstateSet[jjnewStateCnt++] = jjnextStates[start];
+ } while (start++ != end);
+}
+static private final void jjCheckNAddTwoStates(int state1, int state2)
+{
+ jjCheckNAdd(state1);
+ jjCheckNAdd(state2);
+}
+static private final void jjCheckNAddStates(int start, int end)
+{
+ do {
+ jjCheckNAdd(jjnextStates[start]);
+ } while (start++ != end);
+}
+static private final void jjCheckNAddStates(int start)
+{
+ jjCheckNAdd(jjnextStates[start]);
+ jjCheckNAdd(jjnextStates[start + 1]);
+}
+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;
+ for (;;)
+ {
+ if (++jjround == 0x7fffffff)
+ ReInitRounds();
+ if (curChar < 64)
+ {
+ long l = 1L << curChar;
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ if ((0x2400L & l) != 0L)
+ {
+ if (kind > 7)
+ kind = 7;
+ }
+ if (curChar == 13)
+ jjstateSet[jjnewStateCnt++] = 1;
+ break;
+ case 1:
+ if (curChar == 10 && kind > 7)
+ kind = 7;
+ break;
+ case 2:
+ if (curChar == 13)
+ jjstateSet[jjnewStateCnt++] = 1;
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ else if (curChar < 128)
+ {
+ long l = 1L << (curChar & 077);
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ else
+ {
+ int i2 = (curChar & 0xff) >> 6;
+ long l2 = 1L << (curChar & 077);
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ if (kind != 0x7fffffff)
+ {
+ jjmatchedKind = kind;
+ jjmatchedPos = curPos;
+ kind = 0x7fffffff;
+ }
+ ++curPos;
+ if ((i = jjnewStateCnt) == (startsAt = 3 - (jjnewStateCnt = startsAt)))
+ return curPos;
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) { return curPos; }
+ }
+}
+private static final int jjStopStringLiteralDfa_0(int pos, long active0)
+{
+ switch (pos)
+ {
+ case 0:
+ if ((active0 & 0x300780fe00L) != 0L)
+ {
+ jjmatchedKind = 40;
+ return 1;
+ }
+ return -1;
+ case 1:
+ if ((active0 & 0x400a400L) != 0L)
+ return 1;
+ if ((active0 & 0x3003805a00L) != 0L)
+ {
+ jjmatchedKind = 40;
+ jjmatchedPos = 1;
+ return 1;
+ }
+ return -1;
+ case 2:
+ if ((active0 & 0x2004200L) != 0L)
+ return 1;
+ if ((active0 & 0x3001801800L) != 0L)
+ {
+ jjmatchedKind = 40;
+ jjmatchedPos = 2;
+ return 1;
+ }
+ return -1;
+ case 3:
+ if ((active0 & 0x2000800000L) != 0L)
+ {
+ jjmatchedKind = 40;
+ jjmatchedPos = 3;
+ return 1;
+ }
+ if ((active0 & 0x1001001800L) != 0L)
+ return 1;
+ return -1;
+ default :
+ return -1;
+ }
+}
+private static final int jjStartNfa_0(int pos, long active0)
+{
+ return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);
+}
+static private final int jjStopAtPos(int pos, int kind)
+{
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ return pos + 1;
+}
+static private final int jjStartNfaWithStates_0(int pos, int kind, int state)
+{
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) { return pos + 1; }
+ return jjMoveNfa_0(state, pos + 1);
+}
+static private final int jjMoveStringLiteralDfa0_0()
+{
+ switch(curChar)
+ {
+ case 33:
+ jjmatchedKind = 22;
+ return jjMoveStringLiteralDfa1_0(0x200000L);
+ case 37:
+ return jjStopAtPos(0, 30);
+ case 40:
+ return jjStopAtPos(0, 32);
+ case 41:
+ return jjStopAtPos(0, 33);
+ case 42:
+ return jjStopAtPos(0, 29);
+ case 43:
+ return jjStopAtPos(0, 27);
+ case 44:
+ return jjStopAtPos(0, 35);
+ case 45:
+ jjmatchedKind = 28;
+ return jjMoveStringLiteralDfa1_0(0x40L);
+ case 47:
+ return jjStopAtPos(0, 31);
+ case 60:
+ jjmatchedKind = 17;
+ return jjMoveStringLiteralDfa1_0(0x80000L);
+ case 61:
+ jjmatchedKind = 34;
+ return jjMoveStringLiteralDfa1_0(0x100000L);
+ case 62:
+ jjmatchedKind = 16;
+ return jjMoveStringLiteralDfa1_0(0x40000L);
+ case 65:
+ return jjMoveStringLiteralDfa1_0(0x2000000L);
+ case 69:
+ return jjMoveStringLiteralDfa1_0(0x1000L);
+ case 70:
+ return jjMoveStringLiteralDfa1_0(0x802200L);
+ case 73:
+ return jjMoveStringLiteralDfa1_0(0x8400L);
+ case 76:
+ return jjMoveStringLiteralDfa1_0(0x4000L);
+ case 79:
+ return jjMoveStringLiteralDfa1_0(0x4000000L);
+ case 82:
+ return jjMoveStringLiteralDfa1_0(0x1000000000L);
+ case 84:
+ return jjMoveStringLiteralDfa1_0(0x1000800L);
+ case 87:
+ return jjMoveStringLiteralDfa1_0(0x2000000000L);
+ default :
+ return jjMoveNfa_0(0, 0);
+ }
+}
+static private final int jjMoveStringLiteralDfa1_0(long active0)
+{
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(0, active0);
+ return 1;
+ }
+ switch(curChar)
+ {
+ case 45:
+ if ((active0 & 0x40L) != 0L)
+ return jjStopAtPos(1, 6);
+ break;
+ case 61:
+ if ((active0 & 0x40000L) != 0L)
+ return jjStopAtPos(1, 18);
+ else if ((active0 & 0x80000L) != 0L)
+ return jjStopAtPos(1, 19);
+ else if ((active0 & 0x100000L) != 0L)
+ return jjStopAtPos(1, 20);
+ 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)
+ return jjStartNfaWithStates_0(1, 10, 1);
+ break;
+ case 72:
+ return jjMoveStringLiteralDfa2_0(active0, 0x800L);
+ case 73:
+ if ((active0 & 0x2000L) != 0L)
+ return jjStartNfaWithStates_0(1, 13, 1);
+ break;
+ case 76:
+ return jjMoveStringLiteralDfa2_0(active0, 0x1000L);
+ case 78:
+ if ((active0 & 0x8000L) != 0L)
+ return jjStartNfaWithStates_0(1, 15, 1);
+ return jjMoveStringLiteralDfa2_0(active0, 0x2000000L);
+ case 82:
+ if ((active0 & 0x4000000L) != 0L)
+ return jjStartNfaWithStates_0(1, 26, 1);
+ return jjMoveStringLiteralDfa2_0(active0, 0x2001000000L);
+ case 85:
+ return jjMoveStringLiteralDfa2_0(active0, 0x200L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(0, active0);
+}
+static private final int jjMoveStringLiteralDfa2_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(0, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(1, active0);
+ return 2;
+ }
+ switch(curChar)
+ {
+ case 65:
+ return jjMoveStringLiteralDfa3_0(active0, 0x1000000000L);
+ case 68:
+ if ((active0 & 0x2000000L) != 0L)
+ return jjStartNfaWithStates_0(2, 25, 1);
+ break;
+ case 69:
+ return jjMoveStringLiteralDfa3_0(active0, 0x800L);
+ case 73:
+ return jjMoveStringLiteralDfa3_0(active0, 0x2000000000L);
+ case 76:
+ return jjMoveStringLiteralDfa3_0(active0, 0x800000L);
+ case 78:
+ if ((active0 & 0x200L) != 0L)
+ return jjStartNfaWithStates_0(2, 9, 1);
+ break;
+ case 83:
+ return jjMoveStringLiteralDfa3_0(active0, 0x1000L);
+ case 84:
+ if ((active0 & 0x4000L) != 0L)
+ return jjStartNfaWithStates_0(2, 14, 1);
+ break;
+ case 85:
+ return jjMoveStringLiteralDfa3_0(active0, 0x1000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(1, active0);
+}
+static private final int jjMoveStringLiteralDfa3_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(1, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(2, active0);
+ return 3;
+ }
+ switch(curChar)
+ {
+ case 68:
+ if ((active0 & 0x1000000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 36, 1);
+ break;
+ case 69:
+ if ((active0 & 0x1000L) != 0L)
+ return jjStartNfaWithStates_0(3, 12, 1);
+ else if ((active0 & 0x1000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 24, 1);
+ break;
+ case 78:
+ if ((active0 & 0x800L) != 0L)
+ return jjStartNfaWithStates_0(3, 11, 1);
+ break;
+ case 83:
+ return jjMoveStringLiteralDfa4_0(active0, 0x800000L);
+ case 84:
+ return jjMoveStringLiteralDfa4_0(active0, 0x2000000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(2, active0);
+}
+static private final int jjMoveStringLiteralDfa4_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(2, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(3, active0);
+ return 4;
+ }
+ switch(curChar)
+ {
+ case 69:
+ if ((active0 & 0x800000L) != 0L)
+ return jjStartNfaWithStates_0(4, 23, 1);
+ else if ((active0 & 0x2000000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 37, 1);
+ break;
+ default :
+ break;
+ }
+ return jjStartNfa_0(3, active0);
+}
+static final long[] jjbitVec0 = {
+ 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
+};
+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;
+ for (;;)
+ {
+ if (++jjround == 0x7fffffff)
+ ReInitRounds();
+ if (curChar < 64)
+ {
+ long l = 1L << curChar;
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ if ((0x3ff000000000000L & l) != 0L)
+ {
+ if (kind > 41)
+ kind = 41;
+ jjCheckNAdd(2);
+ }
+ else if (curChar == 34)
+ jjCheckNAddTwoStates(4, 5);
+ break;
+ case 1:
+ 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;
+ jjCheckNAdd(2);
+ break;
+ case 3:
+ if (curChar == 34)
+ jjCheckNAddTwoStates(4, 5);
+ break;
+ case 4:
+ if ((0xfffffffbffffdbffL & l) != 0L)
+ jjCheckNAddTwoStates(4, 5);
+ break;
+ case 5:
+ if (curChar == 34 && kind > 42)
+ kind = 42;
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ else if (curChar < 128)
+ {
+ long l = 1L << (curChar & 077);
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ 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;
+ jjCheckNAdd(1);
+ break;
+ case 4:
+ jjAddStates(0, 1);
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ else
+ {
+ int i2 = (curChar & 0xff) >> 6;
+ long l2 = 1L << (curChar & 077);
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 4:
+ if ((jjbitVec0[i2] & l2) != 0L)
+ jjAddStates(0, 1);
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ if (kind != 0x7fffffff)
+ {
+ jjmatchedKind = kind;
+ jjmatchedPos = curPos;
+ kind = 0x7fffffff;
+ }
+ ++curPos;
+ if ((i = jjnewStateCnt) == (startsAt = 6 - (jjnewStateCnt = startsAt)))
+ return curPos;
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) { return curPos; }
+ }
+}
+static final int[] jjnextStates = {
+ 4, 5,
+};
+public static final String[] jjstrLiteralImages = {
+"", null, null, null, null, null, null, null, null, "\106\125\116",
+"\111\106", "\124\110\105\116", "\105\114\123\105", "\106\111", "\114\105\124",
+"\111\116", "\76", "\74", "\76\75", "\74\75", "\75\75", "\41\75", "\41",
+"\106\101\114\123\105", "\124\122\125\105", "\101\116\104", "\117\122", "\53", "\55", "\52", "\45",
+"\57", "\50", "\51", "\75", "\54", "\122\105\101\104", "\127\122\111\124\105", null,
+null, null, null, null, };
+public static final String[] lexStateNames = {
+ "DEFAULT",
+ "SINGLE_LINE_COMMENT_STATE",
+};
+public static final int[] jjnewLexState = {
+ -1, -1, -1, -1, -1, -1, 1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+};
+static final long[] jjtoToken = {
+ 0x73ffffffe01L,
+};
+static final long[] jjtoSkip = {
+ 0xbeL,
+};
+static final long[] jjtoSpecial = {
+ 0x80L,
+};
+static final long[] jjtoMore = {
+ 0x140L,
+};
+static private ASCII_CharStream input_stream;
+static private final int[] jjrounds = new int[6];
+static private final int[] jjstateSet = new int[12];
+static StringBuffer image;
+static int jjimageLen;
+static int lengthOfMatch;
+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);
+ input_stream = stream;
+}
+public MiniParserTokenManager(ASCII_CharStream stream, int lexState)
+{
+ this(stream);
+ SwitchTo(lexState);
+}
+static public void ReInit(ASCII_CharStream stream)
+{
+ jjmatchedPos = jjnewStateCnt = 0;
+ curLexState = defaultLexState;
+ input_stream = stream;
+ ReInitRounds();
+}
+static private final void ReInitRounds()
+{
+ int i;
+ jjround = 0x80000001;
+ for (i = 6; i-- > 0;)
+ jjrounds[i] = 0x80000000;
+}
+static public void ReInit(ASCII_CharStream stream, int lexState)
+{
+ ReInit(stream);
+ SwitchTo(lexState);
+}
+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;
+}
+
+static private final Token jjFillToken()
+{
+ Token t = Token.newToken(jjmatchedKind);
+ t.kind = jjmatchedKind;
+ String im = jjstrLiteralImages[jjmatchedKind];
+ t.image = (im == null) ? input_stream.GetImage() : im;
+ t.beginLine = input_stream.getBeginLine();
+ t.beginColumn = input_stream.getBeginColumn();
+ t.endLine = input_stream.getEndLine();
+ t.endColumn = input_stream.getEndColumn();
+ return t;
+}
+
+static int curLexState = 0;
+static int defaultLexState = 0;
+static int jjnewStateCnt;
+static int jjround;
+static int jjmatchedPos;
+static int jjmatchedKind;
+
+public static final Token getNextToken()
+{
+ int kind;
+ Token specialToken = null;
+ Token matchedToken;
+ int curPos = 0;
+
+ EOFLoop :
+ for (;;)
+ {
+ try
+ {
+ curChar = input_stream.BeginToken();
+ }
+ catch(java.io.IOException e)
+ {
+ jjmatchedKind = 0;
+ matchedToken = jjFillToken();
+ matchedToken.specialToken = specialToken;
+ return matchedToken;
+ }
+ image = null;
+ jjimageLen = 0;
+
+ for (;;)
+ {
+ switch(curLexState)
+ {
+ case 0:
+ try { input_stream.backup(0);
+ while (curChar <= 32 && (0x100003600L & (1L << curChar)) != 0L)
+ curChar = input_stream.BeginToken();
+ }
+ catch (java.io.IOException e1) { continue EOFLoop; }
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_0();
+ break;
+ case 1:
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_1();
+ if (jjmatchedPos == 0 && jjmatchedKind > 8)
+ {
+ jjmatchedKind = 8;
+ }
+ break;
+ }
+ if (jjmatchedKind != 0x7fffffff)
+ {
+ 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];
+ return matchedToken;
+ }
+ else if ((jjtoSkip[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
+ {
+ if ((jjtoSpecial[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
+ {
+ matchedToken = jjFillToken();
+ 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];
+ continue EOFLoop;
+ }
+ jjimageLen += jjmatchedPos + 1;
+ if (jjnewLexState[jjmatchedKind] != -1)
+ curLexState = jjnewLexState[jjmatchedKind];
+ curPos = 0;
+ jjmatchedKind = 0x7fffffff;
+ try {
+ curChar = input_stream.readChar();
+ continue;
+ }
+ catch (java.io.IOException e1) { }
+ }
+ int error_line = input_stream.getEndLine();
+ int error_column = input_stream.getEndColumn();
+ String error_after = null;
+ boolean EOFSeen = false;
+ try { input_stream.readChar(); input_stream.backup(1); }
+ catch (java.io.IOException e1) {
+ EOFSeen = true;
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();
+ if (curChar == '\n' || curChar == '\r') {
+ error_line++;
+ error_column = 0;
+ }
+ else
+ error_column++;
+ }
+ if (!EOFSeen) {
+ input_stream.backup(1);
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();
+ }
+ throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
+ }
+ }
+}
+
+static final void SkipLexicalActions(Token matchedToken)
+{
+ switch(jjmatchedKind)
+ {
+ default :
+ break;
+ }
+}
+}
diff --git a/examples/Mini/MiniParserTreeConstants.java b/examples/Mini/MiniParserTreeConstants.java
new file mode 100644
index 00000000..5f4c54f6
--- /dev/null
+++ b/examples/Mini/MiniParserTreeConstants.java
@@ -0,0 +1,33 @@
+/* Generated By:JJTree: Do not edit this line. MiniParserTreeConstants.java */
+
+package Mini;
+
+public interface MiniParserTreeConstants
+{
+ public int JJTPROGRAM = 0;
+ public int JJTFUNDECL = 1;
+ public int JJTEXPR = 2;
+ public int JJTIFEXPR = 3;
+ public int JJTLETEXPR = 4;
+ public int JJTFUNAPPL = 5;
+ public int JJTTERM = 6;
+ public int JJTFACTOR = 7;
+ public int JJTVOID = 8;
+ public int JJTINTEGER = 9;
+ public int JJTIDENT = 10;
+
+
+ public String[] jjtNodeName = {
+ "Program",
+ "FunDecl",
+ "Expr",
+ "IfExpr",
+ "LetExpr",
+ "FunAppl",
+ "Term",
+ "Factor",
+ "void",
+ "Integer",
+ "Ident",
+ };
+}
diff --git a/examples/Mini/Node.java b/examples/Mini/Node.java
new file mode 100644
index 00000000..eb1e2cac
--- /dev/null
+++ b/examples/Mini/Node.java
@@ -0,0 +1,35 @@
+/* Generated By:JJTree: Do not edit this line. Node.java */
+/* JJT: 0.3pre1 */
+
+package Mini;
+
+/* All AST nodes must implement this interface. It provides basic
+ machinery for constructing the parent and child relationships
+ between nodes. */
+
+public interface Node {
+
+ /** This method is called after the node has been made the current
+ node. It indicates that child nodes can now be added to it. */
+ public void jjtOpen();
+
+ /** This method is called after all the child nodes have been
+ added. */
+ public void jjtClose();
+
+ /** This pair of methods are used to inform the node of its
+ parent. */
+ public void jjtSetParent(Node n);
+ public Node jjtGetParent();
+
+ /** This method tells the node to add its argument to the node's
+ list of children. */
+ public void jjtAddChild(Node n, int i);
+
+ /** This method returns a child node. The children are numbered
+ from zero, left to right. */
+ public Node jjtGetChild(int i);
+
+ /** Return the number of children the node has. */
+ int jjtGetNumChildren();
+}
diff --git a/examples/Mini/ParseException.java b/examples/Mini/ParseException.java
new file mode 100644
index 00000000..8f5b4f55
--- /dev/null
+++ b/examples/Mini/ParseException.java
@@ -0,0 +1,191 @@
+/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 0.7pre6 */
+package Mini;
+
+/**
+ * This exception is thrown when parse errors are encountered.
+ * You can explicitly create objects of this exception type by
+ * calling the method generateParseException in the generated
+ * parser.
+ *
+ * You can modify this class to customize your error reporting
+ * mechanisms so long as you retain the public fields.
+ */
+public class ParseException extends Exception {
+
+ /**
+ * This constructor is used by the method "generateParseException"
+ * in the generated parser. Calling this constructor generates
+ * a new object of this type with the fields "currentToken",
+ * "expectedTokenSequences", and "tokenImage" set. The boolean
+ * flag "specialConstructor" is also set to true to indicate that
+ * this constructor was used to create this object.
+ * This constructor calls its super class with the empty string
+ * to force the "toString" method of parent class "Throwable" to
+ * print the error message in the form:
+ * ParseException: <result of getMessage>
+ */
+ public ParseException(Token currentTokenVal,
+ int[][] expectedTokenSequencesVal,
+ String[] tokenImageVal
+ )
+ {
+ super("");
+ specialConstructor = true;
+ currentToken = currentTokenVal;
+ expectedTokenSequences = expectedTokenSequencesVal;
+ tokenImage = tokenImageVal;
+ }
+
+ /**
+ * The following constructors are for use by you for whatever
+ * purpose you can think of. Constructing the exception in this
+ * manner makes the exception behave in the normal way - i.e., as
+ * documented in the class "Throwable". The fields "errorToken",
+ * "expectedTokenSequences", and "tokenImage" do not contain
+ * relevant information. The JavaCC generated code does not use
+ * these constructors.
+ */
+
+ public ParseException() {
+ super();
+ specialConstructor = false;
+ }
+
+ public ParseException(String message) {
+ super(message);
+ specialConstructor = false;
+ }
+
+ /**
+ * This variable determines which constructor was used to create
+ * this object and thereby affects the semantics of the
+ * "getMessage" method (see below).
+ */
+ protected boolean specialConstructor;
+
+ /**
+ * This is the last token that has been consumed successfully. If
+ * this object has been created due to a parse error, the token
+ * followng this token will (therefore) be the first error token.
+ */
+ public Token currentToken;
+
+ /**
+ * Each entry in this array is an array of integers. Each array
+ * of integers represents a sequence of tokens (by their ordinal
+ * values) that is expected at this point of the parse.
+ */
+ public int[][] expectedTokenSequences;
+
+ /**
+ * This is a reference to the "tokenImage" array of the generated
+ * parser within which the parse error occurred. This array is
+ * defined in the generated ...Constants interface.
+ */
+ public String[] tokenImage;
+
+ /**
+ * This method has the standard behavior when this object has been
+ * created using the standard constructors. Otherwise, it uses
+ * "currentToken" and "expectedTokenSequences" to generate a parse
+ * error message and returns it. If this object has been created
+ * due to a parse error, and you do not catch it (it gets thrown
+ * from the parser), then this method is called during the printing
+ * of the final stack trace, and hence the correct error message
+ * gets displayed.
+ */
+ public String getMessage() {
+ if (!specialConstructor) {
+ return super.getMessage();
+ }
+ String expected = "";
+ int maxSize = 0;
+ for (int i = 0; i < expectedTokenSequences.length; i++) {
+ if (maxSize < expectedTokenSequences[i].length) {
+ maxSize = expectedTokenSequences[i].length;
+ }
+ for (int j = 0; j < expectedTokenSequences[i].length; j++) {
+ expected += tokenImage[expectedTokenSequences[i][j]] + " ";
+ }
+ if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
+ expected += "...";
+ }
+ expected += eol + " ";
+ }
+ String retval = "Encountered \"";
+ Token tok = currentToken.next;
+ for (int i = 0; i < maxSize; i++) {
+ if (i != 0) retval += " ";
+ if (tok.kind == 0) {
+ retval += tokenImage[0];
+ break;
+ }
+ retval += add_escapes(tok.image);
+ tok = tok.next;
+ }
+ retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn + "." + eol;
+ if (expectedTokenSequences.length == 1) {
+ retval += "Was expecting:" + eol + " ";
+ } else {
+ retval += "Was expecting one of:" + eol + " ";
+ }
+ retval += expected;
+ return retval;
+ }
+
+ /**
+ * The end of line string for this machine.
+ */
+ protected String eol = System.getProperty("line.separator", "\n");
+
+ /**
+ * Used to convert raw characters to their escaped version
+ * when these raw version cannot be used as part of an ASCII
+ * string literal.
+ */
+ protected String add_escapes(String str) {
+ StringBuffer retval = new StringBuffer();
+ char ch;
+ for (int i = 0; i < str.length(); i++) {
+ switch (str.charAt(i))
+ {
+ case 0 :
+ continue;
+ case '\b':
+ retval.append("\\b");
+ continue;
+ case '\t':
+ retval.append("\\t");
+ continue;
+ case '\n':
+ retval.append("\\n");
+ continue;
+ case '\f':
+ retval.append("\\f");
+ continue;
+ case '\r':
+ retval.append("\\r");
+ continue;
+ case '\"':
+ retval.append("\\\"");
+ continue;
+ case '\'':
+ retval.append("\\\'");
+ continue;
+ case '\\':
+ retval.append("\\\\");
+ continue;
+ default:
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+ String s = "0000" + Integer.toString(ch, 16);
+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));
+ } else {
+ retval.append(ch);
+ }
+ continue;
+ }
+ }
+ return retval.toString();
+ }
+
+}
diff --git a/examples/Mini/README b/examples/Mini/README
new file mode 100644
index 00000000..8d0ebe7c
--- /dev/null
+++ b/examples/Mini/README
@@ -0,0 +1,54 @@
+ Mini-Mini tutorial
+ ------------------
+
+Mini is a very simple (semi-functional) language that I wrote to test
+the generic package of BCEL.
+
+ http://jakarta.apache.org/bcel/
+
+Mini uses the JavaCC parser generator which comes precompiled from
+
+ http://www.webgain.com/products/java_cc/
+
+After setting the CLASSPATH to the directory just above the Mini
+directory, e.g.
+
+ % cd Mini
+ % setenv CLASSPATH $CLASSPATH:.:..
+
+try the following:
+
+ % java Mini.MiniC max.mini
+
+This produces a Java class file (max.class) which you can execute with
+
+ % java max
+
+Enter a number (4, eg.) and you will be asked to enter 4 numbers. The
+program will then tell you the biggest of them.
+
+Alternatively you can produce a Java file (max.java) which will be
+translated automatically to a .class file.
+
+ % java Mini.MiniC -java max.mini
+
+There are three examples programs (max.mini, fac.mini, fib.mini)
+provided which demonstrate the language syntax and should be quite
+easy to understand.
+
+
+The compiler is not that well documented, I'm afraid, but if you've
+ever seen a compiler before, you should be able to understand what I'm
+doing. The part that produces the byte code is contained in the
+byte_code() method that all AST nodes implement. Take a look at
+MiniC.java at line 85 and follow the recursive byte_code() calls.
+
+It's also useful to use the listclass program provided with BCEL
+to examine the generated class. For example
+
+ % java listclass max.class
+
+
+Send bug reports and suggestions to
+
+ markus.dahm@berlin.de (Markus Dahm)
diff --git a/examples/Mini/SimpleNode.java b/examples/Mini/SimpleNode.java
new file mode 100644
index 00000000..f74779ea
--- /dev/null
+++ b/examples/Mini/SimpleNode.java
@@ -0,0 +1,81 @@
+/* Generated By:JJTree: Do not edit this line. SimpleNode.java */
+/* JJT: 0.3pre1 */
+
+package Mini;
+
+/**
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A>
+ */
+public abstract class SimpleNode implements Node {
+ protected Node parent;
+ protected Node[] children;
+ protected int id;
+ protected MiniParser parser;
+
+ public SimpleNode(int i) {
+ id = i;
+ }
+
+ public SimpleNode(MiniParser p, int i) {
+ this(i);
+ parser = p;
+ }
+
+ public void jjtOpen() {
+ }
+
+ public void jjtClose() {
+ }
+
+ public void closeNode() {
+ }
+
+ public void jjtSetParent(Node n) { parent = n; }
+ public Node jjtGetParent() { return parent; }
+
+ public void jjtAddChild(Node n, int i) {
+ if (children == null) {
+ children = new Node[i + 1];
+ } else if (i >= children.length) {
+ Node c[] = new Node[i + 1];
+ System.arraycopy(children, 0, c, 0, children.length);
+ children = c;
+ }
+ children[i] = n;
+ }
+
+ public Node jjtGetChild(int i) {
+ return children[i];
+ }
+
+ public int jjtGetNumChildren() {
+ return (children == null) ? 0 : children.length;
+ }
+
+ /* You can override these two methods in subclasses of SimpleNode to
+ customize the way the node appears when the tree is dumped. If
+ your output uses more than one line you should override
+ toString(String), otherwise overriding toString() is probably all
+ you need to do. */
+
+ public String toString() { return MiniParserTreeConstants.jjtNodeName[id]; }
+ public String toString(String prefix) { return prefix + toString(); }
+
+ /* Override this method if you want to customize how the node dumps
+ out its children. */
+
+ public void dump(String prefix) {
+ System.out.println(toString(prefix));
+ if (children != null) {
+ for (int i = 0; i < children.length; ++i) {
+ SimpleNode n = (SimpleNode)children[i];
+ if (n != null) {
+ n.dump(prefix + " ");
+ }
+ }
+ }
+ }
+}
+
diff --git a/examples/Mini/Token.java b/examples/Mini/Token.java
new file mode 100644
index 00000000..402f8946
--- /dev/null
+++ b/examples/Mini/Token.java
@@ -0,0 +1,81 @@
+/* Generated By:JavaCC: Do not edit this line. Token.java Version 0.7pre3 */
+package Mini;
+
+/**
+ * Describes the input token stream.
+ */
+
+public class Token {
+
+ /**
+ * An integer that describes the kind of this token. This numbering
+ * system is determined by JavaCCParser, and a table of these numbers is
+ * stored in the file ...Constants.java.
+ */
+ public int kind;
+
+ /**
+ * beginLine and beginColumn describe the position of the first character
+ * of this token; endLine and endColumn describe the position of the
+ * last character of this token.
+ */
+ public int beginLine, beginColumn, endLine, endColumn;
+
+ /**
+ * The string image of the token.
+ */
+ public String image;
+
+ /**
+ * A reference to the next regular (non-special) token from the input
+ * stream. If this is the last token from the input stream, or if the
+ * token manager has not read tokens beyond this one, this field is
+ * set to null. This is true only if this token is also a regular
+ * token. Otherwise, see below for a description of the contents of
+ * this field.
+ */
+ public Token next;
+
+ /**
+ * This field is used to access special tokens that occur prior to this
+ * token, but after the immediately preceding regular (non-special) token.
+ * If there are no such special tokens, this field is set to null.
+ * When there are more than one such special token, this field refers
+ * to the last of these special tokens, which in turn refers to the next
+ * previous special token through its specialToken field, and so on
+ * until the first special token (whose specialToken field is null).
+ * The next fields of special tokens refer to other special tokens that
+ * immediately follow it (without an intervening regular token). If there
+ * is no such token, this field is null.
+ */
+ public Token specialToken;
+
+ /**
+ * Returns the image.
+ */
+ public final String toString()
+ {
+ return image;
+ }
+
+ /**
+ * Returns a new Token object, by default. However, if you want, you
+ * can create and return subclass objects based on the value of ofKind.
+ * Simply add the cases to the switch for all those special cases.
+ * For example, if you have a subclass of Token called IDToken that
+ * you want to create if ofKind is ID, simlpy add something like :
+ *
+ * case MyParserConstants.ID : return new IDToken();
+ *
+ * to the following switch statement. Then you can cast matchedToken
+ * variable to the appropriate type and use it in your lexical actions.
+ */
+ public static final Token newToken(int ofKind)
+ {
+ switch(ofKind)
+ {
+ default : return new Token();
+ }
+ }
+
+}
diff --git a/examples/Mini/TokenMgrError.java b/examples/Mini/TokenMgrError.java
new file mode 100644
index 00000000..e922f5e5
--- /dev/null
+++ b/examples/Mini/TokenMgrError.java
@@ -0,0 +1,133 @@
+/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 0.7pre2 */
+package Mini;
+
+public class TokenMgrError extends Error
+{
+ /*
+ * Ordinals for various reasons why an Error of this type can be thrown.
+ */
+
+ /**
+ * Lexical error occured.
+ */
+ static final int LEXICAL_ERROR = 0;
+
+ /**
+ * An attempt wass made to create a second instance of a static token manager.
+ */
+ static final int STATIC_LEXER_ERROR = 1;
+
+ /**
+ * Tried to change to an invalid lexical state.
+ */
+ static final int INVALID_LEXICAL_STATE = 2;
+
+ /**
+ * Detected (and bailed out of) an infinite loop in the token manager.
+ */
+ static final int LOOP_DETECTED = 3;
+
+ /**
+ * Indicates the reason why the exception is thrown. It will have
+ * one of the above 4 values.
+ */
+ int errorCode;
+
+ /**
+ * Replaces unprintable characters by their espaced (or unicode escaped)
+ * equivalents in the given string
+ */
+ protected static final String addEscapes(String str) {
+ StringBuffer retval = new StringBuffer();
+ char ch;
+ for (int i = 0; i < str.length(); i++) {
+ switch (str.charAt(i))
+ {
+ case 0 :
+ continue;
+ case '\b':
+ retval.append("\\b");
+ continue;
+ case '\t':
+ retval.append("\\t");
+ continue;
+ case '\n':
+ retval.append("\\n");
+ continue;
+ case '\f':
+ retval.append("\\f");
+ continue;
+ case '\r':
+ retval.append("\\r");
+ continue;
+ case '\"':
+ retval.append("\\\"");
+ continue;
+ case '\'':
+ retval.append("\\\'");
+ continue;
+ case '\\':
+ retval.append("\\\\");
+ continue;
+ default:
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+ String s = "0000" + Integer.toString(ch, 16);
+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));
+ } else {
+ retval.append(ch);
+ }
+ continue;
+ }
+ }
+ return retval.toString();
+ }
+
+ /**
+ * Returns a detailed message for the Error when it is thrown by the
+ * token manager to indicate a lexical error.
+ * Parameters :
+ * EOFSeen : indicates if EOF caused the lexicl error
+ * curLexState : lexical state in which this error occured
+ * errorLine : line number when the error occured
+ * errorColumn : column number when the error occured
+ * errorAfter : prefix that was seen before this error occured
+ * curchar : the offending character
+ * Note: You can customize the lexical error message by modifying this method.
+ */
+ private static final String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
+ return("Lexical error at line " +
+ errorLine + ", column " +
+ errorColumn + ". Encountered: " +
+ (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
+ "after : \"" + addEscapes(errorAfter) + "\"");
+ }
+
+ /**
+ * You can also modify the body of this method to customize your error messages.
+ * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
+ * of end-users concern, so you can return something like :
+ *
+ * "Internal Error : Please file a bug report .... "
+ *
+ * from this method for such cases in the release version of your parser.
+ */
+ public String getMessage() {
+ return super.getMessage();
+ }
+
+ /*
+ * Constructors of various flavors follow.
+ */
+
+ public TokenMgrError() {
+ }
+
+ public TokenMgrError(String message, int reason) {
+ super(message);
+ errorCode = reason;
+ }
+
+ public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
+ this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
+ }
+}
diff --git a/examples/Mini/Variable.java b/examples/Mini/Variable.java
new file mode 100644
index 00000000..11aa7c2b
--- /dev/null
+++ b/examples/Mini/Variable.java
@@ -0,0 +1,50 @@
+package Mini;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.generic.*;
+
+/**
+ * Represents a variable declared in a LET expression or a FUN declaration.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A>
+ */
+public class Variable implements EnvEntry {
+ private ASTIdent name; // Reference to the original declaration
+ private boolean reserved; // Is a key word?
+
+ private int line, column; // Extracted from name.getToken()
+ private String var_name; // Short for name.getName()
+ private LocalVariableGen local_var; // local var associated with this variable
+
+ public Variable(ASTIdent name) {
+ this(name, false);
+ }
+
+ public Variable(ASTIdent name, boolean reserved) {
+ this.name = name;
+ this.reserved = reserved;
+
+ var_name = name.getName();
+ line = name.getLine();
+ column = name.getColumn();
+ }
+
+ public String toString() {
+ if(!reserved)
+ return var_name + " declared at line " + line + ", column " + column;
+ else
+ return var_name + " <reserved key word>";
+ }
+
+ public ASTIdent getName() { return name; }
+ public String getHashKey() { return var_name; }
+ public int getLine() { return line; }
+ public int getColumn() { return column; }
+ public int getType() { return name.getType(); }
+
+ void setLocalVariable(LocalVariableGen local_var) {
+ this.local_var = local_var;
+ }
+ LocalVariableGen getLocalVariable() { return local_var; }
+}
+
diff --git a/examples/Mini/fac.mini b/examples/Mini/fac.mini
new file mode 100644
index 00000000..d42b965a
--- /dev/null
+++ b/examples/Mini/fac.mini
@@ -0,0 +1,10 @@
+-- Compute factorial
+
+FUN fac (n) = IF n == 0 THEN 1
+ ELSE n * fac(n - 1)
+ FI
+
+FUN main() = LET
+ n = READ()
+ IN
+ WRITE(fac(n))
diff --git a/examples/Mini/fib.mini b/examples/Mini/fib.mini
new file mode 100644
index 00000000..74fa1018
--- /dev/null
+++ b/examples/Mini/fib.mini
@@ -0,0 +1,11 @@
+-- Compute fibonacci numbers
+
+FUN fib(n) =
+ IF n == 0 THEN 0
+ ELSE IF n == 1 THEN 1
+ ELSE fib(n - 1) + fib(n - 2) FI FI
+
+FUN main() =
+ LET n = READ()
+ IN
+ WRITE(fib(n))
diff --git a/examples/Mini/max.mini b/examples/Mini/max.mini
new file mode 100644
index 00000000..bee8ee51
--- /dev/null
+++ b/examples/Mini/max.mini
@@ -0,0 +1,21 @@
+FUN max(a, b) = IF a > b THEN a ELSE b FI
+
+-- n anzahl schleifendurchlaeufe
+-- m bisheriges maximum
+FUN LOOP(n, m) = IF n > 0 THEN
+ LET
+ x = READ()
+ IN
+ LOOP(n - 1, max(m, x))
+ ELSE
+ m
+ FI
+
+FUN abs(n) = IF n > 0 THEN n ELSE -n FI
+
+FUN main() =
+ LET a = READ()
+-- b = READ()
+ IN
+ --WRITE(max(a, b))
+ WRITE(LOOP(abs(a), -47110815))
diff --git a/examples/Package.java b/examples/Package.java
new file mode 100644
index 00000000..3b47ecd2
--- /dev/null
+++ b/examples/Package.java
@@ -0,0 +1,243 @@
+import java.util.*;
+import java.util.jar.*;
+import java.util.zip.*;
+import java.io.*;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.*;
+import org.apache.bcel.util.ClassPath;
+
+/**
+ * Package the client. Creates a jar file in the current directory
+ * that contains a minimal set of classes needed to run the client.
+ *
+ * Use BCEL to extract class names and read/write classes
+ * @author First Hop Ltd / Torsten Rueger
+ */
+public class Package {
+
+ /**
+ * The name of the resulting jar is Client.jar
+ */
+ static String defaultJar = "Client.jar";
+
+ /*
+ * See usage() for arguments. Create an instance and run that
+ *(just so not all members have to be static)
+ */
+ static void main(String args[]) {
+ Package instance = new Package();
+ try{
+ instance.go(args);
+ }catch(Exception e){
+ e.printStackTrace();
+ instance.usage();
+ }
+ }
+
+ /**
+ * We use a "default ClassPath object which uses the environments
+ * CLASSPATH
+ */
+ ClassPath classPath = new ClassPath();
+
+ /**
+ * A map for all Classes, the ones we're going to package.
+ * Store class name against the JavaClass. From the JavaClass
+ * we get the bytes to create the jar.
+ */
+ TreeMap allClasses = new TreeMap();
+ /**
+ * We start at the root classes, put them in here, then go through
+ * this list, putting dependent classes in here and from there
+ * into allClasses. Store class names against class names of their dependents
+ */
+ TreeMap dependents = new TreeMap();
+ /**
+ * Collect all classes that could not be found in the classpath.
+ * Store class names against class names of their dependents
+ */
+ TreeMap notFound = new TreeMap();
+ /**
+ * See wheather we print the classes that were not found (default = false)
+ */
+ boolean showNotFound = false ;
+ /**
+ * Remember wheather to print allClasses at the end (default = false)
+ */
+ boolean printClasses = false ;
+ /**
+ * Wheather we log classes during processing (default = false)
+ */
+ boolean log = false ;
+
+ public void usage(){
+ System.out.println(" This program packages classes and all their dependents");
+ System.out.println(" into one jar. Give all starting classes (your main)");
+ System.out.println(" on the command line. Use / as separator, the .class is");
+ System.out.println(" optional. We use the environments CLASSPATH to resolve");
+ System.out.println(" classes. Anything but java.* packages are packaged.");
+ System.out.println(" If you use Class.forName (or similar), be sure to");
+ System.out.println(" include the classes that you load dynamically on the");
+ System.out.println(" command line.\n");
+ System.out.println(" These options are recognized:");
+ System.out.println(" -e -error Show errors, meaning classes that could not ");
+ System.out.println(" resolved + the classes that referenced them.");
+ System.out.println(" -l -log Show classes as they are processed. This will");
+ System.out.println(" include doubles, java classes and is difficult to");
+ System.out.println(" read. I use it as a sort of progress monitor");
+ System.out.println(" -s -show Prints all the classes that were packaged");
+ System.out.println(" in alphabetical order, which is ordered by package");
+ System.out.println(" for the most part.");
+ }
+ /**
+ * the main of this class
+ */
+ void go(String[] args) throws IOException {
+ JavaClass clazz ;
+ // sort the options
+ for(int i = 0 ; i < args.length ; i++ ){
+ if( args[i].startsWith("-e") ) {
+ showNotFound = true;
+ continue;
+ }
+ if( args[i].startsWith("-s") ) {
+ printClasses = true ;
+ continue;
+ }
+ if( args[i].startsWith("-l") ) {
+ log = true ;
+ continue;
+ }
+ String clName = args[i];
+ if(clName.endsWith(".class")) {
+ clName = clName.substring(0,clName.length()-6);
+ }
+ clName = clName.replace('.','/');
+ clazz = new ClassParser(classPath.getInputStream(clName),clName).parse();
+ // here we create the root set of classes to process
+ addDependents(clazz);
+ System.out.println("Packaging for class: " + clName );
+ }
+ if( dependents.isEmpty() ){
+ usage();
+ return ;
+ }
+ System.out.println("Creating jar file: " + defaultJar );
+ // starting processing: Grab from the dependents list an add back to it
+ // and the allClasses list. see addDependents
+ while(!dependents.isEmpty() ){
+ String name = (String)dependents.firstKey();
+ String from = (String) dependents.remove(name);
+ if(allClasses.get(name) == null){
+ try{
+ InputStream is = classPath.getInputStream(name);
+ clazz = new ClassParser(is, name).parse();
+ addDependents(clazz);
+ }catch( IOException e){
+ //System.err.println("Error, class not found " + name );
+ notFound.put(name,from);
+ }
+ }
+ }
+ if(printClasses) { // if wanted show all classes
+ printAllClasses();
+ }
+ // create the jar
+ JarOutputStream jarFile = new JarOutputStream(new FileOutputStream(defaultJar));
+ jarFile.setLevel(5); // use compression
+ Iterator keys = allClasses.keySet().iterator();
+ int written = 0 ;
+ while(keys.hasNext()){ // add entries for every class
+ String name = (String)keys.next();
+ JavaClass claz = (JavaClass) allClasses.get(name);
+ ZipEntry zipEntry = new ZipEntry(name+".class");
+ byte[] bytes = claz.getBytes() ;
+ int length = bytes.length ;
+ jarFile.putNextEntry(zipEntry);
+ jarFile.write( bytes , 0 , length );
+ written += length; // for logging
+ }
+ jarFile.close();
+ System.err.println("The jar file contains " + allClasses.size()
+ +" classes and contains " +written+ " bytes");
+ if( !notFound.isEmpty() ){
+ System.err.println( notFound.size() +" classes could not be found");
+ if(showNotFound){ // if wanted show the actual classes that we not found
+ while(!notFound.isEmpty()){
+ String name = (String)notFound.firstKey();
+ System.err.println( name+ " (" + notFound.remove(name)+")");
+ }
+ }else{
+ System.err.println("Use '-e' option to view classes that were not found");
+ }
+ }
+ }
+
+ /**
+ * Print all classes that were packaged. Sort alphabetically for better
+ * overview. Enabled by -s option
+ */
+ void printAllClasses(){
+ ArrayList names = new ArrayList(allClasses.keySet());
+ Collections.sort(names);
+ for( int i = 0 ; i < names.size() ; i ++ ){
+ String cl = (String)names.get(i);
+ System.err.println(cl);
+ }
+ }
+
+ /**
+ *Add this class to allClasses. Then go through all its dependents
+ * and add them to the dependents list if they are not in allClasses
+ */
+ void addDependents( JavaClass clazz ) throws IOException {
+ String name = clazz.getClassName().replace('.', '/');
+ allClasses.put( name , clazz );
+ ConstantPool pool = clazz.getConstantPool();
+ for( int i = 1 ; i < pool.getLength() ; i++){
+ Constant cons = pool.getConstant(i);
+ //System.out.println("("+i+") " + cons );
+ if( cons!=null && cons.getTag() == Constants.CONSTANT_Class ){
+ int idx = ((ConstantClass)pool.getConstant(i)).getNameIndex();
+ String clas = ((ConstantUtf8)pool.getConstant(idx)).getBytes();
+ addClassString(clas,name);
+ }
+ }
+ }
+
+ /**
+ * add given class to dependents (from is where its dependent from)
+ * some fiddeling to be done because of array class notation
+ */
+ void addClassString(String clas,String from) throws IOException{
+ if(log){
+ System.out.println("processing: " + clas +" referenced by " + from);
+ }
+ // must check if it's an arrary (start with "[")
+ if(clas.startsWith("[")) {
+ if(clas.length() == 2 ) {
+ // it's an array of built in type, ignore
+ return;
+ }
+ if( 'L' == clas.charAt(1) ){
+ // it's an array of objects, the class name is between [L and ;
+ // like [Ljava/lang/Object;
+ addClassString(clas.substring(2,clas.length()-1),from);
+ return;
+ }
+ if( '[' == clas.charAt(1) ){
+ // it's an array of arrays, call recursive
+ addClassString(clas.substring(1),from);
+ return ;
+ }
+ throw new IOException("Can't recognize class name =" + clas);
+ }
+
+ if( !clas.startsWith("java/") && allClasses.get(clas) == null) {
+ dependents.put(clas,from);
+ // System.out.println(" yes" );
+ } else {
+ // System.out.println(" no" );
+ }
+ }
+}
diff --git a/examples/Peephole.java b/examples/Peephole.java
new file mode 100644
index 00000000..17d93874
--- /dev/null
+++ b/examples/Peephole.java
@@ -0,0 +1,88 @@
+import java.io.*;
+
+import java.util.Iterator;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.generic.*;
+import org.apache.bcel.Repository;
+import org.apache.bcel.util.InstructionFinder;
+
+/**
+ * Remove NOPs from given class
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A>
+ */
+public class Peephole {
+ public static void main(String[] argv) {
+ try {
+ /* Load the class from CLASSPATH.
+ */
+ JavaClass clazz = Repository.lookupClass(argv[0]);
+ Method[] methods = clazz.getMethods();
+ ConstantPoolGen cp = new ConstantPoolGen(clazz.getConstantPool());
+
+ for(int i=0; i < methods.length; i++) {
+ if(!(methods[i].isAbstract() || methods[i].isNative())) {
+ MethodGen mg = new MethodGen(methods[i],
+ clazz.getClassName(), cp);
+ Method stripped = removeNOPs(mg);
+
+ if(stripped != null) // Any NOPs stripped?
+ methods[i] = stripped; // Overwrite with stripped method
+ }
+ }
+
+ /* Dump the class to <class name>_.class
+ */
+ clazz.setConstantPool(cp.getFinalConstantPool());
+ clazz.dump(clazz.getClassName() + "_.class");
+ } catch(Exception e) { e.printStackTrace(); }
+ }
+
+ private static final Method removeNOPs(MethodGen mg) {
+ InstructionList il = mg.getInstructionList();
+ InstructionFinder f = new InstructionFinder(il);
+ String pat = "NOP+"; // Find at least one NOP
+ InstructionHandle next = null;
+ int count = 0;
+
+ for(Iterator e = f.search(pat); e.hasNext(); ) {
+ InstructionHandle[] match = (InstructionHandle[])e.next();
+ InstructionHandle first = match[0];
+ InstructionHandle last = match[match.length - 1];
+
+ /* Some nasty Java compilers may add NOP at end of method.
+ */
+ if((next = last.getNext()) == null)
+ break;
+
+ count += match.length;
+
+ /* Delete NOPs and redirect any references to them to the following
+ * (non-nop) instruction.
+ */
+ try {
+ il.delete(first, last);
+ } catch(TargetLostException e2) {
+ InstructionHandle[] targets = e2.getTargets();
+ 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);
+ }
+ }
+ }
+
+ Method m = null;
+
+ if(count > 0) {
+ System.out.println("Removed " + count + " NOP instructions from method " +
+ mg.getName());
+ m = mg.getMethod();
+ }
+
+ il.dispose(); // Reuse instruction handles
+ return m;
+ }
+}
diff --git a/examples/ProxyCreator.java b/examples/ProxyCreator.java
new file mode 100644
index 00000000..75b49711
--- /dev/null
+++ b/examples/ProxyCreator.java
@@ -0,0 +1,105 @@
+import java.io.*;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.generic.*;
+import org.apache.bcel.util.ByteSequence;
+import org.apache.bcel.*;
+import java.awt.event.*;
+import java.util.Vector;
+import java.util.zip.*;
+
+/**
+ * Dynamically creates and uses a proxy for <tt>java.awt.event.ActionListener</tt>
+ * via the classloader mechanism if called with
+ * <pre>java org.apache.bcel.util.JavaWrapper ProxyCreator</pre>
+ *
+ * The trick is to encode the byte code we need into the class name
+ * using the Utility.encode() method. This will result however in big
+ * ugly class name, so for many cases it will be more sufficient to
+ * put some clever creation code into the class loader.<br> This is
+ * comparable to the mechanism provided via
+ * <tt>java.lang.reflect.Proxy</tt>, but much more flexible.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A>
+ * @see org.apache.bcel.util.JavaWrapper
+ * @see org.apache.bcel.util.ClassLoader
+ * @see Utility
+ */
+public class ProxyCreator {
+ /** Load class and create instance
+ */
+ public static Object createProxy(String pack, String class_name) {
+ try {
+ Class cl = Class.forName(pack + "$$BCEL$$" + class_name);
+ return cl.newInstance();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ /** Create JavaClass object for a simple proxy for an java.awt.event.ActionListener
+ * that just prints the passed arguments, load and use it via the class loader
+ * mechanism.
+ */
+ public static void main(String[] argv) throws Exception {
+ ClassLoader loader = ProxyCreator.class.getClassLoader();
+
+ // instanceof won't work here ...
+ if(loader.getClass().toString().equals("class org.apache.bcel.util.ClassLoader")) {
+ // Real class name will be set by the class loader
+ ClassGen cg = new ClassGen("foo", "java.lang.Object", "", Constants.ACC_PUBLIC,
+ new String[] {"java.awt.event.ActionListener"});
+
+ // That's important, otherwise newInstance() won't work
+ cg.addEmptyConstructor(Constants.ACC_PUBLIC);
+
+ InstructionList il = new InstructionList();
+ ConstantPoolGen cp = cg.getConstantPool();
+ InstructionFactory factory = new InstructionFactory(cg);
+
+ int out = cp.addFieldref("java.lang.System", "out",
+ "Ljava/io/PrintStream;");
+ int println = cp.addMethodref("java.io.PrintStream", "println",
+ "(Ljava/lang/Object;)V");
+ MethodGen mg = new MethodGen(Constants.ACC_PUBLIC, Type.VOID,
+ new Type[] {
+ new ObjectType("java.awt.event.ActionEvent")
+ }, null, "actionPerformed", "foo", il, cp);
+
+ // System.out.println("actionPerformed:" + event);
+ il.append(new GETSTATIC(out));
+ il.append(factory.createNew("java.lang.StringBuffer"));
+ il.append(InstructionConstants.DUP);
+ il.append(new PUSH(cp, "actionPerformed:"));
+ il.append(factory.createInvoke("java.lang.StringBuffer", "<init>", Type.VOID,
+ new Type[] {Type.STRING}, Constants.INVOKESPECIAL));
+
+ il.append(new ALOAD(1));
+ il.append(factory.createAppend(Type.OBJECT));
+ il.append(new INVOKEVIRTUAL(println));
+ il.append(InstructionConstants.RETURN);
+
+ mg.stripAttributes(true);
+ mg.setMaxStack();
+ mg.setMaxLocals();
+ cg.addMethod(mg.getMethod());
+
+ byte[] bytes = cg.getJavaClass().getBytes();
+
+ System.out.println("Uncompressed class: " + bytes.length);
+
+ String s = Utility.encode(bytes, true);
+ System.out.println("Encoded class: " + s.length());
+
+ System.out.print("Creating proxy ... ");
+ ActionListener a = (ActionListener)createProxy("foo.bar.", s);
+ 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");
+ }
+
+}
diff --git a/examples/helloify.java b/examples/helloify.java
new file mode 100644
index 00000000..3dab45e2
--- /dev/null
+++ b/examples/helloify.java
@@ -0,0 +1,109 @@
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.generic.*;
+import org.apache.bcel.Constants;
+
+/**
+ * Read class file(s) and patch all of its methods, so that they print
+ * "hello" and their name and signature before doing anything else.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A>
+ */
+public final class helloify implements Constants {
+ private static String class_name;
+ private static ConstantPoolGen cp;
+ private static int out; // reference to System.out
+ private static int println; // reference to PrintStream.println
+
+ public static void main(String[] argv) {
+ try {
+ for(int i=0; i < argv.length; i++) {
+ if(argv[i].endsWith(".class")) {
+ JavaClass java_class = new ClassParser(argv[i]).parse();
+ ConstantPool constants = java_class.getConstantPool();
+ String file_name = argv[i].substring(0, argv[i].length() - 6) +
+ "_hello.class";
+ cp = new ConstantPoolGen(constants);
+
+ helloifyClassName(java_class);
+
+ out = cp.addFieldref("java.lang.System", "out",
+ "Ljava/io/PrintStream;");
+ println = cp.addMethodref("java.io.PrintStream", "println",
+ "(Ljava/lang/String;)V");
+ /* Patch all methods.
+ */
+ Method[] methods = java_class.getMethods();
+
+ for(int j=0; j < methods.length; j++) // Directly use array
+ methods[j] = helloifyMethod(methods[j]);
+
+ /* Finally dump it back to a file.
+ */
+ java_class.setConstantPool(cp.getFinalConstantPool());
+ java_class.dump(file_name);
+ }
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /** Change class name to <old_name>_hello
+ */
+ private static void helloifyClassName(JavaClass java_class ) {
+ class_name = java_class.getClassName() + "_hello";
+ int index = java_class.getClassNameIndex();
+
+ index = ((ConstantClass)cp.getConstant(index)).getNameIndex();
+ cp.setConstant(index, new ConstantUtf8(class_name.replace('.', '/')));
+ }
+
+ /**
+ * Patch a method.
+ */
+ private static Method helloifyMethod(Method m) {
+ Code code = m.getCode();
+ int flags = m.getAccessFlags();
+ String name = m.getName();
+
+ // Sanity check
+ if(m.isNative() || m.isAbstract() || (code == null))
+ return m;
+
+ /* Create instruction list to be inserted at method start.
+ */
+ String mesg = "Hello from " + Utility.methodSignatureToString(m.getSignature(),
+ name,
+ Utility.accessToString(flags));
+ InstructionList patch = new InstructionList();
+ patch.append(new GETSTATIC(out));
+ patch.append(new PUSH(cp, mesg));
+ patch.append(new INVOKEVIRTUAL(println));
+
+ MethodGen mg = new MethodGen(m, class_name, cp);
+ InstructionList il = mg.getInstructionList();
+ InstructionHandle[] ihs = il.getInstructionHandles();
+
+ if(name.equals("<init>")) { // First let the super or other constructor be called
+ for(int j=1; j < ihs.length; j++) {
+ if(ihs[j].getInstruction() instanceof INVOKESPECIAL) {
+ il.append(ihs[j], patch); // Should check: method name == "<init>"
+ break;
+ }
+ }
+ } 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);
+
+ m = mg.getMethod();
+
+ il.dispose(); // Reuse instruction handles
+
+ return m;
+ }
+}
diff --git a/examples/id.java b/examples/id.java
new file mode 100644
index 00000000..13b83d9d
--- /dev/null
+++ b/examples/id.java
@@ -0,0 +1,47 @@
+import java.io.*;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.*;
+import org.apache.bcel.generic.*;
+
+/**
+ * Test BCEL if an input file is identical to the outfile generated
+ * with BCEL. Of course there may some small differences, e.g., because
+ * BCEL generates local variable tables by default.
+ *
+ * Try to:
+ * <pre>
+% java id <someclass>
+% java listclass -code <someclass> &gt; foo
+% java listclass -code <someclass>.clazz &gt; bar
+% diff foo bar | more
+ * <pre>
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A>
+ */
+public class id {
+ 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
+
+ ClassGen cg = new ClassGen(clazz);
+
+ Method[] methods = clazz.getMethods();
+
+ for(int i=0; i < methods.length; i++) {
+ MethodGen mg = new MethodGen(methods[i], cg.getClassName(), cg.getConstantPool());
+ cg.replaceMethod(methods[i], mg.getMethod());
+ }
+
+ Field[] fields = clazz.getFields();
+
+ for(int i=0; i < fields.length; i++) {
+ FieldGen fg = new FieldGen(fields[i], cg.getConstantPool());
+ cg.replaceField(fields[i], fg.getField());
+ }
+
+ cg.getJavaClass().dump(clazz.getClassName() + ".clazz");
+ }
+}
diff --git a/examples/listclass.java b/examples/listclass.java
new file mode 100644
index 00000000..049c755f
--- /dev/null
+++ b/examples/listclass.java
@@ -0,0 +1,225 @@
+import java.io.*;
+import java.util.*;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.*;
+
+/**
+ * Read class file(s) and display its contents. The command line usage is:
+ *
+ * <pre>java listclass [-constants] [-code] [-brief] [-dependencies] [-nocontents] [-recurse] class... [-exclude <list>]</pre>
+ * where
+ * <ul>
+ * <li><tt>-code</tt> List byte code of methods</li>
+ * <li><tt>-brief</tt> List byte codes briefly</li>
+ * <li><tt>-constants</tt> Print constants table (constant pool)</li>
+ * <li><tt>-recurse</tt> Usually intended to be used along with
+ * <tt>-dependencies</tt> When this flag is set, listclass will also print information
+ * about all classes which the target class depends on.</li>
+ *
+ * <li><tt>-dependencies</tt> Setting this flag makes listclass print a list of all
+ * classes which the target class depends on. Generated from getting all
+ * CONSTANT_Class constants from the constant pool.</li>
+ *
+ * <li><tt>-exclude</tt> All non-flag arguments after this flag are added to an
+ * 'exclusion list'. Target classes are compared with the members of the
+ * exclusion list. Any target class whose fully qualified name begins with a
+ * name in the exclusion list will not be analyzed/listed. This is meant
+ * primarily when using both <tt>-recurse</tt> to exclude java, javax, and sun classes,
+ * and is recommended as otherwise the output from <tt>-recurse</tt> gets quite long and
+ * most of it is not interesting. Note that <tt>-exclude</tt> prevents listing of
+ * classes, it does not prevent class names from being printed in the
+ * <tt>-dependencies</tt> list.</li>
+ * <li><tt>-nocontents</tt> Do not print JavaClass.toString() for the class. I added
+ * this because sometimes I'm only interested in dependency information.</li>
+ * </ul>
+ * <p>Here's a couple examples of how I typically use listclass:<br>
+ * <pre>java listclass -code MyClass</pre>
+ * Print information about the class and the byte code of the methods
+ * <pre>java listclass -nocontents -dependencies MyClass</pre>
+ * Print a list of all classes which MyClass depends on.
+ * <pre>java listclass -nocontents -recurse MyClass -exclude java. javax. sun.</pre>
+ * Print a recursive listing of all classes which MyClass depends on. Do not
+ * analyze classes beginning with "java.", "javax.", or "sun.".
+ * <pre>java listclass -nocontents -dependencies -recurse MyClass -exclude java.javax. sun.</pre>
+ * Print a recursive listing of dependency information for MyClass and its
+ * dependents. Do not analyze classes beginning with "java.", "javax.", or "sun."
+ * </p>
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.berlin.de/~markus.dahm">M. Dahm</A>,
+ * <a href="mailto:twheeler@objectspace.com">Thomas Wheeler</A>
+ */
+public class listclass {
+ boolean code, constants, verbose, classdep, nocontents, recurse;
+ Hashtable listedClasses;
+ Vector exclude_name;
+
+ public static void main(String[] argv) {
+ Vector file_name = new Vector();
+ Vector exclude_name = new Vector();
+ boolean code = false, constants=false, verbose=true, classdep=false,
+ nocontents=false, recurse=false, exclude=false;
+ String name = null;
+
+ /* Parse command line arguments.
+ */
+ 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")) {
+ System.out.println( "Usage: java listclass [-constants] [-code] [-brief] " +
+ "[-dependencies] [-nocontents] [-recurse] class... " +
+ "[-exclude <list>]\n" +
+ "-constants Print constants table (constant pool)\n" +
+ "-code Dump byte code of methods\n" +
+ "-brief Brief listing\n" +
+ "-dependencies Show class dependencies\n" +
+ "-nocontents Do not print field/method information\n" +
+ "-recurse Recurse into dependent classes\n" +
+ "-exclude <list> Do not list classes beginning with " +
+ "strings in <list>" );
+ System.exit( 0 );
+ } 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(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);
+
+ for(int i=0; i < file_name.size(); i++) {
+ name = (String) file_name.elementAt(i);
+
+ listClass.list(name);
+ }
+ }
+ }
+
+ public listclass(boolean code, boolean constants, boolean verbose, boolean classdep,
+ boolean nocontents, boolean recurse, Vector exclude_name)
+ {
+ this.code = code;
+ this.constants = constants;
+ this.verbose = verbose;
+ this.classdep = classdep;
+ this.nocontents = nocontents;
+ this.recurse = recurse;
+ this.listedClasses = new Hashtable();
+ this.exclude_name = exclude_name;
+ }
+
+ /** Print the given class on screen
+ */
+ public void list(String name) {
+ try {
+ JavaClass java_class;
+
+ 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;
+
+ if((java_class = Repository.lookupClass(name)) == null)
+ java_class = new ClassParser(name).parse(); // May throw IOException
+
+ if(nocontents)
+ System.out.println(java_class.getClassName());
+ else
+ System.out.println(java_class); // Dump the contents
+
+ if(constants) // Dump the constant pool ?
+ System.out.println(java_class.getConstantPool());
+
+ if(code) // Dump the method code ?
+ printCode(java_class.getMethods(), verbose);
+
+ 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]);
+ }
+ } catch(IOException e) {
+ System.out.println("Error loading class " + name + " (" + e.getMessage() + ")");
+ }
+ catch(Exception e) {
+ System.out.println("Error processing class " + name + " (" + e.getMessage() + ")");
+ }
+ }
+
+ /**
+ * Dump the list of classes this class is dependent on
+ */
+ 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]);
+ }
+
+ public static String[] getClassDependencies(ConstantPool pool) {
+ String[] tempArray = new String[pool.getLength()];
+ int size = 0;
+ StringBuffer buf = new StringBuffer();
+
+ for(int idx = 0; idx < pool.getLength(); idx++) {
+ Constant c = pool.getConstant(idx);
+ if(c != null && c.getTag() == Constants.CONSTANT_Class) {
+ ConstantUtf8 c1 = (ConstantUtf8) pool.getConstant(((ConstantClass)c).getNameIndex());
+ buf.setLength(0);
+ buf.append(new String(c1.getBytes()));
+ for(int n = 0; n < buf.length(); n++) {
+ if(buf.charAt(n) == '/')
+ buf.setCharAt(n, '.');
+ }
+
+ tempArray[size++] = buf.toString();
+ }
+ }
+
+ String[] dependencies = new String[size];
+ System.arraycopy(tempArray, 0, dependencies, 0, size);
+ return dependencies;
+ }
+
+ /**
+ * Dump the disassembled code of all methods in the class.
+ */
+ public static void printCode(Method[] methods, boolean verbose) {
+ for(int i=0; i < methods.length; i++) {
+ System.out.println(methods[i]);
+
+ Code code = methods[i].getCode();
+ if(code != null)
+ System.out.println(code.toString(verbose));
+ }
+ }
+}
diff --git a/examples/maxstack.java b/examples/maxstack.java
new file mode 100644
index 00000000..4f62b517
--- /dev/null
+++ b/examples/maxstack.java
@@ -0,0 +1,61 @@
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.generic.*;
+import org.apache.bcel.Constants;
+import org.apache.bcel.*;
+
+/**
+ * Read class file(s) and examine all of its methods, determining the
+ * maximum stack depth used by analyzing control flow.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A>
+ */
+public final class maxstack {
+ public static void main(String[] argv) {
+ try {
+ for(int i = 0; i < argv.length; i++) {
+ 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();
+
+ ConstantPoolGen cp = new ConstantPoolGen(java_class.getConstantPool());
+ Method[] methods = java_class.getMethods();
+
+ for(int j = 0; j < methods.length; j++) {
+ Method m = methods[j];
+
+ if(!(m.isAbstract() || m.isNative())) {
+ MethodGen mg = new MethodGen(m, argv[i], cp);
+
+ int compiled_stack = mg.getMaxStack();
+ int compiled_locals = mg.getMaxLocals();
+ mg.setMaxStack(); // Recompute value
+ mg.setMaxLocals();
+ int computed_stack = mg.getMaxStack();
+ int computed_locals = mg.getMaxLocals();
+
+ mg.getInstructionList().dispose(); // Reuse instruction handles
+
+ 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_locals == compiled_locals)
+ System.out.println("Locals ok(" + computed_locals + ")");
+ else
+ System.out.println("\nCompiled locals " + compiled_locals +
+ " computed size " + computed_locals);
+ }
+ }
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/examples/patchclass.java b/examples/patchclass.java
new file mode 100644
index 00000000..a56c2a5c
--- /dev/null
+++ b/examples/patchclass.java
@@ -0,0 +1,90 @@
+import java.io.*;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.Constants;
+
+/**
+ * Patch all Utf8 constants in the given class file <em>file</em>.class
+ * and save the result in _<em>file</em>.class.
+ *
+ * Usage: patch <oldstring> <newstring> files
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A>
+ */
+public class patchclass {
+ public static void main(String[] argv) {
+ String[] file_name = new String[argv.length];
+ int files = 0;
+ ClassParser parser = null;
+ JavaClass java_class;
+
+ if(argv.length < 3) {
+ System.err.println("Usage: patch <oldstring> <newstring> file1.class ...");
+ System.exit(-1);
+ }
+
+ try {
+ 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]);
+ java_class = parser.parse();
+
+ patchIt(argv[0], argv[1],
+ java_class.getConstantPool().getConstantPool());
+
+ // Dump the changed class to a new file
+ java_class.dump("_" + file_name[i]);
+ System.out.println("Results saved in: _" + file_name[i]);
+ }
+ } catch(Exception e) {
+ System.err.println(e);
+ }
+ }
+ /*
+ * Replace all occurences of string "<em>old</em>" with
+ * "<em>replacement</em>" in all Utf8 constants
+ */
+ private static void patchIt(String old, String replacement,
+ Constant[] constant_pool)
+ {
+ ConstantUtf8 c;
+ String str;
+ int index, old_index;
+ StringBuffer buf;
+
+ /* Loop through constant pool
+ */
+ for(short i=0; i < constant_pool.length; i++) {
+ if(constant_pool[i] instanceof ConstantUtf8) { // Utf8 string found
+ try {
+ c = (ConstantUtf8)constant_pool[i]; // Get the string
+ str = c.getBytes();
+
+ if((index = str.indexOf(old)) != -1) { // `old' found in str
+ buf = new StringBuffer(); // target buffer
+ old_index = 0; // String start offset
+
+ // While we have something to replace
+ while((index = str.indexOf(old, old_index)) != -1) {
+ buf.append(str.substring(old_index, index)); // append prefix
+ buf.append(replacement); // append `replacement'
+
+ old_index = index + old.length(); // Skip `old'.length chars
+ }
+
+ buf.append(str.substring(old_index)); // append rest of string
+ str = buf.toString();
+
+ // Finally push the new string back to the constant pool
+ c = new ConstantUtf8(str);
+ constant_pool[i] = c;
+ }
+ } catch(StringIndexOutOfBoundsException e) { // Should not occur
+ System.err.println(e);
+ }
+ }
+ }
+ }
+}
diff --git a/lib/CCK.jar b/lib/CCK.jar
new file mode 100644
index 00000000..ee54a18c
--- /dev/null
+++ b/lib/CCK.jar
Binary files differ
diff --git a/lib/Regex.jar b/lib/Regex.jar
new file mode 100644
index 00000000..713441c5
--- /dev/null
+++ b/lib/Regex.jar
Binary files differ
diff --git a/src/java/org/apache/bcel/Constants.java b/src/java/org/apache/bcel/Constants.java
new file mode 100644
index 00000000..cab86336
--- /dev/null
+++ b/src/java/org/apache/bcel/Constants.java
@@ -0,0 +1,768 @@
+package org.apache.bcel;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Constants for the project, mostly defined in the JVM specification.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public interface Constants {
+ /** Major and minor version of the code.
+ */
+ public final static short MAJOR_1_1 = 45;
+ public final static short MINOR_1_1 = 3;
+ public final static short MAJOR_1_2 = 46;
+ public final static short MINOR_1_2 = 0;
+ public final static short MAJOR_1_3 = 47;
+ public final static short MINOR_1_3 = 0;
+ public final static short MAJOR = MAJOR_1_1; // Defaults
+ public final static short MINOR = MINOR_1_1;
+
+ /** Maximum value for an unsigned short.
+ */
+ public final static int MAX_SHORT = 65535; // 2^16 - 1
+
+ /** Maximum value for an unsigned byte.
+ */
+ public final static int MAX_BYTE = 255; // 2^8 - 1
+
+ /** Access flags for classes, fields and methods.
+ */
+ public final static short ACC_PUBLIC = 0x0001;
+ public final static short ACC_PRIVATE = 0x0002;
+ public final static short ACC_PROTECTED = 0x0004;
+ public final static short ACC_STATIC = 0x0008;
+
+ public final static short ACC_FINAL = 0x0010;
+ public final static short ACC_SYNCHRONIZED = 0x0020;
+ public final static short ACC_VOLATILE = 0x0040;
+ public final static short ACC_TRANSIENT = 0x0080;
+
+ public final static short ACC_NATIVE = 0x0100;
+ public final static short ACC_INTERFACE = 0x0200;
+ public final static short ACC_ABSTRACT = 0x0400;
+ public final static short ACC_STRICT = 0x0800;
+
+ // Applies to classes compiled by new compilers only
+ public final static short ACC_SUPER = 0x0020;
+
+ public final static short MAX_ACC_FLAG = ACC_ABSTRACT;
+
+ public final static String[] ACCESS_NAMES = {
+ "public", "private", "protected", "static", "final", "synchronized",
+ "volatile", "transient", "native", "interface", "abstract"
+ };
+
+ /** Tags in constant pool to denote type of constant.
+ */
+ public final static byte CONSTANT_Utf8 = 1;
+ public final static byte CONSTANT_Integer = 3;
+ public final static byte CONSTANT_Float = 4;
+ public final static byte CONSTANT_Long = 5;
+ public final static byte CONSTANT_Double = 6;
+ public final static byte CONSTANT_Class = 7;
+ public final static byte CONSTANT_Fieldref = 9;
+ public final static byte CONSTANT_String = 8;
+ public final static byte CONSTANT_Methodref = 10;
+ public final static byte CONSTANT_InterfaceMethodref = 11;
+ public final static byte CONSTANT_NameAndType = 12;
+
+ public final static String[] CONSTANT_NAMES = {
+ "", "CONSTANT_Utf8", "", "CONSTANT_Integer",
+ "CONSTANT_Float", "CONSTANT_Long", "CONSTANT_Double",
+ "CONSTANT_Class", "CONSTANT_String", "CONSTANT_Fieldref",
+ "CONSTANT_Methodref", "CONSTANT_InterfaceMethodref",
+ "CONSTANT_NameAndType" };
+
+ /** The name of the static initializer, also called &quot;class
+ * initialization method&quot; or &quot;interface initialization
+ * method&quot;. This is &quot;&lt;clinit&gt;&quot;.
+ */
+ public final static String STATIC_INITIALIZER_NAME = "<clinit>";
+
+ /** The name of every constructor method in a class, also called
+ * &quot;instance initialization method&quot;. This is &quot;&lt;init&gt;&quot;.
+ */
+ public final static String CONSTRUCTOR_NAME = "<init>";
+
+ /** The names of the interfaces implemented by arrays */
+ public final static String[] INTERFACES_IMPLEMENTED_BY_ARRAYS = {"java.lang.Cloneable", "java.io.Serializable"};
+
+ /**
+ * Limitations of the Java Virtual Machine.
+ * See The Java Virtual Machine Specification, Second Edition, page 152, chapter 4.10.
+ */
+ public static final int MAX_CP_ENTRIES = 65535;
+ public static final int MAX_CODE_SIZE = 65536; //bytes
+
+ /** Java VM opcodes.
+ */
+ public static final short NOP = 0;
+ public static final short ACONST_NULL = 1;
+ public static final short ICONST_M1 = 2;
+ public static final short ICONST_0 = 3;
+ public static final short ICONST_1 = 4;
+ public static final short ICONST_2 = 5;
+ public static final short ICONST_3 = 6;
+ public static final short ICONST_4 = 7;
+ public static final short ICONST_5 = 8;
+ public static final short LCONST_0 = 9;
+ public static final short LCONST_1 = 10;
+ public static final short FCONST_0 = 11;
+ public static final short FCONST_1 = 12;
+ public static final short FCONST_2 = 13;
+ public static final short DCONST_0 = 14;
+ public static final short DCONST_1 = 15;
+ public static final short BIPUSH = 16;
+ public static final short SIPUSH = 17;
+ public static final short LDC = 18;
+ public static final short LDC_W = 19;
+ public static final short LDC2_W = 20;
+ public static final short ILOAD = 21;
+ public static final short LLOAD = 22;
+ public static final short FLOAD = 23;
+ public static final short DLOAD = 24;
+ public static final short ALOAD = 25;
+ public static final short ILOAD_0 = 26;
+ public static final short ILOAD_1 = 27;
+ public static final short ILOAD_2 = 28;
+ public static final short ILOAD_3 = 29;
+ public static final short LLOAD_0 = 30;
+ public static final short LLOAD_1 = 31;
+ public static final short LLOAD_2 = 32;
+ public static final short LLOAD_3 = 33;
+ public static final short FLOAD_0 = 34;
+ public static final short FLOAD_1 = 35;
+ public static final short FLOAD_2 = 36;
+ public static final short FLOAD_3 = 37;
+ public static final short DLOAD_0 = 38;
+ public static final short DLOAD_1 = 39;
+ public static final short DLOAD_2 = 40;
+ public static final short DLOAD_3 = 41;
+ public static final short ALOAD_0 = 42;
+ public static final short ALOAD_1 = 43;
+ public static final short ALOAD_2 = 44;
+ public static final short ALOAD_3 = 45;
+ public static final short IALOAD = 46;
+ public static final short LALOAD = 47;
+ public static final short FALOAD = 48;
+ public static final short DALOAD = 49;
+ public static final short AALOAD = 50;
+ public static final short BALOAD = 51;
+ public static final short CALOAD = 52;
+ public static final short SALOAD = 53;
+ public static final short ISTORE = 54;
+ public static final short LSTORE = 55;
+ public static final short FSTORE = 56;
+ public static final short DSTORE = 57;
+ public static final short ASTORE = 58;
+ public static final short ISTORE_0 = 59;
+ public static final short ISTORE_1 = 60;
+ public static final short ISTORE_2 = 61;
+ public static final short ISTORE_3 = 62;
+ public static final short LSTORE_0 = 63;
+ public static final short LSTORE_1 = 64;
+ public static final short LSTORE_2 = 65;
+ public static final short LSTORE_3 = 66;
+ public static final short FSTORE_0 = 67;
+ public static final short FSTORE_1 = 68;
+ public static final short FSTORE_2 = 69;
+ public static final short FSTORE_3 = 70;
+ public static final short DSTORE_0 = 71;
+ public static final short DSTORE_1 = 72;
+ public static final short DSTORE_2 = 73;
+ public static final short DSTORE_3 = 74;
+ public static final short ASTORE_0 = 75;
+ public static final short ASTORE_1 = 76;
+ public static final short ASTORE_2 = 77;
+ public static final short ASTORE_3 = 78;
+ public static final short IASTORE = 79;
+ public static final short LASTORE = 80;
+ public static final short FASTORE = 81;
+ public static final short DASTORE = 82;
+ public static final short AASTORE = 83;
+ public static final short BASTORE = 84;
+ public static final short CASTORE = 85;
+ public static final short SASTORE = 86;
+ public static final short POP = 87;
+ public static final short POP2 = 88;
+ public static final short DUP = 89;
+ public static final short DUP_X1 = 90;
+ public static final short DUP_X2 = 91;
+ public static final short DUP2 = 92;
+ public static final short DUP2_X1 = 93;
+ public static final short DUP2_X2 = 94;
+ public static final short SWAP = 95;
+ public static final short IADD = 96;
+ public static final short LADD = 97;
+ public static final short FADD = 98;
+ public static final short DADD = 99;
+ public static final short ISUB = 100;
+ public static final short LSUB = 101;
+ public static final short FSUB = 102;
+ public static final short DSUB = 103;
+ public static final short IMUL = 104;
+ public static final short LMUL = 105;
+ public static final short FMUL = 106;
+ public static final short DMUL = 107;
+ public static final short IDIV = 108;
+ public static final short LDIV = 109;
+ public static final short FDIV = 110;
+ public static final short DDIV = 111;
+ public static final short IREM = 112;
+ public static final short LREM = 113;
+ public static final short FREM = 114;
+ public static final short DREM = 115;
+ public static final short INEG = 116;
+ public static final short LNEG = 117;
+ public static final short FNEG = 118;
+ public static final short DNEG = 119;
+ public static final short ISHL = 120;
+ public static final short LSHL = 121;
+ public static final short ISHR = 122;
+ public static final short LSHR = 123;
+ public static final short IUSHR = 124;
+ public static final short LUSHR = 125;
+ public static final short IAND = 126;
+ public static final short LAND = 127;
+ public static final short IOR = 128;
+ public static final short LOR = 129;
+ public static final short IXOR = 130;
+ public static final short LXOR = 131;
+ public static final short IINC = 132;
+ public static final short I2L = 133;
+ public static final short I2F = 134;
+ public static final short I2D = 135;
+ public static final short L2I = 136;
+ public static final short L2F = 137;
+ public static final short L2D = 138;
+ public static final short F2I = 139;
+ public static final short F2L = 140;
+ public static final short F2D = 141;
+ public static final short D2I = 142;
+ public static final short D2L = 143;
+ public static final short D2F = 144;
+ public static final short I2B = 145;
+ public static final short INT2BYTE = 145; // Old notion
+ public static final short I2C = 146;
+ public static final short INT2CHAR = 146; // Old notion
+ public static final short I2S = 147;
+ public static final short INT2SHORT = 147; // Old notion
+ public static final short LCMP = 148;
+ public static final short FCMPL = 149;
+ public static final short FCMPG = 150;
+ public static final short DCMPL = 151;
+ public static final short DCMPG = 152;
+ public static final short IFEQ = 153;
+ public static final short IFNE = 154;
+ public static final short IFLT = 155;
+ public static final short IFGE = 156;
+ public static final short IFGT = 157;
+ public static final short IFLE = 158;
+ public static final short IF_ICMPEQ = 159;
+ public static final short IF_ICMPNE = 160;
+ public static final short IF_ICMPLT = 161;
+ public static final short IF_ICMPGE = 162;
+ public static final short IF_ICMPGT = 163;
+ public static final short IF_ICMPLE = 164;
+ public static final short IF_ACMPEQ = 165;
+ public static final short IF_ACMPNE = 166;
+ public static final short GOTO = 167;
+ public static final short JSR = 168;
+ public static final short RET = 169;
+ public static final short TABLESWITCH = 170;
+ public static final short LOOKUPSWITCH = 171;
+ public static final short IRETURN = 172;
+ public static final short LRETURN = 173;
+ public static final short FRETURN = 174;
+ public static final short DRETURN = 175;
+ public static final short ARETURN = 176;
+ public static final short RETURN = 177;
+ public static final short GETSTATIC = 178;
+ public static final short PUTSTATIC = 179;
+ public static final short GETFIELD = 180;
+ public static final short PUTFIELD = 181;
+ public static final short INVOKEVIRTUAL = 182;
+ public static final short INVOKESPECIAL = 183;
+ public static final short INVOKENONVIRTUAL = 183; // Old name in JDK 1.0
+ public static final short INVOKESTATIC = 184;
+ public static final short INVOKEINTERFACE = 185;
+ public static final short NEW = 187;
+ public static final short NEWARRAY = 188;
+ public static final short ANEWARRAY = 189;
+ public static final short ARRAYLENGTH = 190;
+ public static final short ATHROW = 191;
+ public static final short CHECKCAST = 192;
+ public static final short INSTANCEOF = 193;
+ public static final short MONITORENTER = 194;
+ public static final short MONITOREXIT = 195;
+ public static final short WIDE = 196;
+ public static final short MULTIANEWARRAY = 197;
+ public static final short IFNULL = 198;
+ public static final short IFNONNULL = 199;
+ public static final short GOTO_W = 200;
+ public static final short JSR_W = 201;
+
+ /**
+ * Non-legal opcodes, may be used by JVM internally.
+ */
+ public static final short BREAKPOINT = 202;
+ public static final short LDC_QUICK = 203;
+ public static final short LDC_W_QUICK = 204;
+ public static final short LDC2_W_QUICK = 205;
+ public static final short GETFIELD_QUICK = 206;
+ public static final short PUTFIELD_QUICK = 207;
+ public static final short GETFIELD2_QUICK = 208;
+ public static final short PUTFIELD2_QUICK = 209;
+ public static final short GETSTATIC_QUICK = 210;
+ public static final short PUTSTATIC_QUICK = 211;
+ public static final short GETSTATIC2_QUICK = 212;
+ public static final short PUTSTATIC2_QUICK = 213;
+ public static final short INVOKEVIRTUAL_QUICK = 214;
+ public static final short INVOKENONVIRTUAL_QUICK = 215;
+ public static final short INVOKESUPER_QUICK = 216;
+ public static final short INVOKESTATIC_QUICK = 217;
+ public static final short INVOKEINTERFACE_QUICK = 218;
+ public static final short INVOKEVIRTUALOBJECT_QUICK = 219;
+ public static final short NEW_QUICK = 221;
+ public static final short ANEWARRAY_QUICK = 222;
+ public static final short MULTIANEWARRAY_QUICK = 223;
+ public static final short CHECKCAST_QUICK = 224;
+ public static final short INSTANCEOF_QUICK = 225;
+ public static final short INVOKEVIRTUAL_QUICK_W = 226;
+ public static final short GETFIELD_QUICK_W = 227;
+ public static final short PUTFIELD_QUICK_W = 228;
+ public static final short IMPDEP1 = 254;
+ public static final short IMPDEP2 = 255;
+
+ /**
+ * For internal purposes only.
+ */
+ public static final short PUSH = 4711;
+ public static final short SWITCH = 4712;
+
+ /**
+ * Illegal codes
+ */
+ public static final short UNDEFINED = -1;
+ public static final short UNPREDICTABLE = -2;
+ public static final short RESERVED = -3;
+ public static final String ILLEGAL_OPCODE = "<illegal opcode>";
+ public static final String ILLEGAL_TYPE = "<illegal type>";
+
+ public static final byte T_BOOLEAN = 4;
+ public static final byte T_CHAR = 5;
+ public static final byte T_FLOAT = 6;
+ public static final byte T_DOUBLE = 7;
+ public static final byte T_BYTE = 8;
+ public static final byte T_SHORT = 9;
+ public static final byte T_INT = 10;
+ public static final byte T_LONG = 11;
+
+ public static final byte T_VOID = 12; // Non-standard
+ public static final byte T_ARRAY = 13;
+ public static final byte T_OBJECT = 14;
+ public static final byte T_REFERENCE = 14; // Deprecated
+ public static final byte T_UNKNOWN = 15;
+ public static final byte T_ADDRESS = 16;
+
+ public static final String[] TYPE_NAMES = {
+ ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE,
+ "boolean", "char", "float", "double", "byte", "short", "int", "long",
+ "void", "array", "object", "unknown" // Non-standard
+ };
+
+ public static final String[] SHORT_TYPE_NAMES = {
+ ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE,
+ "Z", "C", "F", "D", "B", "S", "I", "J",
+ "V", ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE
+ };
+
+ /**
+ * Number of byte code operands, i.e., number of bytes after the tag byte
+ * itself.
+ */
+ public static final short[] NO_OF_OPERANDS = {
+ 0/*nop*/, 0/*aconst_null*/, 0/*iconst_m1*/, 0/*iconst_0*/,
+ 0/*iconst_1*/, 0/*iconst_2*/, 0/*iconst_3*/, 0/*iconst_4*/,
+ 0/*iconst_5*/, 0/*lconst_0*/, 0/*lconst_1*/, 0/*fconst_0*/,
+ 0/*fconst_1*/, 0/*fconst_2*/, 0/*dconst_0*/, 0/*dconst_1*/,
+ 1/*bipush*/, 2/*sipush*/, 1/*ldc*/, 2/*ldc_w*/, 2/*ldc2_w*/,
+ 1/*iload*/, 1/*lload*/, 1/*fload*/, 1/*dload*/, 1/*aload*/,
+ 0/*iload_0*/, 0/*iload_1*/, 0/*iload_2*/, 0/*iload_3*/,
+ 0/*lload_0*/, 0/*lload_1*/, 0/*lload_2*/, 0/*lload_3*/,
+ 0/*fload_0*/, 0/*fload_1*/, 0/*fload_2*/, 0/*fload_3*/,
+ 0/*dload_0*/, 0/*dload_1*/, 0/*dload_2*/, 0/*dload_3*/,
+ 0/*aload_0*/, 0/*aload_1*/, 0/*aload_2*/, 0/*aload_3*/,
+ 0/*iaload*/, 0/*laload*/, 0/*faload*/, 0/*daload*/,
+ 0/*aaload*/, 0/*baload*/, 0/*caload*/, 0/*saload*/,
+ 1/*istore*/, 1/*lstore*/, 1/*fstore*/, 1/*dstore*/,
+ 1/*astore*/, 0/*istore_0*/, 0/*istore_1*/, 0/*istore_2*/,
+ 0/*istore_3*/, 0/*lstore_0*/, 0/*lstore_1*/, 0/*lstore_2*/,
+ 0/*lstore_3*/, 0/*fstore_0*/, 0/*fstore_1*/, 0/*fstore_2*/,
+ 0/*fstore_3*/, 0/*dstore_0*/, 0/*dstore_1*/, 0/*dstore_2*/,
+ 0/*dstore_3*/, 0/*astore_0*/, 0/*astore_1*/, 0/*astore_2*/,
+ 0/*astore_3*/, 0/*iastore*/, 0/*lastore*/, 0/*fastore*/,
+ 0/*dastore*/, 0/*aastore*/, 0/*bastore*/, 0/*castore*/,
+ 0/*sastore*/, 0/*pop*/, 0/*pop2*/, 0/*dup*/, 0/*dup_x1*/,
+ 0/*dup_x2*/, 0/*dup2*/, 0/*dup2_x1*/, 0/*dup2_x2*/, 0/*swap*/,
+ 0/*iadd*/, 0/*ladd*/, 0/*fadd*/, 0/*dadd*/, 0/*isub*/,
+ 0/*lsub*/, 0/*fsub*/, 0/*dsub*/, 0/*imul*/, 0/*lmul*/,
+ 0/*fmul*/, 0/*dmul*/, 0/*idiv*/, 0/*ldiv*/, 0/*fdiv*/,
+ 0/*ddiv*/, 0/*irem*/, 0/*lrem*/, 0/*frem*/, 0/*drem*/,
+ 0/*ineg*/, 0/*lneg*/, 0/*fneg*/, 0/*dneg*/, 0/*ishl*/,
+ 0/*lshl*/, 0/*ishr*/, 0/*lshr*/, 0/*iushr*/, 0/*lushr*/,
+ 0/*iand*/, 0/*land*/, 0/*ior*/, 0/*lor*/, 0/*ixor*/, 0/*lxor*/,
+ 2/*iinc*/, 0/*i2l*/, 0/*i2f*/, 0/*i2d*/, 0/*l2i*/, 0/*l2f*/,
+ 0/*l2d*/, 0/*f2i*/, 0/*f2l*/, 0/*f2d*/, 0/*d2i*/, 0/*d2l*/,
+ 0/*d2f*/, 0/*i2b*/, 0/*i2c*/, 0/*i2s*/, 0/*lcmp*/, 0/*fcmpl*/,
+ 0/*fcmpg*/, 0/*dcmpl*/, 0/*dcmpg*/, 2/*ifeq*/, 2/*ifne*/,
+ 2/*iflt*/, 2/*ifge*/, 2/*ifgt*/, 2/*ifle*/, 2/*if_icmpeq*/,
+ 2/*if_icmpne*/, 2/*if_icmplt*/, 2/*if_icmpge*/, 2/*if_icmpgt*/,
+ 2/*if_icmple*/, 2/*if_acmpeq*/, 2/*if_acmpne*/, 2/*goto*/,
+ 2/*jsr*/, 1/*ret*/, UNPREDICTABLE/*tableswitch*/, UNPREDICTABLE/*lookupswitch*/,
+ 0/*ireturn*/, 0/*lreturn*/, 0/*freturn*/,
+ 0/*dreturn*/, 0/*areturn*/, 0/*return*/,
+ 2/*getstatic*/, 2/*putstatic*/, 2/*getfield*/,
+ 2/*putfield*/, 2/*invokevirtual*/, 2/*invokespecial*/, 2/*invokestatic*/,
+ 4/*invokeinterface*/, UNDEFINED, 2/*new*/,
+ 1/*newarray*/, 2/*anewarray*/,
+ 0/*arraylength*/, 0/*athrow*/, 2/*checkcast*/,
+ 2/*instanceof*/, 0/*monitorenter*/,
+ 0/*monitorexit*/, UNPREDICTABLE/*wide*/, 3/*multianewarray*/,
+ 2/*ifnull*/, 2/*ifnonnull*/, 4/*goto_w*/,
+ 4/*jsr_w*/, 0/*breakpoint*/, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, RESERVED/*impdep1*/, RESERVED/*impdep2*/
+ };
+
+ /**
+ * How the byte code operands are to be interpreted.
+ */
+ public static final short[][] TYPE_OF_OPERANDS = {
+ {}/*nop*/, {}/*aconst_null*/, {}/*iconst_m1*/, {}/*iconst_0*/,
+ {}/*iconst_1*/, {}/*iconst_2*/, {}/*iconst_3*/, {}/*iconst_4*/,
+ {}/*iconst_5*/, {}/*lconst_0*/, {}/*lconst_1*/, {}/*fconst_0*/,
+ {}/*fconst_1*/, {}/*fconst_2*/, {}/*dconst_0*/, {}/*dconst_1*/,
+ {T_BYTE}/*bipush*/, {T_SHORT}/*sipush*/, {T_BYTE}/*ldc*/,
+ {T_SHORT}/*ldc_w*/, {T_SHORT}/*ldc2_w*/,
+ {T_BYTE}/*iload*/, {T_BYTE}/*lload*/, {T_BYTE}/*fload*/,
+ {T_BYTE}/*dload*/, {T_BYTE}/*aload*/, {}/*iload_0*/,
+ {}/*iload_1*/, {}/*iload_2*/, {}/*iload_3*/, {}/*lload_0*/,
+ {}/*lload_1*/, {}/*lload_2*/, {}/*lload_3*/, {}/*fload_0*/,
+ {}/*fload_1*/, {}/*fload_2*/, {}/*fload_3*/, {}/*dload_0*/,
+ {}/*dload_1*/, {}/*dload_2*/, {}/*dload_3*/, {}/*aload_0*/,
+ {}/*aload_1*/, {}/*aload_2*/, {}/*aload_3*/, {}/*iaload*/,
+ {}/*laload*/, {}/*faload*/, {}/*daload*/, {}/*aaload*/,
+ {}/*baload*/, {}/*caload*/, {}/*saload*/, {T_BYTE}/*istore*/,
+ {T_BYTE}/*lstore*/, {T_BYTE}/*fstore*/, {T_BYTE}/*dstore*/,
+ {T_BYTE}/*astore*/, {}/*istore_0*/, {}/*istore_1*/,
+ {}/*istore_2*/, {}/*istore_3*/, {}/*lstore_0*/, {}/*lstore_1*/,
+ {}/*lstore_2*/, {}/*lstore_3*/, {}/*fstore_0*/, {}/*fstore_1*/,
+ {}/*fstore_2*/, {}/*fstore_3*/, {}/*dstore_0*/, {}/*dstore_1*/,
+ {}/*dstore_2*/, {}/*dstore_3*/, {}/*astore_0*/, {}/*astore_1*/,
+ {}/*astore_2*/, {}/*astore_3*/, {}/*iastore*/, {}/*lastore*/,
+ {}/*fastore*/, {}/*dastore*/, {}/*aastore*/, {}/*bastore*/,
+ {}/*castore*/, {}/*sastore*/, {}/*pop*/, {}/*pop2*/, {}/*dup*/,
+ {}/*dup_x1*/, {}/*dup_x2*/, {}/*dup2*/, {}/*dup2_x1*/,
+ {}/*dup2_x2*/, {}/*swap*/, {}/*iadd*/, {}/*ladd*/, {}/*fadd*/,
+ {}/*dadd*/, {}/*isub*/, {}/*lsub*/, {}/*fsub*/, {}/*dsub*/,
+ {}/*imul*/, {}/*lmul*/, {}/*fmul*/, {}/*dmul*/, {}/*idiv*/,
+ {}/*ldiv*/, {}/*fdiv*/, {}/*ddiv*/, {}/*irem*/, {}/*lrem*/,
+ {}/*frem*/, {}/*drem*/, {}/*ineg*/, {}/*lneg*/, {}/*fneg*/,
+ {}/*dneg*/, {}/*ishl*/, {}/*lshl*/, {}/*ishr*/, {}/*lshr*/,
+ {}/*iushr*/, {}/*lushr*/, {}/*iand*/, {}/*land*/, {}/*ior*/,
+ {}/*lor*/, {}/*ixor*/, {}/*lxor*/, {T_BYTE, T_BYTE}/*iinc*/,
+ {}/*i2l*/, {}/*i2f*/, {}/*i2d*/, {}/*l2i*/, {}/*l2f*/, {}/*l2d*/,
+ {}/*f2i*/, {}/*f2l*/, {}/*f2d*/, {}/*d2i*/, {}/*d2l*/, {}/*d2f*/,
+ {}/*i2b*/, {}/*i2c*/,{}/*i2s*/, {}/*lcmp*/, {}/*fcmpl*/,
+ {}/*fcmpg*/, {}/*dcmpl*/, {}/*dcmpg*/, {T_SHORT}/*ifeq*/,
+ {T_SHORT}/*ifne*/, {T_SHORT}/*iflt*/, {T_SHORT}/*ifge*/,
+ {T_SHORT}/*ifgt*/, {T_SHORT}/*ifle*/, {T_SHORT}/*if_icmpeq*/,
+ {T_SHORT}/*if_icmpne*/, {T_SHORT}/*if_icmplt*/,
+ {T_SHORT}/*if_icmpge*/, {T_SHORT}/*if_icmpgt*/,
+ {T_SHORT}/*if_icmple*/, {T_SHORT}/*if_acmpeq*/,
+ {T_SHORT}/*if_acmpne*/, {T_SHORT}/*goto*/, {T_SHORT}/*jsr*/,
+ {T_BYTE}/*ret*/, {}/*tableswitch*/, {}/*lookupswitch*/,
+ {}/*ireturn*/, {}/*lreturn*/, {}/*freturn*/, {}/*dreturn*/,
+ {}/*areturn*/, {}/*return*/, {T_SHORT}/*getstatic*/,
+ {T_SHORT}/*putstatic*/, {T_SHORT}/*getfield*/,
+ {T_SHORT}/*putfield*/, {T_SHORT}/*invokevirtual*/,
+ {T_SHORT}/*invokespecial*/, {T_SHORT}/*invokestatic*/,
+ {T_SHORT, T_BYTE, T_BYTE}/*invokeinterface*/, {},
+ {T_SHORT}/*new*/, {T_BYTE}/*newarray*/,
+ {T_SHORT}/*anewarray*/, {}/*arraylength*/, {}/*athrow*/,
+ {T_SHORT}/*checkcast*/, {T_SHORT}/*instanceof*/,
+ {}/*monitorenter*/, {}/*monitorexit*/, {T_BYTE}/*wide*/,
+ {T_SHORT, T_BYTE}/*multianewarray*/, {T_SHORT}/*ifnull*/,
+ {T_SHORT}/*ifnonnull*/, {T_INT}/*goto_w*/, {T_INT}/*jsr_w*/,
+ {}/*breakpoint*/, {}, {}, {}, {}, {}, {}, {},
+ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {},
+ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {},
+ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {},
+ {}/*impdep1*/, {}/*impdep2*/
+ };
+
+ /**
+ * Names of opcodes.
+ */
+ public static final String[] OPCODE_NAMES = {
+ "nop", "aconst_null", "iconst_m1", "iconst_0", "iconst_1",
+ "iconst_2", "iconst_3", "iconst_4", "iconst_5", "lconst_0",
+ "lconst_1", "fconst_0", "fconst_1", "fconst_2", "dconst_0",
+ "dconst_1", "bipush", "sipush", "ldc", "ldc_w", "ldc2_w", "iload",
+ "lload", "fload", "dload", "aload", "iload_0", "iload_1", "iload_2",
+ "iload_3", "lload_0", "lload_1", "lload_2", "lload_3", "fload_0",
+ "fload_1", "fload_2", "fload_3", "dload_0", "dload_1", "dload_2",
+ "dload_3", "aload_0", "aload_1", "aload_2", "aload_3", "iaload",
+ "laload", "faload", "daload", "aaload", "baload", "caload", "saload",
+ "istore", "lstore", "fstore", "dstore", "astore", "istore_0",
+ "istore_1", "istore_2", "istore_3", "lstore_0", "lstore_1",
+ "lstore_2", "lstore_3", "fstore_0", "fstore_1", "fstore_2",
+ "fstore_3", "dstore_0", "dstore_1", "dstore_2", "dstore_3",
+ "astore_0", "astore_1", "astore_2", "astore_3", "iastore", "lastore",
+ "fastore", "dastore", "aastore", "bastore", "castore", "sastore",
+ "pop", "pop2", "dup", "dup_x1", "dup_x2", "dup2", "dup2_x1",
+ "dup2_x2", "swap", "iadd", "ladd", "fadd", "dadd", "isub", "lsub",
+ "fsub", "dsub", "imul", "lmul", "fmul", "dmul", "idiv", "ldiv",
+ "fdiv", "ddiv", "irem", "lrem", "frem", "drem", "ineg", "lneg",
+ "fneg", "dneg", "ishl", "lshl", "ishr", "lshr", "iushr", "lushr",
+ "iand", "land", "ior", "lor", "ixor", "lxor", "iinc", "i2l", "i2f",
+ "i2d", "l2i", "l2f", "l2d", "f2i", "f2l", "f2d", "d2i", "d2l", "d2f",
+ "i2b", "i2c", "i2s", "lcmp", "fcmpl", "fcmpg",
+ "dcmpl", "dcmpg", "ifeq", "ifne", "iflt", "ifge", "ifgt", "ifle",
+ "if_icmpeq", "if_icmpne", "if_icmplt", "if_icmpge", "if_icmpgt",
+ "if_icmple", "if_acmpeq", "if_acmpne", "goto", "jsr", "ret",
+ "tableswitch", "lookupswitch", "ireturn", "lreturn", "freturn",
+ "dreturn", "areturn", "return", "getstatic", "putstatic", "getfield",
+ "putfield", "invokevirtual", "invokespecial", "invokestatic",
+ "invokeinterface", ILLEGAL_OPCODE, "new", "newarray", "anewarray",
+ "arraylength", "athrow", "checkcast", "instanceof", "monitorenter",
+ "monitorexit", "wide", "multianewarray", "ifnull", "ifnonnull",
+ "goto_w", "jsr_w", "breakpoint", ILLEGAL_OPCODE, ILLEGAL_OPCODE,
+ ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
+ ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
+ ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
+ ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
+ ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
+ ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
+ ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
+ ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
+ ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
+ ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
+ ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
+ ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
+ ILLEGAL_OPCODE, "impdep1", "impdep2"
+ };
+
+ /**
+ * Number of words consumed on operand stack by instructions.
+ */
+ public static final int[] CONSUME_STACK = {
+ 0/*nop*/, 0/*aconst_null*/, 0/*iconst_m1*/, 0/*iconst_0*/, 0/*iconst_1*/,
+ 0/*iconst_2*/, 0/*iconst_3*/, 0/*iconst_4*/, 0/*iconst_5*/, 0/*lconst_0*/,
+ 0/*lconst_1*/, 0/*fconst_0*/, 0/*fconst_1*/, 0/*fconst_2*/, 0/*dconst_0*/,
+ 0/*dconst_1*/, 0/*bipush*/, 0/*sipush*/, 0/*ldc*/, 0/*ldc_w*/, 0/*ldc2_w*/, 0/*iload*/,
+ 0/*lload*/, 0/*fload*/, 0/*dload*/, 0/*aload*/, 0/*iload_0*/, 0/*iload_1*/, 0/*iload_2*/,
+ 0/*iload_3*/, 0/*lload_0*/, 0/*lload_1*/, 0/*lload_2*/, 0/*lload_3*/, 0/*fload_0*/,
+ 0/*fload_1*/, 0/*fload_2*/, 0/*fload_3*/, 0/*dload_0*/, 0/*dload_1*/, 0/*dload_2*/,
+ 0/*dload_3*/, 0/*aload_0*/, 0/*aload_1*/, 0/*aload_2*/, 0/*aload_3*/, 2/*iaload*/,
+ 2/*laload*/, 2/*faload*/, 2/*daload*/, 2/*aaload*/, 2/*baload*/, 2/*caload*/, 2/*saload*/,
+ 1/*istore*/, 2/*lstore*/, 1/*fstore*/, 2/*dstore*/, 1/*astore*/, 1/*istore_0*/,
+ 1/*istore_1*/, 1/*istore_2*/, 1/*istore_3*/, 2/*lstore_0*/, 2/*lstore_1*/,
+ 2/*lstore_2*/, 2/*lstore_3*/, 1/*fstore_0*/, 1/*fstore_1*/, 1/*fstore_2*/,
+ 1/*fstore_3*/, 2/*dstore_0*/, 2/*dstore_1*/, 2/*dstore_2*/, 2/*dstore_3*/,
+ 1/*astore_0*/, 1/*astore_1*/, 1/*astore_2*/, 1/*astore_3*/, 3/*iastore*/, 4/*lastore*/,
+ 3/*fastore*/, 4/*dastore*/, 3/*aastore*/, 3/*bastore*/, 3/*castore*/, 3/*sastore*/,
+ 1/*pop*/, 2/*pop2*/, 1/*dup*/, 2/*dup_x1*/, 3/*dup_x2*/, 2/*dup2*/, 3/*dup2_x1*/,
+ 4/*dup2_x2*/, 2/*swap*/, 2/*iadd*/, 4/*ladd*/, 2/*fadd*/, 4/*dadd*/, 2/*isub*/, 4/*lsub*/,
+ 2/*fsub*/, 4/*dsub*/, 2/*imul*/, 4/*lmul*/, 2/*fmul*/, 4/*dmul*/, 2/*idiv*/, 4/*ldiv*/,
+ 2/*fdiv*/, 4/*ddiv*/, 2/*irem*/, 4/*lrem*/, 2/*frem*/, 4/*drem*/, 1/*ineg*/, 2/*lneg*/,
+ 1/*fneg*/, 2/*dneg*/, 2/*ishl*/, 3/*lshl*/, 2/*ishr*/, 3/*lshr*/, 2/*iushr*/, 3/*lushr*/,
+ 2/*iand*/, 4/*land*/, 2/*ior*/, 4/*lor*/, 2/*ixor*/, 4/*lxor*/, 0/*iinc*/,
+ 1/*i2l*/, 1/*i2f*/, 1/*i2d*/, 2/*l2i*/, 2/*l2f*/, 2/*l2d*/, 1/*f2i*/, 1/*f2l*/,
+ 1/*f2d*/, 2/*d2i*/, 2/*d2l*/, 2/*d2f*/, 1/*i2b*/, 1/*i2c*/, 1/*i2s*/,
+ 4/*lcmp*/, 2/*fcmpl*/, 2/*fcmpg*/, 4/*dcmpl*/, 4/*dcmpg*/, 1/*ifeq*/, 1/*ifne*/,
+ 1/*iflt*/, 1/*ifge*/, 1/*ifgt*/, 1/*ifle*/, 2/*if_icmpeq*/, 2/*if_icmpne*/, 2/*if_icmplt*/,
+ 2 /*if_icmpge*/, 2/*if_icmpgt*/, 2/*if_icmple*/, 2/*if_acmpeq*/, 2/*if_acmpne*/,
+ 0/*goto*/, 0/*jsr*/, 0/*ret*/, 1/*tableswitch*/, 1/*lookupswitch*/, 1/*ireturn*/,
+ 2/*lreturn*/, 1/*freturn*/, 2/*dreturn*/, 1/*areturn*/, 0/*return*/, 0/*getstatic*/,
+ UNPREDICTABLE/*putstatic*/, 1/*getfield*/, UNPREDICTABLE/*putfield*/,
+ UNPREDICTABLE/*invokevirtual*/, UNPREDICTABLE/*invokespecial*/,
+ UNPREDICTABLE/*invokestatic*/,
+ UNPREDICTABLE/*invokeinterface*/, UNDEFINED, 0/*new*/, 1/*newarray*/, 1/*anewarray*/,
+ 1/*arraylength*/, 1/*athrow*/, 1/*checkcast*/, 1/*instanceof*/, 1/*monitorenter*/,
+ 1/*monitorexit*/, 0/*wide*/, UNPREDICTABLE/*multianewarray*/, 1/*ifnull*/, 1/*ifnonnull*/,
+ 0/*goto_w*/, 0/*jsr_w*/, 0/*breakpoint*/, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNPREDICTABLE/*impdep1*/, UNPREDICTABLE/*impdep2*/
+ };
+
+ /**
+ * Number of words produced onto operand stack by instructions.
+ */
+ public static final int[] PRODUCE_STACK = {
+ 0/*nop*/, 1/*aconst_null*/, 1/*iconst_m1*/, 1/*iconst_0*/, 1/*iconst_1*/,
+ 1/*iconst_2*/, 1/*iconst_3*/, 1/*iconst_4*/, 1/*iconst_5*/, 2/*lconst_0*/,
+ 2/*lconst_1*/, 1/*fconst_0*/, 1/*fconst_1*/, 1/*fconst_2*/, 2/*dconst_0*/,
+ 2/*dconst_1*/, 1/*bipush*/, 1/*sipush*/, 1/*ldc*/, 1/*ldc_w*/, 2/*ldc2_w*/, 1/*iload*/,
+ 2/*lload*/, 1/*fload*/, 2/*dload*/, 1/*aload*/, 1/*iload_0*/, 1/*iload_1*/, 1/*iload_2*/,
+ 1/*iload_3*/, 2/*lload_0*/, 2/*lload_1*/, 2/*lload_2*/, 2/*lload_3*/, 1/*fload_0*/,
+ 1/*fload_1*/, 1/*fload_2*/, 1/*fload_3*/, 2/*dload_0*/, 2/*dload_1*/, 2/*dload_2*/,
+ 2/*dload_3*/, 1/*aload_0*/, 1/*aload_1*/, 1/*aload_2*/, 1/*aload_3*/, 1/*iaload*/,
+ 2/*laload*/, 1/*faload*/, 2/*daload*/, 1/*aaload*/, 1/*baload*/, 1/*caload*/, 1/*saload*/,
+ 0/*istore*/, 0/*lstore*/, 0/*fstore*/, 0/*dstore*/, 0/*astore*/, 0/*istore_0*/,
+ 0/*istore_1*/, 0/*istore_2*/, 0/*istore_3*/, 0/*lstore_0*/, 0/*lstore_1*/,
+ 0/*lstore_2*/, 0/*lstore_3*/, 0/*fstore_0*/, 0/*fstore_1*/, 0/*fstore_2*/,
+ 0/*fstore_3*/, 0/*dstore_0*/, 0/*dstore_1*/, 0/*dstore_2*/, 0/*dstore_3*/,
+ 0/*astore_0*/, 0/*astore_1*/, 0/*astore_2*/, 0/*astore_3*/, 0/*iastore*/, 0/*lastore*/,
+ 0/*fastore*/, 0/*dastore*/, 0/*aastore*/, 0/*bastore*/, 0/*castore*/, 0/*sastore*/,
+ 0/*pop*/, 0/*pop2*/, 2/*dup*/, 3/*dup_x1*/, 4/*dup_x2*/, 4/*dup2*/, 5/*dup2_x1*/,
+ 6/*dup2_x2*/, 2/*swap*/, 1/*iadd*/, 2/*ladd*/, 1/*fadd*/, 2/*dadd*/, 1/*isub*/, 2/*lsub*/,
+ 1/*fsub*/, 2/*dsub*/, 1/*imul*/, 2/*lmul*/, 1/*fmul*/, 2/*dmul*/, 1/*idiv*/, 2/*ldiv*/,
+ 1/*fdiv*/, 2/*ddiv*/, 1/*irem*/, 2/*lrem*/, 1/*frem*/, 2/*drem*/, 1/*ineg*/, 2/*lneg*/,
+ 1/*fneg*/, 2/*dneg*/, 1/*ishl*/, 2/*lshl*/, 1/*ishr*/, 2/*lshr*/, 1/*iushr*/, 2/*lushr*/,
+ 1/*iand*/, 2/*land*/, 1/*ior*/, 2/*lor*/, 1/*ixor*/, 2/*lxor*/,
+ 0/*iinc*/, 2/*i2l*/, 1/*i2f*/, 2/*i2d*/, 1/*l2i*/, 1/*l2f*/, 2/*l2d*/, 1/*f2i*/,
+ 2/*f2l*/, 2/*f2d*/, 1/*d2i*/, 2/*d2l*/, 1/*d2f*/,
+ 1/*i2b*/, 1/*i2c*/, 1/*i2s*/, 1/*lcmp*/, 1/*fcmpl*/, 1/*fcmpg*/,
+ 1/*dcmpl*/, 1/*dcmpg*/, 0/*ifeq*/, 0/*ifne*/, 0/*iflt*/, 0/*ifge*/, 0/*ifgt*/, 0/*ifle*/,
+ 0/*if_icmpeq*/, 0/*if_icmpne*/, 0/*if_icmplt*/, 0/*if_icmpge*/, 0/*if_icmpgt*/,
+ 0/*if_icmple*/, 0/*if_acmpeq*/, 0/*if_acmpne*/, 0/*goto*/, 1/*jsr*/, 0/*ret*/,
+ 0/*tableswitch*/, 0/*lookupswitch*/, 0/*ireturn*/, 0/*lreturn*/, 0/*freturn*/,
+ 0/*dreturn*/, 0/*areturn*/, 0/*return*/, UNPREDICTABLE/*getstatic*/, 0/*putstatic*/,
+ UNPREDICTABLE/*getfield*/, 0/*putfield*/, UNPREDICTABLE/*invokevirtual*/,
+ UNPREDICTABLE/*invokespecial*/, UNPREDICTABLE/*invokestatic*/,
+ UNPREDICTABLE/*invokeinterface*/, UNDEFINED, 1/*new*/, 1/*newarray*/, 1/*anewarray*/,
+ 1/*arraylength*/, 1/*athrow*/, 1/*checkcast*/, 1/*instanceof*/, 0/*monitorenter*/,
+ 0/*monitorexit*/, 0/*wide*/, 1/*multianewarray*/, 0/*ifnull*/, 0/*ifnonnull*/,
+ 0/*goto_w*/, 1/*jsr_w*/, 0/*breakpoint*/, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+ UNDEFINED, UNPREDICTABLE/*impdep1*/, UNPREDICTABLE/*impdep2*/
+ };
+
+ /** Attributes and their corresponding names.
+ */
+ public static final byte ATTR_UNKNOWN = -1;
+ public static final byte ATTR_SOURCE_FILE = 0;
+ public static final byte ATTR_CONSTANT_VALUE = 1;
+ public static final byte ATTR_CODE = 2;
+ public static final byte ATTR_EXCEPTIONS = 3;
+ public static final byte ATTR_LINE_NUMBER_TABLE = 4;
+ public static final byte ATTR_LOCAL_VARIABLE_TABLE = 5;
+ public static final byte ATTR_INNER_CLASSES = 6;
+ public static final byte ATTR_SYNTHETIC = 7;
+ public static final byte ATTR_DEPRECATED = 8;
+ public static final byte ATTR_PMG = 9;
+ public static final byte ATTR_SIGNATURE = 10;
+ public static final byte ATTR_STACK_MAP = 11;
+
+ public static final short KNOWN_ATTRIBUTES = 12;
+
+ public static final String[] ATTRIBUTE_NAMES = {
+ "SourceFile", "ConstantValue", "Code", "Exceptions",
+ "LineNumberTable", "LocalVariableTable",
+ "InnerClasses", "Synthetic", "Deprecated",
+ "PMGClass", "Signature", "StackMap"
+ };
+
+ /** Constants used in the StackMap attribute.
+ */
+ public static final byte ITEM_Bogus = 0;
+ public static final byte ITEM_Integer = 1;
+ public static final byte ITEM_Float = 2;
+ public static final byte ITEM_Double = 3;
+ public static final byte ITEM_Long = 4;
+ public static final byte ITEM_Null = 5;
+ public static final byte ITEM_InitObject = 6;
+ public static final byte ITEM_Object = 7;
+ public static final byte ITEM_NewObject = 8;
+
+ public static final String[] ITEM_NAMES = {
+ "Bogus", "Integer", "Float", "Double", "Long",
+ "Null", "InitObject", "Object", "NewObject"
+ };
+}
diff --git a/src/java/org/apache/bcel/ExceptionConstants.java b/src/java/org/apache/bcel/ExceptionConstants.java
new file mode 100644
index 00000000..089bea55
--- /dev/null
+++ b/src/java/org/apache/bcel/ExceptionConstants.java
@@ -0,0 +1,123 @@
+package org.apache.bcel;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Exception constants.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase">E. Haase</A>
+ */
+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
+ };
+
+}
diff --git a/src/java/org/apache/bcel/Repository.java b/src/java/org/apache/bcel/Repository.java
new file mode 100644
index 00000000..5c502ea6
--- /dev/null
+++ b/src/java/org/apache/bcel/Repository.java
@@ -0,0 +1,295 @@
+package org.apache.bcel;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.util.*;
+import java.util.HashMap;
+import java.io.*;
+
+/**
+ * Repository maintains informations about class interdependencies, e.g.
+ * whether a class is a sub-class of another. JavaClass objects are put
+ * into a cache which can be purged with clearCache().
+ *
+ * All JavaClass objects used as arguments must have been obtained via
+ * the repository or been added with addClass() manually. This is
+ * because we have to check for object identity (==).
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A
+ */
+public abstract class Repository {
+ private static ClassPath class_path = new ClassPath();
+ private static HashMap classes;
+ private static JavaClass OBJECT; // should be final ...
+
+ static { clearCache(); }
+
+ /** @return class object for given fully qualified class name.
+ */
+ public static JavaClass lookupClass(String class_name) {
+ if(class_name == null || class_name.equals(""))
+ throw new RuntimeException("Invalid class name");
+
+ class_name = class_name.replace('/', '.');
+
+ JavaClass clazz = (JavaClass)classes.get(class_name);
+
+ if(clazz == null) {
+ try {
+ InputStream is = class_path.getInputStream(class_name);
+ clazz = new ClassParser(is, class_name).parse();
+ class_name = clazz.getClassName();
+ } catch(IOException e) { return null; }
+
+ classes.put(class_name, clazz);
+ }
+
+ return clazz;
+ }
+
+ /** @return class file object for given Java class.
+ */
+ public static ClassPath.ClassFile lookupClassFile(String class_name) {
+ try {
+ return class_path.getClassFile(class_name);
+ } catch(IOException e) { return null; }
+ }
+
+ /** Clear the repository.
+ */
+ public static void clearCache() {
+ classes = new HashMap();
+ OBJECT = lookupClass("java.lang.Object");
+
+ if(OBJECT == null)
+ System.err.println("Warning: java.lang.Object not found on CLASSPATH!");
+ else
+ classes.put("java.lang.Object", OBJECT);
+ }
+
+ /**
+ * 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) {
+ String name = clazz.getClassName();
+ JavaClass cl = (JavaClass)classes.get(name);
+
+ if(cl == null)
+ classes.put(name, cl = clazz);
+
+ return cl;
+ }
+
+ /**
+ * Remove class with given (fully qualifid) name from repository.
+ */
+ public static void removeClass(String clazz) {
+ classes.remove(clazz);
+ }
+
+ /**
+ * Remove given class from repository.
+ */
+ public static void removeClass(JavaClass clazz) {
+ removeClass(clazz.getClassName());
+ }
+
+
+ private static final JavaClass getSuperClass(JavaClass clazz) {
+ if(clazz == OBJECT)
+ return null;
+
+ return lookupClass(clazz.getSuperclassName());
+ }
+
+ /**
+ * @return list of super classes of clazz in ascending order, i.e.,
+ * Object is always the last element
+ */
+ public static JavaClass[] getSuperClasses(JavaClass clazz) {
+ ClassVector vec = new ClassVector();
+
+ for(clazz = getSuperClass(clazz); clazz != null; clazz = getSuperClass(clazz))
+ vec.addElement(clazz);
+
+ return vec.toArray();
+ }
+
+ /**
+ * @return list of super classes of clazz in ascending order, i.e.,
+ * Object is always the last element. "null", if clazz cannot be found.
+ */
+ public static JavaClass[] getSuperClasses(String class_name) {
+ JavaClass jc = lookupClass(class_name);
+ return (jc == null? null : getSuperClasses(jc));
+ }
+
+ /**
+ * @return all interfaces implemented by class and its super
+ * classes and the interfaces that those interfaces extend, and so on
+ */
+ public static JavaClass[] getInterfaces(JavaClass clazz) {
+ ClassVector vec = new ClassVector();
+ ClassQueue queue = new ClassQueue();
+
+ queue.enqueue(clazz);
+
+ while(!queue.empty()) {
+ clazz = queue.dequeue();
+
+ String s = clazz.getSuperclassName();
+ String[] interfaces = clazz.getInterfaceNames();
+
+ if(clazz.isInterface())
+ vec.addElement(clazz);
+ else if(!s.equals("java.lang.Object"))
+ queue.enqueue(lookupClass(s));
+
+ for(int i=0; i < interfaces.length; i++)
+ queue.enqueue(lookupClass(interfaces[i]));
+ }
+
+ return vec.toArray();
+ }
+
+ /**
+ * @return all interfaces implemented by class and its super
+ * classes and the interfaces that extend those interfaces, and so on
+ */
+ public static JavaClass[] getInterfaces(String class_name) {
+ return getInterfaces(lookupClass(class_name));
+ }
+
+ /**
+ * @return true, if clazz is an instance of super_class
+ */
+ public static boolean instanceOf(JavaClass clazz, JavaClass super_class) {
+ if(clazz == super_class)
+ return true;
+
+ JavaClass[] super_classes = getSuperClasses(clazz);
+
+ for(int i=0; i < super_classes.length; i++)
+ if(super_classes[i] == super_class)
+ return true;
+
+ if(super_class.isInterface())
+ return implementationOf(clazz, super_class);
+
+ return false;
+ }
+
+ /**
+ * @return true, if clazz is an instance of super_class
+ */
+ public static boolean instanceOf(String clazz, String super_class) {
+ return instanceOf(lookupClass(clazz), lookupClass(super_class));
+ }
+
+ /**
+ * @return true, if clazz is an instance of super_class
+ */
+ public static boolean instanceOf(JavaClass clazz, String super_class) {
+ return instanceOf(clazz, lookupClass(super_class));
+ }
+
+ /**
+ * @return true, if clazz is an instance of super_class
+ */
+ public static boolean instanceOf(String clazz, JavaClass super_class) {
+ return instanceOf(lookupClass(clazz), super_class);
+ }
+
+ /**
+ * @return true, if clazz is an implementation of interface inter
+ */
+ public static boolean implementationOf(JavaClass clazz, JavaClass inter) {
+ if(clazz == inter)
+ return true;
+
+ JavaClass[] super_interfaces = getInterfaces(clazz);
+
+ for(int i=0; i < super_interfaces.length; i++)
+ if(super_interfaces[i] == inter)
+ return true;
+
+ return false;
+ }
+
+ /**
+ * @return true, if clazz is an implementation of interface inter
+ */
+ public static boolean implementationOf(String clazz, String inter) {
+ return implementationOf(lookupClass(clazz), lookupClass(inter));
+ }
+
+ /**
+ * @return true, if clazz is an implementation of interface inter
+ */
+ public static boolean implementationOf(JavaClass clazz, String inter) {
+ return implementationOf(clazz, lookupClass(inter));
+ }
+
+ /**
+ * @return true, if clazz is an implementation of interface inter
+ */
+ public static boolean implementationOf(String clazz, JavaClass inter) {
+ return implementationOf(lookupClass(clazz), inter);
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/AccessFlags.java b/src/java/org/apache/bcel/classfile/AccessFlags.java
new file mode 100644
index 00000000..b909ae0f
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/AccessFlags.java
@@ -0,0 +1,159 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+
+/**
+ * Super class for all objects that have modifiers like private, final, ...
+ * I.e. classes, fields, and methods.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public abstract class AccessFlags {
+ protected int access_flags;
+
+ public AccessFlags() {}
+
+ /**
+ * @param a inital access flags
+ */
+ public AccessFlags(int a) {
+ access_flags = a;
+ }
+
+ /**
+ * @return Access flags of the object.
+ */
+ public final int getAccessFlags() { return access_flags; }
+
+ /**
+ * @param access_flags Access flags of the object.
+ */
+ public final void setAccessFlags(int access_flags) {
+ this.access_flags = 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;
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/Attribute.java b/src/java/org/apache/bcel/classfile/Attribute.java
new file mode 100644
index 00000000..5557fdd4
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/Attribute.java
@@ -0,0 +1,274 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * Abstract super class for <em>Attribute</em> objects. Currently the
+ * <em>ConstantValue</em>, <em>SourceFile</em>, <em>Code</em>,
+ * <em>Exceptiontable</em>, <em>LineNumberTable</em>,
+ * <em>LocalVariableTable</em>, <em>InnerClasses</em> and
+ * <em>Synthetic</em> attributes are supported. The
+ * <em>Unknown</em> attribute stands for non-standard-attributes.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see ConstantValue
+ * @see SourceFile
+ * @see Code
+ * @see Unknown
+ * @see ExceptionTable
+ * @see LineNumberTable
+ * @see LocalVariableTable
+ * @see InnerClasses
+ * @see Synthetic
+ * @see Deprecated
+*/
+public abstract class Attribute implements Cloneable, Node {
+ protected int name_index; // Points to attribute name in constant pool
+ protected int length; // Content length of attribute field
+ protected byte tag; // Tag to distiguish subclasses
+ protected ConstantPool constant_pool;
+
+ Attribute(byte tag, int name_index, int length, ConstantPool constant_pool) {
+ this.tag = tag;
+ this.name_index = name_index;
+ this.length = length;
+ 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 abstract void accept(Visitor v);
+
+ /**
+ * Dump attribute to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public void dump(DataOutputStream file) throws IOException
+ {
+ file.writeShort(name_index);
+ file.writeInt(length);
+ }
+
+ /* Class method reads one attribute from the input data stream.
+ * This method must not be accessible from the outside. It is
+ * called by the Field and Method constructor methods.
+ *
+ * @see Field
+ * @see Method
+ * @param file Input stream
+ * @param constant_pool Array of constants
+ * @return Attribute
+ * @throw IOException
+ * @throw ClassFormatError
+ * @throw InternalError
+ */
+ static final Attribute readAttribute(DataInputStream file,
+ ConstantPool constant_pool)
+ throws IOException, ClassFormatError, InternalError
+ {
+ ConstantUtf8 c;
+ String name;
+ int name_index;
+ int length;
+ byte tag = Constants.ATTR_UNKNOWN; // Unknown attribute
+
+ // Get class name from constant pool via `name_index' indirection
+ name_index = (int)(file.readUnsignedShort());
+ c = (ConstantUtf8)constant_pool.getConstant(name_index,
+ Constants.CONSTANT_Utf8);
+ name = c.getBytes();
+
+ // Length of data in bytes
+ length = file.readInt();
+
+ // Compare strings to find known attribute
+ for(byte i=0; i < Constants.KNOWN_ATTRIBUTES; i++) {
+ if(name.equals(Constants.ATTRIBUTE_NAMES[i])) {
+ tag = i; // found!
+ break;
+ }
+ }
+
+ // Call proper constructor, depending on `tag'
+ switch(tag) {
+ case Constants.ATTR_UNKNOWN:
+ return new Unknown(name_index, length, file, constant_pool);
+
+ case Constants.ATTR_CONSTANT_VALUE:
+ return new ConstantValue(name_index, length, file, constant_pool);
+
+ case Constants.ATTR_SOURCE_FILE:
+ return new SourceFile(name_index, length, file, constant_pool);
+
+ case Constants.ATTR_CODE:
+ return new Code(name_index, length, file, constant_pool);
+
+ case Constants.ATTR_EXCEPTIONS:
+ return new ExceptionTable(name_index, length, file, constant_pool);
+
+ case Constants.ATTR_LINE_NUMBER_TABLE:
+ return new LineNumberTable(name_index, length, file, constant_pool);
+
+ case Constants.ATTR_LOCAL_VARIABLE_TABLE:
+ return new LocalVariableTable(name_index, length, file, constant_pool);
+
+ case Constants.ATTR_INNER_CLASSES:
+ return new InnerClasses(name_index, length, file, constant_pool);
+
+ case Constants.ATTR_SYNTHETIC:
+ return new Synthetic(name_index, length, file, constant_pool);
+
+ case Constants.ATTR_DEPRECATED:
+ return new Deprecated(name_index, length, file, constant_pool);
+
+ case Constants.ATTR_PMG:
+ return new PMGClass(name_index, length, file, constant_pool);
+
+ case Constants.ATTR_SIGNATURE:
+ return new Signature(name_index, length, file, constant_pool);
+
+ case Constants.ATTR_STACK_MAP:
+ return new StackMap(name_index, length, file, constant_pool);
+
+ default: // Never reached
+ throw new InternalError("Ooops! default case reached.");
+ }
+ }
+
+ /**
+ * @return Length of attribute field in bytes.
+ */
+ public final int getLength() { return length; }
+
+ /**
+ * @param Attribute length in bytes.
+ */
+ public final void setLength(int length) {
+ this.length = length;
+ }
+
+ /**
+ * @param name_index of attribute.
+ */
+ public final void setNameIndex(int name_index) {
+ this.name_index = name_index;
+ }
+
+ /**
+ * @return Name index in constant pool of attribute name.
+ */
+ public final int getNameIndex() { return name_index; }
+
+ /**
+ * @return Tag of attribute, i.e., its type. Value may not be altered, thus
+ * there is no setTag() method.
+ */
+ public final byte getTag() { return tag; }
+
+ /**
+ * @return Constant pool used by this object.
+ * @see ConstantPool
+ */
+ public final ConstantPool getConstantPool() { return constant_pool; }
+
+ /**
+ * @param constant_pool Constant pool to be used for this object.
+ * @see ConstantPool
+ */
+ public final void setConstantPool(ConstantPool constant_pool) {
+ this.constant_pool = constant_pool;
+ }
+
+ /**
+ * Use copy() if you want to have a deep copy(), i.e., with all references
+ * copied correctly.
+ *
+ * @return shallow copy of this attribute
+ */
+ public Object clone() {
+ Object o = null;
+
+ try {
+ o = super.clone();
+ } catch(CloneNotSupportedException e) {
+ e.printStackTrace(); // Never occurs
+ }
+
+ return o;
+ }
+
+ /**
+ * @return deep copy of this attribute
+ */
+ public abstract Attribute copy(ConstantPool constant_pool);
+
+ /**
+ * @return attribute name.
+ */
+ public String toString() {
+ return Constants.ATTRIBUTE_NAMES[tag];
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/ClassParser.java b/src/java/org/apache/bcel/classfile/ClassParser.java
new file mode 100644
index 00000000..68801453
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/ClassParser.java
@@ -0,0 +1,329 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+import java.util.zip.*;
+
+/**
+ * Wrapper class that parses a given Java .class file. The method
+ * <A href ="#parse">parse</A> returns a
+ * <A href ="org.apache.bcel.classfile.JavaClass.html">
+ * JavaClass</A> object on success. When an I/O error or an
+ * inconsistency occurs an appropiate exception is propagated back
+ * to the caller.
+ *
+ * The structure and the names comply, except for a few conveniences,
+ * exactly with the <A href="ftp://java.sun.com/docs/specs/vmspec.ps">
+ * JVM specification 1.0</a>. See this paper for
+ * further details about the structure of a bytecode file.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public final class ClassParser {
+ private DataInputStream file;
+ private ZipFile zip;
+ private String file_name;
+ private int class_name_index, superclass_name_index;
+ private int major, minor; // Compiler version
+ private int access_flags; // Access rights of parsed class
+ private int[] interfaces; // Names of implemented interfaces
+ private ConstantPool constant_pool; // collection of constants
+ private Field[] fields; // class fields, i.e., its variables
+ private Method[] methods; // methods defined in the class
+ private Attribute[] attributes; // attributes defined in the class
+ private boolean is_zip; // Loaded from zip file
+
+ private static final int BUFSIZE = 8192;
+
+ /**
+ * Parse class from the given stream.
+ *
+ * @param file Input stream
+ * @param file_name File name
+ */
+ public ClassParser(InputStream file, String file_name) {
+ this.file_name = file_name;
+
+ String clazz = file.getClass().getName(); // Not a very clean solution ...
+ is_zip = clazz.startsWith("java.util.zip.") || clazz.startsWith("java.util.jar.");
+
+ if(file instanceof DataInputStream) // Is already a data stream
+ this.file = (DataInputStream)file;
+ else
+ this.file = new DataInputStream(new BufferedInputStream(file, BUFSIZE));
+ }
+
+ /** Parse class from given .class file.
+ *
+ * @param file_name file name
+ * @throw IOException
+ */
+ public ClassParser(String file_name) throws IOException
+ {
+ is_zip = false;
+ this.file_name = file_name;
+ file = new DataInputStream(new BufferedInputStream
+ (new FileInputStream(file_name), BUFSIZE));
+ }
+
+ /** Parse class from given .class file in a ZIP-archive
+ *
+ * @param file_name file name
+ * @throw IOException
+ */
+ public ClassParser(String zip_file, String file_name) throws IOException
+ {
+ is_zip = true;
+ zip = new ZipFile(zip_file);
+ ZipEntry entry = zip.getEntry(file_name);
+
+ this.file_name = file_name;
+
+ file = new DataInputStream(new BufferedInputStream(zip.getInputStream(entry),
+ BUFSIZE));
+ }
+
+ /**
+ * Parse the given Java class file and return an object that represents
+ * the contained data, i.e., constants, methods, fields and commands.
+ * A <em>ClassFormatError</em> is raised, if the file is not a valid
+ * .class file. (This does not include verification of the byte code as it
+ * is performed by the java interpreter).
+ *
+ * @return Class object representing the parsed class file
+ * @throw IOException
+ * @throw ClassFormatError
+ */
+ public JavaClass parse() throws IOException, ClassFormatError
+ {
+ /****************** Read headers ********************************/
+ // Check magic tag of class file
+ readID();
+
+ // Get compiler version
+ readVersion();
+
+ /****************** Read constant pool and related **************/
+ // Read constant pool entries
+ readConstantPool();
+
+ // Get class information
+ readClassInfo();
+
+ // Get interface information, i.e., implemented interfaces
+ readInterfaces();
+
+ /****************** Read class fields and methods ***************/
+ // Read class fields, i.e., the variables of the class
+ readFields();
+
+ // Read class methods, i.e., the functions in the class
+ readMethods();
+
+ // Read class attributes
+ readAttributes();
+
+ // Check for unknown variables
+ //Unknown[] u = Unknown.getUnknownAttributes();
+ //for(int i=0; i < u.length; i++)
+ // System.err.println("WARNING: " + u[i]);
+
+ // Everything should have been read now
+ // if(file.available() > 0) {
+ // int bytes = file.available();
+ // byte[] buf = new byte[bytes];
+ // file.read(buf);
+
+ // if(!(is_zip && (buf.length == 1))) {
+ // System.err.println("WARNING: Trailing garbage at end of " + file_name);
+ // System.err.println(bytes + " extra bytes: " + Utility.toHexString(buf));
+ // }
+ // }
+
+ // Read everything of interest, so close the file
+ file.close();
+ if(zip != null)
+ zip.close();
+
+ // Return the information we have gathered in a new object
+ return new JavaClass(class_name_index, superclass_name_index,
+ file_name, major, minor, access_flags,
+ constant_pool, interfaces, fields,
+ methods, attributes, is_zip? JavaClass.ZIP : JavaClass.FILE);
+ }
+
+ /**
+ * Read information about the attributes of the attributes of the class.
+ * @throw IOException
+ * @throw ClassFormatError
+ */
+ private final void readAttributes() throws IOException, ClassFormatError
+ {
+ int attributes_count;
+
+ attributes_count = file.readUnsignedShort();
+ attributes = new Attribute[attributes_count];
+
+ for(int i=0; i < attributes_count; i++)
+ attributes[i] = Attribute.readAttribute(file, constant_pool);
+ }
+
+ /**
+ * Read information about the class and its super class.
+ * @throw IOException
+ * @throw ClassFormatError
+ */
+ private final void readClassInfo() throws IOException, ClassFormatError
+ {
+ access_flags = file.readUnsignedShort();
+
+ /* Interfaces are implicitely abstract, the flag should be set
+ * according to the JVM specification.
+ */
+ if((access_flags & Constants.ACC_INTERFACE) != 0)
+ access_flags |= Constants.ACC_ABSTRACT;
+
+ if(((access_flags & Constants.ACC_ABSTRACT) != 0) &&
+ ((access_flags & Constants.ACC_FINAL) != 0 ))
+ throw new ClassFormatError("Class can't be both final and abstract");
+
+ class_name_index = file.readUnsignedShort();
+ superclass_name_index = file.readUnsignedShort();
+ }
+ /**
+ * Read constant pool entries.
+ * @throw IOException
+ * @throw ClassFormatError
+ */
+ private final void readConstantPool() throws IOException, ClassFormatError
+ {
+ constant_pool = new ConstantPool(file);
+ }
+
+ /**
+ * Read information about the fields of the class, i.e., its variables.
+ * @throw IOException
+ * @throw ClassFormatError
+ */
+ private final void readFields() throws IOException, ClassFormatError
+ {
+ int fields_count;
+
+ fields_count = file.readUnsignedShort();
+ fields = new Field[fields_count];
+
+ for(int i=0; i < fields_count; i++)
+ fields[i] = new Field(file, constant_pool);
+ }
+
+ /******************** Private utility methods **********************/
+
+ /**
+ * Check whether the header of the file is ok.
+ * Of course, this has to be the first action on successive file reads.
+ * @throw IOException
+ * @throw ClassFormatError
+ */
+ private final void readID() throws IOException, ClassFormatError
+ {
+ int magic = 0xCAFEBABE;
+
+ if(file.readInt() != magic)
+ throw new ClassFormatError(file_name + " is not a Java .class file");
+ }
+ /**
+ * Read information about the interfaces implemented by this class.
+ * @throw IOException
+ * @throw ClassFormatError
+ */
+ private final void readInterfaces() throws IOException, ClassFormatError
+ {
+ int interfaces_count;
+
+ interfaces_count = file.readUnsignedShort();
+ interfaces = new int[interfaces_count];
+
+ for(int i=0; i < interfaces_count; i++)
+ interfaces[i] = file.readUnsignedShort();
+ }
+ /**
+ * Read information about the methods of the class.
+ * @throw IOException
+ * @throw ClassFormatError
+ */
+ private final void readMethods() throws IOException, ClassFormatError
+ {
+ int methods_count;
+
+ methods_count = file.readUnsignedShort();
+ methods = new Method[methods_count];
+
+ for(int i=0; i < methods_count; i++)
+ methods[i] = new Method(file, constant_pool);
+ }
+ /**
+ * Read major and minor version of compiler which created the file.
+ * @throw IOException
+ * @throw ClassFormatError
+ */
+ private final void readVersion() throws IOException, ClassFormatError
+ {
+ minor = file.readUnsignedShort();
+ major = file.readUnsignedShort();
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/Code.java b/src/java/org/apache/bcel/classfile/Code.java
new file mode 100644
index 00000000..84f2efe7
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/Code.java
@@ -0,0 +1,373 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class represents a chunk of Java byte code contained in a
+ * method. It is instantiated by the
+ * <em>Attribute.readAttribute()</em> method. A <em>Code</em>
+ * attribute contains informations about operand stack, local
+ * variables, byte code and the exceptions handled within this
+ * method.
+ *
+ * This attribute has attributes itself, namely <em>LineNumberTable</em> which
+ * is used for debugging purposes and <em>LocalVariableTable</em> which
+ * contains information about the local variables.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Attribute
+ * @see CodeException
+ * @see LineNumberTable
+ * @see LocalVariableTable
+ */
+public final class Code extends Attribute {
+ private int max_stack; // Maximum size of stack used by this method
+ private int max_locals; // Number of local variables
+ private int code_length; // Length of code in bytes
+ private byte[] code; // Actual byte code
+
+ private int exception_table_length;
+ private CodeException[] exception_table; // Table of handled exceptions
+ private int attributes_count; // Attributes of code: LineNumber
+ private Attribute[] attributes; // or LocalVariable
+
+ /**
+ * Initialize from another object. Note that both objects use the same
+ * references (shallow copy). Use copy() for a physical copy.
+ */
+ public Code(Code c) {
+ this(c.getNameIndex(), c.getLength(), c.getMaxStack(), c.getMaxLocals(),
+ c.getCode(), c.getExceptionTable(), c.getAttributes(),
+ c.getConstantPool());
+ }
+
+ /**
+ * @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
+ */
+ Code(int name_index, int length, DataInputStream file,
+ ConstantPool constant_pool) throws IOException
+ {
+ // Initialize with some default values which will be overwritten later
+ this(name_index, length,
+ file.readUnsignedShort(), file.readUnsignedShort(),
+ (byte[])null, (CodeException[])null, (Attribute[])null,
+ constant_pool);
+
+ code_length = file.readInt();
+ code = new byte[code_length]; // Read byte code
+ file.readFully(code);
+
+ /* Read exception table that contains all regions where an exception
+ * handler is active, i.e., a try { ... } catch() block.
+ */
+ exception_table_length = file.readUnsignedShort();
+ exception_table = new CodeException[exception_table_length];
+
+ for(int i=0; i < exception_table_length; i++)
+ exception_table[i] = new CodeException(file);
+
+ /* Read all attributes, currently `LineNumberTable' and
+ * `LocalVariableTable'
+ */
+ attributes_count = file.readUnsignedShort();
+ attributes = new Attribute[attributes_count];
+ for(int i=0; i < attributes_count; i++)
+ attributes[i] = Attribute.readAttribute(file, constant_pool);
+
+ /* Adjust length, because of setAttributes in this(), s.b. length
+ * is incorrect, because it didn't take the internal attributes
+ * into account yet! Very subtle bug, fixed in 3.1.1.
+ */
+ this.length = length;
+ }
+
+ /**
+ * @param name_index Index pointing to the name <em>Code</em>
+ * @param length Content length in bytes
+ * @param max_stack Maximum size of stack
+ * @param max_locals Number of local variables
+ * @param code Actual byte code
+ * @param exception_table Table of handled exceptions
+ * @param attributes Attributes of code: LineNumber or LocalVariable
+ * @param constant_pool Array of constants
+ */
+ public Code(int name_index, int length,
+ int max_stack, int max_locals,
+ byte[] code,
+ CodeException[] exception_table,
+ Attribute[] attributes,
+ ConstantPool constant_pool)
+ {
+ super(Constants.ATTR_CODE, name_index, length, constant_pool);
+
+ this.max_stack = max_stack;
+ this.max_locals = max_locals;
+
+ setCode(code);
+ setExceptionTable(exception_table);
+ setAttributes(attributes); // Overwrites length!
+ }
+
+ /**
+ * 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.visitCode(this);
+ }
+
+ /**
+ * Dump code attribute to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ super.dump(file);
+
+ file.writeShort(max_stack);
+ file.writeShort(max_locals);
+ file.writeInt(code_length);
+ file.write(code, 0, code_length);
+
+ file.writeShort(exception_table_length);
+ for(int i=0; i < exception_table_length; i++)
+ exception_table[i].dump(file);
+
+ file.writeShort(attributes_count);
+ for(int i=0; i < attributes_count; i++)
+ attributes[i].dump(file);
+ }
+
+ /**
+ * @return Collection of code attributes.
+ * @see Attribute
+ */
+ public final Attribute[] getAttributes() { return attributes; }
+
+ /**
+ * @return LineNumberTable of Code, if it has one
+ */
+ public LineNumberTable getLineNumberTable() {
+ for(int i=0; i < attributes_count; i++)
+ if(attributes[i] instanceof LineNumberTable)
+ return (LineNumberTable)attributes[i];
+
+ return null;
+ }
+
+ /**
+ * @return LocalVariableTable of Code, if it has one
+ */
+ public LocalVariableTable getLocalVariableTable() {
+ for(int i=0; i < attributes_count; i++)
+ if(attributes[i] instanceof LocalVariableTable)
+ return (LocalVariableTable)attributes[i];
+
+ return null;
+ }
+
+ /**
+ * @return Actual byte code of the method.
+ */
+ public final byte[] getCode() { return code; }
+
+ /**
+ * @return Table of handled exceptions.
+ * @see CodeException
+ */
+ public final CodeException[] getExceptionTable() { return exception_table; }
+
+ /**
+ * @return Number of local variables.
+ */
+ public final int getMaxLocals() { return max_locals; }
+
+ /**
+ * @return Maximum size of stack used by this method.
+ */
+
+ public final int getMaxStack() { return max_stack; }
+
+ /**
+ * @return the internal length of this code attribute (minus the first 6 bytes)
+ * and excluding all its attributes
+ */
+ private final int getInternalLength() {
+ return 2 /*max_stack*/ + 2 /*max_locals*/ + 4 /*code length*/
+ + code_length /*byte-code*/
+ + 2 /*exception-table length*/
+ + 8 * exception_table_length /* exception table */
+ + 2 /* attributes count */;
+ }
+
+ /**
+ * @return the full size of this code attribute, minus its first 6 bytes,
+ * including the size of all its contained attributes
+ */
+ private final int calculateLength() {
+ int len = 0;
+
+ for(int i=0; i < attributes_count; i++)
+ len += attributes[i].length + 6 /*attribute header size*/;
+
+ return len + getInternalLength();
+ }
+
+ /**
+ * @param attributes.
+ */
+ public final void setAttributes(Attribute[] attributes) {
+ this.attributes = attributes;
+ attributes_count = (attributes == null)? 0 : attributes.length;
+ length = calculateLength(); // Adjust length
+ }
+
+ /**
+ * @param code byte code
+ */
+ public final void setCode(byte[] code) {
+ this.code = code;
+ code_length = (code == null)? 0 : code.length;
+ }
+
+ /**
+ * @param exception_table exception table
+ */
+ public final void setExceptionTable(CodeException[] exception_table) {
+ this.exception_table = exception_table;
+ exception_table_length = (exception_table == null)? 0 :
+ exception_table.length;
+ }
+
+ /**
+ * @param max_locals maximum number of local variables
+ */
+ public final void setMaxLocals(int max_locals) {
+ this.max_locals = max_locals;
+ }
+
+ /**
+ * @param max_stack maximum stack size
+ */
+ public final void setMaxStack(int max_stack) {
+ this.max_stack = max_stack;
+ }
+
+ /**
+ * @return String representation of code chunk.
+ */
+ public final String toString(boolean verbose) {
+ StringBuffer buf;
+
+ buf = new StringBuffer("Code(max_stack = " + max_stack +
+ ", max_locals = " + max_locals +
+ ", code_length = " + code_length + ")\n" +
+ Utility.codeToString(code, constant_pool, 0, -1, verbose));
+
+ if(exception_table_length > 0) {
+ buf.append("\nException handler(s) = \n" + "From\tTo\tHandler\tType\n");
+
+ for(int i=0; i < exception_table_length; i++)
+ buf.append(exception_table[i].toString(constant_pool, verbose) + "\n");
+ }
+
+ if(attributes_count > 0) {
+ buf.append("\nAttribute(s) = \n");
+
+ for(int i=0; i < attributes_count; i++)
+ buf.append(attributes[i].toString() + "\n");
+ }
+
+ return buf.toString();
+ }
+
+ /**
+ * @return String representation of code chunk.
+ */
+ public final String toString() {
+ return toString(true);
+ }
+
+ /**
+ * @return deep copy of this attribute
+ */
+ public Attribute copy(ConstantPool constant_pool) {
+ Code c = (Code)clone();
+ c.code = (byte[])code.clone();
+ c.constant_pool = constant_pool;
+
+ c.exception_table = new CodeException[exception_table_length];
+ for(int i=0; i < exception_table_length; i++)
+ c.exception_table[i] = exception_table[i].copy();
+
+ c.attributes = new Attribute[attributes_count];
+ for(int i=0; i < attributes_count; i++)
+ c.attributes[i] = attributes[i].copy(constant_pool);
+
+ return c;
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/CodeException.java b/src/java/org/apache/bcel/classfile/CodeException.java
new file mode 100644
index 00000000..c3bb946e
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/CodeException.java
@@ -0,0 +1,227 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class represents an entry in the exception table of the <em>Code</em>
+ * attribute and is used only there. It contains a range in which a
+ * particular exception handler is active.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Code
+ */
+public final class CodeException implements Cloneable, Constants, Node {
+ private int start_pc; // Range in the code the exception handler is
+ private int end_pc; // active. start_pc is inclusive, end_pc exclusive
+ private int handler_pc; /* Starting address of exception handler, i.e.,
+ * an offset from start of code.
+ */
+ private int catch_type; /* If this is zero the handler catches any
+ * exception, otherwise it points to the
+ * exception class which is to be caught.
+ */
+ /**
+ * Initialize from another object.
+ */
+ public CodeException(CodeException c) {
+ this(c.getStartPC(), c.getEndPC(), c.getHandlerPC(), c.getCatchType());
+ }
+
+ /**
+ * Construct object from file stream.
+ * @param file Input stream
+ * @throw IOException
+ */
+ CodeException(DataInputStream file) throws IOException
+ {
+ this(file.readUnsignedShort(), file.readUnsignedShort(),
+ file.readUnsignedShort(), file.readUnsignedShort());
+ }
+
+ /**
+ * @param start_pc Range in the code the exception handler is active,
+ * start_pc is inclusive while
+ * @param end_pc is exclusive
+ * @param handler_pc Starting address of exception handler, i.e.,
+ * an offset from start of code.
+ * @param catch_type If zero the handler catches any
+ * exception, otherwise it points to the exception class which is
+ * to be caught.
+ */
+ public CodeException(int start_pc, int end_pc, int handler_pc,
+ int catch_type)
+ {
+ this.start_pc = start_pc;
+ this.end_pc = end_pc;
+ this.handler_pc = handler_pc;
+ this.catch_type = catch_type;
+ }
+
+ /**
+ * 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.visitCodeException(this);
+ }
+ /**
+ * Dump code exception to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ file.writeShort(start_pc);
+ file.writeShort(end_pc);
+ file.writeShort(handler_pc);
+ file.writeShort(catch_type);
+ }
+
+ /**
+ * @return 0, if the handler catches any exception, otherwise it points to
+ * the exception class which is to be caught.
+ */
+ public final int getCatchType() { return catch_type; }
+
+ /**
+ * @return Exclusive end index of the region where the handler is active.
+ */
+ public final int getEndPC() { return end_pc; }
+
+ /**
+ * @return Starting address of exception handler, relative to the code.
+ */
+ public final int getHandlerPC() { return handler_pc; }
+
+ /**
+ * @return Inclusive start index of the region where the handler is active.
+ */
+ public final int getStartPC() { return start_pc; }
+
+ /**
+ * @param catch_type.
+ */
+ public final void setCatchType(int catch_type) {
+ this.catch_type = catch_type;
+ }
+
+ /**
+ * @param end_pc end of handled block
+ */
+ public final void setEndPC(int end_pc) {
+ this.end_pc = end_pc;
+ }
+
+ /**
+ * @param handler_pc where the actual code is
+ */
+ public final void setHandlerPC(int handler_pc) {
+ this.handler_pc = handler_pc;
+ }
+
+ /**
+ * @param start_pc start of handled block
+ */
+ public final void setStartPC(int start_pc) {
+ this.start_pc = start_pc;
+ }
+
+ /**
+ * @return String representation.
+ */
+ public final String toString() {
+ return "CodeException(start_pc = " + start_pc +
+ ", end_pc = " + end_pc +
+ ", handler_pc = " + handler_pc + ", catch_type = " + catch_type + ")";
+ }
+
+ /**
+ * @return String representation.
+ */
+ public final String toString(ConstantPool cp, boolean verbose) {
+ String str;
+
+ if(catch_type == 0)
+ str = "<Any exception>(0)";
+ else
+ str = Utility.compactClassName(cp.getConstantString(catch_type, CONSTANT_Class), false) +
+ (verbose? "(" + catch_type + ")" : "");
+
+ return start_pc + "\t" + end_pc + "\t" + handler_pc + "\t" + str;
+ }
+
+ public final String toString(ConstantPool cp) {
+ return toString(cp, true);
+ }
+
+ /**
+ * @return deep copy of this object
+ */
+ public CodeException copy() {
+ try {
+ return (CodeException)clone();
+ } catch(CloneNotSupportedException e) {}
+
+ return null;
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/Constant.java b/src/java/org/apache/bcel/classfile/Constant.java
new file mode 100644
index 00000000..62550614
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/Constant.java
@@ -0,0 +1,148 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * Abstract superclass for classes to represent the different constant types
+ * in the constant pool of a class file. The classes keep closely to
+ * the JVM specification.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public abstract class Constant implements Cloneable, Node {
+ /* In fact this tag is redundant since we can distinguish different
+ * `Constant' objects by their type, i.e., via `instanceof'. In some
+ * places we will use the tag for switch()es anyway.
+ *
+ * First, we want match the specification as closely as possible. Second we
+ * need the tag as an index to select the corresponding class name from the
+ * `CONSTANT_NAMES' array.
+ */
+ protected byte tag;
+
+ Constant(byte tag) { this.tag = tag; }
+
+ /**
+ * 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 abstract void accept(Visitor v);
+
+ public abstract void dump(DataOutputStream file) throws IOException;
+
+ /**
+ * @return Tag of constant, i.e., its type. No setTag() method to avoid
+ * confusion.
+ */
+ public final byte getTag() { return tag; }
+
+ /**
+ * @return String representation.
+ */
+ public String toString() {
+ return Constants.CONSTANT_NAMES[tag] + "[" + tag + "]";
+ }
+
+ /**
+ * @return deep copy of this constant
+ */
+ public Constant copy() {
+ try {
+ return (Constant)super.clone();
+ } catch(CloneNotSupportedException e) {}
+
+ return null;
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ /**
+ * Read one constant from the given file, the type depends on a tag byte.
+ *
+ * @param file Input stream
+ * @return Constant object
+ */
+ static final Constant readConstant(DataInputStream file)
+ throws IOException, ClassFormatError
+ {
+ byte b = file.readByte(); // Read tag byte
+
+ switch(b) {
+ case Constants.CONSTANT_Class: return new ConstantClass(file);
+ case Constants.CONSTANT_Fieldref: return new ConstantFieldref(file);
+ case Constants.CONSTANT_Methodref: return new ConstantMethodref(file);
+ case Constants.CONSTANT_InterfaceMethodref: return new
+ ConstantInterfaceMethodref(file);
+ case Constants.CONSTANT_String: return new ConstantString(file);
+ case Constants.CONSTANT_Integer: return new ConstantInteger(file);
+ case Constants.CONSTANT_Float: return new ConstantFloat(file);
+ case Constants.CONSTANT_Long: return new ConstantLong(file);
+ case Constants.CONSTANT_Double: return new ConstantDouble(file);
+ case Constants.CONSTANT_NameAndType: return new ConstantNameAndType(file);
+ case Constants.CONSTANT_Utf8: return new ConstantUtf8(file);
+ default:
+ throw new ClassFormatError("Invalid byte tag in constant pool: " + b);
+ }
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/ConstantCP.java b/src/java/org/apache/bcel/classfile/ConstantCP.java
new file mode 100644
index 00000000..496c57b5
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/ConstantCP.java
@@ -0,0 +1,154 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import java.io.*;
+import org.apache.bcel.Constants;
+
+/**
+ * Abstract super class for Fieldref and Methodref constants.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see ConstantFieldref
+ * @see ConstantMethodref
+ * @see ConstantInterfaceMethodref
+ */
+public abstract class ConstantCP extends Constant {
+ /** References to the constants containing the class and the field signature
+ */
+ protected int class_index, name_and_type_index;
+
+ /**
+ * Initialize from another object.
+ */
+ public ConstantCP(ConstantCP c) {
+ this(c.getTag(), c.getClassIndex(), c.getNameAndTypeIndex());
+ }
+
+ /**
+ * Initialize instance from file data.
+ *
+ * @param tag Constant type tag
+ * @param file Input stream
+ * @throw IOException
+ */
+ ConstantCP(byte tag, DataInputStream file) throws IOException
+ {
+ this(tag, file.readUnsignedShort(), file.readUnsignedShort());
+ }
+
+ /**
+ * @param class_index Reference to the class containing the field
+ * @param name_and_type_index and the field signature
+ */
+ protected ConstantCP(byte tag, int class_index,
+ int name_and_type_index) {
+ super(tag);
+ this.class_index = class_index;
+ this.name_and_type_index = name_and_type_index;
+ }
+
+ /**
+ * Dump constant field reference to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ file.writeByte(tag);
+ file.writeShort(class_index);
+ file.writeShort(name_and_type_index);
+ }
+
+ /**
+ * @return Reference (index) to class this field or method belongs to.
+ */
+ public final int getClassIndex() { return class_index; }
+
+ /**
+ * @return Reference (index) to signature of the field.
+ */
+ public final int getNameAndTypeIndex() { return name_and_type_index; }
+
+ /**
+ * @param class_index points to Constant_class
+ */
+ public final void setClassIndex(int class_index) {
+ this.class_index = class_index;
+ }
+
+ /**
+ * @return Class this field belongs to.
+ */
+ public String getClass(ConstantPool cp) {
+ return cp.constantToString(class_index, Constants.CONSTANT_Class);
+ }
+
+ /**
+ * @param name_and_type_index points to Constant_NameAndType
+ */
+ public final void setNameAndTypeIndex(int name_and_type_index) {
+ this.name_and_type_index = name_and_type_index;
+ }
+
+ /**
+ * @return String representation.
+ */
+ public final String toString() {
+ return super.toString() + "(class_index = " + class_index +
+ ", name_and_type_index = " + name_and_type_index + ")";
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/ConstantClass.java b/src/java/org/apache/bcel/classfile/ConstantClass.java
new file mode 100644
index 00000000..2ae81538
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/ConstantClass.java
@@ -0,0 +1,153 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class is derived from the abstract
+ * <A HREF="org.apache.bcel.classfile.Constant.html">Constant</A> class
+ * and represents a reference to a (external) class.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Constant
+ */
+public final class ConstantClass extends Constant implements ConstantObject {
+ private int name_index; // Identical to ConstantString except for the name
+
+ /**
+ * Initialize from another object.
+ */
+ public ConstantClass(ConstantClass c) {
+ this(c.getNameIndex());
+ }
+
+ /**
+ * Initialize instance from file data.
+ *
+ * @param file Input stream
+ * @throw IOException
+ */
+ ConstantClass(DataInputStream file) throws IOException
+ {
+ this(file.readUnsignedShort());
+ }
+
+ /**
+ * @param name_index Name index in constant pool
+ */
+ public ConstantClass(int name_index) {
+ super(Constants.CONSTANT_Class);
+ this.name_index = name_index;
+ }
+
+ /**
+ * 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.visitConstantClass(this);
+ }
+
+ /**
+ * Dump constant class to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ file.writeByte(tag);
+ file.writeShort(name_index);
+ }
+
+ /**
+ * @return Name index in constant pool of class name.
+ */
+ public final int getNameIndex() { return name_index; }
+
+ /**
+ * @param name_index.
+ */
+ public final void setNameIndex(int name_index) {
+ this.name_index = name_index;
+ }
+
+
+ /** @return String object
+ */
+ public Object getConstantValue(ConstantPool cp) {
+ Constant c = cp.getConstant(name_index, Constants.CONSTANT_Utf8);
+ return ((ConstantUtf8)c).getBytes();
+ }
+
+ /** @return dereferenced string
+ */
+ public String getBytes(ConstantPool cp) {
+ return (String)getConstantValue(cp);
+ }
+
+ /**
+ * @return String representation.
+ */
+ public final String toString() {
+ return super.toString() + "(name_index = " + name_index + ")";
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/ConstantDouble.java b/src/java/org/apache/bcel/classfile/ConstantDouble.java
new file mode 100644
index 00000000..145928fd
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/ConstantDouble.java
@@ -0,0 +1,142 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class is derived from the abstract
+ * <A HREF="org.apache.bcel.classfile.Constant.html">Constant</A> class
+ * and represents a reference to a Double object.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Constant
+ */
+public final class ConstantDouble extends Constant implements ConstantObject {
+ private double bytes;
+
+ /**
+ * @param bytes Data
+ */
+ public ConstantDouble(double bytes) {
+ super(Constants.CONSTANT_Double);
+ this.bytes = bytes;
+ }
+
+ /**
+ * Initialize from another object.
+ */
+ public ConstantDouble(ConstantDouble c) {
+ this(c.getBytes());
+ }
+
+ /**
+ * Initialize instance from file data.
+ *
+ * @param file Input stream
+ * @throw IOException
+ */
+ ConstantDouble(DataInputStream file) throws IOException
+ {
+ this(file.readDouble());
+ }
+
+ /**
+ * 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.visitConstantDouble(this);
+ }
+ /**
+ * Dump constant double to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ file.writeByte(tag);
+ file.writeDouble(bytes);
+ }
+ /**
+ * @return data, i.e., 8 bytes.
+ */
+ public final double getBytes() { return bytes; }
+ /**
+ * @param bytes.
+ */
+ public final void setBytes(double bytes) {
+ this.bytes = bytes;
+ }
+ /**
+ * @return String representation.
+ */
+ public final String toString()
+ {
+ return super.toString() + "(bytes = " + bytes + ")";
+ }
+
+ /** @return Double object
+ */
+ public Object getConstantValue(ConstantPool cp) {
+ return new Double(bytes);
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/ConstantFieldref.java b/src/java/org/apache/bcel/classfile/ConstantFieldref.java
new file mode 100644
index 00000000..7ebd17c2
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/ConstantFieldref.java
@@ -0,0 +1,104 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class represents a constant pool reference to a field.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public final class ConstantFieldref extends ConstantCP {
+ /**
+ * Initialize from another object.
+ */
+ public ConstantFieldref(ConstantFieldref c) {
+ super(Constants.CONSTANT_Fieldref, c.getClassIndex(), c.getNameAndTypeIndex());
+ }
+
+ /**
+ * Initialize instance from file data.
+ *
+ * @param file input stream
+ * @throw IOException
+ */
+ ConstantFieldref(DataInputStream file) throws IOException
+ {
+ super(Constants.CONSTANT_Fieldref, file);
+ }
+
+ /**
+ * @param class_index Reference to the class containing the Field
+ * @param name_and_type_index and the Field signature
+ */
+ public ConstantFieldref(int class_index,
+ int name_and_type_index) {
+ super(Constants.CONSTANT_Fieldref, class_index, name_and_type_index);
+ }
+
+ /**
+ * 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 Fields,
+ * fields, attributes, etc. spawns a tree of objects.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitConstantFieldref(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/ConstantFloat.java b/src/java/org/apache/bcel/classfile/ConstantFloat.java
new file mode 100644
index 00000000..5df62c1b
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/ConstantFloat.java
@@ -0,0 +1,141 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class is derived from the abstract
+ * <A HREF="org.apache.bcel.classfile.Constant.html">Constant</A> class
+ * and represents a reference to a float object.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Constant
+ */
+public final class ConstantFloat extends Constant implements ConstantObject {
+ private float bytes;
+
+ /**
+ * @param bytes Data
+ */
+ public ConstantFloat(float bytes)
+ {
+ super(Constants.CONSTANT_Float);
+ this.bytes = bytes;
+ }
+ /**
+ * Initialize from another object. Note that both objects use the same
+ * references (shallow copy). Use clone() for a physical copy.
+ */
+ public ConstantFloat(ConstantFloat c) {
+ this(c.getBytes());
+ }
+ /**
+ * Initialize instance from file data.
+ *
+ * @param file Input stream
+ * @throw IOException
+ */
+ ConstantFloat(DataInputStream file) throws IOException
+ {
+ this(file.readFloat());
+ }
+ /**
+ * 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.visitConstantFloat(this);
+ }
+ /**
+ * Dump constant float to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ file.writeByte(tag);
+ file.writeFloat(bytes);
+ }
+ /**
+ * @return data, i.e., 4 bytes.
+ */
+ public final float getBytes() { return bytes; }
+ /**
+ * @param bytes.
+ */
+ public final void setBytes(float bytes) {
+ this.bytes = bytes;
+ }
+
+ /**
+ * @return String representation.
+ */
+ public final String toString() {
+ return super.toString() + "(bytes = " + bytes + ")";
+ }
+
+ /** @return Float object
+ */
+ public Object getConstantValue(ConstantPool cp) {
+ return new Float(bytes);
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/ConstantInteger.java b/src/java/org/apache/bcel/classfile/ConstantInteger.java
new file mode 100644
index 00000000..a8b9e2d2
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/ConstantInteger.java
@@ -0,0 +1,148 @@
+
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class is derived from the abstract
+ * <A HREF="org.apache.bcel.classfile.Constant.html">Constant</A> class
+ * and represents a reference to an int object.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Constant
+ */
+public final class ConstantInteger extends Constant implements ConstantObject {
+ private int bytes;
+
+ /**
+ * @param bytes Data
+ */
+ public ConstantInteger(int bytes)
+ {
+ super(Constants.CONSTANT_Integer);
+ this.bytes = bytes;
+ }
+
+ /**
+ * Initialize from another object.
+ */
+ public ConstantInteger(ConstantInteger c) {
+ this(c.getBytes());
+ }
+
+ /**
+ * Initialize instance from file data.
+ *
+ * @param file Input stream
+ * @throw IOException
+ */
+ ConstantInteger(DataInputStream file) throws IOException
+ {
+ this(file.readInt());
+ }
+
+ /**
+ * 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.visitConstantInteger(this);
+ }
+
+ /**
+ * Dump constant integer to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ file.writeByte(tag);
+ file.writeInt(bytes);
+ }
+
+ /**
+ * @return data, i.e., 4 bytes.
+ */
+ public final int getBytes() { return bytes; }
+
+ /**
+ * @param bytes.
+ */
+ public final void setBytes(int bytes) {
+ this.bytes = bytes;
+ }
+
+ /**
+ * @return String representation.
+ */
+ public final String toString() {
+ return super.toString() + "(bytes = " + bytes + ")";
+ }
+
+ /** @return Integer object
+ */
+ public Object getConstantValue(ConstantPool cp) {
+ return new Integer(bytes);
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/ConstantInterfaceMethodref.java b/src/java/org/apache/bcel/classfile/ConstantInterfaceMethodref.java
new file mode 100644
index 00000000..f3fba280
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/ConstantInterfaceMethodref.java
@@ -0,0 +1,104 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class represents a constant pool reference to an interface method.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public final class ConstantInterfaceMethodref extends ConstantCP {
+ /**
+ * Initialize from another object.
+ */
+ public ConstantInterfaceMethodref(ConstantInterfaceMethodref c) {
+ super(Constants.CONSTANT_InterfaceMethodref, c.getClassIndex(), c.getNameAndTypeIndex());
+ }
+
+ /**
+ * Initialize instance from file data.
+ *
+ * @param file input stream
+ * @throw IOException
+ */
+ ConstantInterfaceMethodref(DataInputStream file) throws IOException
+ {
+ super(Constants.CONSTANT_InterfaceMethodref, file);
+ }
+
+ /**
+ * @param class_index Reference to the class containing the method
+ * @param name_and_type_index and the method signature
+ */
+ public ConstantInterfaceMethodref(int class_index,
+ int name_and_type_index) {
+ super(Constants.CONSTANT_InterfaceMethodref, class_index, name_and_type_index);
+ }
+
+ /**
+ * 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.visitConstantInterfaceMethodref(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/ConstantLong.java b/src/java/org/apache/bcel/classfile/ConstantLong.java
new file mode 100644
index 00000000..db521f78
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/ConstantLong.java
@@ -0,0 +1,139 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class is derived from the abstract
+ * <A HREF="org.apache.bcel.classfile.Constant.html">Constant</A> class
+ * and represents a reference to a long object.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Constant
+ */
+public final class ConstantLong extends Constant implements ConstantObject {
+ private long bytes;
+
+ /**
+ * @param bytes Data
+ */
+ public ConstantLong(long bytes)
+ {
+ super(Constants.CONSTANT_Long);
+ this.bytes = bytes;
+ }
+ /**
+ * Initialize from another object.
+ */
+ public ConstantLong(ConstantLong c) {
+ this(c.getBytes());
+ }
+ /**
+ * Initialize instance from file data.
+ *
+ * @param file Input stream
+ * @throw IOException
+ */
+ ConstantLong(DataInputStream file) throws IOException
+ {
+ this(file.readLong());
+ }
+ /**
+ * 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.visitConstantLong(this);
+ }
+ /**
+ * Dump constant long to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ file.writeByte(tag);
+ file.writeLong(bytes);
+ }
+ /**
+ * @return data, i.e., 8 bytes.
+ */
+ public final long getBytes() { return bytes; }
+ /**
+ * @param bytes.
+ */
+ public final void setBytes(long bytes) {
+ this.bytes = bytes;
+ }
+ /**
+ * @return String representation.
+ */
+ public final String toString() {
+ return super.toString() + "(bytes = " + bytes + ")";
+ }
+
+ /** @return Long object
+ */
+ public Object getConstantValue(ConstantPool cp) {
+ return new Long(bytes);
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/ConstantMethodref.java b/src/java/org/apache/bcel/classfile/ConstantMethodref.java
new file mode 100644
index 00000000..05992167
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/ConstantMethodref.java
@@ -0,0 +1,104 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class represents a constant pool reference to a method.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public final class ConstantMethodref extends ConstantCP {
+ /**
+ * Initialize from another object.
+ */
+ public ConstantMethodref(ConstantMethodref c) {
+ super(Constants.CONSTANT_Methodref, c.getClassIndex(), c.getNameAndTypeIndex());
+ }
+
+ /**
+ * Initialize instance from file data.
+ *
+ * @param file input stream
+ * @throw IOException
+ */
+ ConstantMethodref(DataInputStream file) throws IOException
+ {
+ super(Constants.CONSTANT_Methodref, file);
+ }
+
+ /**
+ * @param class_index Reference to the class containing the method
+ * @param name_and_type_index and the method signature
+ */
+ public ConstantMethodref(int class_index,
+ int name_and_type_index) {
+ super(Constants.CONSTANT_Methodref, class_index, name_and_type_index);
+ }
+
+ /**
+ * 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.visitConstantMethodref(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/ConstantNameAndType.java b/src/java/org/apache/bcel/classfile/ConstantNameAndType.java
new file mode 100644
index 00000000..8de59337
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/ConstantNameAndType.java
@@ -0,0 +1,171 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class is derived from the abstract
+ * <A HREF="org.apache.bcel.classfile.Constant.html">Constant</A> class
+ * and represents a reference to the name and signature
+ * of a field or method.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Constant
+ */
+public final class ConstantNameAndType extends Constant {
+ private int name_index; // Name of field/method
+ private int signature_index; // and its signature.
+
+ /**
+ * Initialize from another object.
+ */
+ public ConstantNameAndType(ConstantNameAndType c) {
+ this(c.getNameIndex(), c.getSignatureIndex());
+ }
+
+ /**
+ * Initialize instance from file data.
+ *
+ * @param file Input stream
+ * @throw IOException
+ */
+ ConstantNameAndType(DataInputStream file) throws IOException
+ {
+ this((int)file.readUnsignedShort(), (int)file.readUnsignedShort());
+ }
+
+ /**
+ * @param name_index Name of field/method
+ * @param signature_index and its signature
+ */
+ public ConstantNameAndType(int name_index,
+ int signature_index)
+ {
+ super(Constants.CONSTANT_NameAndType);
+ this.name_index = name_index;
+ this.signature_index = signature_index;
+ }
+
+ /**
+ * 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.visitConstantNameAndType(this);
+ }
+
+ /**
+ * Dump name and signature index to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ file.writeByte(tag);
+ file.writeShort(name_index);
+ file.writeShort(signature_index);
+ }
+
+ /**
+ * @return Name index in constant pool of field/method name.
+ */
+ public final int getNameIndex() { return name_index; }
+
+ /** @return name
+ */
+ public final String getName(ConstantPool cp) {
+ return cp.constantToString(getNameIndex(), Constants.CONSTANT_Utf8);
+ }
+
+ /**
+ * @return Index in constant pool of field/method signature.
+ */
+ public final int getSignatureIndex() { return signature_index; }
+
+ /** @return signature
+ */
+ public final String getSignature(ConstantPool cp) {
+ return cp.constantToString(getSignatureIndex(), Constants.CONSTANT_Utf8);
+ }
+
+ /**
+ * @param name_index.
+ */
+ public final void setNameIndex(int name_index) {
+ this.name_index = name_index;
+ }
+
+ /**
+ * @param signature_index.
+ */
+ public final void setSignatureIndex(int signature_index) {
+ this.signature_index = signature_index;
+ }
+
+ /**
+ * @return String representation
+ */
+ public final String toString() {
+ return super.toString() + "(name_index = " + name_index +
+ ", signature_index = " + signature_index + ")";
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/ConstantObject.java b/src/java/org/apache/bcel/classfile/ConstantObject.java
new file mode 100644
index 00000000..ff41502c
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/ConstantObject.java
@@ -0,0 +1,69 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * This interface denotes those constants that have a "natural" value,
+ * such as ConstantLong, ConstantString, etc..
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Constant
+ */
+public interface ConstantObject {
+ /** @return object representing the constant, e.g., Long for ConstantLong
+ */
+ public abstract Object getConstantValue(ConstantPool cp);
+}
diff --git a/src/java/org/apache/bcel/classfile/ConstantPool.java b/src/java/org/apache/bcel/classfile/ConstantPool.java
new file mode 100644
index 00000000..a10ad43f
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/ConstantPool.java
@@ -0,0 +1,369 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class represents the constant pool, i.e., a table of constants.
+ * It may contain null references, due to the JVM specification that skips
+ * an entry after an 8-byte constant (double, long) entry.
+ *
+ * @version $Id$
+ * @see Constant
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class ConstantPool implements Cloneable, Node {
+ private int constant_pool_count;
+ private Constant[] constant_pool;
+
+ /**
+ * @param constant_pool Array of constants
+ */
+ public ConstantPool(Constant[] constant_pool)
+ {
+ setConstantPool(constant_pool);
+ }
+
+ /**
+ * Read constants from given file stream.
+ *
+ * @param file Input stream
+ * @throw IOException
+ * @throw ClassFormatError
+ */
+ ConstantPool(DataInputStream file) throws IOException, ClassFormatError
+ {
+ byte tag;
+
+ constant_pool_count = file.readUnsignedShort();
+ constant_pool = new Constant[constant_pool_count];
+
+ /* constant_pool[0] is unused by the compiler and may be used freely
+ * by the implementation.
+ */
+ for(int i=1; i < constant_pool_count; i++) {
+ constant_pool[i] = Constant.readConstant(file);
+
+ /* Quote from the JVM specification:
+ * "All eight byte constants take up two spots in the constant pool.
+ * If this is the n'th byte in the constant pool, then the next item
+ * will be numbered n+2"
+ *
+ * Thus we have to increment the index counter.
+ */
+ tag = constant_pool[i].getTag();
+ if((tag == Constants.CONSTANT_Double) || (tag == Constants.CONSTANT_Long))
+ i++;
+ }
+ }
+
+ /**
+ * 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.visitConstantPool(this);
+ }
+
+ /**
+ * Resolve constant to a string representation.
+ *
+ * @param constant Constant to be printed
+ * @return String representation
+ */
+ public String constantToString(Constant c)
+ throws ClassFormatError
+ {
+ String str;
+ int i;
+ byte tag = c.getTag();
+
+ switch(tag) {
+ case Constants.CONSTANT_Class:
+ i = ((ConstantClass)c).getNameIndex();
+ c = getConstant(i, Constants.CONSTANT_Utf8);
+ str = Utility.compactClassName(((ConstantUtf8)c).getBytes(), false);
+ break;
+
+ case Constants.CONSTANT_String:
+ i = ((ConstantString)c).getStringIndex();
+ c = getConstant(i, Constants.CONSTANT_Utf8);
+ str = "\"" + escape(((ConstantUtf8)c).getBytes()) + "\"";
+ break;
+
+ case Constants.CONSTANT_Utf8: str = ((ConstantUtf8)c).getBytes(); break;
+ case Constants.CONSTANT_Double: str = "" + ((ConstantDouble)c).getBytes(); break;
+ case Constants.CONSTANT_Float: str = "" + ((ConstantFloat)c).getBytes(); break;
+ case Constants.CONSTANT_Long: str = "" + ((ConstantLong)c).getBytes(); break;
+ case Constants.CONSTANT_Integer: str = "" + ((ConstantInteger)c).getBytes(); break;
+
+ case Constants.CONSTANT_NameAndType:
+ str = (constantToString(((ConstantNameAndType)c).getNameIndex(),
+ Constants.CONSTANT_Utf8) + " " +
+ constantToString(((ConstantNameAndType)c).getSignatureIndex(),
+ Constants.CONSTANT_Utf8));
+ break;
+
+ case Constants.CONSTANT_InterfaceMethodref: case Constants.CONSTANT_Methodref:
+ case Constants.CONSTANT_Fieldref:
+ str = (constantToString(((ConstantCP)c).getClassIndex(),
+ Constants.CONSTANT_Class) + "." +
+ constantToString(((ConstantCP)c).getNameAndTypeIndex(),
+ Constants.CONSTANT_NameAndType));
+ break;
+
+ default: // Never reached
+ throw new RuntimeException("Unknown constant type " + tag);
+ }
+
+ return str;
+ }
+
+ private static final String escape(String str) {
+ int len = str.length();
+ StringBuffer buf = new StringBuffer(len + 5);
+ char[] ch = str.toCharArray();
+
+ for(int i=0; i < len; i++) {
+ switch(ch[i]) {
+ case '\n' : buf.append("\\n"); break;
+ case '\r' : buf.append("\\r"); break;
+ case '\t' : buf.append("\\t"); break;
+ case '\b' : buf.append("\\b"); break;
+ case '"' : buf.append("\\\""); break;
+ default: buf.append(ch[i]);
+ }
+ }
+
+ return buf.toString();
+ }
+
+
+ /**
+ * Retrieve constant at `index' from constant pool and resolve it to
+ * a string representation.
+ *
+ * @param index of constant in constant pool
+ * @param tag expected type
+ * @return String representation
+ */
+ public String constantToString(int index, byte tag)
+ throws ClassFormatError
+ {
+ Constant c = getConstant(index, tag);
+ return constantToString(c);
+ }
+
+ /**
+ * Dump constant pool to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public void dump(DataOutputStream file) throws IOException
+ {
+ file.writeShort(constant_pool_count);
+
+ for(int i=1; i < constant_pool_count; i++)
+ if(constant_pool[i] != null)
+ constant_pool[i].dump(file);
+ }
+
+ /**
+ * Get constant from constant pool.
+ *
+ * @param index Index in constant pool
+ * @return Constant value
+ * @see Constant
+ */
+ public Constant getConstant(int index) {
+ if (index >= constant_pool.length || index < 0)
+ throw new ClassFormatError("Invalid constant pool reference: " +
+ index + ". Constant pool size is: " +
+ constant_pool.length);
+ return constant_pool[index];
+ }
+
+ /**
+ * Get constant from constant pool and check whether it has the
+ * expected type.
+ *
+ * @param index Index in constant pool
+ * @param tag Tag of expected constant, i.e., its type
+ * @return Constant value
+ * @see Constant
+ * @throw ClassFormatError
+ */
+ public Constant getConstant(int index, byte tag)
+ throws ClassFormatError
+ {
+ Constant c;
+
+ c = getConstant(index);
+
+ if(c == null)
+ throw new ClassFormatError("Constant pool at index " + index + " is null.");
+
+ if(c.getTag() == tag)
+ return c;
+ else
+ throw new ClassFormatError("Expected class `" + Constants.CONSTANT_NAMES[tag] +
+ "' at index " + index + " and got " + c);
+ }
+
+ /**
+ * @return Array of constants.
+ * @see Constant
+ */
+ public Constant[] getConstantPool() { return constant_pool; }
+ /**
+ * Get string from constant pool and bypass the indirection of
+ * `ConstantClass' and `ConstantString' objects. I.e. these classes have
+ * an index field that points to another entry of the constant pool of
+ * type `ConstantUtf8' which contains the real data.
+ *
+ * @param index Index in constant pool
+ * @param tag Tag of expected constant, either ConstantClass or ConstantString
+ * @return Contents of string reference
+ * @see ConstantClass
+ * @see ConstantString
+ * @throw ClassFormatError
+ */
+ public String getConstantString(int index, byte tag)
+ throws ClassFormatError
+ {
+ Constant c;
+ int i;
+ String s;
+
+ c = getConstant(index, tag);
+
+ /* This switch() is not that elegant, since the two classes have the
+ * same contents, they just differ in the name of the index
+ * field variable.
+ * But we want to stick to the JVM naming conventions closely though
+ * we could have solved these more elegantly by using the same
+ * variable name or by subclassing.
+ */
+ switch(tag) {
+ case Constants.CONSTANT_Class: i = ((ConstantClass)c).getNameIndex(); break;
+ case Constants.CONSTANT_String: i = ((ConstantString)c).getStringIndex(); break;
+ default:
+ throw new RuntimeException("getConstantString called with illegal tag " + tag);
+ }
+
+ // Finally get the string from the constant pool
+ c = getConstant(i, Constants.CONSTANT_Utf8);
+ return ((ConstantUtf8)c).getBytes();
+ }
+ /**
+ * @return Length of constant pool.
+ */
+ public int getLength()
+ {
+ return constant_pool_count;
+ }
+
+ /**
+ * @param constant Constant to set
+ */
+ public void setConstant(int index, Constant constant) {
+ constant_pool[index] = constant;
+ }
+
+ /**
+ * @param constant_pool
+ */
+ public void setConstantPool(Constant[] constant_pool) {
+ this.constant_pool = constant_pool;
+ constant_pool_count = (constant_pool == null)? 0 : constant_pool.length;
+ }
+ /**
+ * @return String representation.
+ */
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+
+ for(int i=1; i < constant_pool_count; i++)
+ buf.append(i + ")" + constant_pool[i] + "\n");
+
+ return buf.toString();
+ }
+
+ /**
+ * @return deep copy of this constant pool
+ */
+ public ConstantPool copy() {
+ ConstantPool c = null;
+
+ try {
+ c = (ConstantPool)clone();
+ } catch(CloneNotSupportedException e) {}
+
+ c.constant_pool = new Constant[constant_pool_count];
+
+ for(int i=1; i < constant_pool_count; i++) {
+ if(constant_pool[i] != null)
+ c.constant_pool[i] = constant_pool[i].copy();
+ }
+
+ return c;
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/ConstantString.java b/src/java/org/apache/bcel/classfile/ConstantString.java
new file mode 100644
index 00000000..3ed78f44
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/ConstantString.java
@@ -0,0 +1,147 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class is derived from the abstract
+ * <A HREF="org.apache.bcel.classfile.Constant.html">Constant</A> class
+ * and represents a reference to a String object.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Constant
+ */
+public final class ConstantString extends Constant implements ConstantObject {
+ private int string_index; // Identical to ConstantClass except for this name
+
+ /**
+ * Initialize from another object.
+ */
+ public ConstantString(ConstantString c) {
+ this(c.getStringIndex());
+ }
+ /**
+ * Initialize instance from file data.
+ *
+ * @param file Input stream
+ * @throw IOException
+ */
+ ConstantString(DataInputStream file) throws IOException
+ {
+ this((int)file.readUnsignedShort());
+ }
+ /**
+ * @param string_index Index of Constant_Utf8 in constant pool
+ */
+ public ConstantString(int string_index)
+ {
+ super(Constants.CONSTANT_String);
+ this.string_index = string_index;
+ }
+ /**
+ * 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.visitConstantString(this);
+ }
+ /**
+ * Dump constant field reference to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ file.writeByte(tag);
+ file.writeShort(string_index);
+ }
+ /**
+ * @return Index in constant pool of the string (ConstantUtf8).
+ */
+ public final int getStringIndex() { return string_index; }
+ /**
+ * @param string_index.
+ */
+ public final void setStringIndex(int string_index) {
+ this.string_index = string_index;
+ }
+ /**
+ * @return String representation.
+ */
+ public final String toString()
+ {
+ return super.toString() + "(string_index = " + string_index + ")";
+ }
+
+ /** @return String object
+ */
+ public Object getConstantValue(ConstantPool cp) {
+ Constant c = cp.getConstant(string_index, Constants.CONSTANT_Utf8);
+ return ((ConstantUtf8)c).getBytes();
+ }
+
+ /** @return dereferenced string
+ */
+ public String getBytes(ConstantPool cp) {
+ return (String)getConstantValue(cp);
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/ConstantUtf8.java b/src/java/org/apache/bcel/classfile/ConstantUtf8.java
new file mode 100644
index 00000000..a087d5c6
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/ConstantUtf8.java
@@ -0,0 +1,143 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class is derived from the abstract
+ * <A HREF="org.apache.bcel.classfile.Constant.html">Constant</A> class
+ * and represents a reference to a Utf8 encoded string.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Constant
+ */
+public final class ConstantUtf8 extends Constant {
+ private String bytes;
+
+ /**
+ * Initialize from another object.
+ */
+ public ConstantUtf8(ConstantUtf8 c) {
+ this(c.getBytes());
+ }
+
+ /**
+ * Initialize instance from file data.
+ *
+ * @param file Input stream
+ * @throw IOException
+ */
+ ConstantUtf8(DataInputStream file) throws IOException
+ {
+ super(Constants.CONSTANT_Utf8);
+
+ bytes = file.readUTF();
+ }
+
+ /**
+ * @param bytes Data
+ */
+ public ConstantUtf8(String bytes)
+ {
+ super(Constants.CONSTANT_Utf8);
+ this.bytes = bytes;
+ }
+
+ /**
+ * 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.visitConstantUtf8(this);
+ }
+
+ /**
+ * Dump String in Utf8 format to file stream.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ file.writeByte(tag);
+ file.writeUTF(bytes);
+ }
+
+ /**
+ * @return Data converted to string.
+ */
+ public final String getBytes() { return bytes; }
+
+ /**
+ * @param bytes.
+ */
+ public final void setBytes(String bytes) {
+ this.bytes = bytes;
+ }
+
+ /**
+ * @return String representation
+ */
+ public final String toString()
+ {
+ return super.toString() + "(\"" + Utility.replace(bytes, "\n", "\\n") + "\")";
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/ConstantValue.java b/src/java/org/apache/bcel/classfile/ConstantValue.java
new file mode 100644
index 00000000..bd4e53b9
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/ConstantValue.java
@@ -0,0 +1,204 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class is derived from <em>Attribute</em> and represents a constant
+ * value, i.e., a default value for initializing a class field.
+ * This class is instantiated by the <em>Attribute.readAttribute()</em> method.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Attribute
+ */
+public final class ConstantValue extends Attribute {
+ private int constantvalue_index;
+
+ /**
+ * Initialize from another object. Note that both objects use the same
+ * references (shallow copy). Use clone() for a physical copy.
+ */
+ public ConstantValue(ConstantValue c) {
+ this(c.getNameIndex(), c.getLength(), c.getConstantValueIndex(),
+ c.getConstantPool());
+ }
+
+ /**
+ * Construct object from file stream.
+ * @param name_index Name index in constant pool
+ * @param length Content length in bytes
+ * @param file Input stream
+ * @param constant_pool Array of constants
+ * @throw IOException
+ */
+ ConstantValue(int name_index, int length, DataInputStream file,
+ ConstantPool constant_pool) throws IOException
+ {
+ this(name_index, length, (int)file.readUnsignedShort(), constant_pool);
+ }
+
+ /**
+ * @param name_index Name index in constant pool
+ * @param length Content length in bytes
+ * @param constantvalue_index Index in constant pool
+ * @param constant_pool Array of constants
+ */
+ public ConstantValue(int name_index, int length,
+ int constantvalue_index,
+ ConstantPool constant_pool)
+ {
+ super(Constants.ATTR_CONSTANT_VALUE, name_index, length, constant_pool);
+ this.constantvalue_index = constantvalue_index;
+ }
+
+ /**
+ * 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.visitConstantValue(this);
+ }
+ /**
+ * Dump constant value attribute to file stream on binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ super.dump(file);
+ file.writeShort(constantvalue_index);
+ }
+ /**
+ * @return Index in constant pool of constant value.
+ */
+ public final int getConstantValueIndex() { return constantvalue_index; }
+
+ /**
+ * @param constantvalue_index.
+ */
+ public final void setConstantValueIndex(int constantvalue_index) {
+ this.constantvalue_index = constantvalue_index;
+ }
+
+ /**
+ * @return String representation of constant value.
+ */
+ public final String toString() throws InternalError
+ {
+ Constant c = constant_pool.getConstant(constantvalue_index);
+
+ String buf;
+ int i;
+
+ // Print constant to string depending on its type
+ switch(c.getTag()) {
+ case Constants.CONSTANT_Long: buf = "" + ((ConstantLong)c).getBytes(); break;
+ case Constants.CONSTANT_Float: buf = "" + ((ConstantFloat)c).getBytes(); break;
+ case Constants.CONSTANT_Double: buf = "" + ((ConstantDouble)c).getBytes(); break;
+ case Constants.CONSTANT_Integer: buf = "" + ((ConstantInteger)c).getBytes(); break;
+ case Constants.CONSTANT_String:
+ i = ((ConstantString)c).getStringIndex();
+ c = constant_pool.getConstant(i, Constants.CONSTANT_Utf8);
+ buf = "\"" + convertString(((ConstantUtf8)c).getBytes()) + "\"";
+ break;
+ default: throw new InternalError("Type of ConstValue invalid: " + c);
+ }
+
+ return buf;
+ }
+
+ /**
+ * Escape all occurences of newline chars '\n', quotes \", etc.
+ */
+ private static final String convertString(String label) {
+ char[] ch = label.toCharArray();
+ StringBuffer buf = new StringBuffer();
+
+ for(int i=0; i < ch.length; i++) {
+ switch(ch[i]) {
+ case '\n':
+ buf.append("\\n"); break;
+ case '\r':
+ buf.append("\\r"); break;
+ case '\"':
+ buf.append("\\\""); break;
+ case '\'':
+ buf.append("\\'"); break;
+ case '\\':
+ buf.append("\\\\"); break;
+ default:
+ buf.append(ch[i]); break;
+ }
+ }
+
+ return buf.toString();
+ }
+
+ /**
+ * @return deep copy of this attribute
+ */
+ public Attribute copy(ConstantPool constant_pool) {
+ ConstantValue c = (ConstantValue)clone();
+ c.constant_pool = constant_pool;
+ return c;
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/Deprecated.java b/src/java/org/apache/bcel/classfile/Deprecated.java
new file mode 100644
index 00000000..7502cff8
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/Deprecated.java
@@ -0,0 +1,170 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class is derived from <em>Attribute</em> and denotes that this is a
+ * deprecated method.
+ * It is instantiated from the <em>Attribute.readAttribute()</em> method.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Attribute
+ */
+public final class Deprecated extends Attribute {
+ private byte[] bytes;
+
+ /**
+ * Initialize from another object. Note that both objects use the same
+ * references (shallow copy). Use clone() for a physical copy.
+ */
+ public Deprecated(Deprecated c) {
+ this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool());
+ }
+
+ /**
+ * @param name_index Index in constant pool to CONSTANT_Utf8
+ * @param length Content length in bytes
+ * @param bytes Attribute contents
+ * @param constant_pool Array of constants
+ * @param sourcefile_index Index in constant pool to CONSTANT_Utf8
+ */
+ public Deprecated(int name_index, int length, byte[] bytes,
+ ConstantPool constant_pool)
+ {
+ super(Constants.ATTR_DEPRECATED, name_index, length, constant_pool);
+ this.bytes = bytes;
+ }
+
+ /**
+ * Construct object from file stream.
+ * @param name_index Index in constant pool to CONSTANT_Utf8
+ * @param length Content length in bytes
+ * @param file Input stream
+ * @param constant_pool Array of constants
+ * @throw IOException
+ */
+ Deprecated(int name_index, int length, DataInputStream file,
+ ConstantPool constant_pool) throws IOException
+ {
+ this(name_index, length, (byte [])null, constant_pool);
+
+ if(length > 0) {
+ bytes = new byte[length];
+ file.readFully(bytes);
+ System.err.println("Deprecated attribute with length > 0");
+ }
+ }
+
+ /**
+ * 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.visitDeprecated(this);
+ }
+
+ /**
+ * Dump source file attribute to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ super.dump(file);
+
+ if(length > 0)
+ file.write(bytes, 0, length);
+ }
+
+ /**
+ * @return data bytes.
+ */
+ public final byte[] getBytes() { return bytes; }
+
+ /**
+ * @param bytes.
+ */
+ public final void setBytes(byte[] bytes) {
+ this.bytes = bytes;
+ }
+
+ /**
+ * @return attribute name
+ */
+ public final String toString() {
+ return Constants.ATTRIBUTE_NAMES[Constants.ATTR_DEPRECATED];
+ }
+
+ /**
+ * @return deep copy of this attribute
+ */
+ public Attribute copy(ConstantPool constant_pool) {
+ Deprecated c = (Deprecated)clone();
+
+ if(bytes != null)
+ c.bytes = (byte[])bytes.clone();
+
+ c.constant_pool = constant_pool;
+ return c;
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/DescendingVisitor.java b/src/java/org/apache/bcel/classfile/DescendingVisitor.java
new file mode 100644
index 00000000..c98e4b22
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/DescendingVisitor.java
@@ -0,0 +1,351 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import java.util.Stack;
+
+/**
+ * Traverses a JavaClass with another Visitor object 'piggy-backed'
+ * that is applied to all components of a JavaClass object. I.e. this
+ * class supplies the traversal strategy, other classes can make use
+ * of it.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class DescendingVisitor implements Visitor {
+ private JavaClass clazz;
+ private Visitor visitor;
+ private Stack stack = new Stack();
+
+ /** @return container of current entitity, i.e., predecessor during traversal
+ */
+ public Object predecessor() {
+ return predecessor(0);
+ }
+
+ /**
+ * @param level nesting level, i.e., 0 returns the direct predecessor
+ * @return container of current entitity, i.e., predecessor during traversal
+ */
+ public Object predecessor(int level) {
+ int size = stack.size();
+
+ if((size < 2) || (level < 0))
+ return null;
+ else
+ return stack.elementAt(size - (level + 2)); // size - 1 == current
+ }
+
+ /** @return current object
+ */
+ public Object current() {
+ return stack.peek();
+ }
+
+ /**
+ * @param clazz Class to traverse
+ * @param visitor visitor object to apply to all components
+ */
+ public DescendingVisitor(JavaClass clazz, Visitor visitor) {
+ this.clazz = clazz;
+ this.visitor = visitor;
+ }
+
+ /**
+ * Start traversal.
+ */
+ public void visit() { clazz.accept(this); }
+
+ public void visitJavaClass(JavaClass clazz) {
+ stack.push(clazz);
+ clazz.accept(visitor);
+
+ Field[] fields = clazz.getFields();
+ for(int i=0; i < fields.length; i++)
+ fields[i].accept(this);
+
+ Method[] methods = clazz.getMethods();
+ for(int i=0; i < methods.length; i++)
+ methods[i].accept(this);
+
+ Attribute[] attributes = clazz.getAttributes();
+ for(int i=0; i < attributes.length; i++)
+ attributes[i].accept(this);
+
+ clazz.getConstantPool().accept(this);
+ stack.pop();
+ }
+
+ public void visitField(Field field) {
+ stack.push(field);
+ field.accept(visitor);
+
+ Attribute[] attributes = field.getAttributes();
+ for(int i=0; i < attributes.length; i++)
+ attributes[i].accept(this);
+ stack.pop();
+ }
+
+ public void visitConstantValue(ConstantValue cv) {
+ stack.push(cv);
+ cv.accept(visitor);
+ stack.pop();
+ }
+
+ public void visitMethod(Method method) {
+ stack.push(method);
+ method.accept(visitor);
+
+ Attribute[] attributes = method.getAttributes();
+ for(int i=0; i < attributes.length; i++)
+ attributes[i].accept(this);
+
+ stack.pop();
+ }
+
+ public void visitExceptionTable(ExceptionTable table) {
+ stack.push(table);
+ table.accept(visitor);
+ stack.pop();
+ }
+
+ public void visitCode(Code code) {
+ stack.push(code);
+ code.accept(visitor);
+
+ CodeException[] table = code.getExceptionTable();
+ for(int i=0; i < table.length; i++)
+ table[i].accept(this);
+
+ Attribute[] attributes = code.getAttributes();
+ for(int i=0; i < attributes.length; i++)
+ attributes[i].accept(this);
+ stack.pop();
+ }
+
+ public void visitCodeException(CodeException ce) {
+ stack.push(ce);
+ ce.accept(visitor);
+ stack.pop();
+ }
+
+ public void visitLineNumberTable(LineNumberTable table) {
+ stack.push(table);
+ table.accept(visitor);
+
+ LineNumber[] numbers = table.getLineNumberTable();
+ for(int i=0; i < numbers.length; i++)
+ numbers[i].accept(this);
+ stack.pop();
+ }
+
+ public void visitLineNumber(LineNumber number) {
+ stack.push(number);
+ number.accept(visitor);
+ stack.pop();
+ }
+
+ public void visitLocalVariableTable(LocalVariableTable table) {
+ stack.push(table);
+ table.accept(visitor);
+
+ LocalVariable[] vars = table.getLocalVariableTable();
+ for(int i=0; i < vars.length; i++)
+ vars[i].accept(this);
+ stack.pop();
+ }
+
+ public void visitStackMap(StackMap table) {
+ stack.push(table);
+ table.accept(visitor);
+
+ StackMapEntry[] vars = table.getStackMap();
+
+ for(int i=0; i < vars.length; i++)
+ vars[i].accept(this);
+ stack.pop();
+ }
+
+ public void visitStackMapEntry(StackMapEntry var) {
+ stack.push(var);
+ var.accept(visitor);
+ stack.pop();
+ }
+
+ public void visitLocalVariable(LocalVariable var) {
+ stack.push(var);
+ var.accept(visitor);
+ stack.pop();
+ }
+
+ public void visitConstantPool(ConstantPool cp) {
+ stack.push(cp);
+ cp.accept(visitor);
+
+ Constant[] constants = cp.getConstantPool();
+ for(int i=1; i < constants.length; i++) {
+ if(constants[i] != null)
+ constants[i].accept(this);
+ }
+
+ stack.pop();
+ }
+
+ public void visitConstantClass(ConstantClass constant) {
+ stack.push(constant);
+ constant.accept(visitor);
+ stack.pop();
+ }
+
+ public void visitConstantDouble(ConstantDouble constant) {
+ stack.push(constant);
+ constant.accept(visitor);
+ stack.pop();
+ }
+
+ public void visitConstantFieldref(ConstantFieldref constant) {
+ stack.push(constant);
+ constant.accept(visitor);
+ stack.pop();
+ }
+
+ public void visitConstantFloat(ConstantFloat constant) {
+ stack.push(constant);
+ constant.accept(visitor);
+ stack.pop();
+ }
+
+ public void visitConstantInteger(ConstantInteger constant) {
+ stack.push(constant);
+ constant.accept(visitor);
+ stack.pop();
+ }
+
+ public void visitConstantInterfaceMethodref(ConstantInterfaceMethodref constant) {
+ stack.push(constant);
+ constant.accept(visitor);
+ stack.pop();
+ }
+
+ public void visitConstantLong(ConstantLong constant) {
+ stack.push(constant);
+ constant.accept(visitor);
+ stack.pop();
+ }
+
+ public void visitConstantMethodref(ConstantMethodref constant) {
+ stack.push(constant);
+ constant.accept(visitor);
+ stack.pop();
+ }
+
+ public void visitConstantNameAndType(ConstantNameAndType constant) {
+ stack.push(constant);
+ constant.accept(visitor);
+ stack.pop();
+ }
+
+ public void visitConstantString(ConstantString constant) {
+ stack.push(constant);
+ constant.accept(visitor);
+ stack.pop();
+ }
+
+ public void visitConstantUtf8(ConstantUtf8 constant) {
+ stack.push(constant);
+ constant.accept(visitor);
+ stack.pop();
+ }
+
+ public void visitInnerClasses(InnerClasses ic) {
+ stack.push(ic);
+ ic.accept(visitor);
+
+ InnerClass[] ics = ic.getInnerClasses();
+ for(int i=0; i < ics.length; i++)
+ ics[i].accept(this);
+ stack.pop();
+ }
+
+ public void visitInnerClass(InnerClass inner) {
+ stack.push(inner);
+ inner.accept(visitor);
+ stack.pop();
+ }
+
+ public void visitDeprecated(Deprecated attribute) {
+ stack.push(attribute);
+ attribute.accept(visitor);
+ stack.pop();
+ }
+
+ public void visitSourceFile(SourceFile attribute) {
+ stack.push(attribute);
+ attribute.accept(visitor);
+ stack.pop();
+ }
+
+ public void visitSynthetic(Synthetic attribute) {
+ stack.push(attribute);
+ attribute.accept(visitor);
+ stack.pop();
+ }
+
+ public void visitUnknown(Unknown attribute) {
+ stack.push(attribute);
+ attribute.accept(visitor);
+ stack.pop();
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/EmptyVisitor.java b/src/java/org/apache/bcel/classfile/EmptyVisitor.java
new file mode 100644
index 00000000..ff1ea7e7
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/EmptyVisitor.java
@@ -0,0 +1,104 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.*;
+
+/**
+ * Visitor with empty method bodies, can be extended and used in conjunction with the
+ * DescendingVisitor class, e.g.
+ *
+ * By courtesy of David Spencer.
+ *
+ * @see DescendingVisitor
+ * @version $Id$
+ *
+ */
+public class EmptyVisitor implements Visitor {
+ protected EmptyVisitor() { }
+
+ public void visitCode(Code obj) {}
+ public void visitCodeException(CodeException obj) {}
+ public void visitConstantClass(ConstantClass obj) {}
+ public void visitConstantDouble(ConstantDouble obj) {}
+ public void visitConstantFieldref(ConstantFieldref obj) {}
+ public void visitConstantFloat(ConstantFloat obj) {}
+ public void visitConstantInteger(ConstantInteger obj) {}
+ public void visitConstantInterfaceMethodref(ConstantInterfaceMethodref obj) {}
+ public void visitConstantLong(ConstantLong obj) {}
+ public void visitConstantMethodref(ConstantMethodref obj) {}
+ public void visitConstantNameAndType(ConstantNameAndType obj) {}
+ public void visitConstantPool(ConstantPool obj) {}
+ public void visitConstantString(ConstantString obj) {}
+ public void visitConstantUtf8(ConstantUtf8 obj) {}
+ public void visitConstantValue(ConstantValue obj) {}
+ public void visitDeprecated(Deprecated obj) {}
+ public void visitExceptionTable(ExceptionTable obj) {}
+ public void visitField(Field obj) {}
+ public void visitInnerClass(InnerClass obj) {}
+ public void visitInnerClasses(InnerClasses obj) {}
+ public void visitJavaClass(JavaClass obj) {}
+ public void visitLineNumber(LineNumber obj) {}
+ public void visitLineNumberTable(LineNumberTable obj) {}
+ public void visitLocalVariable(LocalVariable obj) {}
+ public void visitLocalVariableTable(LocalVariableTable obj) {}
+ public void visitMethod(Method obj) {}
+ public void visitSourceFile(SourceFile obj) {}
+ public void visitSynthetic(Synthetic obj) {}
+ public void visitUnknown(Unknown obj) {}
+ public void visitStackMap(StackMap obj) {}
+ public void visitStackMapEntry(StackMapEntry obj) {}
+}
diff --git a/src/java/org/apache/bcel/classfile/ExceptionTable.java b/src/java/org/apache/bcel/classfile/ExceptionTable.java
new file mode 100644
index 00000000..0f26b1f4
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/ExceptionTable.java
@@ -0,0 +1,202 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class represents the table of exceptions that are thrown by a
+ * method. This attribute may be used once per method. The name of
+ * this class is <em>ExceptionTable</em> for historical reasons; The
+ * Java Virtual Machine Specification, Second Edition defines this
+ * attribute using the name <em>Exceptions</em> (which is inconsistent
+ * with the other classes).
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Code
+ */
+public final class ExceptionTable extends Attribute {
+ private int number_of_exceptions; // Table of indices into
+ private int[] exception_index_table; // constant pool
+
+ /**
+ * Initialize from another object. Note that both objects use the same
+ * references (shallow copy). Use copy() for a physical copy.
+ */
+ public ExceptionTable(ExceptionTable c) {
+ this(c.getNameIndex(), c.getLength(), c.getExceptionIndexTable(),
+ c.getConstantPool());
+ }
+
+ /**
+ * @param name_index Index in constant pool
+ * @param length Content length in bytes
+ * @param exception_index_table Table of indices in constant pool
+ * @param constant_pool Array of constants
+ */
+ public ExceptionTable(int name_index, int length,
+ int[] exception_index_table,
+ ConstantPool constant_pool)
+ {
+ super(Constants.ATTR_EXCEPTIONS, name_index, length, constant_pool);
+ setExceptionIndexTable(exception_index_table);
+ }
+
+ /**
+ * Construct object from file stream.
+ * @param name_index Index in constant pool
+ * @param length Content length in bytes
+ * @param file Input stream
+ * @param constant_pool Array of constants
+ * @throw IOException
+ */
+ ExceptionTable(int name_index, int length, DataInputStream file,
+ ConstantPool constant_pool) throws IOException
+ {
+ this(name_index, length, (int[])null, constant_pool);
+
+ number_of_exceptions = file.readUnsignedShort();
+ exception_index_table = new int[number_of_exceptions];
+
+ for(int i=0; i < number_of_exceptions; i++)
+ exception_index_table[i] = file.readUnsignedShort();
+ }
+
+ /**
+ * 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.visitExceptionTable(this);
+ }
+
+ /**
+ * Dump exceptions attribute to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ super.dump(file);
+ file.writeShort(number_of_exceptions);
+ for(int i=0; i < number_of_exceptions; i++)
+ file.writeShort(exception_index_table[i]);
+ }
+
+ /**
+ * @return Array of indices into constant pool of thrown exceptions.
+ */
+ public final int[] getExceptionIndexTable() {return exception_index_table;}
+ /**
+ * @return Length of exception table.
+ */
+ public final int getNumberOfExceptions() { return number_of_exceptions; }
+
+ /**
+ * @return class names of thrown exceptions
+ */
+ public final String[] getExceptionNames() {
+ String[] names = new String[number_of_exceptions];
+ for(int i=0; i < number_of_exceptions; i++)
+ names[i] = constant_pool.getConstantString(exception_index_table[i],
+ Constants.CONSTANT_Class).
+ replace('/', '.');
+ return names;
+ }
+
+ /**
+ * @param exception_index_table.
+ * Also redefines number_of_exceptions according to table length.
+ */
+ public final void setExceptionIndexTable(int[] exception_index_table) {
+ this.exception_index_table = exception_index_table;
+ number_of_exceptions = (exception_index_table == null)? 0 :
+ exception_index_table.length;
+ }
+ /**
+ * @return String representation, i.e., a list of thrown exceptions.
+ */
+ public final String toString() {
+ StringBuffer buf = new StringBuffer("");
+ String str;
+
+ for(int i=0; i < number_of_exceptions; i++) {
+ str = constant_pool.getConstantString(exception_index_table[i],
+ Constants.CONSTANT_Class);
+ buf.append(Utility.compactClassName(str, false));
+
+ if(i < number_of_exceptions - 1)
+ buf.append(", ");
+ }
+
+ return buf.toString();
+ }
+
+ /**
+ * @return deep copy of this attribute
+ */
+ public Attribute copy(ConstantPool constant_pool) {
+ ExceptionTable c = (ExceptionTable)clone();
+ c.exception_index_table = (int[])exception_index_table.clone();
+ c.constant_pool = constant_pool;
+ return c;
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/Field.java b/src/java/org/apache/bcel/classfile/Field.java
new file mode 100644
index 00000000..741f7e1d
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/Field.java
@@ -0,0 +1,157 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class represents the field info structure, i.e., the representation
+ * for a variable in the class. See JVM specification for details.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public final class Field extends FieldOrMethod {
+ /**
+ * Initialize from another object. Note that both objects use the same
+ * references (shallow copy). Use clone() for a physical copy.
+ */
+ public Field(Field c) {
+ super(c);
+ }
+
+ /**
+ * Construct object from file stream.
+ * @param file Input stream
+ */
+ Field(DataInputStream file, ConstantPool constant_pool)
+ throws IOException, ClassFormatError
+ {
+ super(file, constant_pool);
+ }
+
+ /**
+ * @param access_flags Access rights of field
+ * @param name_index Points to field name in constant pool
+ * @param signature_index Points to encoded signature
+ * @param attributes Collection of attributes
+ * @param constant_pool Array of constants
+ */
+ public Field(int access_flags, int name_index, int signature_index,
+ Attribute[] attributes, ConstantPool constant_pool)
+ {
+ super(access_flags, name_index, signature_index, attributes, 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.visitField(this);
+ }
+
+ /**
+ * @return constant value associated with this field (may be null)
+ */
+ public final ConstantValue getConstantValue() {
+ for(int i=0; i < attributes_count; i++)
+ if(attributes[i].getTag() == Constants.ATTR_CONSTANT_VALUE)
+ return (ConstantValue)attributes[i];
+
+ return null;
+ }
+
+ /**
+ * Return string representation close to declaration format,
+ * `public static final short MAX = 100', e.g..
+ *
+ * @return String representation of field, including the signature.
+ */
+ public final String toString() {
+ String name, signature, access; // Short cuts to constant pool
+
+ // Get names from constant pool
+ access = Utility.accessToString(access_flags);
+ access = access.equals("")? "" : (access + " ");
+ signature = Utility.signatureToString(getSignature());
+ name = getName();
+
+ StringBuffer buf = new StringBuffer(access + signature + " " + name);
+ ConstantValue cv = getConstantValue();
+
+ if(cv != null)
+ buf.append(" = " + cv);
+
+ for(int i=0; i < attributes_count; i++) {
+ Attribute a = attributes[i];
+
+ if(!(a instanceof ConstantValue))
+ buf.append(" [" + a.toString() + "]");
+ }
+
+ return buf.toString();
+ }
+
+ /**
+ * @return deep copy of this field
+ */
+ public final Field copy(ConstantPool constant_pool) {
+ return (Field)copy_(constant_pool);
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/FieldOrMethod.java b/src/java/org/apache/bcel/classfile/FieldOrMethod.java
new file mode 100644
index 00000000..a32d1a85
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/FieldOrMethod.java
@@ -0,0 +1,223 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * Abstract super class for fields and methods.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public abstract class FieldOrMethod extends AccessFlags implements Cloneable, Node {
+ protected int name_index; // Points to field name in constant pool
+ protected int signature_index; // Points to encoded signature
+ protected int attributes_count;// No. of attributes
+ protected Attribute[] attributes; // Collection of attributes
+ protected ConstantPool constant_pool;
+
+ FieldOrMethod() {}
+
+ /**
+ * Initialize from another object. Note that both objects use the same
+ * references (shallow copy). Use clone() for a physical copy.
+ */
+ protected FieldOrMethod(FieldOrMethod c) {
+ this(c.getAccessFlags(), c.getNameIndex(), c.getSignatureIndex(),
+ c.getAttributes(), c.getConstantPool());
+ }
+
+ /**
+ * Construct object from file stream.
+ * @param file Input stream
+ * @throw IOException
+ * @throw ClassFormatError
+ */
+ protected FieldOrMethod(DataInputStream file, ConstantPool constant_pool)
+ throws IOException, ClassFormatError
+ {
+ this(file.readUnsignedShort(), file.readUnsignedShort(),
+ file.readUnsignedShort(), null, constant_pool);
+
+ attributes_count = file.readUnsignedShort();
+ attributes = new Attribute[attributes_count];
+ for(int i=0; i < attributes_count; i++)
+ attributes[i] = Attribute.readAttribute(file, constant_pool);
+ }
+
+ /**
+ * @param access_flags Access rights of method
+ * @param name_index Points to field name in constant pool
+ * @param signature_index Points to encoded signature
+ * @param attributes Collection of attributes
+ * @param constant_pool Array of constants
+ */
+ protected FieldOrMethod(int access_flags, int name_index, int signature_index,
+ Attribute[] attributes, ConstantPool constant_pool)
+ {
+ this.access_flags = access_flags;
+ this.name_index = name_index;
+ this.signature_index = signature_index;
+ this.constant_pool = constant_pool;
+
+ setAttributes(attributes);
+ }
+
+ /**
+ * Dump object to file stream on binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ file.writeShort(access_flags);
+ file.writeShort(name_index);
+ file.writeShort(signature_index);
+ file.writeShort(attributes_count);
+
+ for(int i=0; i < attributes_count; i++)
+ attributes[i].dump(file);
+ }
+
+ /**
+ * @return Collection of object attributes.
+ */
+ public final Attribute[] getAttributes() { return attributes; }
+
+ /**
+ * @param attributes Collection of object attributes.
+ */
+ public final void setAttributes(Attribute[] attributes) {
+ this.attributes = attributes;
+ attributes_count = (attributes == null)? 0 : attributes.length;
+ }
+
+ /**
+ * @return Constant pool used by this object.
+ */
+ public final ConstantPool getConstantPool() { return constant_pool; }
+
+ /**
+ * @param constant_pool Constant pool to be used for this object.
+ */
+ public final void setConstantPool(ConstantPool constant_pool) {
+ this.constant_pool = constant_pool;
+ }
+
+ /**
+ * @return Index in constant pool of object's name.
+ */
+ public final int getNameIndex() { return name_index; }
+
+ /**
+ * @param name_index Index in constant pool of object's name.
+ */
+ public final void setNameIndex(int name_index) {
+ this.name_index = name_index;
+ }
+
+ /**
+ * @return Index in constant pool of field signature.
+ */
+ public final int getSignatureIndex() { return signature_index; }
+
+ /**
+ * @param signature_index Index in constant pool of field signature.
+ */
+ public final void setSignatureIndex(int signature_index) {
+ this.signature_index = signature_index;
+ }
+
+ /**
+ * @return Name of object, i.e., method name or field name
+ */
+ public final String getName() {
+ ConstantUtf8 c;
+ c = (ConstantUtf8)constant_pool.getConstant(name_index,
+ Constants.CONSTANT_Utf8);
+ return c.getBytes();
+ }
+
+ /**
+ * @return String representation of object's type signature (java style)
+ */
+ public final String getSignature() {
+ ConstantUtf8 c;
+ c = (ConstantUtf8)constant_pool.getConstant(signature_index,
+ Constants.CONSTANT_Utf8);
+ return c.getBytes();
+ }
+
+ /**
+ * @return deep copy of this field
+ */
+ protected FieldOrMethod copy_(ConstantPool constant_pool) {
+ FieldOrMethod c = null;
+
+ try {
+ c = (FieldOrMethod)clone();
+ } catch(CloneNotSupportedException e) {}
+
+ c.constant_pool = constant_pool;
+ c.attributes = new Attribute[attributes_count];
+
+ for(int i=0; i < attributes_count; i++)
+ c.attributes[i] = attributes[i].copy(constant_pool);
+
+ return c;
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/InnerClass.java b/src/java/org/apache/bcel/classfile/InnerClass.java
new file mode 100644
index 00000000..21e0b0bb
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/InnerClass.java
@@ -0,0 +1,221 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class represents a inner class attribute, i.e., the class
+ * indices of the inner and outer classes, the name and the attributes
+ * of the inner class.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see InnerClasses
+ */
+public final class InnerClass implements Cloneable, Node {
+ private int inner_class_index;
+ private int outer_class_index;
+ private int inner_name_index;
+ private int inner_access_flags;
+
+ /**
+ * Initialize from another object.
+ */
+ public InnerClass(InnerClass c) {
+ this(c.getInnerClassIndex(), c.getOuterClassIndex(), c.getInnerNameIndex(),
+ c.getInnerAccessFlags());
+ }
+
+ /**
+ * Construct object from file stream.
+ * @param file Input stream
+ * @throw IOException
+ */
+ InnerClass(DataInputStream file) throws IOException
+ {
+ this(file.readUnsignedShort(), file.readUnsignedShort(),
+ file.readUnsignedShort(), file.readUnsignedShort());
+ }
+
+ /**
+ * @param inner_class_index Class index in constant pool of inner class
+ * @param outer_class_index Class index in constant pool of outer class
+ * @param inner_name_index Name index in constant pool of inner class
+ * @param inner_access_flags Access flags of inner class
+ */
+ public InnerClass(int inner_class_index, int outer_class_index,
+ int inner_name_index, int inner_access_flags)
+ {
+ this.inner_class_index = inner_class_index;
+ this.outer_class_index = outer_class_index;
+ this.inner_name_index = inner_name_index;
+ this.inner_access_flags = inner_access_flags;
+ }
+
+ /**
+ * 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.visitInnerClass(this);
+ }
+ /**
+ * Dump inner class attribute to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ file.writeShort(inner_class_index);
+ file.writeShort(outer_class_index);
+ file.writeShort(inner_name_index);
+ file.writeShort(inner_access_flags);
+ }
+ /**
+ * @return access flags of inner class.
+ */
+ public final int getInnerAccessFlags() { return inner_access_flags; }
+ /**
+ * @return class index of inner class.
+ */
+ public final int getInnerClassIndex() { return inner_class_index; }
+ /**
+ * @return name index of inner class.
+ */
+ public final int getInnerNameIndex() { return inner_name_index; }
+ /**
+ * @return class index of outer class.
+ */
+ public final int getOuterClassIndex() { return outer_class_index; }
+ /**
+ * @param inner_access_flags.
+ */
+ public final void setInnerAccessFlags(int inner_access_flags) {
+ this.inner_access_flags = inner_access_flags;
+ }
+ /**
+ * @param inner_class_index.
+ */
+ public final void setInnerClassIndex(int inner_class_index) {
+ this.inner_class_index = inner_class_index;
+ }
+ /**
+ * @param inner_name_index.
+ */
+ public final void setInnerNameIndex(int inner_name_index) {
+ this.inner_name_index = inner_name_index;
+ }
+ /**
+ * @param outer_class_index.
+ */
+ public final void setOuterClassIndex(int outer_class_index) {
+ this.outer_class_index = outer_class_index;
+ }
+ /**
+ * @return String representation.
+ */
+ public final String toString() {
+ return "InnerClass(" + inner_class_index + ", " + outer_class_index +
+ ", " + inner_name_index + ", " + inner_access_flags + ")";
+ }
+
+ /**
+ * @return Resolved string representation
+ */
+ public final String toString(ConstantPool constant_pool) {
+ String inner_class_name, outer_class_name, inner_name, access;
+
+ inner_class_name = constant_pool.getConstantString(inner_class_index,
+ Constants.CONSTANT_Class);
+ inner_class_name = Utility.compactClassName(inner_class_name);
+
+ if (outer_class_index != 0) {
+ outer_class_name = constant_pool.getConstantString(outer_class_index,
+ Constants.CONSTANT_Class);
+ outer_class_name = Utility.compactClassName(outer_class_name);
+ }
+ else
+ outer_class_name = "<not a member>";
+
+ if(inner_name_index != 0)
+ inner_name = ((ConstantUtf8)constant_pool.
+ getConstant(inner_name_index, Constants.CONSTANT_Utf8)).getBytes();
+ else
+ inner_name = "<anonymous>";
+
+ access = Utility.accessToString(inner_access_flags, true);
+ access = access.equals("")? "" : (access + " ");
+
+ return "InnerClass:" + access + inner_class_name +
+ "(\"" + outer_class_name + "\", \"" + inner_name + "\")";
+ }
+
+ /**
+ * @return deep copy of this object
+ */
+ public InnerClass copy() {
+ try {
+ return (InnerClass)clone();
+ } catch(CloneNotSupportedException e) {}
+
+ return null;
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/InnerClasses.java b/src/java/org/apache/bcel/classfile/InnerClasses.java
new file mode 100644
index 00000000..beefa38e
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/InnerClasses.java
@@ -0,0 +1,181 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class is derived from <em>Attribute</em> and denotes that this class
+ * is an Inner class of another.
+ * to the source file of this class.
+ * It is instantiated from the <em>Attribute.readAttribute()</em> method.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Attribute
+ */
+public final class InnerClasses extends Attribute {
+ private InnerClass[] inner_classes;
+ private int number_of_classes;
+
+ /**
+ * Initialize from another object. Note that both objects use the same
+ * references (shallow copy). Use clone() for a physical copy.
+ */
+ public InnerClasses(InnerClasses c) {
+ this(c.getNameIndex(), c.getLength(), c.getInnerClasses(),
+ c.getConstantPool());
+ }
+
+ /**
+ * @param name_index Index in constant pool to CONSTANT_Utf8
+ * @param length Content length in bytes
+ * @param inner_classes array of inner classes attributes
+ * @param constant_pool Array of constants
+ * @param sourcefile_index Index in constant pool to CONSTANT_Utf8
+ */
+ public InnerClasses(int name_index, int length,
+ InnerClass[] inner_classes,
+ ConstantPool constant_pool)
+ {
+ super(Constants.ATTR_INNER_CLASSES, name_index, length, constant_pool);
+ setInnerClasses(inner_classes);
+ }
+
+ /**
+ * Construct object from file stream.
+ *
+ * @param name_index Index in constant pool to CONSTANT_Utf8
+ * @param length Content length in bytes
+ * @param file Input stream
+ * @param constant_pool Array of constants
+ * @throw IOException
+ */
+ InnerClasses(int name_index, int length, DataInputStream file,
+ ConstantPool constant_pool) throws IOException
+ {
+ this(name_index, length, (InnerClass[])null, constant_pool);
+
+ number_of_classes = file.readUnsignedShort();
+ inner_classes = new InnerClass[number_of_classes];
+
+ for(int i=0; i < number_of_classes; i++)
+ inner_classes[i] = new InnerClass(file);
+ }
+ /**
+ * 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.visitInnerClasses(this);
+ }
+ /**
+ * Dump source file attribute to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ super.dump(file);
+ file.writeShort(number_of_classes);
+
+ for(int i=0; i < number_of_classes; i++)
+ inner_classes[i].dump(file);
+ }
+
+ /**
+ * @return array of inner class "records"
+ */
+ public final InnerClass[] getInnerClasses() { return inner_classes; }
+
+ /**
+ * @param inner_classes.
+ */
+ public final void setInnerClasses(InnerClass[] inner_classes) {
+ this.inner_classes = inner_classes;
+ number_of_classes = (inner_classes == null)? 0 : inner_classes.length;
+ }
+
+ /**
+ * @return String representation.
+ */
+ public final String toString() {
+ StringBuffer buf = new StringBuffer();
+
+ for(int i=0; i < number_of_classes; i++)
+ buf.append(inner_classes[i].toString(constant_pool) + "\n");
+
+ return buf.toString();
+ }
+
+ /**
+ * @return deep copy of this attribute
+ */
+ public Attribute copy(ConstantPool constant_pool) {
+ InnerClasses c = (InnerClasses)clone();
+
+ c.inner_classes = new InnerClass[number_of_classes];
+ for(int i=0; i < number_of_classes; i++)
+ c.inner_classes[i] = inner_classes[i].copy();
+
+ c.constant_pool = constant_pool;
+ return c;
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/JavaClass.java b/src/java/org/apache/bcel/classfile/JavaClass.java
new file mode 100644
index 00000000..82084ab5
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/JavaClass.java
@@ -0,0 +1,611 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import org.apache.bcel.Repository;
+import java.io.*;
+import java.util.StringTokenizer;
+
+/**
+ * Represents a Java class, i.e., the data structures, constant pool,
+ * fields, methods and commands contained in a Java .class file.
+ * See <a href="ftp://java.sun.com/docs/specs/">JVM
+ * specification</a> for details.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class JavaClass extends AccessFlags implements Cloneable, Node {
+ private String file_name;
+ private String package_name;
+ private String source_file_name = "<Unknown>";
+ private int class_name_index;
+ private int superclass_name_index;
+ private String class_name;
+ private String superclass_name;
+ private int major, minor; // Compiler version
+ private ConstantPool constant_pool; // Constant pool
+ private int[] interfaces; // implemented interfaces
+ private String[] interface_names;
+ private Field[] fields; // Fields, i.e., variables of class
+ private Method[] methods; // methods defined in the class
+ private Attribute[] attributes; // attributes defined in the class
+ private byte source = HEAP; // Generated in memory
+
+ public static final byte HEAP = 1;
+ public static final byte FILE = 2;
+ public static final byte ZIP = 3;
+
+ static boolean debug = false; // Debugging on/off
+ static char sep = '/'; // directory separator
+
+ /**
+ * Constructor gets all contents as arguments.
+ *
+ * @param class_name Class name
+ * @param superclass_name Superclass name
+ * @param file_name File name
+ * @param major Major compiler version
+ * @param minor Minor compiler version
+ * @param access_flags Access rights defined by bit flags
+ * @param constant_pool Array of constants
+ * @param interfaces Implemented interfaces
+ * @param fields Class fields
+ * @param methods Class methods
+ * @param attributes Class attributes
+ * @param source Read from file or generated in memory?
+ */
+ public JavaClass(int class_name_index,
+ int superclass_name_index,
+ String file_name,
+ int major,
+ int minor,
+ int access_flags,
+ ConstantPool constant_pool,
+ int[] interfaces,
+ Field[] fields,
+ Method[] methods,
+ Attribute[] attributes,
+ byte source)
+ {
+ if(interfaces == null) // Allowed for backward compatibility
+ interfaces = new int[0];
+ if(attributes == null)
+ this.attributes = new Attribute[0];
+ if(fields == null)
+ fields = new Field[0];
+ if(methods == null)
+ methods = new Method[0];
+
+ this.class_name_index = class_name_index;
+ this.superclass_name_index = superclass_name_index;
+ this.file_name = file_name;
+ this.major = major;
+ this.minor = minor;
+ this.access_flags = access_flags;
+ this.constant_pool = constant_pool;
+ this.interfaces = interfaces;
+ this.fields = fields;
+ this.methods = methods;
+ this.attributes = attributes;
+ this.source = source;
+
+ // Get source file name if available
+ for(int i=0; i < attributes.length; i++) {
+ if(attributes[i] instanceof SourceFile) {
+ source_file_name = ((SourceFile)attributes[i]).getSourceFileName();
+ break;
+ }
+ }
+
+ // Get class name and superclass name
+ ConstantUtf8 name;
+
+ /* According to the specification the following entries must be of type
+ * `ConstantClass' but we check that anyway via the
+ * `ConstPool.getConstant' method.
+ */
+ class_name = constant_pool.getConstantString(class_name_index,
+ Constants.CONSTANT_Class);
+ class_name = Utility.compactClassName(class_name, false);
+
+ int index = class_name.lastIndexOf('.');
+ if(index < 0)
+ package_name = "";
+ else
+ package_name = class_name.substring(0, index);
+
+ if(superclass_name_index > 0) { // May be zero -> class is java.lang.Object
+ superclass_name = constant_pool.getConstantString(superclass_name_index,
+ Constants.CONSTANT_Class);
+ superclass_name = Utility.compactClassName(superclass_name, false);
+ }
+ else
+ superclass_name = "java.lang.Object";
+
+ interface_names = new String[interfaces.length];
+ for(int i=0; i < interfaces.length; i++) {
+ String str = constant_pool.getConstantString(interfaces[i], Constants.CONSTANT_Class);
+ interface_names[i] = Utility.compactClassName(str, false);
+ }
+ }
+
+ /**
+ * Constructor gets all contents as arguments.
+ *
+ * @param class_name Class name
+ * @param superclass_name Superclass name
+ * @param file_name File name
+ * @param major Major compiler version
+ * @param minor Minor compiler version
+ * @param access_flags Access rights defined by bit flags
+ * @param constant_pool Array of constants
+ * @param interfaces Implemented interfaces
+ * @param fields Class fields
+ * @param methods Class methods
+ * @param attributes Class attributes
+ */
+ public JavaClass(int class_name_index,
+ int superclass_name_index,
+ String file_name,
+ int major,
+ int minor,
+ int access_flags,
+ ConstantPool constant_pool,
+ int[] interfaces,
+ Field[] fields,
+ Method[] methods,
+ Attribute[] attributes) {
+ this(class_name_index, superclass_name_index, file_name, major, minor, access_flags,
+ constant_pool, interfaces, fields, methods, attributes, HEAP);
+ }
+
+
+ /**
+ * 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.visitJavaClass(this);
+ }
+
+ /* Print debug information depending on `JavaClass.debug'
+ */
+ static final void Debug(String str) {
+ if(debug)
+ System.out.println(str);
+ }
+
+ /**
+ * Dump class to a file.
+ *
+ * @param file Output file
+ * @throw IOException
+ */
+ public void dump(File file) throws IOException
+ {
+ String parent = file.getParent();
+
+ if(parent != null) {
+ File dir = new File(parent);
+
+ if(dir != null)
+ dir.mkdirs();
+ }
+
+ dump(new DataOutputStream(new FileOutputStream(file)));
+ }
+
+ /**
+ * Dump class to a file named file_name.
+ *
+ * @param file_name Output file name
+ * @exception IOException
+ */
+ public void dump(String file_name) throws IOException
+ {
+ dump(new File(file_name));
+ }
+
+ /**
+ * @return class in binary format
+ */
+ public byte[] getBytes() {
+ ByteArrayOutputStream s = new ByteArrayOutputStream();
+ DataOutputStream ds = new DataOutputStream(s);
+
+ try {
+ dump(ds);
+ ds.close();
+ } catch(IOException e) { e.printStackTrace(); }
+
+ return s.toByteArray();
+ }
+
+ /**
+ * Dump Java class to output stream in binary format.
+ *
+ * @param file Output stream
+ * @exception IOException
+ */
+ public void dump(OutputStream file) throws IOException {
+ dump(new DataOutputStream(file));
+ }
+
+ /**
+ * Dump Java class to output stream in binary format.
+ *
+ * @param file Output stream
+ * @exception IOException
+ */
+ public void dump(DataOutputStream file) throws IOException
+ {
+ file.writeInt(0xcafebabe);
+ file.writeShort(minor);
+ file.writeShort(major);
+
+ constant_pool.dump(file);
+
+ file.writeShort(access_flags);
+ file.writeShort(class_name_index);
+ file.writeShort(superclass_name_index);
+
+ file.writeShort(interfaces.length);
+ for(int i=0; i < interfaces.length; i++)
+ file.writeShort(interfaces[i]);
+
+ file.writeShort(fields.length);
+ for(int i=0; i < fields.length; i++)
+ fields[i].dump(file);
+
+ file.writeShort(methods.length);
+ for(int i=0; i < methods.length; i++)
+ methods[i].dump(file);
+
+ if(attributes != null) {
+ file.writeShort(attributes.length);
+ for(int i=0; i < attributes.length; i++)
+ attributes[i].dump(file);
+ }
+ else
+ file.writeShort(0);
+
+ file.close();
+ }
+
+ /**
+ * @return Attributes of the class.
+ */
+ public Attribute[] getAttributes() { return attributes; }
+
+ /**
+ * @return Class name.
+ */
+ public String getClassName() { return class_name; }
+
+ /**
+ * @return Package name.
+ */
+ public String getPackageName() { return package_name; }
+
+ /**
+ * @return Class name index.
+ */
+ public int getClassNameIndex() { return class_name_index; }
+
+ /**
+ * @return Constant pool.
+ */
+ public ConstantPool getConstantPool() { return constant_pool; }
+
+ /**
+ * @return Fields, i.e., variables of the class.
+ */
+ public Field[] getFields() { return fields; }
+ /**
+ * @return File name of class, aka SourceFile attribute value
+ */
+ public String getFileName() { return file_name; }
+ /**
+ * @return Names of implemented interfaces.
+ */
+ public String[] getInterfaceNames() { return interface_names; }
+ /**
+ * @return Implemented interfaces.
+ */
+ public int[] getInterfaces() { return interfaces; }
+ /**
+ * @return Major number of compiler version.
+ */
+ public int getMajor() { return major; }
+ /**
+ * @return Methods of the class.
+ */
+ public Method[] getMethods() { return methods; }
+ /**
+ * @return Minor number of compiler version.
+ */
+ public int getMinor() { return minor; }
+
+ /**
+ * @return sbsolute path to file where this class was read from
+ */
+ public String getSourceFileName() { return source_file_name; }
+
+ /**
+ * @return Superclass name.
+ */
+ public String getSuperclassName() { return superclass_name; }
+ /**
+ * @return Class name index.
+ */
+ public int getSuperclassNameIndex() { return superclass_name_index; }
+
+ static {
+ // Debugging ... on/off
+ String debug = System.getProperty("JavaClass.debug");
+
+ if(debug != null)
+ JavaClass.debug = new Boolean(debug).booleanValue();
+
+ // Get path separator either / or \ usually
+ String sep = System.getProperty("file.separator");
+
+ if(sep != null)
+ try {
+ JavaClass.sep = sep.charAt(0);
+ } catch(StringIndexOutOfBoundsException e) {} // Never reached
+ }
+
+ /**
+ * @param attributes.
+ */
+ public void setAttributes(Attribute[] attributes) {
+ this.attributes = attributes;
+ }
+ /**
+ * @param class_name.
+ */
+ public void setClassName(String class_name) {
+ this.class_name = class_name;
+ }
+ /**
+ * @param class_name_index.
+ */
+ public void setClassNameIndex(int class_name_index) {
+ this.class_name_index = class_name_index;
+ }
+ /**
+ * @param constant_pool.
+ */
+ public void setConstantPool(ConstantPool constant_pool) {
+ this.constant_pool = constant_pool;
+ }
+ /**
+ * @param fields.
+ */
+ public void setFields(Field[] fields) {
+ this.fields = fields;
+ }
+ /**
+ * Set File name of class, aka SourceFile attribute value
+ */
+ public void setFileName(String file_name) {
+ this.file_name = file_name;
+ }
+ /**
+ * @param interface_names.
+ */
+ public void setInterfaceNames(String[] interface_names) {
+ this.interface_names = interface_names;
+ }
+ /**
+ * @param interfaces.
+ */
+ public void setInterfaces(int[] interfaces) {
+ this.interfaces = interfaces;
+ }
+ /**
+ * @param major.
+ */
+ public void setMajor(int major) {
+ this.major = major;
+ }
+ /**
+ * @param methods.
+ */
+ public void setMethods(Method[] methods) {
+ this.methods = methods;
+ }
+ /**
+ * @param minor.
+ */
+ public void setMinor(int minor) {
+ this.minor = minor;
+ }
+ /**
+ * Set absolute path to file this class was read from.
+ */
+ public void setSourceFileName(String source_file_name) {
+ this.source_file_name = source_file_name;
+ }
+ /**
+ * @param superclass_name.
+ */
+ public void setSuperclassName(String superclass_name) {
+ this.superclass_name = superclass_name;
+ }
+ /**
+ * @param superclass_name_index.
+ */
+ public void setSuperclassNameIndex(int superclass_name_index) {
+ this.superclass_name_index = superclass_name_index;
+ }
+ /**
+ * @return String representing class contents.
+ */
+ public String toString() {
+ String access = Utility.accessToString(access_flags, true);
+ access = access.equals("")? "" : (access + " ");
+
+ StringBuffer buf = new StringBuffer(access +
+ Utility.classOrInterface(access_flags) +
+ " " +
+ class_name + " extends " +
+ Utility.compactClassName(superclass_name,
+ false) + '\n');
+ int size = interfaces.length;
+
+ if(size > 0) {
+ buf.append("implements\t\t");
+
+ for(int i=0; i < size; i++) {
+ buf.append(interface_names[i]);
+ if(i < size - 1)
+ buf.append(", ");
+ }
+
+ buf.append('\n');
+ }
+
+ buf.append("filename\t\t" + file_name + '\n');
+ buf.append("compiled from\t\t" + source_file_name + '\n');
+ buf.append("compiler version\t" + major + "." + minor + '\n');
+ buf.append("access flags\t\t" + access_flags + '\n');
+ buf.append("constant pool\t\t" + constant_pool.getLength() + " entries\n");
+ buf.append("ACC_SUPER flag\t\t" + isSuper() + "\n");
+
+ if(attributes.length > 0) {
+ buf.append("\nAttribute(s):\n");
+ for(int i=0; i < attributes.length; i++)
+ buf.append(indent(attributes[i]));
+ }
+
+ if(fields.length > 0) {
+ buf.append("\n" + fields.length + " fields:\n");
+ for(int i=0; i < fields.length; i++)
+ buf.append("\t" + fields[i] + '\n');
+ }
+
+ if(methods.length > 0) {
+ buf.append("\n" + methods.length + " methods:\n");
+ for(int i=0; i < methods.length; i++)
+ buf.append("\t" + methods[i] + '\n');
+ }
+
+ return buf.toString();
+ }
+
+ private static final String indent(Object obj) {
+ StringTokenizer tok = new StringTokenizer(obj.toString(), "\n");
+ StringBuffer buf = new StringBuffer();
+
+ while(tok.hasMoreTokens())
+ buf.append("\t" + tok.nextToken() + "\n");
+
+ return buf.toString();
+ }
+
+ /**
+ * @return deep copy of this class
+ */
+ public JavaClass copy() {
+ JavaClass c = null;
+
+ try {
+ c = (JavaClass)clone();
+ } catch(CloneNotSupportedException e) {}
+
+ c.constant_pool = constant_pool.copy();
+ c.interfaces = (int[])interfaces.clone();
+ c.interface_names = (String[])interface_names.clone();
+
+ c.fields = new Field[fields.length];
+ for(int i=0; i < fields.length; i++)
+ c.fields[i] = fields[i].copy(c.constant_pool);
+
+ c.methods = new Method[methods.length];
+ for(int i=0; i < methods.length; i++)
+ c.methods[i] = methods[i].copy(c.constant_pool);
+
+ c.attributes = new Attribute[attributes.length];
+ for(int i=0; i < attributes.length; i++)
+ c.attributes[i] = attributes[i].copy(c.constant_pool);
+
+ return c;
+ }
+
+ public final boolean instanceOf(JavaClass super_class) {
+ return Repository.instanceOf(this, super_class);
+ }
+
+ public final boolean isSuper() {
+ return (access_flags & Constants.ACC_SUPER) != 0;
+ }
+
+ public final boolean isClass() {
+ return (access_flags & Constants.ACC_INTERFACE) == 0;
+ }
+
+ /** @return returns either HEAP (generated), FILE, or ZIP
+ */
+ public final byte getSource() {
+ return source;
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/LineNumber.java b/src/java/org/apache/bcel/classfile/LineNumber.java
new file mode 100644
index 00000000..d7b76ae8
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/LineNumber.java
@@ -0,0 +1,164 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class represents a (PC offset, line number) pair, i.e., a line number in
+ * the source that corresponds to a relative address in the byte code. This
+ * is used for debugging purposes.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see LineNumberTable
+ */
+public final class LineNumber implements Cloneable, Node {
+ private int start_pc; // Program Counter (PC) corresponds to line
+ private int line_number; // number in source file
+
+ /**
+ * Initialize from another object.
+ */
+ public LineNumber(LineNumber c) {
+ this(c.getStartPC(), c.getLineNumber());
+ }
+
+ /**
+ * Construct object from file stream.
+ * @param file Input stream
+ * @throw IOException
+ */
+ LineNumber(DataInputStream file) throws IOException
+ {
+ this(file.readUnsignedShort(), file.readUnsignedShort());
+ }
+
+ /**
+ * @param start_pc Program Counter (PC) corresponds to
+ * @param line_number line number in source file
+ */
+ public LineNumber(int start_pc, int line_number)
+ {
+ this.start_pc = start_pc;
+ this.line_number = line_number;
+ }
+
+ /**
+ * 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.visitLineNumber(this);
+ }
+
+ /**
+ * Dump line number/pc pair to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ file.writeShort(start_pc);
+ file.writeShort(line_number);
+
+ }
+ /**
+ * @return Corresponding source line
+ */
+ public final int getLineNumber() { return line_number; }
+
+ /**
+ * @return PC in code
+ */
+ public final int getStartPC() { return start_pc; }
+
+ /**
+ * @param line_number.
+ */
+ public final void setLineNumber(int line_number) {
+ this.line_number = line_number;
+ }
+
+ /**
+ * @param start_pc.
+ */
+ public final void setStartPC(int start_pc) {
+ this.start_pc = start_pc;
+ }
+
+ /**
+ * @return String representation
+ */
+ public final String toString() {
+ return "LineNumber(" + start_pc + ", " + line_number + ")";
+ }
+
+ /**
+ * @return deep copy of this object
+ */
+ public LineNumber copy() {
+ try {
+ return (LineNumber)clone();
+ } catch(CloneNotSupportedException e) {}
+
+ return null;
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/LineNumberTable.java b/src/java/org/apache/bcel/classfile/LineNumberTable.java
new file mode 100644
index 00000000..bc71ca80
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/LineNumberTable.java
@@ -0,0 +1,234 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class represents a table of line numbers for debugging
+ * purposes. This attribute is used by the <em>Code</em> attribute. It
+ * contains pairs of PCs and line numbers.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Code
+ * @see LineNumber
+ */
+public final class LineNumberTable extends Attribute {
+ private int line_number_table_length;
+ private LineNumber[] line_number_table; // Table of line/numbers pairs
+
+ /*
+ * Initialize from another object. Note that both objects use the same
+ * references (shallow copy). Use copy() for a physical copy.
+ */
+ public LineNumberTable(LineNumberTable c) {
+ this(c.getNameIndex(), c.getLength(), c.getLineNumberTable(),
+ c.getConstantPool());
+ }
+
+ /*
+ * @param name_index Index of name
+ * @param length Content length in bytes
+ * @param line_number_table Table of line/numbers pairs
+ * @param constant_pool Array of constants
+ */
+ public LineNumberTable(int name_index, int length,
+ LineNumber[] line_number_table,
+ ConstantPool constant_pool)
+ {
+ super(Constants.ATTR_LINE_NUMBER_TABLE, name_index, length, constant_pool);
+ setLineNumberTable(line_number_table);
+ }
+
+ /**
+ * Construct object from file stream.
+ * @param name_index Index of name
+ * @param length Content length in bytes
+ * @param file Input stream
+ * @throw IOException
+ * @param constant_pool Array of constants
+ */
+ LineNumberTable(int name_index, int length, DataInputStream file,
+ ConstantPool constant_pool) throws IOException
+ {
+ this(name_index, length, (LineNumber[])null, constant_pool);
+ line_number_table_length = (file.readUnsignedShort());
+ line_number_table = new LineNumber[line_number_table_length];
+
+ for(int i=0; i < line_number_table_length; i++)
+ line_number_table[i] = new LineNumber(file);
+ }
+ /**
+ * 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.visitLineNumberTable(this);
+ }
+ /**
+ * Dump line number table attribute to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ super.dump(file);
+ file.writeShort(line_number_table_length);
+ for(int i=0; i < line_number_table_length; i++)
+ line_number_table[i].dump(file);
+ }
+
+ /**
+ * @return Array of (pc offset, line number) pairs.
+ */
+ public final LineNumber[] getLineNumberTable() { return line_number_table; }
+
+ /**
+ * @param line_number_table.
+ */
+ public final void setLineNumberTable(LineNumber[] line_number_table) {
+ this.line_number_table = line_number_table;
+
+ line_number_table_length = (line_number_table == null)? 0 :
+ line_number_table.length;
+ }
+
+ /**
+ * @return String representation.
+ */
+ public final String toString() {
+ StringBuffer buf = new StringBuffer();
+ StringBuffer line = new StringBuffer();
+
+ for(int i=0; i < line_number_table_length; i++) {
+ line.append(line_number_table[i].toString());
+
+ if(i < line_number_table_length - 1)
+ line.append(", ");
+
+ if(line.length() > 72) {
+ line.append('\n');
+ buf.append(line);
+ line.setLength(0);
+ }
+ }
+
+ buf.append(line);
+
+ return buf.toString();
+ }
+
+ /**
+ * Map byte code positions to source code lines.
+ *
+ * @param pos byte code offset
+ * @return corresponding line in source code
+ */
+ public int getSourceLine(int pos) {
+ int l = 0, r = line_number_table_length-1;
+
+ if(r < 0) // array is empty
+ return -1;
+
+ int min_index = -1, min=-1;
+
+ /* Do a binary search since the array is ordered.
+ */
+ do {
+ int i = (l + r) / 2;
+ int j = line_number_table[i].getStartPC();
+
+ if(j == pos)
+ return line_number_table[i].getLineNumber();
+ else if(pos < j) // else constrain search area
+ r = i - 1;
+ else // pos > j
+ l = i + 1;
+
+ /* If exact match can't be found (which is the most common case)
+ * return the line number that corresponds to the greatest index less
+ * than pos.
+ */
+ if(j < pos && j > min) {
+ min = j;
+ min_index = i;
+ }
+ } while(l <= r);
+
+ return line_number_table[min_index].getLineNumber();
+ }
+
+ /**
+ * @return deep copy of this attribute
+ */
+ public Attribute copy(ConstantPool constant_pool) {
+ LineNumberTable c = (LineNumberTable)clone();
+
+ c.line_number_table = new LineNumber[line_number_table_length];
+ for(int i=0; i < line_number_table_length; i++)
+ c.line_number_table[i] = line_number_table[i].copy();
+
+ c.constant_pool = constant_pool;
+ return c;
+ }
+
+ public final int getTableLength() { return line_number_table_length; }
+}
diff --git a/src/java/org/apache/bcel/classfile/LocalVariable.java b/src/java/org/apache/bcel/classfile/LocalVariable.java
new file mode 100644
index 00000000..76a67c0f
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/LocalVariable.java
@@ -0,0 +1,257 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class represents a local variable within a method. It contains its
+ * scope, name, signature and index on the method's frame.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see LocalVariableTable
+ */
+public final class LocalVariable implements Constants, Cloneable, Node {
+ private int start_pc; // Range in which the variable is valid
+ private int length;
+ private int name_index; // Index in constant pool of variable name
+ private int signature_index; // Index of variable signature
+ private int index; /* Variable is `index'th local variable on
+ * this method's frame.
+ */
+
+ private ConstantPool constant_pool;
+
+ /**
+ * Initialize from another object. Note that both objects use the same
+ * references (shallow copy). Use copy() for a physical copy.
+ */
+ public LocalVariable(LocalVariable c) {
+ this(c.getStartPC(), c.getLength(), c.getNameIndex(),
+ c.getSignatureIndex(), c.getIndex(), c.getConstantPool());
+ }
+
+ /**
+ * Construct object from file stream.
+ * @param file Input stream
+ * @throw IOException
+ */
+ LocalVariable(DataInputStream file, ConstantPool constant_pool)
+ throws IOException
+ {
+ this(file.readUnsignedShort(), file.readUnsignedShort(),
+ file.readUnsignedShort(), file.readUnsignedShort(),
+ file.readUnsignedShort(), constant_pool);
+ }
+
+ /**
+ * @param start_pc Range in which the variable
+ * @param length ... is valid
+ * @param name_index Index in constant pool of variable name
+ * @param signature_index Index of variable's signature
+ * @param index Variable is `index'th local variable on the method's frame
+ * @param constant_pool Array of constants
+ */
+ public LocalVariable(int start_pc, int length, int name_index,
+ int signature_index, int index,
+ ConstantPool constant_pool)
+ {
+ this.start_pc = start_pc;
+ this.length = length;
+ this.name_index = name_index;
+ this.signature_index = signature_index;
+ this.index = index;
+ 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.visitLocalVariable(this);
+ }
+
+ /**
+ * Dump local variable to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ file.writeShort(start_pc);
+ file.writeShort(length);
+ file.writeShort(name_index);
+ file.writeShort(signature_index);
+ file.writeShort(index);
+ }
+
+ /**
+ * @return Constant pool used by this object.
+ */
+ public final ConstantPool getConstantPool() { return constant_pool; }
+
+ /**
+ * @return Variable is valid within getStartPC() .. getStartPC()+getLength()
+ */
+ public final int getLength() { return length; }
+
+ /**
+ * @return Variable name.
+ */
+ public final String getName() {
+ ConstantUtf8 c;
+
+ c = (ConstantUtf8)constant_pool.getConstant(name_index, CONSTANT_Utf8);
+ return c.getBytes();
+ }
+
+ /**
+ * @return Index in constant pool of variable name.
+ */
+ public final int getNameIndex() { return name_index; }
+
+ /**
+ * @return Signature.
+ */
+ public final String getSignature() {
+ ConstantUtf8 c;
+ c = (ConstantUtf8)constant_pool.getConstant(signature_index,
+ CONSTANT_Utf8);
+ return c.getBytes();
+ }
+
+ /**
+ * @return Index in constant pool of variable signature.
+ */
+ public final int getSignatureIndex() { return signature_index; }
+
+ /**
+ * @return index of register where variable is stored
+ */
+ public final int getIndex() { return index; }
+
+ /**
+ * @return Start of range where he variable is valid
+ */
+ public final int getStartPC() { return start_pc; }
+
+ /**
+ * @param constant_pool Constant pool to be used for this object.
+ */
+ public final void setConstantPool(ConstantPool constant_pool) {
+ this.constant_pool = constant_pool;
+ }
+
+ /**
+ * @param length.
+ */
+ public final void setLength(int length) {
+ this.length = length;
+ }
+
+ /**
+ * @param name_index.
+ */
+ public final void setNameIndex(int name_index) {
+ this.name_index = name_index;
+ }
+
+ /**
+ * @param signature_index.
+ */
+ public final void setSignatureIndex(int signature_index) {
+ this.signature_index = signature_index;
+ }
+
+ /**
+ * @param index.
+ */
+ public final void setIndex(int index) { this.index = index; }
+
+ /**
+ * @param start_pc Specify range where the local variable is valid.
+ */
+ public final void setStartPC(int start_pc) {
+ this.start_pc = start_pc;
+ }
+
+ /**
+ * @return string representation.
+ */
+ public final String toString() {
+ String name = getName(), signature = Utility.signatureToString(getSignature());
+
+ return "LocalVariable(start_pc = " + start_pc + ", length = " + length +
+ ", index = " + index + ":" + signature + " " + name + ")";
+ }
+
+ /**
+ * @return deep copy of this object
+ */
+ public LocalVariable copy() {
+ try {
+ return (LocalVariable)clone();
+ } catch(CloneNotSupportedException e) {}
+
+ return null;
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/LocalVariableTable.java b/src/java/org/apache/bcel/classfile/LocalVariableTable.java
new file mode 100644
index 00000000..809b6406
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/LocalVariableTable.java
@@ -0,0 +1,196 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class represents colection of local variables in a
+ * method. This attribute is contained in the <em>Code</em> attribute.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Code
+ * @see LocalVariable
+ */
+public class LocalVariableTable extends Attribute {
+ private int local_variable_table_length; // Table of local
+ private LocalVariable[] local_variable_table; // variables
+
+ /**
+ * Initialize from another object. Note that both objects use the same
+ * references (shallow copy). Use copy() for a physical copy.
+ */
+ public LocalVariableTable(LocalVariableTable c) {
+ this(c.getNameIndex(), c.getLength(), c.getLocalVariableTable(),
+ c.getConstantPool());
+ }
+
+ /**
+ * @param name_index Index in constant pool to `LocalVariableTable'
+ * @param length Content length in bytes
+ * @param local_variable_table Table of local variables
+ * @param constant_pool Array of constants
+ */
+ public LocalVariableTable(int name_index, int length,
+ LocalVariable[] local_variable_table,
+ ConstantPool constant_pool)
+ {
+ super(Constants.ATTR_LOCAL_VARIABLE_TABLE, name_index, length, constant_pool);
+ setLocalVariableTable(local_variable_table);
+ }
+
+ /**
+ * Construct object from file stream.
+ * @param name_index Index in constant pool
+ * @param length Content length in bytes
+ * @param file Input stream
+ * @param constant_pool Array of constants
+ * @throw IOException
+ */
+ LocalVariableTable(int name_index, int length, DataInputStream file,
+ ConstantPool constant_pool) throws IOException
+ {
+ this(name_index, length, (LocalVariable[])null, constant_pool);
+
+ local_variable_table_length = (file.readUnsignedShort());
+ local_variable_table = new LocalVariable[local_variable_table_length];
+
+ for(int i=0; i < local_variable_table_length; i++)
+ local_variable_table[i] = new LocalVariable(file, 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.visitLocalVariableTable(this);
+ }
+
+ /**
+ * Dump local variable table attribute to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ super.dump(file);
+ file.writeShort(local_variable_table_length);
+ for(int i=0; i < local_variable_table_length; i++)
+ local_variable_table[i].dump(file);
+ }
+
+ /**
+ * @return Array of local variables of method.
+ */
+ public final LocalVariable[] getLocalVariableTable() {
+ return local_variable_table;
+ }
+
+ /** @return first matching variable using index
+ */
+ public final LocalVariable getLocalVariable(int index) {
+ for(int i=0; i < local_variable_table_length; i++)
+ if(local_variable_table[i].getIndex() == index)
+ return local_variable_table[i];
+
+ return null;
+ }
+
+ public final void setLocalVariableTable(LocalVariable[] local_variable_table)
+ {
+ this.local_variable_table = local_variable_table;
+ local_variable_table_length = (local_variable_table == null)? 0 :
+ local_variable_table.length;
+ }
+
+ /**
+ * @return String representation.
+ */
+ public final String toString() {
+ StringBuffer buf = new StringBuffer("");
+
+ for(int i=0; i < local_variable_table_length; i++) {
+ buf.append(local_variable_table[i].toString());
+
+ if(i < local_variable_table_length - 1)
+ buf.append('\n');
+ }
+
+ return buf.toString();
+ }
+
+ /**
+ * @return deep copy of this attribute
+ */
+ public Attribute copy(ConstantPool constant_pool) {
+ LocalVariableTable c = (LocalVariableTable)clone();
+
+ c.local_variable_table = new LocalVariable[local_variable_table_length];
+ for(int i=0; i < local_variable_table_length; i++)
+ c.local_variable_table[i] = local_variable_table[i].copy();
+
+ c.constant_pool = constant_pool;
+ return c;
+ }
+
+ public final int getTableLength() { return local_variable_table_length; }
+}
diff --git a/src/java/org/apache/bcel/classfile/Method.java b/src/java/org/apache/bcel/classfile/Method.java
new file mode 100644
index 00000000..7acf4389
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/Method.java
@@ -0,0 +1,216 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class represents the method info structure, i.e., the representation
+ * for a method in the class. See JVM specification for details.
+ * A method has access flags, a name, a signature and a number of attributes.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public final class Method extends FieldOrMethod {
+ /**
+ * Empty constructor, all attributes have to be defined via `setXXX'
+ * methods. Use at your own risk.
+ */
+ public Method() {}
+
+ /**
+ * Initialize from another object. Note that both objects use the same
+ * references (shallow copy). Use clone() for a physical copy.
+ */
+ public Method(Method c) {
+ super(c);
+ }
+
+ /**
+ * Construct object from file stream.
+ * @param file Input stream
+ * @throw IOException
+ * @throw ClassFormatError
+ */
+ Method(DataInputStream file, ConstantPool constant_pool)
+ throws IOException, ClassFormatError
+ {
+ super(file, constant_pool);
+ }
+
+ /**
+ * @param access_flags Access rights of method
+ * @param name_index Points to field name in constant pool
+ * @param signature_index Points to encoded signature
+ * @param attributes Collection of attributes
+ * @param constant_pool Array of constants
+ */
+ public Method(int access_flags, int name_index, int signature_index,
+ Attribute[] attributes, ConstantPool constant_pool)
+ {
+ super(access_flags, name_index, signature_index, attributes, 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.visitMethod(this);
+ }
+
+ /**
+ * @return Code attribute of method, if any
+ */
+ public final Code getCode() {
+ for(int i=0; i < attributes_count; i++)
+ if(attributes[i] instanceof Code)
+ return (Code)attributes[i];
+
+ return null;
+ }
+
+ /**
+ * @return ExceptionTable attribute of method, if any, i.e., list all
+ * exceptions the method may throw not exception handlers!
+ */
+ public final ExceptionTable getExceptionTable() {
+ for(int i=0; i < attributes_count; i++)
+ if(attributes[i] instanceof ExceptionTable)
+ return (ExceptionTable)attributes[i];
+
+ return null;
+ }
+
+ /** @return LocalVariableTable of code attribute if any, i.e. the call is forwarded
+ * to the Code atribute.
+ */
+ public final LocalVariableTable getLocalVariableTable() {
+ Code code = getCode();
+
+ if(code != null)
+ return code.getLocalVariableTable();
+ else
+ return null;
+ }
+
+ /** @return LineNumberTable of code attribute if any, i.e. the call is forwarded
+ * to the Code atribute.
+ */
+ public final LineNumberTable getLineNumberTable() {
+ Code code = getCode();
+
+ if(code != null)
+ return code.getLineNumberTable();
+ else
+ return null;
+ }
+
+ /**
+ * Return string representation close to declaration format,
+ * `public static void main(String[] args) throws IOException', e.g.
+ *
+ * @return String representation of the method.
+ */
+ public final String toString() {
+ ConstantUtf8 c;
+ ConstantValue cv;
+ String name, signature, access; // Short cuts to constant pool
+ String exceptions;
+ StringBuffer buf;
+ Attribute[] attr;
+
+ access = Utility.accessToString(access_flags);
+
+ // Get name and signature from constant pool
+ c = (ConstantUtf8)constant_pool.getConstant(signature_index,
+ Constants.CONSTANT_Utf8);
+ signature = c.getBytes();
+
+ c = (ConstantUtf8)constant_pool.getConstant(name_index, Constants.CONSTANT_Utf8);
+ name = c.getBytes();
+
+ signature = Utility.methodSignatureToString(signature, name, access, true,
+ getLocalVariableTable());
+ buf = new StringBuffer(signature);
+
+ for(int i=0; i < attributes_count; i++) {
+ Attribute a = attributes[i];
+
+ if(!((a instanceof Code) || (a instanceof ExceptionTable)))
+ buf.append(" [" + a.toString() + "]");
+ }
+
+ ExceptionTable e = getExceptionTable();
+ if(e != null) {
+ String str = e.toString();
+ if(!str.equals(""))
+ buf.append("\n\t\tthrows " + str);
+ }
+
+ return buf.toString();
+ }
+
+ /**
+ * @return deep copy of this method
+ */
+ public final Method copy(ConstantPool constant_pool) {
+ return (Method)copy_(constant_pool);
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/Node.java b/src/java/org/apache/bcel/classfile/Node.java
new file mode 100644
index 00000000..28b8c6ff
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/Node.java
@@ -0,0 +1,65 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Denote class to have an accept method();
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public interface Node {
+ public void accept(Visitor obj);
+}
diff --git a/src/java/org/apache/bcel/classfile/PMGClass.java b/src/java/org/apache/bcel/classfile/PMGClass.java
new file mode 100644
index 00000000..d76b34c8
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/PMGClass.java
@@ -0,0 +1,189 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class is derived from <em>Attribute</em> and represents a reference
+ * to a <a href="http://www.inf.fu-berlin.de/~bokowski/pmgjava/index.html">PMG</a>
+ * attribute.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Attribute
+ */
+public final class PMGClass extends Attribute {
+ private int pmg_class_index, pmg_index;
+
+ /**
+ * Initialize from another object. Note that both objects use the same
+ * references (shallow copy). Use clone() for a physical copy.
+ */
+ public PMGClass(PMGClass c) {
+ this(c.getNameIndex(), c.getLength(), c.getPMGIndex(), c.getPMGClassIndex(),
+ c.getConstantPool());
+ }
+
+ /**
+ * Construct object from file stream.
+ * @param name_index Index in constant pool to CONSTANT_Utf8
+ * @param length Content length in bytes
+ * @param file Input stream
+ * @param constant_pool Array of constants
+ * @throw IOException
+ */
+ PMGClass(int name_index, int length, DataInputStream file,
+ ConstantPool constant_pool) throws IOException
+ {
+ this(name_index, length, file.readUnsignedShort(), file.readUnsignedShort(),
+ constant_pool);
+ }
+
+ /**
+ * @param name_index Index in constant pool to CONSTANT_Utf8
+ * @param length Content length in bytes
+ * @param constant_pool Array of constants
+ * @param PMGClass_index Index in constant pool to CONSTANT_Utf8
+ */
+ public PMGClass(int name_index, int length, int pmg_index, int pmg_class_index,
+ ConstantPool constant_pool)
+ {
+ super(Constants.ATTR_PMG, name_index, length, constant_pool);
+ this.pmg_index = pmg_index;
+ this.pmg_class_index = pmg_class_index;
+ }
+
+ /**
+ * 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) {
+ System.err.println("Visiting non-standard PMGClass object");
+ }
+
+ /**
+ * Dump source file attribute to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ super.dump(file);
+ file.writeShort(pmg_index);
+ file.writeShort(pmg_class_index);
+ }
+
+ /**
+ * @return Index in constant pool of source file name.
+ */
+ public final int getPMGClassIndex() { return pmg_class_index; }
+
+ /**
+ * @param PMGClass_index.
+ */
+ public final void setPMGClassIndex(int pmg_class_index) {
+ this.pmg_class_index = pmg_class_index;
+ }
+
+ /**
+ * @return Index in constant pool of source file name.
+ */
+ public final int getPMGIndex() { return pmg_index; }
+
+ /**
+ * @param PMGClass_index.
+ */
+ public final void setPMGIndex(int pmg_index) {
+ this.pmg_index = pmg_index;
+ }
+
+ /**
+ * @return PMG name.
+ */
+ public final String getPMGName() {
+ ConstantUtf8 c = (ConstantUtf8)constant_pool.getConstant(pmg_index,
+ Constants.CONSTANT_Utf8);
+ return c.getBytes();
+ }
+
+ /**
+ * @return PMG class name.
+ */
+ public final String getPMGClassName() {
+ ConstantUtf8 c = (ConstantUtf8)constant_pool.getConstant(pmg_class_index,
+ Constants.CONSTANT_Utf8);
+ return c.getBytes();
+ }
+
+ /**
+ * @return String representation
+ */
+ public final String toString() {
+ return "PMGClass(" + getPMGName() + ", " + getPMGClassName() + ")";
+ }
+
+ /**
+ * @return deep copy of this attribute
+ */
+ public Attribute copy(ConstantPool constant_pool) {
+ return (PMGClass)clone();
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/Signature.java b/src/java/org/apache/bcel/classfile/Signature.java
new file mode 100644
index 00000000..7da60b9b
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/Signature.java
@@ -0,0 +1,295 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class is derived from <em>Attribute</em> and represents a reference
+ * to a <href="http://wwwipd.ira.uka.de/~pizza/gj/">GJ</a> attribute.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Attribute
+ */
+public final class Signature extends Attribute {
+ private int signature_index;
+
+ /**
+ * Initialize from another object. Note that both objects use the same
+ * references (shallow copy). Use clone() for a physical copy.
+ */
+ public Signature(Signature c) {
+ this(c.getNameIndex(), c.getLength(), c.getSignatureIndex(), c.getConstantPool());
+ }
+
+ /**
+ * Construct object from file stream.
+ * @param name_index Index in constant pool to CONSTANT_Utf8
+ * @param length Content length in bytes
+ * @param file Input stream
+ * @param constant_pool Array of constants
+ * @throw IOException
+ */
+ Signature(int name_index, int length, DataInputStream file,
+ ConstantPool constant_pool) throws IOException
+ {
+ this(name_index, length, file.readUnsignedShort(), constant_pool);
+ }
+
+ /**
+ * @param name_index Index in constant pool to CONSTANT_Utf8
+ * @param length Content length in bytes
+ * @param constant_pool Array of constants
+ * @param Signature_index Index in constant pool to CONSTANT_Utf8
+ */
+ public Signature(int name_index, int length, int signature_index,
+ ConstantPool constant_pool)
+ {
+ super(Constants.ATTR_SIGNATURE, name_index, length, constant_pool);
+ this.signature_index = signature_index;
+ }
+
+ /**
+ * 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) {
+ System.err.println("Visiting non-standard Signature object");
+ }
+
+ /**
+ * Dump source file attribute to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ super.dump(file);
+ file.writeShort(signature_index);
+ }
+
+ /**
+ * @return Index in constant pool of source file name.
+ */
+ public final int getSignatureIndex() { return signature_index; }
+
+ /**
+ * @param Signature_index.
+ */
+ public final void setSignatureIndex(int signature_index) {
+ this.signature_index = signature_index;
+ }
+
+ /**
+ * @return GJ signature.
+ */
+ public final String getSignature() {
+ ConstantUtf8 c = (ConstantUtf8)constant_pool.getConstant(signature_index,
+ Constants.CONSTANT_Utf8);
+ return c.getBytes();
+ }
+
+ /**
+ * Extends ByteArrayInputStream to make 'unreading' chars possible.
+ */
+ private static final class MyByteArrayInputStream extends ByteArrayInputStream {
+ MyByteArrayInputStream(String data) { super(data.getBytes()); }
+ final int mark() { return pos; }
+ final String getData() { return new String(buf); }
+ final void reset(int p) { pos = p; }
+ final void unread() { if(pos > 0) pos--; }
+ }
+
+ private static boolean identStart(int ch) {
+ return ch == 'T' || ch == 'L';
+ }
+
+ private static boolean identPart(int ch) {
+ return ch == '/' || ch == ';';
+ }
+
+ private static final void matchIdent(MyByteArrayInputStream in, StringBuffer buf) {
+ int ch;
+
+ if((ch = in.read()) == -1)
+ throw new RuntimeException("Illegal signature: " + in.getData() +
+ " no ident, reaching EOF");
+
+ //System.out.println("return from ident:" + (char)ch);
+
+ if(!identStart(ch)) {
+ StringBuffer buf2 = new StringBuffer();
+
+ int count = 1;
+ while(Character.isJavaIdentifierPart((char)ch)) {
+ buf2.append((char)ch);
+ count++;
+ ch = in.read();
+ }
+
+ if(ch == ':') { // Ok, formal parameter
+ in.skip("Ljava/lang/Object".length());
+ buf.append(buf2);
+
+ ch = in.read();
+ in.unread();
+ //System.out.println("so far:" + buf2 + ":next:" +(char)ch);
+ } else {
+ for(int i=0; i < count; i++)
+ in.unread();
+ }
+
+ return;
+ }
+
+ StringBuffer buf2 = new StringBuffer();
+ ch = in.read();
+
+ do {
+ buf2.append((char)ch);
+ ch = in.read();
+ //System.out.println("within ident:"+ (char)ch);
+
+ } while((ch != -1) && (Character.isJavaIdentifierPart((char)ch) || (ch == '/')));
+
+ buf.append(buf2.toString().replace('/', '.'));
+
+ //System.out.println("regular return ident:"+ (char)ch + ":" + buf2);
+
+ if(ch != -1)
+ in.unread();
+ }
+
+ private static final void matchGJIdent(MyByteArrayInputStream in,
+ StringBuffer buf)
+ {
+ int ch;
+
+ matchIdent(in, buf);
+
+ ch = in.read();
+ if((ch == '<') || ch == '(') { // Parameterized or method
+ //System.out.println("Enter <");
+ buf.append((char)ch);
+ matchGJIdent(in, buf);
+
+ while(((ch = in.read()) != '>') && (ch != ')')) { // List of parameters
+ if(ch == -1)
+ throw new RuntimeException("Illegal signature: " + in.getData() +
+ " reaching EOF");
+
+ //System.out.println("Still no >");
+ buf.append(", ");
+ in.unread();
+ matchGJIdent(in, buf); // Recursive call
+ }
+
+ //System.out.println("Exit >");
+
+ buf.append((char)ch);
+ } else
+ in.unread();
+
+ ch = in.read();
+ if(identStart(ch)) {
+ in.unread();
+ matchGJIdent(in, buf);
+ } else if(ch == ')') {
+ in.unread();
+ return;
+ } else if(ch != ';')
+ throw new RuntimeException("Illegal signature: " + in.getData() + " read " +
+ (char)ch);
+ }
+
+ public static String translate(String s) {
+ //System.out.println("Sig:" + s);
+ StringBuffer buf = new StringBuffer();
+
+ matchGJIdent(new MyByteArrayInputStream(s), buf);
+
+ return buf.toString();
+ }
+
+ public static final boolean isFormalParameterList(String s) {
+ return s.startsWith("<") && (s.indexOf(':') > 0);
+ }
+
+ public static final boolean isActualParameterList(String s) {
+ return s.startsWith("L") && s.endsWith(">;");
+ }
+
+ /**
+ * @return String representation
+ */
+ public final String toString() {
+ String s = getSignature();
+
+ return "Signature(" + s + ")";
+ }
+
+ /**
+ * @return deep copy of this attribute
+ */
+ public Attribute copy(ConstantPool constant_pool) {
+ return (Signature)clone();
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/SourceFile.java b/src/java/org/apache/bcel/classfile/SourceFile.java
new file mode 100644
index 00000000..2e9db567
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/SourceFile.java
@@ -0,0 +1,165 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class is derived from <em>Attribute</em> and represents a reference
+ * to the source file of this class.
+ * It is instantiated from the <em>Attribute.readAttribute()</em> method.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Attribute
+ */
+public final class SourceFile extends Attribute {
+ private int sourcefile_index;
+
+ /**
+ * Initialize from another object. Note that both objects use the same
+ * references (shallow copy). Use clone() for a physical copy.
+ */
+ public SourceFile(SourceFile c) {
+ this(c.getNameIndex(), c.getLength(), c.getSourceFileIndex(),
+ c.getConstantPool());
+ }
+
+ /**
+ * Construct object from file stream.
+ * @param name_index Index in constant pool to CONSTANT_Utf8
+ * @param length Content length in bytes
+ * @param file Input stream
+ * @param constant_pool Array of constants
+ * @throw IOException
+ */
+ SourceFile(int name_index, int length, DataInputStream file,
+ ConstantPool constant_pool) throws IOException
+ {
+ this(name_index, length, file.readUnsignedShort(), constant_pool);
+ }
+
+ /**
+ * @param name_index Index in constant pool to CONSTANT_Utf8
+ * @param length Content length in bytes
+ * @param constant_pool Array of constants
+ * @param sourcefile_index Index in constant pool to CONSTANT_Utf8
+ */
+ public SourceFile(int name_index, int length, int sourcefile_index,
+ ConstantPool constant_pool)
+ {
+ super(Constants.ATTR_SOURCE_FILE, name_index, length, constant_pool);
+ this.sourcefile_index = sourcefile_index;
+ }
+
+ /**
+ * 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.visitSourceFile(this);
+ }
+
+ /**
+ * Dump source file attribute to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ super.dump(file);
+ file.writeShort(sourcefile_index);
+ }
+
+ /**
+ * @return Index in constant pool of source file name.
+ */
+ public final int getSourceFileIndex() { return sourcefile_index; }
+
+ /**
+ * @param sourcefile_index.
+ */
+ public final void setSourceFileIndex(int sourcefile_index) {
+ this.sourcefile_index = sourcefile_index;
+ }
+
+ /**
+ * @return Source file name.
+ */
+ public final String getSourceFileName() {
+ ConstantUtf8 c = (ConstantUtf8)constant_pool.getConstant(sourcefile_index,
+ Constants.CONSTANT_Utf8);
+ return c.getBytes();
+ }
+
+ /**
+ * @return String representation
+ */
+ public final String toString() {
+ return "SourceFile(" + getSourceFileName() + ")";
+ }
+
+ /**
+ * @return deep copy of this attribute
+ */
+ public Attribute copy(ConstantPool constant_pool) {
+ return (SourceFile)clone();
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/StackMap.java b/src/java/org/apache/bcel/classfile/StackMap.java
new file mode 100644
index 00000000..50460ebc
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/StackMap.java
@@ -0,0 +1,185 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class represents a stack map attribute used for
+ * preverification of Java classes for the <a
+ * href="http://java.sun.com/j2me/"> Java 2 Micro Edition</a>
+ * (J2ME). This attribute is used by the <a
+ * href="http://java.sun.com/products/cldc/">KVM</a> and contained
+ * within the Code attribute of a method. See CLDC specification
+ * §5.3.1.2
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Code
+ * @see StackMapEntry
+ * @see StackMapType
+ */
+public final class StackMap extends Attribute implements Node {
+ private int map_length;
+ private StackMapEntry[] map; // Table of stack map entries
+
+ /*
+ * @param name_index Index of name
+ * @param length Content length in bytes
+ * @param map Table of stack map entries
+ * @param constant_pool Array of constants
+ */
+ public StackMap(int name_index, int length, StackMapEntry[] map,
+ ConstantPool constant_pool)
+ {
+ super(Constants.ATTR_STACK_MAP, name_index, length, constant_pool);
+
+ setStackMap(map);
+ }
+
+ /**
+ * Construct object from file stream.
+ * @param name_index Index of name
+ * @param length Content length in bytes
+ * @param file Input stream
+ * @throw IOException
+ * @param constant_pool Array of constants
+ */
+ StackMap(int name_index, int length, DataInputStream file,
+ ConstantPool constant_pool) throws IOException
+ {
+ this(name_index, length, (StackMapEntry[])null, constant_pool);
+
+ map_length = file.readUnsignedShort();
+ map = new StackMapEntry[map_length];
+
+ for(int i=0; i < map_length; i++)
+ map[i] = new StackMapEntry(file, constant_pool);
+ }
+
+ /**
+ * Dump line number table attribute to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ super.dump(file);
+ file.writeShort(map_length);
+ for(int i=0; i < map_length; i++)
+ map[i].dump(file);
+ }
+
+ /**
+ * @return Array of stack map entries
+ */
+ public final StackMapEntry[] getStackMap() { return map; }
+
+ /**
+ * @param map Array of stack map entries
+ */
+ public final void setStackMap(StackMapEntry[] map) {
+ this.map = map;
+
+ map_length = (map == null)? 0 : map.length;
+ }
+
+ /**
+ * @return String representation.
+ */
+ public final String toString() {
+ StringBuffer buf = new StringBuffer("StackMap(");
+
+ for(int i=0; i < map_length; i++) {
+ buf.append(map[i].toString());
+
+ if(i < map_length - 1)
+ buf.append(", ");
+ }
+
+ buf.append(')');
+
+ return buf.toString();
+ }
+
+ /**
+ * @return deep copy of this attribute
+ */
+ public Attribute copy(ConstantPool constant_pool) {
+ StackMap c = (StackMap)clone();
+
+ c.map = new StackMapEntry[map_length];
+ for(int i=0; i < map_length; i++)
+ c.map[i] = map[i].copy();
+
+ c.constant_pool = constant_pool;
+ return c;
+ }
+
+ /**
+ * 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.visitStackMap(this);
+ }
+
+ public final int getMapLength() { return map_length; }
+}
diff --git a/src/java/org/apache/bcel/classfile/StackMapEntry.java b/src/java/org/apache/bcel/classfile/StackMapEntry.java
new file mode 100644
index 00000000..a64184ea
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/StackMapEntry.java
@@ -0,0 +1,209 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class represents a stack map entry recording the types of
+ * local variables and the the of stack items at a given byte code offset.
+ * See CLDC specification §5.3.1.2
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see StackMap
+ * @see StackMapType
+ */
+public final class StackMapEntry implements Cloneable {
+ private int byte_code_offset;
+ private int number_of_locals;
+ private StackMapType[] types_of_locals;
+ private int number_of_stack_items;
+ private StackMapType[] types_of_stack_items;
+ private ConstantPool constant_pool;
+
+ /**
+ * Construct object from file stream.
+ * @param file Input stream
+ * @throw IOException
+ */
+ StackMapEntry(DataInputStream file, ConstantPool constant_pool) throws IOException
+ {
+ this(file.readShort(), file.readShort(), null, -1, null, constant_pool);
+
+ types_of_locals = new StackMapType[number_of_locals];
+ for(int i=0; i < number_of_locals; i++)
+ types_of_locals[i] = new StackMapType(file, constant_pool);
+
+ number_of_stack_items = file.readShort();
+ types_of_stack_items = new StackMapType[number_of_stack_items];
+ for(int i=0; i < number_of_stack_items; i++)
+ types_of_stack_items[i] = new StackMapType(file, constant_pool);
+ }
+
+ public StackMapEntry(int byte_code_offset, int number_of_locals,
+ StackMapType[] types_of_locals,
+ int number_of_stack_items,
+ StackMapType[] types_of_stack_items,
+ ConstantPool constant_pool) {
+ this.byte_code_offset = byte_code_offset;
+ this.number_of_locals = number_of_locals;
+ this.types_of_locals = types_of_locals;
+ this.number_of_stack_items = number_of_stack_items;
+ this.types_of_stack_items = types_of_stack_items;
+ this.constant_pool = constant_pool;
+ }
+
+ /**
+ * Dump stack map entry
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ file.writeShort(byte_code_offset);
+
+ file.writeShort(number_of_locals);
+ for(int i=0; i < number_of_locals; i++)
+ types_of_locals[i].dump(file);
+
+ file.writeShort(number_of_stack_items);
+ for(int i=0; i < number_of_stack_items; i++)
+ types_of_stack_items[i].dump(file);
+ }
+
+ /**
+ * @return String representation.
+ */
+ public final String toString() {
+ StringBuffer buf = new StringBuffer("(offset=" + byte_code_offset);
+
+ if(number_of_locals > 0) {
+ buf.append(", locals={");
+
+ for(int i=0; i < number_of_locals; i++) {
+ buf.append(types_of_locals[i]);
+ if(i < number_of_locals - 1)
+ buf.append(", ");
+ }
+
+ buf.append("}");
+ }
+
+ if(number_of_stack_items > 0) {
+ buf.append(", stack items={");
+
+ for(int i=0; i < number_of_stack_items; i++) {
+ buf.append(types_of_stack_items[i]);
+ if(i < number_of_stack_items - 1)
+ buf.append(", ");
+ }
+
+ buf.append("}");
+ }
+
+ buf.append(")");
+
+ return buf.toString();
+ }
+
+
+ public void setByteCodeOffset(int b) { byte_code_offset = b; }
+ public int getByteCodeOffset() { return byte_code_offset; }
+ public void setNumberOfLocals(int n) { number_of_locals = n; }
+ public int getNumberOfLocals() { return number_of_locals; }
+ public void setTypesOfLocals(StackMapType[] t) { types_of_locals = t; }
+ public StackMapType[] getTypesOfLocals() { return types_of_locals; }
+ public void setNumberOfStackItems(int n) { number_of_stack_items = n; }
+ public int getNumberOfStackItems() { return number_of_stack_items; }
+ public void setTypesOfStackItems(StackMapType[] t) { types_of_stack_items = t; }
+ public StackMapType[] getTypesOfStackItems() { return types_of_stack_items; }
+
+ /**
+ * @return deep copy of this object
+ */
+ public StackMapEntry copy() {
+ try {
+ return (StackMapEntry)clone();
+ } catch(CloneNotSupportedException e) {}
+
+ return null;
+ }
+
+ /**
+ * 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.visitStackMapEntry(this);
+ }
+
+ /**
+ * @return Constant pool used by this object.
+ */
+ public final ConstantPool getConstantPool() { return constant_pool; }
+
+ /**
+ * @param constant_pool Constant pool to be used for this object.
+ */
+ public final void setConstantPool(ConstantPool constant_pool) {
+ this.constant_pool = constant_pool;
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/StackMapType.java b/src/java/org/apache/bcel/classfile/StackMapType.java
new file mode 100644
index 00000000..39f63092
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/StackMapType.java
@@ -0,0 +1,172 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class represents the type of a local variable or item on stack
+ * used in the StackMap entries.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see StackMapEntry
+ * @see StackMap
+ * @see Constants
+ */
+public final class StackMapType implements Cloneable {
+ private byte type;
+ private int index = -1; // Index to CONSTANT_Class or offset
+ private ConstantPool constant_pool;
+
+ /**
+ * Construct object from file stream.
+ * @param file Input stream
+ * @throw IOException
+ */
+ StackMapType(DataInputStream file, ConstantPool constant_pool) throws IOException
+ {
+ this(file.readByte(), -1, constant_pool);
+
+ if(hasIndex())
+ setIndex(file.readShort());
+
+ setConstantPool(constant_pool);
+ }
+
+ /**
+ * @param type type tag as defined in the Constants interface
+ * @param index index to constant pool, or byte code offset
+ */
+ public StackMapType(byte type, int index, ConstantPool constant_pool) {
+ setType(type);
+ setIndex(index);
+ setConstantPool(constant_pool);
+ }
+
+ public void setType(byte t) {
+ if((t < Constants.ITEM_Bogus) || (t > Constants.ITEM_NewObject))
+ throw new RuntimeException("Illegal type for StackMapType: " + t);
+ type = t;
+ }
+
+ public byte getType() { return type; }
+ public void setIndex(int t) { index = t; }
+
+ /** @return index to constant pool if type == ITEM_Object, or offset
+ * in byte code, if type == ITEM_NewObject, and -1 otherwise
+ */
+ public int getIndex() { return index; }
+
+ /**
+ * Dump type entries to file.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ file.writeByte(type);
+ if(hasIndex())
+ file.writeShort(getIndex());
+ }
+
+ /** @return true, if type is either ITEM_Object or ITEM_NewObject
+ */
+ public final boolean hasIndex() {
+ return ((type == Constants.ITEM_Object) ||
+ (type == Constants.ITEM_NewObject));
+ }
+
+ private String printIndex() {
+ if(type == Constants.ITEM_Object)
+ return ", class=" + constant_pool.constantToString(index, Constants.CONSTANT_Class);
+ else if(type == Constants.ITEM_NewObject)
+ return ", offset=" + index;
+ else
+ return "";
+ }
+
+ /**
+ * @return String representation
+ */
+ public final String toString() {
+ return "(type=" + Constants.ITEM_NAMES[type] + printIndex() + ")";
+ }
+
+ /**
+ * @return deep copy of this object
+ */
+ public StackMapType copy() {
+ try {
+ return (StackMapType)clone();
+ } catch(CloneNotSupportedException e) {}
+
+ return null;
+ }
+
+ /**
+ * @return Constant pool used by this object.
+ */
+ public final ConstantPool getConstantPool() { return constant_pool; }
+
+ /**
+ * @param constant_pool Constant pool to be used for this object.
+ */
+ public final void setConstantPool(ConstantPool constant_pool) {
+ this.constant_pool = constant_pool;
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/Synthetic.java b/src/java/org/apache/bcel/classfile/Synthetic.java
new file mode 100644
index 00000000..c06c630e
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/Synthetic.java
@@ -0,0 +1,171 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * This class is derived from <em>Attribute</em> and declares this class
+ * as `synthetic', i.e., it needs special handling.
+ * It is instantiated from the <em>Attribute.readAttribute()</em> method.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Attribute
+ */
+public final class Synthetic extends Attribute {
+ private byte[] bytes;
+
+ /**
+ * Initialize from another object. Note that both objects use the same
+ * references (shallow copy). Use copy() for a physical copy.
+ */
+ public Synthetic(Synthetic c) {
+ this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool());
+ }
+
+ /**
+ * @param name_index Index in constant pool to CONSTANT_Utf8
+ * @param length Content length in bytes
+ * @param bytes Attribute contents
+ * @param constant_pool Array of constants
+ * @param sourcefile_index Index in constant pool to CONSTANT_Utf8
+ */
+ public Synthetic(int name_index, int length, byte[] bytes,
+ ConstantPool constant_pool)
+ {
+ super(Constants.ATTR_SYNTHETIC, name_index, length, constant_pool);
+ this.bytes = bytes;
+ }
+
+ /**
+ * Construct object from file stream.
+ * @param name_index Index in constant pool to CONSTANT_Utf8
+ * @param length Content length in bytes
+ * @param file Input stream
+ * @param constant_pool Array of constants
+ * @throw IOException
+ */
+ Synthetic(int name_index, int length, DataInputStream file,
+ ConstantPool constant_pool) throws IOException
+ {
+ this(name_index, length, (byte [])null, constant_pool);
+
+ if(length > 0) {
+ bytes = new byte[length];
+ file.readFully(bytes);
+ System.err.println("Synthetic attribute with length > 0");
+ }
+ }
+ /**
+ * 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.visitSynthetic(this);
+ }
+ /**
+ * Dump source file attribute to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ super.dump(file);
+ if(length > 0)
+ file.write(bytes, 0, length);
+ }
+ /**
+ * @return data bytes.
+ */
+ public final byte[] getBytes() { return bytes; }
+
+ /**
+ * @param bytes.
+ */
+ public final void setBytes(byte[] bytes) {
+ this.bytes = bytes;
+ }
+
+ /**
+ * @return String representation.
+ */
+ public final String toString() {
+ StringBuffer buf = new StringBuffer("Synthetic");
+
+ if(length > 0)
+ buf.append(" " + Utility.toHexString(bytes));
+
+ return buf.toString();
+ }
+
+ /**
+ * @return deep copy of this attribute
+ */
+ public Attribute copy(ConstantPool constant_pool) {
+ Synthetic c = (Synthetic)clone();
+
+ if(bytes != null)
+ c.bytes = (byte[])bytes.clone();
+
+ c.constant_pool = constant_pool;
+ return c;
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/Unknown.java b/src/java/org/apache/bcel/classfile/Unknown.java
new file mode 100644
index 00000000..e6f17efd
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/Unknown.java
@@ -0,0 +1,205 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import java.io.*;
+import java.util.*;
+
+/**
+ * This class represents a reference to an unknown (i.e.,
+ * application-specific) attribute of a class. It is instantiated
+ * from the <em>Attribute.readAttribute()</em> method.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public final class Unknown extends Attribute {
+ private byte[] bytes;
+ private String name;
+
+ private static HashMap unknown_attributes = new HashMap();
+
+ /** @return array of unknown attributes, but just one for each kind.
+ */
+ static Unknown[] getUnknownAttributes() {
+ Unknown[] unknowns = new Unknown[unknown_attributes.size()];
+ Iterator entries = unknown_attributes.values().iterator();
+
+ for(int i=0; entries.hasNext(); i++)
+ unknowns[i] = (Unknown)entries.next();
+
+ unknown_attributes.clear();
+ return unknowns;
+ }
+
+ /**
+ * Initialize from another object. Note that both objects use the same
+ * references (shallow copy). Use clone() for a physical copy.
+ */
+ public Unknown(Unknown c) {
+ this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool());
+ }
+
+ /**
+ * Create a non-standard attribute.
+ *
+ * @param name_index Index in constant pool
+ * @param length Content length in bytes
+ * @param bytes Attribute contents
+ * @param constant_pool Array of constants
+ */
+ public Unknown(int name_index, int length, byte[] bytes,
+ ConstantPool constant_pool)
+ {
+ super(Constants.ATTR_UNKNOWN, name_index, length, constant_pool);
+ this.bytes = bytes;
+
+ name = ((ConstantUtf8)constant_pool.getConstant(name_index,
+ Constants.CONSTANT_Utf8)).getBytes();
+ unknown_attributes.put(name, this);
+ }
+
+ /**
+ * Construct object from file stream.
+ * @param name_index Index in constant pool
+ * @param length Content length in bytes
+ * @param file Input stream
+ * @param constant_pool Array of constants
+ * @throw IOException
+ */
+ Unknown(int name_index, int length, DataInputStream file,
+ ConstantPool constant_pool)
+ throws IOException
+ {
+ this(name_index, length, (byte [])null, constant_pool);
+
+ if(length > 0) {
+ bytes = new byte[length];
+ file.readFully(bytes);
+ }
+ }
+
+ /**
+ * 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.visitUnknown(this);
+ }
+ /**
+ * Dump unknown bytes to file stream.
+ *
+ * @param file Output file stream
+ * @throw IOException
+ */
+ public final void dump(DataOutputStream file) throws IOException
+ {
+ super.dump(file);
+ if(length > 0)
+ file.write(bytes, 0, length);
+ }
+ /**
+ * @return data bytes.
+ */
+ public final byte[] getBytes() { return bytes; }
+
+ /**
+ * @return name of attribute.
+ */
+ public final String getName() { return name; }
+
+ /**
+ * @param bytes.
+ */
+ public final void setBytes(byte[] bytes) {
+ this.bytes = bytes;
+ }
+
+ /**
+ * @return String representation.
+ */
+ public final String toString() {
+ if(length == 0 || bytes == null)
+ return "(Unknown attribute " + name + ")";
+
+ String hex;
+ if(length > 10) {
+ byte[] tmp = new byte[10];
+ System.arraycopy(bytes, 0, tmp, 0, 10);
+ hex = Utility.toHexString(tmp) + "... (truncated)";
+ }
+ else
+ hex = Utility.toHexString(bytes);
+
+ return "(Unknown attribute " + name + ": " + hex + ")";
+ }
+
+ /**
+ * @return deep copy of this attribute
+ */
+ public Attribute copy(ConstantPool constant_pool) {
+ Unknown c = (Unknown)clone();
+
+ if(bytes != null)
+ c.bytes = (byte[])bytes.clone();
+
+ c.constant_pool = constant_pool;
+ return c;
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/Utility.java b/src/java/org/apache/bcel/classfile/Utility.java
new file mode 100644
index 00000000..6eb2a696
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/Utility.java
@@ -0,0 +1,1355 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import org.apache.bcel.util.ByteSequence;
+import java.io.*;
+import java.util.ArrayList;
+import java.util.zip.*;
+
+/**
+ * Utility functions that do not really belong to any class in particular.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public abstract class Utility {
+ private static int consumed_chars; /* How many chars have been consumed
+ * during parsing in signatureToString().
+ * Read by methodSignatureToString().
+ * Set by side effect,but only internally.
+ */
+ private static boolean wide=false; /* The `WIDE' instruction is used in the
+ * byte code to allow 16-bit wide indices
+ * for local variables. This opcode
+ * precedes an `ILOAD', e.g.. The opcode
+ * immediately following takes an extra
+ * byte which is combined with the
+ * following byte to form a
+ * 16-bit value.
+ */
+ /**
+ * Convert bit field of flags into string such as `static final'.
+ *
+ * @param access_flags Access flags
+ * @return String representation of flags
+ */
+ public static final String accessToString(int access_flags) {
+ return accessToString(access_flags, false);
+ }
+
+ /**
+ * Convert bit field of flags into string such as `static final'.
+ *
+ * Special case: Classes compiled with new compilers and with the
+ * `ACC_SUPER' flag would be said to be "synchronized". This is
+ * because SUN used the same value for the flags `ACC_SUPER' and
+ * `ACC_SYNCHRONIZED'.
+ *
+ * @param access_flags Access flags
+ * @param for_class access flags are for class qualifiers ?
+ * @return String representation of flags
+ */
+ public static final String accessToString(int access_flags,
+ boolean for_class)
+ {
+ StringBuffer buf = new StringBuffer();
+
+ int p = 0;
+ for(int i=0; p < Constants.MAX_ACC_FLAG; i++) { // Loop through known flags
+ p = pow2(i);
+
+ if((access_flags & p) != 0) {
+ /* Special case: Classes compiled with new compilers and with the
+ * `ACC_SUPER' flag would be said to be "synchronized". This is
+ * because SUN used the same value for the flags `ACC_SUPER' and
+ * `ACC_SYNCHRONIZED'.
+ */
+ if(for_class && ((p == Constants.ACC_SUPER) || (p == Constants.ACC_INTERFACE)))
+ continue;
+
+ buf.append(Constants.ACCESS_NAMES[i] + " ");
+ }
+ }
+
+ return buf.toString().trim();
+ }
+
+ /**
+ * @return "class" or "interface", depending on the ACC_INTERFACE flag
+ */
+ public static final String classOrInterface(int access_flags) {
+ return ((access_flags & Constants.ACC_INTERFACE) != 0)? "interface" : "class";
+ }
+
+ /**
+ * Disassemble a byte array of JVM byte codes starting from code line
+ * `index' and return the disassembled string representation. Decode only
+ * `num' opcodes (including their operands), use -1 if you want to
+ * decompile everything.
+ *
+ * @param code byte code array
+ * @param constant_pool Array of constants
+ * @param index offset in `code' array
+ * <EM>(number of opcodes, not bytes!)</EM>
+ * @param length number of opcodes to decompile, -1 for all
+ * @param verbose be verbose, e.g. print constant pool index
+ * @return String representation of byte codes
+ */
+ public static final String codeToString(byte[] code,
+ ConstantPool constant_pool,
+ int index, int length, boolean verbose)
+ {
+ StringBuffer buf = new StringBuffer(code.length * 20); // Should be sufficient
+ ByteSequence stream = new ByteSequence(code);
+
+ try {
+ for(int i=0; i < index; i++) // Skip `index' lines of code
+ codeToString(stream, constant_pool, verbose);
+
+ for(int i=0; stream.available() > 0; i++) {
+ if((length < 0) || (i < length)) {
+ String indices = fillup(stream.getIndex() + ":", 6, true, ' ');
+ buf.append(indices + codeToString(stream, constant_pool, verbose) + '\n');
+ }
+ }
+ } catch(IOException e) {
+ System.out.println(buf.toString());
+ e.printStackTrace();
+ throw new ClassFormatError("Byte code error: " + e);
+ }
+
+ return buf.toString();
+ }
+
+ public static final String codeToString(byte[] code,
+ ConstantPool constant_pool,
+ int index, int length) {
+ return codeToString(code, constant_pool, index, length, true);
+ }
+
+ /**
+ * Disassemble a stream of byte codes and return the
+ * string representation.
+ *
+ * @param bytes stream of bytes
+ * @param constant_pool Array of constants
+ * @param verbose be verbose, e.g. print constant pool index
+ * @return String representation of byte code
+ */
+ public static final String codeToString(ByteSequence bytes,
+ ConstantPool constant_pool, boolean verbose)
+ throws IOException
+ {
+ short opcode = (short)bytes.readUnsignedByte();
+ int default_offset=0, low, high, npairs;
+ int index, vindex, constant;
+ int[] match, jump_table;
+ int no_pad_bytes=0, offset;
+ StringBuffer buf = new StringBuffer(Constants.OPCODE_NAMES[opcode]);
+
+ /* Special case: Skip (0-3) padding bytes, i.e., the
+ * following bytes are 4-byte-aligned
+ */
+ if((opcode == Constants.TABLESWITCH) || (opcode == Constants.LOOKUPSWITCH)) {
+ int remainder = bytes.getIndex() % 4;
+ no_pad_bytes = (remainder == 0)? 0 : 4 - remainder;
+
+ for(int i=0; i < no_pad_bytes; i++) {
+ byte b;
+
+ if((b=bytes.readByte()) != 0)
+ System.err.println("Warning: Padding byte != 0 in " +
+ Constants.OPCODE_NAMES[opcode] + ":" + b);
+ }
+
+ // Both cases have a field default_offset in common
+ default_offset = bytes.readInt();
+ }
+
+ switch(opcode) {
+ /* Table switch has variable length arguments.
+ */
+ case Constants.TABLESWITCH:
+ low = bytes.readInt();
+ high = bytes.readInt();
+
+ offset = bytes.getIndex() - 12 - no_pad_bytes - 1;
+ default_offset += offset;
+
+ buf.append("\tdefault = " + default_offset + ", low = " + low +
+ ", high = " + high + "(");
+
+ jump_table = new int[high - low + 1];
+ for(int i=0; i < jump_table.length; i++) {
+ jump_table[i] = offset + bytes.readInt();
+ buf.append(jump_table[i]);
+
+ if(i < jump_table.length - 1)
+ buf.append(", ");
+ }
+ buf.append(")");
+
+ break;
+
+ /* Lookup switch has variable length arguments.
+ */
+ case Constants.LOOKUPSWITCH: {
+
+ npairs = bytes.readInt();
+ offset = bytes.getIndex() - 8 - no_pad_bytes - 1;
+
+ match = new int[npairs];
+ jump_table = new int[npairs];
+ default_offset += offset;
+
+ buf.append("\tdefault = " + default_offset + ", npairs = " + npairs +
+ " (");
+
+ for(int i=0; i < npairs; i++) {
+ match[i] = bytes.readInt();
+
+ jump_table[i] = offset + bytes.readInt();
+
+ buf.append("(" + match[i] + ", " + jump_table[i] + ")");
+
+ if(i < npairs - 1)
+ buf.append(", ");
+ }
+ buf.append(")");
+ }
+ break;
+
+ /* Two address bytes + offset from start of byte stream form the
+ * jump target
+ */
+ case Constants.GOTO: case Constants.IFEQ: case Constants.IFGE: case Constants.IFGT:
+ case Constants.IFLE: case Constants.IFLT: case Constants.JSR: case Constants.IFNE:
+ case Constants.IFNONNULL: case Constants.IFNULL: case Constants.IF_ACMPEQ:
+ case Constants.IF_ACMPNE: case Constants.IF_ICMPEQ: case Constants.IF_ICMPGE: case Constants.IF_ICMPGT:
+ case Constants.IF_ICMPLE: case Constants.IF_ICMPLT: case Constants.IF_ICMPNE:
+ buf.append("\t\t#" + ((bytes.getIndex() - 1) + bytes.readShort()));
+ break;
+
+ /* 32-bit wide jumps
+ */
+ case Constants.GOTO_W: case Constants.JSR_W:
+ buf.append("\t\t#" + ((bytes.getIndex() - 1) + bytes.readInt()));
+ break;
+
+ /* Index byte references local variable (register)
+ */
+ case Constants.ALOAD: case Constants.ASTORE: case Constants.DLOAD: case Constants.DSTORE: case Constants.FLOAD:
+ case Constants.FSTORE: case Constants.ILOAD: case Constants.ISTORE: case Constants.LLOAD: case Constants.LSTORE:
+ case Constants.RET:
+ if(wide) {
+ vindex = bytes.readUnsignedShort();
+ wide=false; // Clear flag
+ }
+ else
+ vindex = bytes.readUnsignedByte();
+
+ buf.append("\t\t%" + vindex);
+ break;
+
+ /*
+ * Remember wide byte which is used to form a 16-bit address in the
+ * following instruction. Relies on that the method is called again with
+ * the following opcode.
+ */
+ case Constants.WIDE:
+ wide = true;
+ buf.append("\t(wide)");
+ break;
+
+ /* Array of basic type.
+ */
+ case Constants.NEWARRAY:
+ buf.append("\t\t<" + Constants.TYPE_NAMES[bytes.readByte()] + ">");
+ break;
+
+ /* Access object/class fields.
+ */
+ case Constants.GETFIELD: case Constants.GETSTATIC: case Constants.PUTFIELD: case Constants.PUTSTATIC:
+ index = bytes.readUnsignedShort();
+ buf.append("\t\t" +
+ constant_pool.constantToString(index, Constants.CONSTANT_Fieldref) +
+ (verbose? " (" + index + ")" : ""));
+ break;
+
+ /* Operands are references to classes in constant pool
+ */
+ case Constants.NEW:
+ case Constants.CHECKCAST:
+ buf.append("\t");
+ case Constants.INSTANCEOF:
+ index = bytes.readUnsignedShort();
+ buf.append("\t<" + constant_pool.constantToString(index,
+ Constants.CONSTANT_Class) +
+ ">" + (verbose? " (" + index + ")" : ""));
+ break;
+
+ /* Operands are references to methods in constant pool
+ */
+ case Constants.INVOKESPECIAL: case Constants.INVOKESTATIC: case Constants.INVOKEVIRTUAL:
+ index = bytes.readUnsignedShort();
+ buf.append("\t" + constant_pool.constantToString(index,
+ Constants.CONSTANT_Methodref) +
+ (verbose? " (" + index + ")" : ""));
+ break;
+
+ case Constants.INVOKEINTERFACE:
+ index = bytes.readUnsignedShort();
+ int nargs = bytes.readUnsignedByte(); // historical, redundant
+ buf.append("\t" +
+ constant_pool.constantToString(index,
+ Constants.CONSTANT_InterfaceMethodref) +
+ (verbose? " (" + index + ")\t" : "") + nargs + "\t" +
+ bytes.readUnsignedByte()); // Last byte is a reserved space
+ break;
+
+ /* Operands are references to items in constant pool
+ */
+ case Constants.LDC_W: case Constants.LDC2_W:
+ index = bytes.readUnsignedShort();
+
+ buf.append("\t\t" + constant_pool.constantToString
+ (index, constant_pool.getConstant(index).getTag()) +
+ (verbose? " (" + index + ")" : ""));
+ break;
+
+ case Constants.LDC:
+ index = bytes.readUnsignedByte();
+
+ buf.append("\t\t" +
+ constant_pool.constantToString
+ (index, constant_pool.getConstant(index).getTag()) +
+ (verbose? " (" + index + ")" : ""));
+ break;
+
+ /* Array of references.
+ */
+ case Constants.ANEWARRAY:
+ index = bytes.readUnsignedShort();
+
+ buf.append("\t\t<" + compactClassName(constant_pool.getConstantString
+ (index, Constants.CONSTANT_Class), false) +
+ ">" + (verbose? " (" + index + ")": ""));
+ break;
+
+ /* Multidimensional array of references.
+ */
+ case Constants.MULTIANEWARRAY: {
+ index = bytes.readUnsignedShort();
+ int dimensions = bytes.readUnsignedByte();
+
+ buf.append("\t<" + compactClassName(constant_pool.getConstantString
+ (index, Constants.CONSTANT_Class), false) +
+ ">\t" + dimensions + (verbose? " (" + index + ")" : ""));
+ }
+ break;
+
+ /* Increment local variable.
+ */
+ case Constants.IINC:
+ if(wide) {
+ vindex = bytes.readUnsignedShort();
+ constant = bytes.readShort();
+ wide = false;
+ }
+ else {
+ vindex = bytes.readUnsignedByte();
+ constant = bytes.readByte();
+ }
+ buf.append("\t\t%" + vindex + "\t" + constant);
+ break;
+
+ default:
+ if(Constants.NO_OF_OPERANDS[opcode] > 0) {
+ for(int i=0; i < Constants.TYPE_OF_OPERANDS[opcode].length; i++) {
+ buf.append("\t\t");
+ switch(Constants.TYPE_OF_OPERANDS[opcode][i]) {
+ case Constants.T_BYTE: buf.append(bytes.readByte()); break;
+ case Constants.T_SHORT: buf.append(bytes.readShort()); break;
+ case Constants.T_INT: buf.append(bytes.readInt()); break;
+
+ default: // Never reached
+ System.err.println("Unreachable default case reached!");
+ System.exit(-1);
+ }
+ }
+ }
+ }
+
+ return buf.toString();
+ }
+
+ public static final String codeToString(ByteSequence bytes, ConstantPool constant_pool)
+ throws IOException
+ {
+ return codeToString(bytes, constant_pool, true);
+ }
+
+ /**
+ * Shorten long class names, <em>java/lang/String</em> becomes
+ * <em>String</em>.
+ *
+ * @param str The long class name
+ * @return Compacted class name
+ */
+ public static final String compactClassName(String str) {
+ return compactClassName(str, true);
+ }
+
+ /**
+ * Shorten long class name <em>str</em>, i.e., chop off the <em>prefix</em>,
+ * if the
+ * class name starts with this string and the flag <em>chopit</em> is true.
+ * Slashes <em>/</em> are converted to dots <em>.</em>.
+ *
+ * @param str The long class name
+ * @param prefix The prefix the get rid off
+ * @param chopit Flag that determines whether chopping is executed or not
+ * @return Compacted class name
+ */
+ public static final String compactClassName(String str,
+ String prefix,
+ boolean chopit)
+ {
+ int len = prefix.length();
+
+ str = str.replace('/', '.'); // Is `/' on all systems, even DOS
+
+ if(chopit) {
+ // If string starts with `prefix' and contains no further dots
+ if(str.startsWith(prefix) &&
+ (str.substring(len).indexOf('.') == -1))
+ str = str.substring(len);
+ }
+
+ return str;
+ }
+
+ /**
+ * Shorten long class names, <em>java/lang/String</em> becomes
+ * <em>java.lang.String</em>,
+ * e.g.. If <em>chopit</em> is <em>true</em> the prefix <em>java.lang</em>
+ * is also removed.
+ *
+ * @param str The long class name
+ * @param chopit Flag that determines whether chopping is executed or not
+ * @return Compacted class name
+ */
+ public static final String compactClassName(String str, boolean chopit) {
+ return compactClassName(str, "java.lang.", chopit);
+ }
+
+ private static final boolean is_digit(char ch) {
+ return (ch >= '0') && (ch <= '9');
+ }
+
+ private static final boolean is_space(char ch) {
+ return (ch == ' ') || (ch == '\t') || (ch == '\r') || (ch == '\n');
+ }
+
+ /**
+ * @return `flag' with bit `i' set to 1
+ */
+ public static final int setBit(int flag, int i) {
+ return flag | pow2(i);
+ }
+
+ /**
+ * @return `flag' with bit `i' set to 0
+ */
+ public static final int clearBit(int flag, int i) {
+ int bit = pow2(i);
+ return (flag & bit) == 0? flag : flag ^ bit;
+ }
+
+ /**
+ * @return true, if bit `i' in `flag' is set
+ */
+ public static final boolean isSet(int flag, int i) {
+ return (flag & pow2(i)) != 0;
+ }
+
+ /**
+ * Converts string containing the method return and argument types
+ * to a byte code method signature.
+ *
+ * @param ret Return type of method
+ * @param argv Types of method arguments
+ * @return Byte code representation of method signature
+ */
+ public final static String methodTypeToSignature(String ret, String[] argv)
+ throws ClassFormatError
+ {
+ StringBuffer buf = new StringBuffer("(");
+ String str;
+
+ if(argv != null)
+ for(int i=0; i < argv.length; i++) {
+ str = getSignature(argv[i]);
+
+ if(str.endsWith("V")) // void can't be a method argument
+ throw new ClassFormatError("Invalid type: " + argv[i]);
+
+ buf.append(str);
+ }
+
+ str = getSignature(ret);
+
+ buf.append(")" + str);
+
+ return buf.toString();
+ }
+
+ /**
+ * @param signature Method signature
+ * @return Array of argument types
+ * @throw ClassFormatError
+ */
+ public static final String[] methodSignatureArgumentTypes(String signature)
+ throws ClassFormatError
+ {
+ return methodSignatureArgumentTypes(signature, true);
+ }
+
+ /**
+ * @param signature Method signature
+ * @param chopit Shorten class names ?
+ * @return Array of argument types
+ * @throw ClassFormatError
+ */
+ public static final String[] methodSignatureArgumentTypes(String signature,
+ boolean chopit)
+ throws ClassFormatError
+ {
+ ArrayList vec = new ArrayList();
+ int index;
+ String[] types;
+
+ try { // Read all declarations between for `(' and `)'
+ if(signature.charAt(0) != '(')
+ throw new ClassFormatError("Invalid method signature: " + signature);
+
+ index = 1; // current string position
+
+ while(signature.charAt(index) != ')') {
+ vec.add(signatureToString(signature.substring(index), chopit));
+ index += consumed_chars; // update position
+ }
+ } catch(StringIndexOutOfBoundsException e) { // Should never occur
+ throw new ClassFormatError("Invalid method signature: " + signature);
+ }
+
+ types = new String[vec.size()];
+ vec.toArray(types);
+ return types;
+ }
+ /**
+ * @param signature Method signature
+ * @return return type of method
+ * @throw ClassFormatError
+ */
+ public static final String methodSignatureReturnType(String signature)
+ throws ClassFormatError
+ {
+ return methodSignatureReturnType(signature, true);
+ }
+ /**
+ * @param signature Method signature
+ * @param chopit Shorten class names ?
+ * @return return type of method
+ * @throw ClassFormatError
+ */
+ public static final String methodSignatureReturnType(String signature,
+ boolean chopit)
+ throws ClassFormatError
+ {
+ int index;
+ String type;
+
+ try {
+ // Read return type after `)'
+ index = signature.lastIndexOf(')') + 1;
+ type = signatureToString(signature.substring(index), chopit);
+ } catch(StringIndexOutOfBoundsException e) { // Should never occur
+ throw new ClassFormatError("Invalid method signature: " + signature);
+ }
+
+ return type;
+ }
+
+ /**
+ * Converts method signature to string with all class names compacted.
+ *
+ * @param signature to convert
+ * @param name of method
+ * @param access flags of method
+ * @return Human readable signature
+ */
+ public static final String methodSignatureToString(String signature,
+ String name,
+ String access) {
+ return methodSignatureToString(signature, name, access, true);
+ }
+
+ public static final String methodSignatureToString(String signature,
+ String name,
+ String access,
+ boolean chopit) {
+ return methodSignatureToString(signature, name, access, chopit, null);
+ }
+
+ /**
+ * A return­type signature represents the return value from a method.
+ * It is a series of bytes in the following grammar:
+ *
+ * <return_signature> ::= <field_type> | V
+ *
+ * The character V indicates that the method returns no value. Otherwise, the
+ * signature indicates the type of the return value.
+ * An argument signature represents an argument passed to a method:
+ *
+ * <argument_signature> ::= <field_type>
+ *
+ * A method signature represents the arguments that the method expects, and
+ * the value that it returns.
+ * <method_signature> ::= (<arguments_signature>) <return_signature>
+ * <arguments_signature>::= <argument_signature>*
+ *
+ * This method converts such a string into a Java type declaration like
+ * `void main(String[])' and throws a `ClassFormatError' when the parsed
+ * type is invalid.
+ *
+ * @param signature Method signature
+ * @param name Method name
+ * @param access Method access rights
+ * @return Java type declaration
+ * @throw ClassFormatError
+ */
+ public static final String methodSignatureToString(String signature,
+ String name,
+ String access,
+ boolean chopit,
+ LocalVariableTable vars)
+ throws ClassFormatError
+ {
+ StringBuffer buf = new StringBuffer("(");
+ String type;
+ int index;
+ int var_index = (access.indexOf("static") >= 0)? 0 : 1;
+
+ try { // Read all declarations between for `(' and `)'
+ if(signature.charAt(0) != '(')
+ throw new ClassFormatError("Invalid method signature: " + signature);
+
+ index = 1; // current string position
+
+ while(signature.charAt(index) != ')') {
+ buf.append(signatureToString(signature.substring(index), chopit));
+
+ if(vars != null) {
+ LocalVariable l = vars.getLocalVariable(var_index);
+
+ if(l != null)
+ buf.append(" " + l.getName());
+ } else
+ buf.append(" arg" + var_index);
+
+ var_index++;
+ buf.append(", ");
+ index += consumed_chars; // update position
+ }
+
+ index++; // update position
+
+ // Read return type after `)'
+ type = signatureToString(signature.substring(index), chopit);
+
+ } catch(StringIndexOutOfBoundsException e) { // Should never occur
+ throw new ClassFormatError("Invalid method signature: " + signature);
+ }
+
+ if(buf.length() > 1) // Tack off the extra ", "
+ buf.setLength(buf.length() - 2);
+
+ buf.append(")");
+
+ return access + ((access.length() > 0)? " " : "") + // May be an empty string
+ type + " " + name + buf.toString();
+ }
+
+ // Guess what this does
+ private static final int pow2(int n) {
+ return 1 << n;
+ }
+
+ /**
+ * Replace all occurences of <em>old</em> in <em>str</em> with <em>new</em>.
+ *
+ * @param str String to permute
+ * @param old String to be replaced
+ * @param new Replacement string
+ * @return new String object
+ */
+ public static final String replace(String str, String old, String new_) {
+ int index, old_index;
+ StringBuffer buf = new StringBuffer();
+
+ try {
+ if((index = str.indexOf(old)) != -1) { // `old' found in str
+ old_index = 0; // String start offset
+
+ // While we have something to replace
+ while((index = str.indexOf(old, old_index)) != -1) {
+ buf.append(str.substring(old_index, index)); // append prefix
+ buf.append(new_); // append replacement
+
+ old_index = index + old.length(); // Skip `old'.length chars
+ }
+
+ buf.append(str.substring(old_index)); // append rest of string
+ str = buf.toString();
+ }
+ } catch(StringIndexOutOfBoundsException e) { // Should not occur
+ System.err.println(e);
+ }
+
+ return str;
+ }
+
+ /**
+ * Converts signature to string with all class names compacted.
+ *
+ * @param signature to convert
+ * @return Human readable signature
+ */
+ public static final String signatureToString(String signature) {
+ return signatureToString(signature, true);
+ }
+
+ /**
+ * The field signature represents the value of an argument to a function or
+ * the value of a variable. It is a series of bytes generated by the
+ * following grammar:
+ *
+ * <PRE>
+ * <field_signature> ::= <field_type>
+ * <field_type> ::= <base_type>|<object_type>|<array_type>
+ * <base_type> ::= B|C|D|F|I|J|S|Z
+ * <object_type> ::= L<fullclassname>;
+ * <array_type> ::= [<field_type>
+ *
+ * The meaning of the base types is as follows:
+ * B byte signed byte
+ * C char character
+ * D double double precision IEEE float
+ * F float single precision IEEE float
+ * I int integer
+ * J long long integer
+ * L<fullclassname>; ... an object of the given class
+ * S short signed short
+ * Z boolean true or false
+ * [<field sig> ... array
+ * </PRE>
+ *
+ * This method converts this string into a Java type declaration such as
+ * `String[]' and throws a `ClassFormatError' when the parsed type is
+ * invalid.
+ *
+ * @param signature Class signature
+ * @param chopit Flag that determines whether chopping is executed or not
+ * @return Java type declaration
+ * @throws ClassFormatError
+ */
+ public static final String signatureToString(String signature,
+ boolean chopit)
+ {
+ consumed_chars = 1; // This is the default, read just one char like `B'
+
+ try {
+ switch(signature.charAt(0)) {
+ case 'B' : return "byte";
+ case 'C' : return "char";
+ case 'D' : return "double";
+ case 'F' : return "float";
+ case 'I' : return "int";
+ case 'J' : return "long";
+
+ case 'L' : { // Full class name
+ int index = signature.indexOf(';'); // Look for closing `;'
+
+ if(index < 0)
+ throw new ClassFormatError("Invalid signature: " + signature);
+
+ consumed_chars = index + 1; // "Lblabla;" `L' and `;' are removed
+
+ return compactClassName(signature.substring(1, index), chopit);
+ }
+
+ case 'S' : return "short";
+ case 'Z' : return "boolean";
+
+ case '[' : { // Array declaration
+ int n;
+ StringBuffer buf, brackets;
+ String type;
+ char ch;
+ int consumed_chars; // Shadows global var
+
+ brackets = new StringBuffer(); // Accumulate []'s
+
+ // Count opening brackets and look for optional size argument
+ for(n=0; signature.charAt(n) == '['; n++)
+ brackets.append("[]");
+
+ consumed_chars = n; // Remember value
+
+ // The rest of the string denotes a `<field_type>'
+ type = signatureToString(signature.substring(n), chopit);
+
+ Utility.consumed_chars += consumed_chars;
+ return type + brackets.toString();
+ }
+
+ case 'V' : return "void";
+
+ default : throw new ClassFormatError("Invalid signature: `" +
+ signature + "'");
+ }
+ } catch(StringIndexOutOfBoundsException e) { // Should never occur
+ throw new ClassFormatError("Invalid signature: " + e + ":" + signature);
+ }
+ }
+
+ /** Parse Java type such as "char", or "java.lang.String[]" and return the
+ * signature in byte code format, e.g. "C" or "[Ljava/lang/String;" respectively.
+ *
+ * @param type Java type
+ * @return byte code signature
+ */
+ public static String getSignature(String type) {
+ StringBuffer buf = new StringBuffer();
+ char[] chars = type.toCharArray();
+ boolean char_found = false, delim = false;
+ int index = -1;
+
+ loop:
+ for(int i=0; i < chars.length; i++) {
+ switch(chars[i]) {
+ case ' ': case '\t': case '\n': case '\r': case '\f':
+ if(char_found)
+ delim = true;
+ break;
+
+ case '[':
+ if(!char_found)
+ throw new RuntimeException("Illegal type: " + type);
+
+ index = i;
+ break loop;
+
+ default:
+ char_found = true;
+ if(!delim)
+ buf.append(chars[i]);
+ }
+ }
+
+ int brackets = 0;
+
+ if(index > 0)
+ brackets = countBrackets(type.substring(index));
+
+ type = buf.toString();
+ buf.setLength(0);
+
+ for(int i=0; i < brackets; i++)
+ buf.append('[');
+
+ boolean found = false;
+
+ for(int i=Constants.T_BOOLEAN; (i <= Constants.T_VOID) && !found; i++) {
+ if(Constants.TYPE_NAMES[i].equals(type)) {
+ found = true;
+ buf.append(Constants.SHORT_TYPE_NAMES[i]);
+ }
+ }
+
+ if(!found) // Class name
+ buf.append('L' + type.replace('.', '/') + ';');
+
+ return buf.toString();
+ }
+
+ private static int countBrackets(String brackets) {
+ char[] chars = brackets.toCharArray();
+ int count = 0;
+ boolean open = false;
+
+ for(int i=0; i<chars.length; i++) {
+ switch(chars[i]) {
+ case '[':
+ if(open)
+ throw new RuntimeException("Illegally nested brackets:" + brackets);
+ open = true;
+ break;
+
+ case ']':
+ if(!open)
+ throw new RuntimeException("Illegally nested brackets:" + brackets);
+ open = false;
+ count++;
+ break;
+
+ default:
+ // Don't care
+ }
+ }
+
+ if(open)
+ throw new RuntimeException("Illegally nested brackets:" + brackets);
+
+ return count;
+ }
+
+ /**
+ * Return type of method signature as a byte value as defined in <em>Constants</em>
+ *
+ * @param signature in format described above
+ * @return type of method signature
+ * @see Constants
+ */
+ public static final byte typeOfMethodSignature(String signature)
+ throws ClassFormatError
+ {
+ int index;
+
+ try {
+ if(signature.charAt(0) != '(')
+ throw new ClassFormatError("Invalid method signature: " + signature);
+
+ index = signature.lastIndexOf(')') + 1;
+ return typeOfSignature(signature.substring(index));
+ } catch(StringIndexOutOfBoundsException e) {
+ throw new ClassFormatError("Invalid method signature: " + signature);
+ }
+ }
+
+ /**
+ * Return type of signature as a byte value as defined in <em>Constants</em>
+ *
+ * @param signature in format described above
+ * @return type of signature
+ * @see Constants
+ */
+ public static final byte typeOfSignature(String signature)
+ throws ClassFormatError
+ {
+ try {
+ switch(signature.charAt(0)) {
+ case 'B' : return Constants.T_BYTE;
+ case 'C' : return Constants.T_CHAR;
+ case 'D' : return Constants.T_DOUBLE;
+ case 'F' : return Constants.T_FLOAT;
+ case 'I' : return Constants.T_INT;
+ case 'J' : return Constants.T_LONG;
+ case 'L' : return Constants.T_REFERENCE;
+ case '[' : return Constants.T_ARRAY;
+ case 'V' : return Constants.T_VOID;
+ case 'Z' : return Constants.T_BOOLEAN;
+ case 'S' : return Constants.T_SHORT;
+ default:
+ throw new ClassFormatError("Invalid method signature: " + signature);
+ }
+ } catch(StringIndexOutOfBoundsException e) {
+ throw new ClassFormatError("Invalid method signature: " + signature);
+ }
+ }
+
+ /** Map opcode names to opcode numbers. E.g., return Constants.ALOAD for "aload"
+ */
+ public static short searchOpcode(String name) {
+ name = name.toLowerCase();
+
+ for(short i=0; i < Constants.OPCODE_NAMES.length; i++)
+ if(Constants.OPCODE_NAMES[i].equals(name))
+ return i;
+
+ return -1;
+ }
+
+ /**
+ * Convert (signed) byte to (unsigned) short value, i.e., all negative
+ * values become positive.
+ */
+ private static final short byteToShort(byte b) {
+ return (b < 0)? (short)(256 + b) : (short)b;
+ }
+
+ /** Convert bytes into hexidecimal string
+ *
+ * @return bytes as hexidecimal string, e.g. 00 FA 12 ...
+ */
+ public static final String toHexString(byte[] bytes) {
+ StringBuffer buf = new StringBuffer();
+
+ for(int i=0; i < bytes.length; i++) {
+ short b = byteToShort(bytes[i]);
+ String hex = Integer.toString(b, 0x10);
+
+ if(b < 0x10) // just one digit, prepend '0'
+ buf.append('0');
+
+ buf.append(hex);
+
+ if(i < bytes.length - 1)
+ buf.append(' ');
+ }
+
+ return buf.toString();
+ }
+
+ /**
+ * Return a string for an integer justified left or right and filled up with
+ * `fill' characters if necessary.
+ *
+ * @param i integer to format
+ * @param length length of desired string
+ * @param left_justify format left or right
+ * @param fill fill character
+ * @return formatted int
+ */
+ public static final String format(int i, int length, boolean left_justify, char fill) {
+ return fillup(Integer.toString(i), length, left_justify, fill);
+ }
+
+ /**
+ * Fillup char with up to length characters with char `fill' and justify it left or right.
+ *
+ * @param str string to format
+ * @param length length of desired string
+ * @param left_justify format left or right
+ * @param fill fill character
+ * @return formatted string
+ */
+ public static final String fillup(String str, int length, boolean left_justify, char fill) {
+ int len = length - str.length();
+ char[] buf = new char[(len < 0)? 0 : len];
+
+ for(int j=0; j < buf.length; j++)
+ buf[j] = fill;
+
+ if(left_justify)
+ return str + new String(buf);
+ else
+ return new String(buf) + str;
+ }
+
+ static final boolean equals(byte[] a, byte[] b) {
+ int size;
+
+ if((size=a.length) != b.length)
+ return false;
+
+ for(int i=0; i < size; i++)
+ if(a[i] != b[i])
+ return false;
+
+ return true;
+ }
+
+ public static final void printArray(PrintStream out, Object[] obj) {
+ out.println(printArray(obj, true));
+ }
+
+ public static final void printArray(PrintWriter out, Object[] obj) {
+ out.println(printArray(obj, true));
+ }
+
+ public static final String printArray(Object[] obj) {
+ return printArray(obj, true);
+ }
+
+ public static final String printArray(Object[] obj, boolean braces) {
+ if(obj == null)
+ return null;
+
+ StringBuffer buf = new StringBuffer();
+ if(braces)
+ buf.append('{');
+
+ for(int i=0; i < obj.length; i++) {
+ if(obj[i] != null)
+ buf.append(obj[i].toString());
+ else
+ buf.append("null");
+
+ if(i < obj.length - 1)
+ buf.append(", ");
+ }
+
+ if(braces)
+ buf.append('}');
+
+ return buf.toString();
+ }
+
+ /** @return true, if character is one of (a, ... z, A, ... Z, 0, ... 9, _)
+ */
+ public static boolean isJavaIdentifierPart(char ch) {
+ return ((ch >= 'a') && (ch <= 'z')) ||
+ ((ch >= 'A') && (ch <= 'Z')) ||
+ ((ch >= '0') && (ch <= '9')) ||
+ (ch == '_');
+ }
+
+ /** Encode byte array it into Java identifier string, i.e., a string
+ * that only contains the following characters: (a, ... z, A, ... Z,
+ * 0, ... 9, _, $). The encoding algorithm itself is not too
+ * clever: if the current byte's ASCII value already is a valid Java
+ * identifier part, leave it as it is. Otherwise it writes the
+ * escape character($) followed by <p><ul><li> the ASCII value as a
+ * hexadecimal string, if the value is not in the range
+ * 200..247</li> <li>a Java identifier char not used in a lowercase
+ * hexadecimal string, if the value is in the range
+ * 200..247</li><ul></p>
+ *
+ * <p>This operation inflates the original byte array by roughly 40-50%</p>
+ *
+ * @param bytes the byte array to convert
+ * @param compress use gzip to minimize string
+ */
+ public static String encode(byte[] bytes, boolean compress) throws IOException {
+ if(compress) {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ GZIPOutputStream gos = new GZIPOutputStream(baos);
+
+ gos.write(bytes, 0, bytes.length);
+ gos.close();
+ baos.close();
+
+ bytes = baos.toByteArray();
+ }
+
+ CharArrayWriter caw = new CharArrayWriter();
+ JavaWriter jw = new JavaWriter(caw);
+
+ for(int i=0; i < bytes.length; i++) {
+ int in = bytes[i] & 0x000000ff; // Normalize to unsigned
+ jw.write(in);
+ }
+
+ return caw.toString();
+ }
+
+ /** Decode a string back to a byte array.
+ *
+ * @param bytes the byte array to convert
+ * @param uncompress use gzip to uncompress the stream of bytes
+ */
+ public static byte[] decode(String s, boolean uncompress) throws IOException {
+ char[] chars = s.toCharArray();
+
+ CharArrayReader car = new CharArrayReader(chars);
+ JavaReader jr = new JavaReader(car);
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+
+ int ch;
+
+ while((ch = jr.read()) >= 0) {
+ bos.write(ch);
+ }
+
+ bos.close();
+ car.close();
+ jr.close();
+
+ byte[] bytes = bos.toByteArray();
+
+ if(uncompress) {
+ GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(bytes));
+
+ byte[] tmp = new byte[bytes.length * 3]; // Rough estimate
+ int count = 0;
+ int b;
+
+ while((b = gis.read()) >= 0)
+ tmp[count++] = (byte)b;
+
+ bytes = new byte[count];
+ System.arraycopy(tmp, 0, bytes, 0, count);
+ }
+
+ return bytes;
+ }
+
+ // A-Z, g-z, _, $
+ private static final int FREE_CHARS = 48;
+ private static int[] CHAR_MAP = new int[FREE_CHARS];
+ private static int[] MAP_CHAR = new int[256]; // Reverse map
+ private static final char ESCAPE_CHAR = '$';
+
+ static {
+ int j = 0, k = 0;
+ for(int i='A'; i <= 'Z'; i++) {
+ CHAR_MAP[j] = i;
+ MAP_CHAR[i] = j;
+ j++;
+ }
+
+ for(int i='g'; i <= 'z'; i++) {
+ CHAR_MAP[j] = i;
+ MAP_CHAR[i] = j;
+ j++;
+ }
+
+ CHAR_MAP[j] = '$';
+ MAP_CHAR['$'] = j;
+ j++;
+
+ CHAR_MAP[j] = '_';
+ MAP_CHAR['_'] = j;
+ }
+
+ /** Decode characters into bytes.
+ * Used by <a href="Utility.html#decode(java.lang.String, boolean)">decode()</a>
+ */
+ private static class JavaReader extends FilterReader {
+ public JavaReader(Reader in) {
+ super(in);
+ }
+
+ public int read() throws IOException {
+ int b = in.read();
+
+ if(b != ESCAPE_CHAR) {
+ return b;
+ } else {
+ int i = in.read();
+
+ if(i < 0)
+ return -1;
+
+ if(((i >= '0') && (i <= '9')) || ((i >= 'a') && (i <= 'f'))) { // Normal escape
+ int j = in.read();
+
+ if(j < 0)
+ return -1;
+
+ char[] tmp = { (char)i, (char)j };
+ int s = Integer.parseInt(new String(tmp), 16);
+
+ return s;
+ } else { // Special escape
+ return MAP_CHAR[i];
+ }
+ }
+ }
+
+ public int read(char[] cbuf, int off, int len) throws IOException {
+ for(int i=0; i < len; i++)
+ cbuf[off + i] = (char)read();
+
+ return len;
+ }
+ }
+
+ /** Encode bytes into valid java identifier characters.
+ * Used by <a href="Utility.html#encode(byte[], boolean)">encode()</a>
+ */
+ private static class JavaWriter extends FilterWriter {
+ public JavaWriter(Writer out) {
+ super(out);
+ }
+
+ public void write(int b) throws IOException {
+ if(isJavaIdentifierPart((char)b) && (b != ESCAPE_CHAR)) {
+ out.write(b);
+ } else {
+ out.write(ESCAPE_CHAR); // Escape character
+
+ // Special escape
+ if(b >= 0 && b < FREE_CHARS) {
+ out.write(CHAR_MAP[b]);
+ } else { // Normal escape
+ char[] tmp = Integer.toHexString(b).toCharArray();
+
+ if(tmp.length == 1) {
+ out.write('0');
+ out.write(tmp[0]);
+ } else {
+ out.write(tmp[0]);
+ out.write(tmp[1]);
+ }
+ }
+ }
+ }
+
+ public void write(char[] cbuf, int off, int len) throws IOException {
+ for(int i=0; i < len; i++)
+ write(cbuf[off + i]);
+ }
+
+ public void write(String str, int off, int len) throws IOException {
+ write(str.toCharArray(), off, len);
+ }
+ }
+}
diff --git a/src/java/org/apache/bcel/classfile/Visitor.java b/src/java/org/apache/bcel/classfile/Visitor.java
new file mode 100644
index 00000000..c3149de4
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/Visitor.java
@@ -0,0 +1,100 @@
+package org.apache.bcel.classfile;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Interface to make use of the Visitor pattern programming style.
+ * I.e. a class that implements this interface can traverse the contents of
+ * a Java class just by calling the `accept' method which all classes have.
+ *
+ * Implemented by wish of
+ * <A HREF="http://www.inf.fu-berlin.de/~bokowski">Boris Bokowski</A>.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public interface Visitor {
+ public void visitCode(Code obj);
+ public void visitCodeException(CodeException obj);
+ public void visitConstantClass(ConstantClass obj);
+ public void visitConstantDouble(ConstantDouble obj);
+ public void visitConstantFieldref(ConstantFieldref obj);
+ public void visitConstantFloat(ConstantFloat obj);
+ public void visitConstantInteger(ConstantInteger obj);
+ public void visitConstantInterfaceMethodref(ConstantInterfaceMethodref obj);
+ public void visitConstantLong(ConstantLong obj);
+ public void visitConstantMethodref(ConstantMethodref obj);
+ public void visitConstantNameAndType(ConstantNameAndType obj);
+ public void visitConstantPool(ConstantPool obj);
+ public void visitConstantString(ConstantString obj);
+ public void visitConstantUtf8(ConstantUtf8 obj);
+ public void visitConstantValue(ConstantValue obj);
+ public void visitDeprecated(Deprecated obj);
+ public void visitExceptionTable(ExceptionTable obj);
+ public void visitField(Field obj);
+ public void visitInnerClass(InnerClass obj);
+ public void visitInnerClasses(InnerClasses obj);
+ public void visitJavaClass(JavaClass obj);
+ public void visitLineNumber(LineNumber obj);
+ public void visitLineNumberTable(LineNumberTable obj);
+ public void visitLocalVariable(LocalVariable obj);
+ public void visitLocalVariableTable(LocalVariableTable obj);
+ public void visitMethod(Method obj);
+ public void visitSourceFile(SourceFile obj);
+ public void visitSynthetic(Synthetic obj);
+ public void visitUnknown(Unknown obj);
+ public void visitStackMap(StackMap obj);
+ public void visitStackMapEntry(StackMapEntry obj);
+}
diff --git a/src/java/org/apache/bcel/classfile/lic b/src/java/org/apache/bcel/classfile/lic
new file mode 100644
index 00000000..66e71199
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/lic
@@ -0,0 +1,53 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
diff --git a/src/java/org/apache/bcel/classfile/package.html b/src/java/org/apache/bcel/classfile/package.html
new file mode 100644
index 00000000..2bf7c28c
--- /dev/null
+++ b/src/java/org/apache/bcel/classfile/package.html
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+$Id$
+-->
+</head>
+<body bgcolor="white">
+<p>
+This package contains the classes that describe the structure of a
+Java class file and a class file parser.
+</p>
+</body>
+</html>
diff --git a/src/java/org/apache/bcel/generic/AALOAD.java b/src/java/org/apache/bcel/generic/AALOAD.java
new file mode 100644
index 00000000..628dbb73
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/AALOAD.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * AALOAD - Load reference from array
+ * <PRE>Stack: ..., arrayref, index -&gt; value</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class AALOAD extends ArrayInstruction implements StackProducer {
+ /** Load reference from array
+ */
+ public AALOAD() {
+ super(org.apache.bcel.Constants.AALOAD);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackProducer(this);
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitArrayInstruction(this);
+ v.visitAALOAD(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/AASTORE.java b/src/java/org/apache/bcel/generic/AASTORE.java
new file mode 100644
index 00000000..c78e9bb6
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/AASTORE.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * AASTORE - Store into reference array
+ * <PRE>Stack: ..., arrayref, index, value -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class AASTORE extends ArrayInstruction implements StackConsumer {
+ /** Store into reference array
+ */
+ public AASTORE() {
+ super(org.apache.bcel.Constants.AASTORE);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitArrayInstruction(this);
+ v.visitAASTORE(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/ACONST_NULL.java b/src/java/org/apache/bcel/generic/ACONST_NULL.java
new file mode 100644
index 00000000..c379a7f5
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ACONST_NULL.java
@@ -0,0 +1,94 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * ACONST_NULL - Push null reference
+ * <PRE>Stack: ... -&gt; ..., null</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class ACONST_NULL extends Instruction
+ implements PushInstruction, TypedInstruction {
+ /**
+ * Push null reference
+ */
+ public ACONST_NULL() {
+ super(org.apache.bcel.Constants.ACONST_NULL, (short)1);
+ }
+
+ /** @return Type.NULL
+ */
+ public Type getType(ConstantPoolGen cp) {
+ return Type.NULL;
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackProducer(this);
+ v.visitPushInstruction(this);
+ v.visitTypedInstruction(this);
+ v.visitACONST_NULL(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/ALOAD.java b/src/java/org/apache/bcel/generic/ALOAD.java
new file mode 100644
index 00000000..3ed5b466
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ALOAD.java
@@ -0,0 +1,92 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * ALOAD - Load reference from local variable
+ * <PRE>Stack: ... -&gt; ..., objectref</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class ALOAD extends LoadInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ ALOAD() {
+ super(org.apache.bcel.Constants.ALOAD, org.apache.bcel.Constants.ALOAD_0);
+ }
+
+ /** Load reference from local variable
+ * @param n index of local variable
+ */
+ public ALOAD(int n) {
+ super(org.apache.bcel.Constants.ALOAD, org.apache.bcel.Constants.ALOAD_0, n);
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ super.accept(v);
+ v.visitALOAD(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/ANEWARRAY.java b/src/java/org/apache/bcel/generic/ANEWARRAY.java
new file mode 100644
index 00000000..8248befe
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ANEWARRAY.java
@@ -0,0 +1,114 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import org.apache.bcel.ExceptionConstants;
+
+/**
+ * ANEWARRAY - Create new array of references
+ * <PRE>Stack: ..., count -&gt; ..., arrayref</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class ANEWARRAY extends CPInstruction
+ implements LoadClass, AllocationInstruction, ExceptionThrower, StackProducer {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ ANEWARRAY() {}
+
+ public ANEWARRAY(int index) {
+ super(org.apache.bcel.Constants.ANEWARRAY, index);
+ }
+
+ public Class[] getExceptions(){
+ Class[] cs = new Class[1 + ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length];
+
+ System.arraycopy(ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION, 0,
+ cs, 0, ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length);
+ cs[ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length] =
+ ExceptionConstants.NEGATIVE_ARRAY_SIZE_EXCEPTION;
+ return cs;
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitLoadClass(this);
+ v.visitAllocationInstruction(this);
+ v.visitExceptionThrower(this);
+ v.visitStackProducer(this);
+ v.visitTypedInstruction(this);
+ v.visitCPInstruction(this);
+ v.visitANEWARRAY(this);
+ }
+
+ public ObjectType getLoadClassType(ConstantPoolGen cpg) {
+ Type t = getType(cpg);
+
+ if (t instanceof ArrayType){
+ t = ((ArrayType) t).getBasicType();
+ }
+
+ return (t instanceof ObjectType)? (ObjectType) t : null;
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/ARETURN.java b/src/java/org/apache/bcel/generic/ARETURN.java
new file mode 100644
index 00000000..577a15f4
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ARETURN.java
@@ -0,0 +1,88 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * ARETURN - Return reference from method
+ * <PRE>Stack: ..., objectref -&gt; &lt;empty&gt;</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class ARETURN extends ReturnInstruction {
+ /**
+ * Return reference from method
+ */
+ public ARETURN() {
+ super(org.apache.bcel.Constants.ARETURN);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitStackConsumer(this);
+ v.visitReturnInstruction(this);
+ v.visitARETURN(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/ARRAYLENGTH.java b/src/java/org/apache/bcel/generic/ARRAYLENGTH.java
new file mode 100644
index 00000000..8bab6cb0
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ARRAYLENGTH.java
@@ -0,0 +1,92 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * ARRAYLENGTH - Get length of array
+ * <PRE>Stack: ..., arrayref -&gt; ..., length</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class ARRAYLENGTH extends Instruction
+ implements ExceptionThrower, StackProducer {
+ /** Get length of array
+ */
+ public ARRAYLENGTH() {
+ super(org.apache.bcel.Constants.ARRAYLENGTH, (short)1);
+ }
+
+ /** @return exceptions this instruction may cause
+ */
+ public Class[] getExceptions() {
+ return new Class[] { org.apache.bcel.ExceptionConstants.NULL_POINTER_EXCEPTION };
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitExceptionThrower(this);
+ v.visitStackProducer(this);
+ v.visitARRAYLENGTH(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/ASTORE.java b/src/java/org/apache/bcel/generic/ASTORE.java
new file mode 100644
index 00000000..b123a571
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ASTORE.java
@@ -0,0 +1,92 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * ASTORE - Store reference into local variable
+ * <PRE>Stack ..., objectref -&gt; ... </PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class ASTORE extends StoreInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ ASTORE() {
+ super(org.apache.bcel.Constants.ASTORE, org.apache.bcel.Constants.ASTORE_0);
+ }
+
+ /** Store reference into local variable
+ * @param n index of local variable
+ */
+ public ASTORE(int n) {
+ super(org.apache.bcel.Constants.ASTORE, org.apache.bcel.Constants.ASTORE_0, n);
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ super.accept(v);
+ v.visitASTORE(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/ATHROW.java b/src/java/org/apache/bcel/generic/ATHROW.java
new file mode 100644
index 00000000..89a8025d
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ATHROW.java
@@ -0,0 +1,92 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * ATHROW - Throw exception
+ * <PRE>Stack: ..., objectref -&gt; objectref</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class ATHROW extends Instruction implements UnconditionalBranch, ExceptionThrower {
+ /**
+ * Throw exception
+ */
+ public ATHROW() {
+ super(org.apache.bcel.Constants.ATHROW, (short)1);
+ }
+
+ /** @return exceptions this instruction may cause
+ */
+ public Class[] getExceptions() {
+ return new Class[] { org.apache.bcel.ExceptionConstants.THROWABLE };
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitUnconditionalBranch(this);
+ v.visitExceptionThrower(this);
+ v.visitATHROW(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/AllocationInstruction.java b/src/java/org/apache/bcel/generic/AllocationInstruction.java
new file mode 100644
index 00000000..b2922d4a
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/AllocationInstruction.java
@@ -0,0 +1,64 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Denote family of instructions that allocates space in the heap.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public interface AllocationInstruction {}
+
diff --git a/src/java/org/apache/bcel/generic/ArithmeticInstruction.java b/src/java/org/apache/bcel/generic/ArithmeticInstruction.java
new file mode 100644
index 00000000..aa185924
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ArithmeticInstruction.java
@@ -0,0 +1,106 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import org.apache.bcel.Constants;
+/**
+ * Super class for the family of arithmetic instructions.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public abstract class ArithmeticInstruction extends Instruction
+ implements TypedInstruction, StackProducer, StackConsumer {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ ArithmeticInstruction() {}
+
+ /**
+ * @param opcode of instruction
+ */
+ protected ArithmeticInstruction(short opcode) {
+ super(opcode, (short)1);
+ }
+
+ /** @return type associated with the instruction
+ */
+ public Type getType(ConstantPoolGen cp) {
+ switch(opcode) {
+ case Constants.DADD: case Constants.DDIV: case Constants.DMUL:
+ case Constants.DNEG: case Constants.DREM: case Constants.DSUB:
+ return Type.DOUBLE;
+
+ case Constants.FADD: case Constants.FDIV: case Constants.FMUL:
+ case Constants.FNEG: case Constants.FREM: case Constants.FSUB:
+ return Type.FLOAT;
+
+ case Constants.IADD: case Constants.IAND: case Constants.IDIV:
+ case Constants.IMUL: case Constants.INEG: case Constants.IOR: case Constants.IREM:
+ case Constants.ISHL: case Constants.ISHR: case Constants.ISUB:
+ case Constants.IUSHR: case Constants.IXOR:
+ return Type.INT;
+
+ case Constants.LADD: case Constants.LAND: case Constants.LDIV:
+ case Constants.LMUL: case Constants.LNEG: case Constants.LOR: case Constants.LREM:
+ case Constants.LSHL: case Constants.LSHR: case Constants.LSUB:
+ case Constants.LUSHR: case Constants.LXOR:
+ return Type.LONG;
+
+ default: // Never reached
+ throw new ClassGenException("Unknown type " + opcode);
+ }
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/ArrayInstruction.java b/src/java/org/apache/bcel/generic/ArrayInstruction.java
new file mode 100644
index 00000000..b8586bd4
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ArrayInstruction.java
@@ -0,0 +1,106 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Super class for instructions dealing with array access such as IALOAD.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public abstract class ArrayInstruction extends Instruction
+ implements ExceptionThrower, TypedInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ ArrayInstruction() {}
+
+ /**
+ * @param opcode of instruction
+ */
+ protected ArrayInstruction(short opcode) {
+ super(opcode, (short)1);
+ }
+
+ public Class[] getExceptions() {
+ return org.apache.bcel.ExceptionConstants.EXCS_ARRAY_EXCEPTION;
+ }
+
+ /** @return type associated with the instruction
+ */
+ public Type getType(ConstantPoolGen cp) {
+ switch(opcode) {
+ case org.apache.bcel.Constants.IALOAD: case org.apache.bcel.Constants.IASTORE:
+ return Type.INT;
+ case org.apache.bcel.Constants.CALOAD: case org.apache.bcel.Constants.CASTORE:
+ return Type.CHAR;
+ case org.apache.bcel.Constants.BALOAD: case org.apache.bcel.Constants.BASTORE:
+ return Type.BYTE;
+ case org.apache.bcel.Constants.SALOAD: case org.apache.bcel.Constants.SASTORE:
+ return Type.SHORT;
+ case org.apache.bcel.Constants.LALOAD: case org.apache.bcel.Constants.LASTORE:
+ return Type.LONG;
+ case org.apache.bcel.Constants.DALOAD: case org.apache.bcel.Constants.DASTORE:
+ return Type.DOUBLE;
+ case org.apache.bcel.Constants.FALOAD: case org.apache.bcel.Constants.FASTORE:
+ return Type.FLOAT;
+ case org.apache.bcel.Constants.AALOAD: case org.apache.bcel.Constants.AASTORE:
+ return Type.OBJECT;
+
+ default: throw new ClassGenException("Oops: unknown case in switch" + opcode);
+ }
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/ArrayType.java b/src/java/org/apache/bcel/generic/ArrayType.java
new file mode 100644
index 00000000..738a5990
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ArrayType.java
@@ -0,0 +1,156 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import org.apache.bcel.Constants;
+
+/**
+ * Denotes array type, such as int[][]
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public final class ArrayType extends ReferenceType {
+ private int dimensions;
+ private Type basic_type;
+
+ /**
+ * Convenience constructor for array type, e.g. int[]
+ *
+ * @param type array type, e.g. T_INT
+ */
+ public ArrayType(byte type, int dimensions) {
+ this(BasicType.getType(type), dimensions);
+ }
+
+ /**
+ * Convenience constructor for reference array type, e.g. Object[]
+ *
+ * @param class_name complete name of class (java.lang.String, e.g.)
+ */
+ public ArrayType(String class_name, int dimensions) {
+ this(new ObjectType(class_name), dimensions);
+ }
+
+ /**
+ * Constructor for array of given type
+ *
+ * @param type type of array (may be an array itself)
+ */
+ public ArrayType(Type type, int dimensions) {
+ super(Constants.T_ARRAY, "<dummy>");
+
+ if((dimensions < 1) || (dimensions > Constants.MAX_BYTE))
+ throw new ClassGenException("Invalid number of dimensions: " + dimensions);
+
+ switch(type.getType()) {
+ case Constants.T_ARRAY:
+ ArrayType array = (ArrayType)type;
+ this.dimensions = dimensions + array.dimensions;
+ basic_type = array.basic_type;
+ break;
+
+ case Constants.T_VOID:
+ throw new ClassGenException("Invalid type: void[]");
+
+ default: // Basic type or reference
+ this.dimensions = dimensions;
+ basic_type = type;
+ break;
+ }
+
+ StringBuffer buf = new StringBuffer();
+ for(int i=0; i < this.dimensions; i++)
+ buf.append('[');
+
+ buf.append(basic_type.getSignature());
+
+ signature = buf.toString();
+ }
+
+ /**
+ * @return basic type of array, i.e., for int[][][] the basic type is int
+ */
+ public Type getBasicType() {
+ return basic_type;
+ }
+
+ /**
+ * @return element type of array, i.e., for int[][][] the element type is int[][]
+ */
+ public Type getElementType() {
+ if(dimensions == 1)
+ return basic_type;
+ else
+ return new ArrayType(basic_type, dimensions - 1);
+ }
+
+ /** @return number of dimensions of array
+ */
+ public int getDimensions() { return dimensions; }
+
+ /** @return a hash code value for the object.
+ */
+ public int hashcode() { return basic_type.hashCode() ^ dimensions; }
+
+ /** @return true if both type objects refer to the same array type.
+ */
+ public boolean equals(Object type) {
+ if(type instanceof ArrayType) {
+ ArrayType array = (ArrayType)type;
+ return (array.dimensions == dimensions) && array.basic_type.equals(basic_type);
+ } else
+ return false;
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/BALOAD.java b/src/java/org/apache/bcel/generic/BALOAD.java
new file mode 100644
index 00000000..ff309eb0
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/BALOAD.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * BALOAD - Load byte or boolean from array
+ * <PRE>Stack: ..., arrayref, index -&gt; ..., value</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class BALOAD extends ArrayInstruction implements StackProducer {
+ /** Load byte or boolean from array
+ */
+ public BALOAD() {
+ super(org.apache.bcel.Constants.BALOAD);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackProducer(this);
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitArrayInstruction(this);
+ v.visitBALOAD(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/BASTORE.java b/src/java/org/apache/bcel/generic/BASTORE.java
new file mode 100644
index 00000000..ce5a1028
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/BASTORE.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * BASTORE - Store into byte or boolean array
+ * <PRE>Stack: ..., arrayref, index, value -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class BASTORE extends ArrayInstruction implements StackConsumer {
+ /** Store byte or boolean into array
+ */
+ public BASTORE() {
+ super(org.apache.bcel.Constants.BASTORE);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitArrayInstruction(this);
+ v.visitBASTORE(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/BIPUSH.java b/src/java/org/apache/bcel/generic/BIPUSH.java
new file mode 100644
index 00000000..d9b6efd1
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/BIPUSH.java
@@ -0,0 +1,132 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import java.io.*;
+import org.apache.bcel.util.ByteSequence;
+
+/**
+ * BIPUSH - Push byte on stack
+ *
+ * <PRE>Stack: ... -&gt; ..., value</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class BIPUSH extends Instruction implements ConstantPushInstruction {
+ private byte b;
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ BIPUSH() {}
+
+ /** Push byte on stack
+ */
+ public BIPUSH(byte b) {
+ super(org.apache.bcel.Constants.BIPUSH, (short)2);
+ this.b = b;
+ }
+
+ /**
+ * Dump instruction as byte code to stream out.
+ */
+ public void dump(DataOutputStream out) throws IOException {
+ super.dump(out);
+ out.writeByte(b);
+ }
+
+ /**
+ * @return mnemonic for instruction
+ */
+ public String toString(boolean verbose) {
+ return super.toString(verbose) + " " + b;
+ }
+
+ /**
+ * Read needed data (e.g. index) from file.
+ */
+ protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
+ {
+ length = 2;
+ b = bytes.readByte();
+ }
+
+ public Number getValue() { return new Integer(b); }
+
+ /** @return Type.BYTE
+ */
+ public Type getType(ConstantPoolGen cp) {
+ return Type.BYTE;
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitPushInstruction(this);
+ v.visitStackProducer(this);
+ v.visitTypedInstruction(this);
+ v.visitConstantPushInstruction(this);
+ v.visitBIPUSH(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/BREAKPOINT.java b/src/java/org/apache/bcel/generic/BREAKPOINT.java
new file mode 100644
index 00000000..22547865
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/BREAKPOINT.java
@@ -0,0 +1,80 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * BREAKPOINT
+ *
+ * @version $Id$
+ * @author Enver Haase
+ */
+public class BREAKPOINT extends Instruction {
+ public BREAKPOINT() {
+ super(org.apache.bcel.Constants.BREAKPOINT, (short)1);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitBREAKPOINT(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/BasicType.java b/src/java/org/apache/bcel/generic/BasicType.java
new file mode 100644
index 00000000..00785e95
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/BasicType.java
@@ -0,0 +1,101 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import org.apache.bcel.Constants;
+
+/**
+ * Denotes basic type such as int.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public final class BasicType extends Type {
+ /**
+ * Constructor for basic types such as int, long, `void'
+ *
+ * @param type one of T_INT, T_BOOLEAN, ..., T_VOID
+ * @see org.apache.bcel.Constants
+ */
+ BasicType(byte type) {
+ super(type, Constants.SHORT_TYPE_NAMES[type]);
+
+ if((type < Constants.T_BOOLEAN) || (type > Constants.T_VOID))
+ throw new ClassGenException("Invalid type: " + type);
+ }
+
+ public static final BasicType getType(byte type) {
+ switch(type) {
+ case Constants.T_VOID: return VOID;
+ case Constants.T_BOOLEAN: return BOOLEAN;
+ case Constants.T_BYTE: return BYTE;
+ case Constants.T_SHORT: return SHORT;
+ case Constants.T_CHAR: return CHAR;
+ case Constants.T_INT: return INT;
+ case Constants.T_LONG: return LONG;
+ case Constants.T_DOUBLE: return DOUBLE;
+ case Constants.T_FLOAT: return FLOAT;
+
+ default:
+ throw new ClassGenException("Invalid type: " + type);
+ }
+ }
+
+ /** @return true if both type objects refer to the same type
+ */
+ public boolean equals(Object type) {
+ return (type instanceof BasicType)?
+ ((BasicType)type).type == this.type : false;
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/BranchHandle.java b/src/java/org/apache/bcel/generic/BranchHandle.java
new file mode 100644
index 00000000..9ba154db
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/BranchHandle.java
@@ -0,0 +1,151 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * BranchHandle is returned by specialized InstructionList.append() whenever a
+ * BranchInstruction is appended. This is useful when the target of this
+ * instruction is not known at time of creation and must be set later
+ * via setTarget().
+ *
+ * @see InstructionHandle
+ * @see Instruction
+ * @see InstructionList
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public final class BranchHandle extends InstructionHandle {
+ private BranchInstruction bi; // An alias in fact, but saves lots of casts
+
+ private BranchHandle(BranchInstruction i) {
+ super(i);
+ bi = i;
+ }
+
+ /** Factory methods.
+ */
+ private static BranchHandle bh_list = null; // List of reusable handles
+
+ static final BranchHandle getBranchHandle(BranchInstruction i) {
+ if(bh_list == null)
+ return new BranchHandle(i);
+ else {
+ BranchHandle bh = bh_list;
+ bh_list = (BranchHandle)bh.next;
+
+ bh.setInstruction(i);
+
+ return bh;
+ }
+ }
+
+ /** Handle adds itself to the list of resuable handles.
+ */
+ protected void addHandle() {
+ next = bh_list;
+ bh_list = this;
+ }
+
+ /* Override InstructionHandle methods: delegate to branch instruction.
+ * Through this overriding all access to the private i_position field should
+ * be prevented.
+ */
+ public int getPosition() { return bi.position; }
+
+ void setPosition(int pos) {
+ i_position = bi.position = pos;
+ }
+
+ protected int updatePosition(int offset, int max_offset) {
+ int x = bi.updatePosition(offset, max_offset);
+ i_position = bi.position;
+ return x;
+ }
+
+ /**
+ * Pass new target to instruction.
+ */
+ public void setTarget(InstructionHandle ih) {
+ bi.setTarget(ih);
+ }
+
+ /**
+ * Update target of instruction.
+ */
+ public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) {
+ bi.updateTarget(old_ih, new_ih);
+ }
+
+ /**
+ * @return target of instruction.
+ */
+ public InstructionHandle getTarget() {
+ return bi.getTarget();
+ }
+
+ /**
+ * Set new contents. Old instruction is disposed and may not be used anymore.
+ */
+ public void setInstruction(Instruction i) {
+ super.setInstruction(i);
+
+ if(!(i instanceof BranchInstruction))
+ throw new ClassGenException("Assigning " + i +
+ " to branch handle which is not a branch instruction");
+
+ bi = (BranchInstruction)i;
+ }
+}
+
diff --git a/src/java/org/apache/bcel/generic/BranchInstruction.java b/src/java/org/apache/bcel/generic/BranchInstruction.java
new file mode 100644
index 00000000..099eef20
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/BranchInstruction.java
@@ -0,0 +1,246 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import java.io.*;
+import org.apache.bcel.util.ByteSequence;
+
+/**
+ * Abstract super class for branching instructions like GOTO, IFEQ, etc..
+ * Branch instructions may have a variable length, namely GOTO, JSR,
+ * LOOKUPSWITCH and TABLESWITCH.
+ *
+ * @see InstructionList
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public abstract class BranchInstruction extends Instruction implements InstructionTargeter {
+ protected int index; // Branch target relative to this instruction
+ protected InstructionHandle target; // Target object in instruction list
+ protected int position; // Byte code offset
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ BranchInstruction() {}
+
+ /** Common super constructor
+ * @param opcodee Instruction opcode
+ * @param target instruction to branch to
+ */
+ protected BranchInstruction(short opcode, InstructionHandle target) {
+ super(opcode, (short)3);
+ setTarget(target);
+ }
+
+ /**
+ * Dump instruction as byte code to stream out.
+ * @param out Output stream
+ */
+ public void dump(DataOutputStream out) throws IOException {
+ out.writeByte(opcode);
+
+ index = getTargetOffset();
+
+ if(Math.abs(index) >= 32767) // too large for short
+ throw new ClassGenException("Branch target offset too large for short");
+
+ out.writeShort(index); // May be negative, i.e., point backwards
+ }
+
+ /**
+ * @param target branch target
+ * @return the offset to `target' relative to this instruction
+ */
+ protected int getTargetOffset(InstructionHandle target) {
+ if(target == null)
+ throw new ClassGenException("Target of " + super.toString(true) +
+ " is invalid null handle");
+
+ int t = target.getPosition();
+
+ if(t < 0)
+ throw new ClassGenException("Invalid branch target position offset for " +
+ super.toString(true) + ":" + t + ":" + target);
+
+ return t - position;
+ }
+
+ /**
+ * @return the offset to this instruction's target
+ */
+ protected int getTargetOffset() { return getTargetOffset(target); }
+
+ /**
+ * Called by InstructionList.setPositions when setting the position for every
+ * instruction. In the presence of variable length instructions `setPositions'
+ * performs multiple passes over the instruction list to calculate the
+ * correct (byte) positions and offsets by calling this function.
+ *
+ * @param offset additional offset caused by preceding (variable length) instructions
+ * @param max_offset the maximum offset that may be caused by these instructions
+ * @return additional offset caused by possible change of this instruction's length
+ */
+ protected int updatePosition(int offset, int max_offset) {
+ position += offset;
+ return 0;
+ }
+
+ /**
+ * Long output format:
+ *
+ * &lt;position in byte code&gt;
+ * &lt;name of opcode&gt; "["&lt;opcode number&gt;"]"
+ * "("&lt;length of instruction&gt;")"
+ * "&lt;"&lt;target instruction&gt;"&gt;" "@"&lt;branch target offset&gt;
+ *
+ * @param verbose long/short format switch
+ * @return mnemonic for instruction
+ */
+ public String toString(boolean verbose) {
+ String s = super.toString(verbose);
+ String t = "null";
+
+ if(verbose) {
+ if(target != null) {
+ if(target.getInstruction() == this)
+ t = "<points to itself>";
+ else if(target.getInstruction() == null)
+ t = "<null instruction!!!?>";
+ else
+ t = target.getInstruction().toString(false); // Avoid circles
+ }
+ } else {
+ if(target != null) {
+ index = getTargetOffset();
+ t = "" + (index + position);
+ }
+ }
+
+ return s + " -> " + t;
+ }
+
+ /**
+ * Read needed data (e.g. index) from file. Conversion to a InstructionHandle
+ * is done in InstructionList(byte[]).
+ *
+ * @param bytes input stream
+ * @param wide wide prefix?
+ * @see InstructionList
+ */
+ protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
+ {
+ length = 3;
+ index = bytes.readShort();
+ }
+
+ /**
+ * @return target offset in byte code
+ */
+ public final int getIndex() { return index; }
+
+ /**
+ * @return target of branch instruction
+ */
+ public InstructionHandle getTarget() { return target; }
+
+ /**
+ * Set branch target
+ * @param target branch target
+ */
+ public void setTarget(InstructionHandle target) {
+ notifyTarget(this.target, target, this);
+ this.target = target;
+ }
+
+ /**
+ * Used by BranchInstruction, LocalVariableGen, CodeExceptionGen
+ */
+ static final void notifyTarget(InstructionHandle old_ih, InstructionHandle new_ih,
+ InstructionTargeter t) {
+ if(old_ih != null)
+ old_ih.removeTargeter(t);
+ if(new_ih != null)
+ new_ih.addTargeter(t);
+ }
+
+ /**
+ * @param old_ih old target
+ * @param new_ih new target
+ */
+ public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) {
+ if(target == old_ih)
+ setTarget(new_ih);
+ else
+ throw new ClassGenException("Not targeting " + old_ih + ", but " + target);
+ }
+
+ /**
+ * @return true, if ih is target of this instruction
+ */
+ public boolean containsTarget(InstructionHandle ih) {
+ return (target == ih);
+ }
+
+ /**
+ * Inform target that it's not targeted anymore.
+ */
+ void dispose() {
+ setTarget(null);
+ index=-1;
+ position=-1;
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/CALOAD.java b/src/java/org/apache/bcel/generic/CALOAD.java
new file mode 100644
index 00000000..bf4f0c9f
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/CALOAD.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * CALOAD - Load char from array
+ * <PRE>Stack: ..., arrayref, index -&gt; ..., value</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class CALOAD extends ArrayInstruction implements StackProducer {
+ /** Load char from array
+ */
+ public CALOAD() {
+ super(org.apache.bcel.Constants.CALOAD);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackProducer(this);
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitArrayInstruction(this);
+ v.visitCALOAD(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/CASTORE.java b/src/java/org/apache/bcel/generic/CASTORE.java
new file mode 100644
index 00000000..864a60b5
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/CASTORE.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * CASTORE - Store into char array
+ * <PRE>Stack: ..., arrayref, index, value -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class CASTORE extends ArrayInstruction implements StackConsumer {
+ /** Store char into array
+ */
+ public CASTORE() {
+ super(org.apache.bcel.Constants.CASTORE);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitArrayInstruction(this);
+ v.visitCASTORE(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/CHECKCAST.java b/src/java/org/apache/bcel/generic/CHECKCAST.java
new file mode 100644
index 00000000..7bd66206
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/CHECKCAST.java
@@ -0,0 +1,117 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import org.apache.bcel.ExceptionConstants;
+/**
+ * CHECKCAST - Check whether object is of given type
+ * <PRE>Stack: ..., objectref -&gt; ..., objectref</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class CHECKCAST extends CPInstruction
+ implements LoadClass, ExceptionThrower, StackProducer, StackConsumer {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ CHECKCAST() {}
+
+ /** Check whether object is of given type
+ * @param n index to class in constant pool
+ */
+ public CHECKCAST(int index) {
+ super(org.apache.bcel.Constants.CHECKCAST, index);
+ }
+
+ /** @return exceptions this instruction may cause
+ */
+ public Class[] getExceptions() {
+ Class[] cs = new Class[1 + ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length];
+
+ System.arraycopy(ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION, 0,
+ cs, 0, ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length);
+ cs[ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length] =
+ ExceptionConstants.CLASS_CAST_EXCEPTION;
+ return cs;
+ }
+
+ public ObjectType getLoadClassType(ConstantPoolGen cpg) {
+ Type t = getType(cpg);
+
+ if(t instanceof ArrayType)
+ t = ((ArrayType) t).getBasicType();
+
+ return (t instanceof ObjectType)? (ObjectType) t : null;
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitLoadClass(this);
+ v.visitExceptionThrower(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitTypedInstruction(this);
+ v.visitCPInstruction(this);
+ v.visitCHECKCAST(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/CPInstruction.java b/src/java/org/apache/bcel/generic/CPInstruction.java
new file mode 100644
index 00000000..d6eb0d1f
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/CPInstruction.java
@@ -0,0 +1,166 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import java.io.*;
+import org.apache.bcel.util.ByteSequence;
+import org.apache.bcel.Constants;
+import org.apache.bcel.classfile.*;
+
+/**
+ * Abstract super class for instructions that use an index into the
+ * constant pool such as LDC, INVOKEVIRTUAL, etc.
+ *
+ * @see ConstantPoolGen
+ * @see LDC
+ * @see INVOKEVIRTUAL
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public abstract class CPInstruction extends Instruction
+ implements TypedInstruction, IndexedInstruction
+{
+ protected int index; // index to constant pool
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ CPInstruction() {}
+
+ /**
+ * @param index to constant pool
+ */
+ protected CPInstruction(short opcode, int index) {
+ super(opcode, (short)3);
+ setIndex(index);
+ }
+
+ /**
+ * Dump instruction as byte code to stream out.
+ * @param out Output stream
+ */
+ public void dump(DataOutputStream out) throws IOException {
+ out.writeByte(opcode);
+ out.writeShort(index);
+ }
+
+ /**
+ * Long output format:
+ *
+ * &lt;name of opcode&gt; "["&lt;opcode number&gt;"]"
+ * "("&lt;length of instruction&gt;")" "&lt;"&lt; constant pool index&gt;"&gt;"
+ *
+ * @param verbose long/short format switch
+ * @return mnemonic for instruction
+ */
+ public String toString(boolean verbose) {
+ return super.toString(verbose) + " " + index;
+ }
+
+ /**
+ * @return mnemonic for instruction with symbolic references resolved
+ */
+ public String toString(ConstantPool cp) {
+ Constant c = cp.getConstant(index);
+ String str = cp.constantToString(c);
+
+ if(c instanceof ConstantClass)
+ str = str.replace('.', '/');
+
+ return org.apache.bcel.Constants.OPCODE_NAMES[opcode] + " " + str;
+ }
+
+ /**
+ * Read needed data (i.e., index) from file.
+ * @param bytes input stream
+ * @param wide wide prefix?
+ */
+ protected void initFromFile(ByteSequence bytes, boolean wide)
+ throws IOException
+ {
+ setIndex(bytes.readUnsignedShort());
+ length = 3;
+ }
+
+ /**
+ * @return index in constant pool referred by this instruction.
+ */
+ public final int getIndex() { return index; }
+
+ /**
+ * Set the index to constant pool.
+ * @param index in constant pool.
+ */
+ public void setIndex(int index) {
+ if(index < 0)
+ throw new ClassGenException("Negative index value: " + index);
+
+ this.index = index;
+ }
+
+ /** @return type related with this instruction.
+ */
+ public Type getType(ConstantPoolGen cpg) {
+ ConstantPool cp = cpg.getConstantPool();
+ String name = cp.getConstantString(index, org.apache.bcel.Constants.CONSTANT_Class);
+
+ if(!name.startsWith("["))
+ name = "L" + name + ";";
+
+ return Type.getType(name);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/ClassGen.java b/src/java/org/apache/bcel/generic/ClassGen.java
new file mode 100644
index 00000000..8c6d95d6
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ClassGen.java
@@ -0,0 +1,434 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import org.apache.bcel.classfile.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * Template class for building up a java class. May be initialized with an
+ * existing java class (file).
+ *
+ * @see JavaClass
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class ClassGen extends AccessFlags implements Cloneable {
+ /* Corresponds to the fields found in a JavaClass object.
+ */
+ private String class_name, super_class_name, file_name;
+ private int class_name_index = -1, superclass_name_index = -1;
+ private int major = Constants.MAJOR_1_1, minor = Constants.MINOR_1_1;
+
+ private ConstantPoolGen cp; // Template for building up constant pool
+
+ // ArrayLists instead of arrays to gather fields, methods, etc.
+ private ArrayList field_vec = new ArrayList();
+ private ArrayList method_vec = new ArrayList();
+ private ArrayList attribute_vec = new ArrayList();
+ private ArrayList interface_vec = new ArrayList();
+
+ /** Convenience constructor to set up some important values initially.
+ *
+ * @param class_name fully qualified class name
+ * @param super_class_name fully qualified superclass name
+ * @param file_name source file name
+ * @param access_flags access qualifiers
+ * @param interfaces implemented interfaces
+ */
+ public ClassGen(String class_name, String super_class_name, String file_name,
+ int access_flags, String[] interfaces) {
+ this.class_name = class_name;
+ this.super_class_name = super_class_name;
+ this.file_name = file_name;
+ this.access_flags = access_flags;
+ cp = new ConstantPoolGen(); // Create empty constant pool
+
+ // Put everything needed by default into the constant pool and the vectors
+ addAttribute(new SourceFile(cp.addUtf8("SourceFile"), 2,
+ cp.addUtf8(file_name), cp.getConstantPool()));
+ class_name_index = cp.addClass(class_name);
+ superclass_name_index = cp.addClass(super_class_name);
+
+ if(interfaces != null)
+ for(int i=0; i < interfaces.length; i++)
+ addInterface(interfaces[i]);
+ }
+
+ /**
+ * Initialize with existing class.
+ * @param clazz JavaClass object (e.g. read from file)
+ */
+ public ClassGen(JavaClass clazz) {
+ class_name_index = clazz.getClassNameIndex();
+ superclass_name_index = clazz.getSuperclassNameIndex();
+ class_name = clazz.getClassName();
+ super_class_name = clazz.getSuperclassName();
+ file_name = clazz.getSourceFileName();
+ access_flags = clazz.getAccessFlags();
+ cp = new ConstantPoolGen(clazz.getConstantPool());
+ major = clazz.getMajor();
+ minor = clazz.getMinor();
+
+ Attribute[] attributes = clazz.getAttributes();
+ Method[] methods = clazz.getMethods();
+ Field[] fields = clazz.getFields();
+ String[] interfaces = clazz.getInterfaceNames();
+
+ for(int i=0; i < interfaces.length; i++)
+ addInterface(interfaces[i]);
+
+ for(int i=0; i < attributes.length; i++)
+ addAttribute(attributes[i]);
+
+ for(int i=0; i < methods.length; i++)
+ addMethod(methods[i]);
+
+ for(int i=0; i < fields.length; i++)
+ addField(fields[i]);
+ }
+
+ /**
+ * @return the (finally) built up Java class object.
+ */
+ public JavaClass getJavaClass() {
+ int[] interfaces = getInterfaces();
+ Field[] fields = getFields();
+ Method[] methods = getMethods();
+ Attribute[] attributes = getAttributes();
+
+ // Must be last since the above calls may still add something to it
+ ConstantPool cp = this.cp.getFinalConstantPool();
+
+ return new JavaClass(class_name_index, superclass_name_index,
+ file_name, major, minor, access_flags,
+ cp, interfaces, fields, methods, attributes);
+ }
+
+ /**
+ * Add an interface to this class, i.e., this class has to implement it.
+ * @param name interface to implement (fully qualified class name)
+ */
+ public void addInterface(String name) {
+ interface_vec.add(name);
+ }
+
+ /**
+ * Remove an interface from this class.
+ * @param name interface to remove (fully qualified name)
+ */
+ public void removeInterface(String name) {
+ interface_vec.remove(name);
+ }
+
+ /**
+ * @return major version number of class file
+ */
+ public int getMajor() { return major; }
+
+ /** Set major version number of class file, default value is 45 (JDK 1.1)
+ * @param major major version number
+ */
+ public void setMajor(int major) {
+ this.major = major;
+ }
+
+ /** Set minor version number of class file, default value is 3 (JDK 1.1)
+ * @param minor minor version number
+ */
+ public void setMinor(int minor) {
+ this.minor = minor;
+ }
+
+ /**
+ * @return minor version number of class file
+ */
+ public int getMinor() { return minor; }
+
+ /**
+ * Add an attribute to this class.
+ * @param a attribute to add
+ */
+ public void addAttribute(Attribute a) { attribute_vec.add(a); }
+
+ /**
+ * Add a method to this class.
+ * @param m method to add
+ */
+ public void addMethod(Method m) { method_vec.add(m); }
+
+ /**
+ * Convenience method.
+ *
+ * Add an empty constructor to this class that does nothing but calling super().
+ * @param access rights for constructor
+ */
+ public void addEmptyConstructor(int access_flags) {
+ InstructionList il = new InstructionList();
+ il.append(InstructionConstants.THIS); // Push `this'
+ il.append(new INVOKESPECIAL(cp.addMethodref(super_class_name,
+ "<init>", "()V")));
+ il.append(InstructionConstants.RETURN);
+
+ MethodGen mg = new MethodGen(access_flags, Type.VOID, Type.NO_ARGS, null,
+ "<init>", class_name, il, cp);
+ mg.setMaxStack(1);
+ addMethod(mg.getMethod());
+ }
+
+ /**
+ * Add a field to this class.
+ * @param f field to add
+ */
+ public void addField(Field f) { field_vec.add(f); }
+
+ public boolean containsField(Field f) { return field_vec.contains(f); }
+
+ /** @return field object with given name, or null
+ */
+ public Field containsField(String name) {
+ for(Iterator e=field_vec.iterator(); e.hasNext(); ) {
+ Field f = (Field)e.next();
+ if(f.getName().equals(name))
+ return f;
+ }
+
+ return null;
+ }
+
+ /** @return method object with given name and signature, or null
+ */
+ public Method containsMethod(String name, String signature) {
+ for(Iterator e=method_vec.iterator(); e.hasNext();) {
+ Method m = (Method)e.next();
+ if(m.getName().equals(name) && m.getSignature().equals(signature))
+ return m;
+ }
+
+ return null;
+ }
+
+ /**
+ * Remove an attribute from this class.
+ * @param a attribute to remove
+ */
+ public void removeAttribute(Attribute a) { attribute_vec.remove(a); }
+
+ /**
+ * Remove a method from this class.
+ * @param m method to remove
+ */
+ public void removeMethod(Method m) { method_vec.remove(m); }
+
+ /** Replace given method with new one. If the old one does not exist
+ * add the new_ method to the class anyway.
+ */
+ public void replaceMethod(Method old, Method new_) {
+ if(new_ == null)
+ throw new ClassGenException("Replacement method must not be null");
+
+ int i = method_vec.indexOf(old);
+
+ if(i < 0)
+ method_vec.add(new_);
+ else
+ method_vec.set(i, new_);
+ }
+
+ /** Replace given field with new one. If the old one does not exist
+ * add the new_ field to the class anyway.
+ */
+ public void replaceField(Field old, Field new_) {
+ if(new_ == null)
+ throw new ClassGenException("Replacement method must not be null");
+
+ int i = field_vec.indexOf(old);
+
+ if(i < 0)
+ field_vec.add(new_);
+ else
+ field_vec.set(i, new_);
+ }
+
+ /**
+ * Remove a field to this class.
+ * @param f field to remove
+ */
+ public void removeField(Field f) { field_vec.remove(f); }
+
+ public String getClassName() { return class_name; }
+ public String getSuperclassName() { return super_class_name; }
+ public String getFileName() { return file_name; }
+
+ public void setClassName(String name) {
+ class_name = name.replace('/', '.');
+ class_name_index = cp.addClass(name);
+ }
+
+ public void setSuperclassName(String name) {
+ super_class_name = name.replace('/', '.');
+ superclass_name_index = cp.addClass(name);
+ }
+
+ public Method[] getMethods() {
+ Method[] methods = new Method[method_vec.size()];
+ method_vec.toArray(methods);
+ return methods;
+ }
+
+ public void setMethods(Method[] methods) {
+ method_vec.clear();
+ for(int m=0; m<methods.length; m++)
+ addMethod(methods[m]);
+ }
+
+ public void setMethodAt(Method method, int pos) {
+ method_vec.set(pos, method);
+ }
+
+ public Method getMethodAt(int pos) {
+ return (Method)method_vec.get(pos);
+ }
+
+ public String[] getInterfaceNames() {
+ int size = interface_vec.size();
+ String[] interfaces = new String[size];
+
+ interface_vec.toArray(interfaces);
+ return interfaces;
+ }
+
+ public int[] getInterfaces() {
+ int size = interface_vec.size();
+ int[] interfaces = new int[size];
+
+ for(int i=0; i < size; i++)
+ interfaces[i] = cp.addClass((String)interface_vec.get(i));
+
+ return interfaces;
+ }
+
+ public Field[] getFields() {
+ Field[] fields = new Field[field_vec.size()];
+ field_vec.toArray(fields);
+ return fields;
+ }
+
+ public Attribute[] getAttributes() {
+ Attribute[] attributes = new Attribute[attribute_vec.size()];
+ attribute_vec.toArray(attributes);
+ return attributes;
+ }
+
+ public ConstantPoolGen getConstantPool() { return cp; }
+ public void setConstantPool(ConstantPoolGen constant_pool) {
+ cp = constant_pool;
+ }
+
+ public void setClassNameIndex(int class_name_index) {
+ this.class_name_index = class_name_index;
+ class_name = cp.getConstantPool().
+ getConstantString(class_name_index, Constants.CONSTANT_Class).replace('/', '.');
+ }
+
+ public void setSuperclassNameIndex(int superclass_name_index) {
+ this.superclass_name_index = superclass_name_index;
+ super_class_name = cp.getConstantPool().
+ getConstantString(superclass_name_index, Constants.CONSTANT_Class).replace('/', '.');
+ }
+
+ public int getSuperclassNameIndex() { return superclass_name_index; }
+
+ public int getClassNameIndex() { return class_name_index; }
+
+ private ArrayList observers;
+
+ /** Add observer for this object.
+ */
+ public void addObserver(ClassObserver o) {
+ if(observers == null)
+ observers = new ArrayList();
+
+ observers.add(o);
+ }
+
+ /** Remove observer for this object.
+ */
+ public void removeObserver(ClassObserver o) {
+ if(observers != null)
+ observers.remove(o);
+ }
+
+ /** Call notify() method on all observers. This method is not called
+ * automatically whenever the state has changed, but has to be
+ * called by the user after he has finished editing the object.
+ */
+ public void update() {
+ if(observers != null)
+ for(Iterator e = observers.iterator(); e.hasNext(); )
+ ((ClassObserver)e.next()).notify(this);
+ }
+
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch(CloneNotSupportedException e) {
+ System.err.println(e);
+ return null;
+ }
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/ClassGenException.java b/src/java/org/apache/bcel/generic/ClassGenException.java
new file mode 100644
index 00000000..56d21c28
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ClassGenException.java
@@ -0,0 +1,68 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Thrown on internal errors. Extends RuntimeException so it hasn't to be declared
+ * in the throws clause every time.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class ClassGenException extends RuntimeException {
+ public ClassGenException() { super(); }
+ public ClassGenException(String s) { super(s); }
+}
+
diff --git a/src/java/org/apache/bcel/generic/ClassObserver.java b/src/java/org/apache/bcel/generic/ClassObserver.java
new file mode 100644
index 00000000..ee37ceda
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ClassObserver.java
@@ -0,0 +1,67 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Implement this interface if you're interested in changes to a ClassGen object
+ * and register yourself with addObserver().
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public interface ClassObserver {
+ public void notify(ClassGen clazz);
+}
+
diff --git a/src/java/org/apache/bcel/generic/CodeExceptionGen.java b/src/java/org/apache/bcel/generic/CodeExceptionGen.java
new file mode 100644
index 00000000..1f58b28d
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/CodeExceptionGen.java
@@ -0,0 +1,201 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import org.apache.bcel.classfile.*;
+
+/**
+ * This class represents an exception handler, i.e., specifies the region where
+ * a handler is active and an instruction where the actual handling is done.
+ * pool as parameters. Opposed to the JVM specification the end of the handled
+ * region is set to be inclusive, i.e. all instructions between start and end
+ * are protected including the start and end instructions (handles) themselves.
+ * The end of the region is automatically mapped to be exclusive when calling
+ * getCodeException(), i.e., there is no difference semantically.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see MethodGen
+ * @see CodeException
+ * @see InstructionHandle
+ */
+public final class CodeExceptionGen implements InstructionTargeter, Cloneable {
+ private InstructionHandle start_pc;
+ private InstructionHandle end_pc;
+ private InstructionHandle handler_pc;
+ private ObjectType catch_type;
+
+ /**
+ * Add an exception handler, i.e., specify region where a handler is active and an
+ * instruction where the actual handling is done.
+ *
+ * @param start_pc Start of handled region (inclusive)
+ * @param end_pc End of handled region (inclusive)
+ * @param handler_pc Where handling is done
+ * @param catch_type which exception is handled, null for ANY
+ */
+ public CodeExceptionGen(InstructionHandle start_pc, InstructionHandle end_pc,
+ InstructionHandle handler_pc, ObjectType catch_type) {
+ setStartPC(start_pc);
+ setEndPC(end_pc);
+ setHandlerPC(handler_pc);
+ this.catch_type = catch_type;
+ }
+
+ /**
+ * Get CodeException object.<BR>
+ *
+ * This relies on that the instruction list has already been dumped
+ * to byte code or or that the `setPositions' methods has been
+ * called for the instruction list.
+ *
+ * @param cp constant pool
+ */
+ public CodeException getCodeException(ConstantPoolGen cp) {
+ return new CodeException(start_pc.getPosition(),
+ end_pc.getPosition() + end_pc.getInstruction().getLength(),
+ handler_pc.getPosition(),
+ (catch_type == null)? 0 : cp.addClass(catch_type));
+ }
+
+ /* Set start of handler
+ * @param start_pc Start of handled region (inclusive)
+ */
+ public void setStartPC(InstructionHandle start_pc) {
+ BranchInstruction.notifyTarget(this.start_pc, start_pc, this);
+ this.start_pc = start_pc;
+ }
+
+ /* Set end of handler
+ * @param end_pc End of handled region (inclusive)
+ */
+ public void setEndPC(InstructionHandle end_pc) {
+ BranchInstruction.notifyTarget(this.end_pc, end_pc, this);
+ this.end_pc = end_pc;
+ }
+
+ /* Set handler code
+ * @param handler_pc Start of handler
+ */
+ public void setHandlerPC(InstructionHandle handler_pc) {
+ BranchInstruction.notifyTarget(this.handler_pc, handler_pc, this);
+ this.handler_pc = handler_pc;
+ }
+
+ /**
+ * @param old_ih old target, either start or end
+ * @param new_ih new target
+ */
+ public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) {
+ boolean targeted = false;
+
+ if(start_pc == old_ih) {
+ targeted = true;
+ setStartPC(new_ih);
+ }
+
+ if(end_pc == old_ih) {
+ targeted = true;
+ setEndPC(new_ih);
+ }
+
+ if(handler_pc == old_ih) {
+ targeted = true;
+ setHandlerPC(new_ih);
+ }
+
+ if(!targeted)
+ throw new ClassGenException("Not targeting " + old_ih + ", but {" + start_pc + ", " +
+ end_pc + ", " + handler_pc + "}");
+ }
+
+ /**
+ * @return true, if ih is target of this handler
+ */
+ public boolean containsTarget(InstructionHandle ih) {
+ return (start_pc == ih) || (end_pc == ih) || (handler_pc == ih);
+ }
+
+ /** Sets the type of the Exception to catch. Set 'null' for ANY. */
+ public void setCatchType(ObjectType catch_type) { this.catch_type = catch_type; }
+ /** Gets the type of the Exception to catch, 'null' for ANY. */
+ public ObjectType getCatchType() { return catch_type; }
+
+ /** @return start of handled region (inclusive)
+ */
+ public InstructionHandle getStartPC() { return start_pc; }
+
+ /** @return end of handled region (inclusive)
+ */
+ public InstructionHandle getEndPC() { return end_pc; }
+
+ /** @return start of handler
+ */
+ public InstructionHandle getHandlerPC() { return handler_pc; }
+
+ public String toString() {
+ return "CodeExceptionGen(" + start_pc + ", " + end_pc + ", " + handler_pc + ")";
+ }
+
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch(CloneNotSupportedException e) {
+ System.err.println(e);
+ return null;
+ }
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/CompoundInstruction.java b/src/java/org/apache/bcel/generic/CompoundInstruction.java
new file mode 100644
index 00000000..5198dc43
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/CompoundInstruction.java
@@ -0,0 +1,76 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Wrapper class for `compound' operations, virtual instructions that
+ * don't exist as byte code, but give a useful meaning. For example,
+ * the (virtual) PUSH instruction takes an arbitray argument and produces the
+ * appropiate code at dump time (ICONST, LDC, BIPUSH, ...). Also you can use the
+ * SWITCH instruction as a useful template for either LOOKUPSWITCH or
+ * TABLESWITCH.
+ *
+ * The interface provides the possibilty for the user to write
+ * `templates' or `macros' for such reuseable code patterns.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see PUSH
+ * @see SWITCH
+ */
+public interface CompoundInstruction {
+ public InstructionList getInstructionList();
+}
+
diff --git a/src/java/org/apache/bcel/generic/ConstantPoolGen.java b/src/java/org/apache/bcel/generic/ConstantPoolGen.java
new file mode 100644
index 00000000..54cf2bb1
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ConstantPoolGen.java
@@ -0,0 +1,782 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import org.apache.bcel.classfile.*;
+import java.util.HashMap;
+
+/**
+ * This class is used to build up a constant pool. The user adds
+ * constants via `addXXX' methods, `addString', `addClass',
+ * etc.. These methods return an index into the constant
+ * pool. Finally, `getFinalConstantPool()' returns the constant pool
+ * built up. Intermediate versions of the constant pool can be
+ * obtained with `getConstantPool()'. A constant pool has capacity for
+ * Constants.MAX_SHORT entries. Note that the first (0) is used by the
+ * JVM and that Double and Long constants need two slots.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Constant
+ */
+public class ConstantPoolGen {
+ protected int size = 1024; // Inital size, sufficient in most cases
+ protected Constant[] constants = new Constant[size];
+ protected int index = 1; // First entry (0) used by JVM
+
+ private static final String METHODREF_DELIM = ":";
+ private static final String IMETHODREF_DELIM = "#";
+ private static final String FIELDREF_DELIM = "&";
+ private static final String NAT_DELIM = "%";
+
+ private static class Index {
+ int index;
+ Index(int i) { index = i; }
+ }
+
+ /**
+ * Initialize with given array of constants.
+ *
+ * @param c array of given constants, new ones will be appended
+ */
+ public ConstantPoolGen(Constant[] cs) {
+ if(cs.length > size) {
+ size = cs.length;
+ constants = new Constant[size];
+ }
+
+ System.arraycopy(cs, 0, constants, 0, cs.length);
+
+ if(cs.length > 0)
+ index = cs.length;
+
+ for(int i=1; i < index; i++) {
+ Constant c = constants[i];
+
+ if(c instanceof ConstantString) {
+ ConstantString s = (ConstantString)c;
+ ConstantUtf8 u8 = (ConstantUtf8)constants[s.getStringIndex()];
+
+ string_table.put(u8.getBytes(), new Index(i));
+ } else if(c instanceof ConstantClass) {
+ ConstantClass s = (ConstantClass)c;
+ ConstantUtf8 u8 = (ConstantUtf8)constants[s.getNameIndex()];
+
+ class_table.put(u8.getBytes(), new Index(i));
+ } else if(c instanceof ConstantNameAndType) {
+ ConstantNameAndType n = (ConstantNameAndType)c;
+ ConstantUtf8 u8 = (ConstantUtf8)constants[n.getNameIndex()];
+ ConstantUtf8 u8_2 = (ConstantUtf8)constants[n.getSignatureIndex()];
+
+ n_a_t_table.put(u8.getBytes() + NAT_DELIM + u8_2.getBytes(), new Index(i));
+ } else if(c instanceof ConstantUtf8) {
+ ConstantUtf8 u = (ConstantUtf8)c;
+
+ utf8_table.put(u.getBytes(), new Index(i));
+ } else if(c instanceof ConstantCP) {
+ ConstantCP m = (ConstantCP)c;
+ ConstantClass clazz = (ConstantClass)constants[m.getClassIndex()];
+ ConstantNameAndType n = (ConstantNameAndType)constants[m.getNameAndTypeIndex()];
+
+ ConstantUtf8 u8 = (ConstantUtf8)constants[clazz.getNameIndex()];
+ String class_name = u8.getBytes().replace('/', '.');
+
+ u8 = (ConstantUtf8)constants[n.getNameIndex()];
+ String method_name = u8.getBytes();
+
+ u8 = (ConstantUtf8)constants[n.getSignatureIndex()];
+ String signature = u8.getBytes();
+
+ String delim = METHODREF_DELIM;
+
+ if(c instanceof ConstantInterfaceMethodref)
+ delim = IMETHODREF_DELIM;
+ else if(c instanceof ConstantFieldref)
+ delim = FIELDREF_DELIM;
+
+ cp_table.put(class_name + delim + method_name + delim + signature, new Index(i));
+ }
+ }
+ }
+
+ /**
+ * Initialize with given constant pool.
+ */
+ public ConstantPoolGen(ConstantPool cp) {
+ this(cp.getConstantPool());
+ }
+
+ /**
+ * Create empty constant pool.
+ */
+ public ConstantPoolGen() {}
+
+ /** Resize internal array of constants.
+ */
+ protected void adjustSize() {
+ if(index + 3 >= size) {
+ Constant[] cs = constants;
+
+ size *= 2;
+ constants = new Constant[size];
+ System.arraycopy(cs, 0, constants, 0, index);
+ }
+ }
+
+ private HashMap string_table = new HashMap();
+
+ /**
+ * Look for ConstantString in ConstantPool containing String `str'.
+ *
+ * @param str String to search for
+ * @return index on success, -1 otherwise
+ */
+ public int lookupString(String str) {
+ Index index = (Index)string_table.get(str);
+ return (index != null)? index.index : -1;
+ }
+
+ /**
+ * Add a new String constant to the ConstantPool, if it is not already in there.
+ *
+ * @param str String to add
+ * @return index of entry
+ */
+ public int addString(String str) {
+ int ret;
+
+ if((ret = lookupString(str)) != -1)
+ return ret; // Already in CP
+
+ adjustSize();
+
+ ConstantUtf8 u8 = new ConstantUtf8(str);
+ ConstantString s = new ConstantString(index);
+
+ constants[index++] = u8;
+ ret = index;
+ constants[index++] = s;
+
+ string_table.put(str, new Index(ret));
+
+ return ret;
+ }
+
+ private HashMap class_table = new HashMap();
+
+ /**
+ * Look for ConstantClass in ConstantPool named `str'.
+ *
+ * @param str String to search for
+ * @return index on success, -1 otherwise
+ */
+ public int lookupClass(String str) {
+ Index index = (Index)class_table.get(str.replace('.', '/'));
+ return (index != null)? index.index : -1;
+ }
+
+ private int addClass_(String clazz) {
+ int ret;
+
+ if((ret = lookupClass(clazz)) != -1)
+ return ret; // Already in CP
+
+ adjustSize();
+
+ ConstantClass c = new ConstantClass(addUtf8(clazz));
+
+ ret = index;
+ constants[index++] = c;
+
+ class_table.put(clazz, new Index(ret));
+
+ return ret;
+ }
+
+ /**
+ * Add a new Class reference to the ConstantPool, if it is not already in there.
+ *
+ * @param str Class to add
+ * @return index of entry
+ */
+ public int addClass(String str) {
+ return addClass_(str.replace('.', '/'));
+ }
+
+ /**
+ * Add a new Class reference to the ConstantPool for a given type.
+ *
+ * @param str Class to add
+ * @return index of entry
+ */
+ public int addClass(ObjectType type) {
+ return addClass(type.getClassName());
+ }
+
+ /**
+ * Add a reference to an array class (e.g. String[][]) as needed by MULTIANEWARRAY
+ * instruction, e.g. to the ConstantPool.
+ *
+ * @param type type of array class
+ * @return index of entry
+ */
+ public int addArrayClass(ArrayType type) {
+ return addClass_(type.getSignature());
+ }
+
+ /**
+ * Look for ConstantInteger in ConstantPool.
+ *
+ * @param n integer number to look for
+ * @return index on success, -1 otherwise
+ */
+ public int lookupInteger(int n) {
+ for(int i=1; i < index; i++) {
+ if(constants[i] instanceof ConstantInteger) {
+ ConstantInteger c = (ConstantInteger)constants[i];
+
+ if(c.getBytes() == n)
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ /**
+ * Add a new Integer constant to the ConstantPool, if it is not already in there.
+ *
+ * @param n integer number to add
+ * @return index of entry
+ */
+ public int addInteger(int n) {
+ int ret;
+
+ if((ret = lookupInteger(n)) != -1)
+ return ret; // Already in CP
+
+ adjustSize();
+
+ ret = index;
+ constants[index++] = new ConstantInteger(n);
+
+ return ret;
+ }
+
+ /**
+ * Look for ConstantFloat in ConstantPool.
+ *
+ * @param n Float number to look for
+ * @return index on success, -1 otherwise
+ */
+ public int lookupFloat(float n) {
+ for(int i=1; i < index; i++) {
+ if(constants[i] instanceof ConstantFloat) {
+ ConstantFloat c = (ConstantFloat)constants[i];
+
+ if(c.getBytes() == n)
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ /**
+ * Add a new Float constant to the ConstantPool, if it is not already in there.
+ *
+ * @param n Float number to add
+ * @return index of entry
+ */
+ public int addFloat(float n) {
+ int ret;
+
+ if((ret = lookupFloat(n)) != -1)
+ return ret; // Already in CP
+
+ adjustSize();
+
+ ret = index;
+ constants[index++] = new ConstantFloat(n);
+
+ return ret;
+ }
+
+ private HashMap utf8_table = new HashMap();
+
+ /**
+ * Look for ConstantUtf8 in ConstantPool.
+ *
+ * @param n Utf8 string to look for
+ * @return index on success, -1 otherwise
+ */
+ public int lookupUtf8(String n) {
+ Index index = (Index)utf8_table.get(n);
+
+ return (index != null)? index.index : -1;
+ }
+
+ /**
+ * Add a new Utf8 constant to the ConstantPool, if it is not already in there.
+ *
+ * @param n Utf8 string to add
+ * @return index of entry
+ */
+ public int addUtf8(String n) {
+ int ret;
+
+ if((ret = lookupUtf8(n)) != -1)
+ return ret; // Already in CP
+
+ adjustSize();
+
+ ret = index;
+ constants[index++] = new ConstantUtf8(n);
+
+ utf8_table.put(n, new Index(ret));
+
+ return ret;
+ }
+
+ /**
+ * Look for ConstantLong in ConstantPool.
+ *
+ * @param n Long number to look for
+ * @return index on success, -1 otherwise
+ */
+ public int lookupLong(long n) {
+ for(int i=1; i < index; i++) {
+ if(constants[i] instanceof ConstantLong) {
+ ConstantLong c = (ConstantLong)constants[i];
+
+ if(c.getBytes() == n)
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ /**
+ * Add a new long constant to the ConstantPool, if it is not already in there.
+ *
+ * @param n Long number to add
+ * @return index of entry
+ */
+ public int addLong(long n) {
+ int ret;
+
+ if((ret = lookupLong(n)) != -1)
+ return ret; // Already in CP
+
+ adjustSize();
+
+ ret = index;
+ constants[index] = new ConstantLong(n);
+ index += 2; // Wastes one entry according to spec
+
+ return ret;
+ }
+
+ /**
+ * Look for ConstantDouble in ConstantPool.
+ *
+ * @param n Double number to look for
+ * @return index on success, -1 otherwise
+ */
+ public int lookupDouble(double n) {
+ for(int i=1; i < index; i++) {
+ if(constants[i] instanceof ConstantDouble) {
+ ConstantDouble c = (ConstantDouble)constants[i];
+
+ if(c.getBytes() == n)
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ /**
+ * Add a new double constant to the ConstantPool, if it is not already in there.
+ *
+ * @param n Double number to add
+ * @return index of entry
+ */
+ public int addDouble(double n) {
+ int ret;
+
+ if((ret = lookupDouble(n)) != -1)
+ return ret; // Already in CP
+
+ adjustSize();
+
+ ret = index;
+ constants[index] = new ConstantDouble(n);
+ index += 2; // Wastes one entry according to spec
+
+ return ret;
+ }
+
+ private HashMap n_a_t_table = new HashMap();
+
+ /**
+ * Look for ConstantNameAndType in ConstantPool.
+ *
+ * @param name of variable/method
+ * @param signature of variable/method
+ * @return index on success, -1 otherwise
+ */
+ public int lookupNameAndType(String name, String signature) {
+ Index index = (Index)n_a_t_table.get(name + NAT_DELIM + signature);
+ return (index != null)? index.index : -1;
+ }
+
+ /**
+ * Add a new NameAndType constant to the ConstantPool if it is not already
+ * in there.
+ *
+ * @param n NameAndType string to add
+ * @return index of entry
+ */
+ public int addNameAndType(String name, String signature) {
+ int ret;
+ int name_index, signature_index;
+
+ if((ret = lookupNameAndType(name, signature)) != -1)
+ return ret; // Already in CP
+
+ adjustSize();
+
+ name_index = addUtf8(name);
+ signature_index = addUtf8(signature);
+ ret = index;
+ constants[index++] = new ConstantNameAndType(name_index, signature_index);
+
+ n_a_t_table.put(name + NAT_DELIM + signature, new Index(ret));
+ return ret;
+ }
+
+ private HashMap cp_table = new HashMap();
+
+ /**
+ * Look for ConstantMethodref in ConstantPool.
+ *
+ * @param class_name Where to find method
+ * @param method_name Guess what
+ * @param signature return and argument types
+ * @return index on success, -1 otherwise
+ */
+ public int lookupMethodref(String class_name, String method_name, String signature) {
+ Index index = (Index)cp_table.get(class_name + METHODREF_DELIM + method_name +
+ METHODREF_DELIM + signature);
+ return (index != null)? index.index : -1;
+ }
+
+ public int lookupMethodref(MethodGen method) {
+ return lookupMethodref(method.getClassName(), method.getName(),
+ method.getSignature());
+ }
+
+ /**
+ * Add a new Methodref constant to the ConstantPool, if it is not already
+ * in there.
+ *
+ * @param n Methodref string to add
+ * @return index of entry
+ */
+ public int addMethodref(String class_name, String method_name, String signature) {
+ int ret, class_index, name_and_type_index;
+
+ if((ret = lookupMethodref(class_name, method_name, signature)) != -1)
+ return ret; // Already in CP
+
+ adjustSize();
+
+ name_and_type_index = addNameAndType(method_name, signature);
+ class_index = addClass(class_name);
+ ret = index;
+ constants[index++] = new ConstantMethodref(class_index, name_and_type_index);
+
+ cp_table.put(class_name + METHODREF_DELIM + method_name +
+ METHODREF_DELIM + signature, new Index(ret));
+
+ return ret;
+ }
+
+ public int addMethodref(MethodGen method) {
+ return addMethodref(method.getClassName(), method.getName(),
+ method.getSignature());
+ }
+
+ /**
+ * Look for ConstantInterfaceMethodref in ConstantPool.
+ *
+ * @param class_name Where to find method
+ * @param method_name Guess what
+ * @param signature return and argument types
+ * @return index on success, -1 otherwise
+ */
+ public int lookupInterfaceMethodref(String class_name, String method_name, String signature) {
+ Index index = (Index)cp_table.get(class_name + IMETHODREF_DELIM + method_name +
+ IMETHODREF_DELIM + signature);
+ return (index != null)? index.index : -1;
+ }
+
+ public int lookupInterfaceMethodref(MethodGen method) {
+ return lookupInterfaceMethodref(method.getClassName(), method.getName(),
+ method.getSignature());
+ }
+
+ /**
+ * Add a new InterfaceMethodref constant to the ConstantPool, if it is not already
+ * in there.
+ *
+ * @param n InterfaceMethodref string to add
+ * @return index of entry
+ */
+ public int addInterfaceMethodref(String class_name, String method_name, String signature) {
+ int ret, class_index, name_and_type_index;
+
+ if((ret = lookupInterfaceMethodref(class_name, method_name, signature)) != -1)
+ return ret; // Already in CP
+
+ adjustSize();
+
+ class_index = addClass(class_name);
+ name_and_type_index = addNameAndType(method_name, signature);
+ ret = index;
+ constants[index++] = new ConstantInterfaceMethodref(class_index, name_and_type_index);
+
+ cp_table.put(class_name + IMETHODREF_DELIM + method_name +
+ IMETHODREF_DELIM + signature, new Index(ret));
+
+ return ret;
+ }
+
+ public int addInterfaceMethodref(MethodGen method) {
+ return addInterfaceMethodref(method.getClassName(), method.getName(),
+ method.getSignature());
+ }
+
+ /**
+ * Look for ConstantFieldref in ConstantPool.
+ *
+ * @param class_name Where to find method
+ * @param field_name Guess what
+ * @param signature return and argument types
+ * @return index on success, -1 otherwise
+ */
+ public int lookupFieldref(String class_name, String field_name, String signature) {
+ Index index = (Index)cp_table.get(class_name + FIELDREF_DELIM + field_name +
+ FIELDREF_DELIM + signature);
+ return (index != null)? index.index : -1;
+ }
+
+ /**
+ * Add a new Fieldref constant to the ConstantPool, if it is not already
+ * in there.
+ *
+ * @param n Fieldref string to add
+ * @return index of entry
+ */
+ public int addFieldref(String class_name, String field_name, String signature) {
+ int ret;
+ int class_index, name_and_type_index;
+
+ if((ret = lookupFieldref(class_name, field_name, signature)) != -1)
+ return ret; // Already in CP
+
+ adjustSize();
+
+ class_index = addClass(class_name);
+ name_and_type_index = addNameAndType(field_name, signature);
+ ret = index;
+ constants[index++] = new ConstantFieldref(class_index, name_and_type_index);
+
+ cp_table.put(class_name + FIELDREF_DELIM + field_name + FIELDREF_DELIM + signature, new Index(ret));
+
+ return ret;
+ }
+
+ /**
+ * @param i index in constant pool
+ * @return constant pool entry at index i
+ */
+ public Constant getConstant(int i) { return constants[i]; }
+
+ /**
+ * Use with care!
+ *
+ * @param i index in constant pool
+ * @param c new constant pool entry at index i
+ */
+ public void setConstant(int i, Constant c) { constants[i] = c; }
+
+ /**
+ * @return intermediate constant pool
+ */
+ public ConstantPool getConstantPool() {
+ return new ConstantPool(constants);
+ }
+
+ /**
+ * @return current size of constant pool
+ */
+ public int getSize() {
+ return index;
+ }
+
+ /**
+ * @return constant pool with proper length
+ */
+ public ConstantPool getFinalConstantPool() {
+ Constant[] cs = new Constant[index];
+
+ System.arraycopy(constants, 0, cs, 0, index);
+
+ return new ConstantPool(cs);
+ }
+
+ /**
+ * @return String representation.
+ */
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+
+ for(int i=1; i < index; i++)
+ buf.append(i + ")" + constants[i] + "\n");
+
+ return buf.toString();
+ }
+
+ /** Import constant from another ConstantPool and return new index.
+ */
+ public int addConstant(Constant c, ConstantPoolGen cp) {
+ Constant[] constants = cp.getConstantPool().getConstantPool();
+
+ switch(c.getTag()) {
+ case Constants.CONSTANT_String: {
+ ConstantString s = (ConstantString)c;
+ ConstantUtf8 u8 = (ConstantUtf8)constants[s.getStringIndex()];
+
+ return addString(u8.getBytes());
+ }
+
+ case Constants.CONSTANT_Class: {
+ ConstantClass s = (ConstantClass)c;
+ ConstantUtf8 u8 = (ConstantUtf8)constants[s.getNameIndex()];
+
+ return addClass(u8.getBytes());
+ }
+
+ case Constants.CONSTANT_NameAndType: {
+ ConstantNameAndType n = (ConstantNameAndType)c;
+ ConstantUtf8 u8 = (ConstantUtf8)constants[n.getNameIndex()];
+ ConstantUtf8 u8_2 = (ConstantUtf8)constants[n.getSignatureIndex()];
+
+ return addNameAndType(u8.getBytes(), u8_2.getBytes());
+ }
+
+ case Constants.CONSTANT_Utf8:
+ return addUtf8(((ConstantUtf8)c).getBytes());
+
+ case Constants.CONSTANT_Double:
+ return addDouble(((ConstantDouble)c).getBytes());
+
+ case Constants.CONSTANT_Float:
+ return addFloat(((ConstantFloat)c).getBytes());
+
+ case Constants.CONSTANT_Long:
+ return addLong(((ConstantLong)c).getBytes());
+
+ case Constants.CONSTANT_Integer:
+ return addInteger(((ConstantInteger)c).getBytes());
+
+ case Constants.CONSTANT_InterfaceMethodref: case Constants.CONSTANT_Methodref:
+ case Constants.CONSTANT_Fieldref: {
+ ConstantCP m = (ConstantCP)c;
+ ConstantClass clazz = (ConstantClass)constants[m.getClassIndex()];
+ ConstantNameAndType n = (ConstantNameAndType)constants[m.getNameAndTypeIndex()];
+ ConstantUtf8 u8 = (ConstantUtf8)constants[clazz.getNameIndex()];
+ String class_name = u8.getBytes().replace('/', '.');
+
+ u8 = (ConstantUtf8)constants[n.getNameIndex()];
+ String name = u8.getBytes();
+
+ u8 = (ConstantUtf8)constants[n.getSignatureIndex()];
+ String signature = u8.getBytes();
+
+ switch(c.getTag()) {
+ case Constants.CONSTANT_InterfaceMethodref:
+ return addInterfaceMethodref(class_name, name, signature);
+
+ case Constants.CONSTANT_Methodref:
+ return addMethodref(class_name, name, signature);
+
+ case Constants.CONSTANT_Fieldref:
+ return addFieldref(class_name, name, signature);
+
+ default: // Never reached
+ throw new RuntimeException("Unknown constant type " + c);
+ }
+ }
+
+ default: // Never reached
+ throw new RuntimeException("Unknown constant type " + c);
+ }
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/ConstantPushInstruction.java b/src/java/org/apache/bcel/generic/ConstantPushInstruction.java
new file mode 100644
index 00000000..95886618
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ConstantPushInstruction.java
@@ -0,0 +1,70 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Denotes a push instruction that produces a literal on the stack
+ * such as SIPUSH, BIPUSH, ICONST, etc.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+
+ * @see ICONST
+ * @see SIPUSH
+ */
+public interface ConstantPushInstruction extends PushInstruction, TypedInstruction {
+ public Number getValue();
+}
+
diff --git a/src/java/org/apache/bcel/generic/ConversionInstruction.java b/src/java/org/apache/bcel/generic/ConversionInstruction.java
new file mode 100644
index 00000000..8aba47a0
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ConversionInstruction.java
@@ -0,0 +1,102 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import org.apache.bcel.Constants;
+/**
+ * Super class for the x2y family of instructions.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public abstract class ConversionInstruction extends Instruction
+ implements TypedInstruction, StackProducer, StackConsumer {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ ConversionInstruction() {}
+
+ /**
+ * @param opcode opcode of instruction
+ */
+ protected ConversionInstruction(short opcode) {
+ super(opcode, (short)1);
+ }
+
+ /** @return type associated with the instruction
+ */
+ public Type getType(ConstantPoolGen cp) {
+ switch(opcode) {
+ case Constants.D2I: case Constants.F2I: case Constants.L2I:
+ return Type.INT;
+ case Constants.D2F: case Constants.I2F: case Constants.L2F:
+ return Type.FLOAT;
+ case Constants.D2L: case Constants.F2L: case Constants.I2L:
+ return Type.LONG;
+ case Constants.F2D: case Constants.I2D: case Constants.L2D:
+ return Type.DOUBLE;
+ case Constants.I2B:
+ return Type.BYTE;
+ case Constants.I2C:
+ return Type.CHAR;
+ case Constants.I2S:
+ return Type.SHORT;
+
+ default: // Never reached
+ throw new ClassGenException("Unknown type " + opcode);
+ }
+ }
+}
+
diff --git a/src/java/org/apache/bcel/generic/D2F.java b/src/java/org/apache/bcel/generic/D2F.java
new file mode 100644
index 00000000..63c5714c
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/D2F.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * D2F - Convert double to float
+ * <PRE>Stack: ..., value.word1, value.word2 -&gt; ..., result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class D2F extends ConversionInstruction {
+ /** Convert double to float
+ */
+ public D2F() {
+ super(org.apache.bcel.Constants.D2F);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitConversionInstruction(this);
+ v.visitD2F(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/D2I.java b/src/java/org/apache/bcel/generic/D2I.java
new file mode 100644
index 00000000..cf8e29b6
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/D2I.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * D2I - Convert double to int
+ * <PRE>Stack: ..., value.word1, value.word2 -&gt; ..., result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class D2I extends ConversionInstruction {
+ /** Convert double to int
+ */
+ public D2I() {
+ super(org.apache.bcel.Constants.D2I);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitConversionInstruction(this);
+ v.visitD2I(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/D2L.java b/src/java/org/apache/bcel/generic/D2L.java
new file mode 100644
index 00000000..1de3431f
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/D2L.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * D2L - Convert double to long
+ * <PRE>Stack: ..., value.word1, value.word2 -&gt; ..., result.word1, result.word2</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class D2L extends ConversionInstruction {
+ /** Convert double to long
+ */
+ public D2L() {
+ super(org.apache.bcel.Constants.D2L);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitConversionInstruction(this);
+ v.visitD2L(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/DADD.java b/src/java/org/apache/bcel/generic/DADD.java
new file mode 100644
index 00000000..6caefba5
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/DADD.java
@@ -0,0 +1,88 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * DADD - Add doubles
+ * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;</PRE>
+ * ..., result.word1, result1.word2
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class DADD extends ArithmeticInstruction {
+ /** Add doubles
+ */
+ public DADD() {
+ super(org.apache.bcel.Constants.DADD);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitDADD(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/DALOAD.java b/src/java/org/apache/bcel/generic/DALOAD.java
new file mode 100644
index 00000000..21605003
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/DALOAD.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * DALOAD - Load double from array
+ * <PRE>Stack: ..., arrayref, index -&gt; ..., result.word1, result.word2</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class DALOAD extends ArrayInstruction implements StackProducer {
+ /** Load double from array
+ */
+ public DALOAD() {
+ super(org.apache.bcel.Constants.DALOAD);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackProducer(this);
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitArrayInstruction(this);
+ v.visitDALOAD(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/DASTORE.java b/src/java/org/apache/bcel/generic/DASTORE.java
new file mode 100644
index 00000000..afba81cf
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/DASTORE.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * DASTORE - Store into double array
+ * <PRE>Stack: ..., arrayref, index, value.word1, value.word2 -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class DASTORE extends ArrayInstruction implements StackConsumer {
+ /** Store double into array
+ */
+ public DASTORE() {
+ super(org.apache.bcel.Constants.DASTORE);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitArrayInstruction(this);
+ v.visitDASTORE(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/DCMPG.java b/src/java/org/apache/bcel/generic/DCMPG.java
new file mode 100644
index 00000000..ac4bbc2b
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/DCMPG.java
@@ -0,0 +1,93 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * DCMPG - Compare doubles: value1 > value2
+ * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;</PRE>
+ * ..., result
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class DCMPG extends Instruction
+ implements TypedInstruction, StackProducer, StackConsumer {
+
+ public DCMPG() {
+ super(org.apache.bcel.Constants.DCMPG, (short)1);
+ }
+
+ /** @return Type.DOUBLE
+ */
+ public Type getType(ConstantPoolGen cp) {
+ return Type.DOUBLE;
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitDCMPG(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/DCMPL.java b/src/java/org/apache/bcel/generic/DCMPL.java
new file mode 100644
index 00000000..c64a8e27
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/DCMPL.java
@@ -0,0 +1,92 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * DCMPL - Compare doubles: value1 < value2
+ * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;</PRE>
+ * ..., result
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class DCMPL extends Instruction
+ implements TypedInstruction, StackProducer, StackConsumer {
+ public DCMPL() {
+ super(org.apache.bcel.Constants.DCMPL, (short)1);
+ }
+
+ /** @return Type.DOUBLE
+ */
+ public Type getType(ConstantPoolGen cp) {
+ return Type.DOUBLE;
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitDCMPL(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/DCONST.java b/src/java/org/apache/bcel/generic/DCONST.java
new file mode 100644
index 00000000..7f07a270
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/DCONST.java
@@ -0,0 +1,112 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * DCONST - Push 0.0 or 1.0, other values cause an exception
+ *
+ * <PRE>Stack: ... -&gt; ..., <i></PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class DCONST extends Instruction
+ implements ConstantPushInstruction, TypedInstruction {
+ private double value;
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ DCONST() {}
+
+ public DCONST(double f) {
+ super(org.apache.bcel.Constants.DCONST_0, (short)1);
+
+ if(f == 0.0)
+ opcode = org.apache.bcel.Constants.DCONST_0;
+ else if(f == 1.0)
+ opcode = org.apache.bcel.Constants.DCONST_1;
+ else
+ throw new ClassGenException("DCONST can be used only for 0.0 and 1.0: " + f);
+
+ value = f;
+ }
+
+ public Number getValue() { return new Double(value); }
+
+ /** @return Type.DOUBLE
+ */
+ public Type getType(ConstantPoolGen cp) {
+ return Type.DOUBLE;
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitPushInstruction(this);
+ v.visitStackProducer(this);
+ v.visitTypedInstruction(this);
+ v.visitConstantPushInstruction(this);
+ v.visitDCONST(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/DDIV.java b/src/java/org/apache/bcel/generic/DDIV.java
new file mode 100644
index 00000000..3eec9167
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/DDIV.java
@@ -0,0 +1,88 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * DDIV - Divide doubles
+ * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;</PRE>
+ * ..., result.word1, result.word2
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class DDIV extends ArithmeticInstruction {
+ /** Divide doubles
+ */
+ public DDIV() {
+ super(org.apache.bcel.Constants.DDIV);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitDDIV(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/DLOAD.java b/src/java/org/apache/bcel/generic/DLOAD.java
new file mode 100644
index 00000000..8533c08c
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/DLOAD.java
@@ -0,0 +1,92 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * DLOAD - Load double from local variable
+ * <PRE>Stack ... -&gt; ..., result.word1, result.word2</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class DLOAD extends LoadInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ DLOAD() {
+ super(org.apache.bcel.Constants.DLOAD, org.apache.bcel.Constants.DLOAD_0);
+ }
+
+ /** Load double from local variable
+ * @param n index of local variable
+ */
+ public DLOAD(int n) {
+ super(org.apache.bcel.Constants.DLOAD, org.apache.bcel.Constants.DLOAD_0, n);
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ super.accept(v);
+ v.visitDLOAD(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/DMUL.java b/src/java/org/apache/bcel/generic/DMUL.java
new file mode 100644
index 00000000..d070a7f9
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/DMUL.java
@@ -0,0 +1,88 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * DMUL - Multiply doubles
+ * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;</PRE>
+ * ..., result.word1, result.word2
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class DMUL extends ArithmeticInstruction {
+ /** Multiply doubles
+ */
+ public DMUL() {
+ super(org.apache.bcel.Constants.DMUL);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitDMUL(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/DNEG.java b/src/java/org/apache/bcel/generic/DNEG.java
new file mode 100644
index 00000000..c0911463
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/DNEG.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * DNEG - Negate double
+ * <PRE>Stack: ..., value.word1, value.word2 -&gt; ..., result.word1, result.word2</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class DNEG extends ArithmeticInstruction {
+ public DNEG() {
+ super(org.apache.bcel.Constants.DNEG);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitDNEG(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/DREM.java b/src/java/org/apache/bcel/generic/DREM.java
new file mode 100644
index 00000000..e32e9add
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/DREM.java
@@ -0,0 +1,88 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * DREM - Remainder of doubles
+ * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;</PRE>
+ * ..., result.word1, result.word2
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class DREM extends ArithmeticInstruction {
+ /** Remainder of doubles
+ */
+ public DREM() {
+ super(org.apache.bcel.Constants.DREM);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitDREM(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/DRETURN.java b/src/java/org/apache/bcel/generic/DRETURN.java
new file mode 100644
index 00000000..3acae91d
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/DRETURN.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * DRETURN - Return double from method
+ * <PRE>Stack: ..., value.word1, value.word2 -&gt; &lt;empty&gt;</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class DRETURN extends ReturnInstruction {
+ /** Return double from method
+ */
+ public DRETURN() {
+ super(org.apache.bcel.Constants.DRETURN);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitStackConsumer(this);
+ v.visitReturnInstruction(this);
+ v.visitDRETURN(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/DSTORE.java b/src/java/org/apache/bcel/generic/DSTORE.java
new file mode 100644
index 00000000..d087afdd
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/DSTORE.java
@@ -0,0 +1,92 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * DSTORE - Store double into local variable
+ * <pre>Stack: ..., value.word1, value.word2 -&gt; ... </PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class DSTORE extends StoreInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ DSTORE() {
+ super(org.apache.bcel.Constants.DSTORE, org.apache.bcel.Constants.DSTORE_0);
+ }
+
+ /** Store double into local variable
+ * @param n index of local variable
+ */
+ public DSTORE(int n) {
+ super(org.apache.bcel.Constants.DSTORE, org.apache.bcel.Constants.DSTORE_0, n);
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ super.accept(v);
+ v.visitDSTORE(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/DSUB.java b/src/java/org/apache/bcel/generic/DSUB.java
new file mode 100644
index 00000000..96471865
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/DSUB.java
@@ -0,0 +1,88 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * DSUB - Substract doubles
+ * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;</PRE>
+ * ..., result.word1, result.word2
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class DSUB extends ArithmeticInstruction {
+ /** Substract doubles
+ */
+ public DSUB() {
+ super(org.apache.bcel.Constants.DSUB);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitDSUB(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/DUP.java b/src/java/org/apache/bcel/generic/DUP.java
new file mode 100644
index 00000000..d77acdc5
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/DUP.java
@@ -0,0 +1,84 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * DUP - Duplicate top operand stack word
+ * <PRE>Stack: ..., word -&gt; ..., word, word</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class DUP extends StackInstruction implements PushInstruction {
+ public DUP() {
+ super(org.apache.bcel.Constants.DUP);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackProducer(this);
+ v.visitPushInstruction(this);
+ v.visitStackInstruction(this);
+ v.visitDUP(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/DUP2.java b/src/java/org/apache/bcel/generic/DUP2.java
new file mode 100644
index 00000000..aae4be13
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/DUP2.java
@@ -0,0 +1,84 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * DUP2 - Duplicate two top operand stack words
+ * <PRE>Stack: ..., word2, word1 -&gt; ..., word2, word1, word2, word1</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class DUP2 extends StackInstruction implements PushInstruction {
+ public DUP2() {
+ super(org.apache.bcel.Constants.DUP2);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackProducer(this);
+ v.visitPushInstruction(this);
+ v.visitStackInstruction(this);
+ v.visitDUP2(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/DUP2_X1.java b/src/java/org/apache/bcel/generic/DUP2_X1.java
new file mode 100644
index 00000000..38eccc1d
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/DUP2_X1.java
@@ -0,0 +1,82 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * DUP2_X1 - Duplicate two top operand stack words and put three down
+ * <PRE>Stack: ..., word3, word2, word1 -&gt; ..., word2, word1, word3, word2, word1</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class DUP2_X1 extends StackInstruction {
+ public DUP2_X1() {
+ super(org.apache.bcel.Constants.DUP2_X1);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackInstruction(this);
+ v.visitDUP2_X1(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/DUP2_X2.java b/src/java/org/apache/bcel/generic/DUP2_X2.java
new file mode 100644
index 00000000..f68c22e8
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/DUP2_X2.java
@@ -0,0 +1,82 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * DUP2_X2 - Duplicate two top operand stack words and put four down
+ * <PRE>Stack: ..., word4, word3, word2, word1 -&gt; ..., word2, word1, word4, word3, word2, word1</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class DUP2_X2 extends StackInstruction {
+ public DUP2_X2() {
+ super(org.apache.bcel.Constants.DUP2_X2);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackInstruction(this);
+ v.visitDUP2_X2(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/DUP_X1.java b/src/java/org/apache/bcel/generic/DUP_X1.java
new file mode 100644
index 00000000..1c8bdb64
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/DUP_X1.java
@@ -0,0 +1,82 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * DUP_X1 - Duplicate top operand stack word and put two down
+ * <PRE>Stack: ..., word2, word1 -&gt; ..., word1, word2, word1</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class DUP_X1 extends StackInstruction {
+ public DUP_X1() {
+ super(org.apache.bcel.Constants.DUP_X1);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackInstruction(this);
+ v.visitDUP_X1(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/DUP_X2.java b/src/java/org/apache/bcel/generic/DUP_X2.java
new file mode 100644
index 00000000..fd0b8bdd
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/DUP_X2.java
@@ -0,0 +1,82 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * DUP_X2 - Duplicate top operand stack word and put three down
+ * <PRE>Stack: ..., word3, word2, word1 -&gt; ..., word1, word3, word2, word1</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class DUP_X2 extends StackInstruction {
+ public DUP_X2() {
+ super(org.apache.bcel.Constants.DUP_X2);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackInstruction(this);
+ v.visitDUP_X2(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/EmptyVisitor.java b/src/java/org/apache/bcel/generic/EmptyVisitor.java
new file mode 100644
index 00000000..fdaf5270
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/EmptyVisitor.java
@@ -0,0 +1,244 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Supplies empty method bodies to be overridden by subclasses.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public abstract class EmptyVisitor implements Visitor {
+ public void visitStackInstruction(StackInstruction obj) { }
+ public void visitLocalVariableInstruction(LocalVariableInstruction obj) { }
+ public void visitBranchInstruction(BranchInstruction obj) { }
+ public void visitLoadClass(LoadClass obj) { }
+ public void visitFieldInstruction(FieldInstruction obj) { }
+ public void visitIfInstruction(IfInstruction obj) { }
+ public void visitConversionInstruction(ConversionInstruction obj) { }
+ public void visitPopInstruction(PopInstruction obj) { }
+ public void visitJsrInstruction(JsrInstruction obj) { }
+ public void visitGotoInstruction(GotoInstruction obj) { }
+ public void visitStoreInstruction(StoreInstruction obj) { }
+ public void visitTypedInstruction(TypedInstruction obj) { }
+ public void visitSelect(Select obj) { }
+ public void visitUnconditionalBranch(UnconditionalBranch obj) { }
+ public void visitPushInstruction(PushInstruction obj) { }
+ public void visitArithmeticInstruction(ArithmeticInstruction obj) { }
+ public void visitCPInstruction(CPInstruction obj) { }
+ public void visitInvokeInstruction(InvokeInstruction obj) { }
+ public void visitArrayInstruction(ArrayInstruction obj) { }
+ public void visitAllocationInstruction(AllocationInstruction obj) { }
+ public void visitReturnInstruction(ReturnInstruction obj) { }
+ public void visitFieldOrMethod(FieldOrMethod obj) { }
+ public void visitConstantPushInstruction(ConstantPushInstruction obj) { }
+ public void visitExceptionThrower(ExceptionThrower obj) { }
+ public void visitLoadInstruction(LoadInstruction obj) { }
+ public void visitVariableLengthInstruction(VariableLengthInstruction obj) { }
+ public void visitStackProducer(StackProducer obj) { }
+ public void visitStackConsumer(StackConsumer obj) { }
+ public void visitACONST_NULL(ACONST_NULL obj) { }
+ public void visitGETSTATIC(GETSTATIC obj) { }
+ public void visitIF_ICMPLT(IF_ICMPLT obj) { }
+ public void visitMONITOREXIT(MONITOREXIT obj) { }
+ public void visitIFLT(IFLT obj) { }
+ public void visitLSTORE(LSTORE obj) { }
+ public void visitPOP2(POP2 obj) { }
+ public void visitBASTORE(BASTORE obj) { }
+ public void visitISTORE(ISTORE obj) { }
+ public void visitCHECKCAST(CHECKCAST obj) { }
+ public void visitFCMPG(FCMPG obj) { }
+ public void visitI2F(I2F obj) { }
+ public void visitATHROW(ATHROW obj) { }
+ public void visitDCMPL(DCMPL obj) { }
+ public void visitARRAYLENGTH(ARRAYLENGTH obj) { }
+ public void visitDUP(DUP obj) { }
+ public void visitINVOKESTATIC(INVOKESTATIC obj) { }
+ public void visitLCONST(LCONST obj) { }
+ public void visitDREM(DREM obj) { }
+ public void visitIFGE(IFGE obj) { }
+ public void visitCALOAD(CALOAD obj) { }
+ public void visitLASTORE(LASTORE obj) { }
+ public void visitI2D(I2D obj) { }
+ public void visitDADD(DADD obj) { }
+ public void visitINVOKESPECIAL(INVOKESPECIAL obj) { }
+ public void visitIAND(IAND obj) { }
+ public void visitPUTFIELD(PUTFIELD obj) { }
+ public void visitILOAD(ILOAD obj) { }
+ public void visitDLOAD(DLOAD obj) { }
+ public void visitDCONST(DCONST obj) { }
+ public void visitNEW(NEW obj) { }
+ public void visitIFNULL(IFNULL obj) { }
+ public void visitLSUB(LSUB obj) { }
+ public void visitL2I(L2I obj) { }
+ public void visitISHR(ISHR obj) { }
+ public void visitTABLESWITCH(TABLESWITCH obj) { }
+ public void visitIINC(IINC obj) { }
+ public void visitDRETURN(DRETURN obj) { }
+ public void visitFSTORE(FSTORE obj) { }
+ public void visitDASTORE(DASTORE obj) { }
+ public void visitIALOAD(IALOAD obj) { }
+ public void visitDDIV(DDIV obj) { }
+ public void visitIF_ICMPGE(IF_ICMPGE obj) { }
+ public void visitLAND(LAND obj) { }
+ public void visitIDIV(IDIV obj) { }
+ public void visitLOR(LOR obj) { }
+ public void visitCASTORE(CASTORE obj) { }
+ public void visitFREM(FREM obj) { }
+ public void visitLDC(LDC obj) { }
+ public void visitBIPUSH(BIPUSH obj) { }
+ public void visitDSTORE(DSTORE obj) { }
+ public void visitF2L(F2L obj) { }
+ public void visitFMUL(FMUL obj) { }
+ public void visitLLOAD(LLOAD obj) { }
+ public void visitJSR(JSR obj) { }
+ public void visitFSUB(FSUB obj) { }
+ public void visitSASTORE(SASTORE obj) { }
+ public void visitALOAD(ALOAD obj) { }
+ public void visitDUP2_X2(DUP2_X2 obj) { }
+ public void visitRETURN(RETURN obj) { }
+ public void visitDALOAD(DALOAD obj) { }
+ public void visitSIPUSH(SIPUSH obj) { }
+ public void visitDSUB(DSUB obj) { }
+ public void visitL2F(L2F obj) { }
+ public void visitIF_ICMPGT(IF_ICMPGT obj) { }
+ public void visitF2D(F2D obj) { }
+ public void visitI2L(I2L obj) { }
+ public void visitIF_ACMPNE(IF_ACMPNE obj) { }
+ public void visitPOP(POP obj) { }
+ public void visitI2S(I2S obj) { }
+ public void visitIFEQ(IFEQ obj) { }
+ public void visitSWAP(SWAP obj) { }
+ public void visitIOR(IOR obj) { }
+ public void visitIREM(IREM obj) { }
+ public void visitIASTORE(IASTORE obj) { }
+ public void visitNEWARRAY(NEWARRAY obj) { }
+ public void visitINVOKEINTERFACE(INVOKEINTERFACE obj) { }
+ public void visitINEG(INEG obj) { }
+ public void visitLCMP(LCMP obj) { }
+ public void visitJSR_W(JSR_W obj) { }
+ public void visitMULTIANEWARRAY(MULTIANEWARRAY obj) { }
+ public void visitDUP_X2(DUP_X2 obj) { }
+ public void visitSALOAD(SALOAD obj) { }
+ public void visitIFNONNULL(IFNONNULL obj) { }
+ public void visitDMUL(DMUL obj) { }
+ public void visitIFNE(IFNE obj) { }
+ public void visitIF_ICMPLE(IF_ICMPLE obj) { }
+ public void visitLDC2_W(LDC2_W obj) { }
+ public void visitGETFIELD(GETFIELD obj) { }
+ public void visitLADD(LADD obj) { }
+ public void visitNOP(NOP obj) { }
+ public void visitFALOAD(FALOAD obj) { }
+ public void visitINSTANCEOF(INSTANCEOF obj) { }
+ public void visitIFLE(IFLE obj) { }
+ public void visitLXOR(LXOR obj) { }
+ public void visitLRETURN(LRETURN obj) { }
+ public void visitFCONST(FCONST obj) { }
+ public void visitIUSHR(IUSHR obj) { }
+ public void visitBALOAD(BALOAD obj) { }
+ public void visitDUP2(DUP2 obj) { }
+ public void visitIF_ACMPEQ(IF_ACMPEQ obj) { }
+ public void visitIMPDEP1(IMPDEP1 obj) { }
+ public void visitMONITORENTER(MONITORENTER obj) { }
+ public void visitLSHL(LSHL obj) { }
+ public void visitDCMPG(DCMPG obj) { }
+ public void visitD2L(D2L obj) { }
+ public void visitIMPDEP2(IMPDEP2 obj) { }
+ public void visitL2D(L2D obj) { }
+ public void visitRET(RET obj) { }
+ public void visitIFGT(IFGT obj) { }
+ public void visitIXOR(IXOR obj) { }
+ public void visitINVOKEVIRTUAL(INVOKEVIRTUAL obj) { }
+ public void visitFASTORE(FASTORE obj) { }
+ public void visitIRETURN(IRETURN obj) { }
+ public void visitIF_ICMPNE(IF_ICMPNE obj) { }
+ public void visitFLOAD(FLOAD obj) { }
+ public void visitLDIV(LDIV obj) { }
+ public void visitPUTSTATIC(PUTSTATIC obj) { }
+ public void visitAALOAD(AALOAD obj) { }
+ public void visitD2I(D2I obj) { }
+ public void visitIF_ICMPEQ(IF_ICMPEQ obj) { }
+ public void visitAASTORE(AASTORE obj) { }
+ public void visitARETURN(ARETURN obj) { }
+ public void visitDUP2_X1(DUP2_X1 obj) { }
+ public void visitFNEG(FNEG obj) { }
+ public void visitGOTO_W(GOTO_W obj) { }
+ public void visitD2F(D2F obj) { }
+ public void visitGOTO(GOTO obj) { }
+ public void visitISUB(ISUB obj) { }
+ public void visitF2I(F2I obj) { }
+ public void visitDNEG(DNEG obj) { }
+ public void visitICONST(ICONST obj) { }
+ public void visitFDIV(FDIV obj) { }
+ public void visitI2B(I2B obj) { }
+ public void visitLNEG(LNEG obj) { }
+ public void visitLREM(LREM obj) { }
+ public void visitIMUL(IMUL obj) { }
+ public void visitIADD(IADD obj) { }
+ public void visitLSHR(LSHR obj) { }
+ public void visitLOOKUPSWITCH(LOOKUPSWITCH obj) { }
+ public void visitDUP_X1(DUP_X1 obj) { }
+ public void visitFCMPL(FCMPL obj) { }
+ public void visitI2C(I2C obj) { }
+ public void visitLMUL(LMUL obj) { }
+ public void visitLUSHR(LUSHR obj) { }
+ public void visitISHL(ISHL obj) { }
+ public void visitLALOAD(LALOAD obj) { }
+ public void visitASTORE(ASTORE obj) { }
+ public void visitANEWARRAY(ANEWARRAY obj) { }
+ public void visitFRETURN(FRETURN obj) { }
+ public void visitFADD(FADD obj) { }
+ public void visitBREAKPOINT(BREAKPOINT obj) { }
+}
diff --git a/src/java/org/apache/bcel/generic/ExceptionThrower.java b/src/java/org/apache/bcel/generic/ExceptionThrower.java
new file mode 100644
index 00000000..15dd085e
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ExceptionThrower.java
@@ -0,0 +1,79 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Denote an instruction that may throw a run-time or a linking
+ * exception (or both) during execution. This is not quite the truth
+ * as such; because all instructions may throw an
+ * java.lang.VirtualMachineError. These exceptions are omitted.
+ *
+ * The Lava Language Specification specifies exactly which
+ * <i>RUN-TIME</i> and which <i>LINKING</i> exceptions each
+ * instruction may throw which is reflected by the implementers. Due
+ * to the structure of the JVM specification, it may be possible that
+ * an Instruction implementing this interface returns a Class[] of
+ * size 0.
+ *
+ * Please note that we speak of an "exception" here when we mean any
+ * "Throwable" object; so this term is equally used for "Exception"
+ * and "Error" objects.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase">Enver Haase</A>
+ */
+public interface ExceptionThrower {
+ public java.lang.Class[] getExceptions();
+}
diff --git a/src/java/org/apache/bcel/generic/F2D.java b/src/java/org/apache/bcel/generic/F2D.java
new file mode 100644
index 00000000..381d4284
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/F2D.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * F2D - Convert float to double
+ * <PRE>Stack: ..., value -&gt; ..., result.word1, result.word2</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class F2D extends ConversionInstruction {
+ /** Convert float to double
+ */
+ public F2D() {
+ super(org.apache.bcel.Constants.F2D);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitConversionInstruction(this);
+ v.visitF2D(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/F2I.java b/src/java/org/apache/bcel/generic/F2I.java
new file mode 100644
index 00000000..3d0092df
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/F2I.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * F2I - Convert float to int
+ * <PRE>Stack: ..., value -&gt; ..., result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class F2I extends ConversionInstruction {
+ /** Convert float to int
+ */
+ public F2I() {
+ super(org.apache.bcel.Constants.F2I);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitConversionInstruction(this);
+ v.visitF2I(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/F2L.java b/src/java/org/apache/bcel/generic/F2L.java
new file mode 100644
index 00000000..eb6689fc
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/F2L.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * F2L - Convert float to long
+ * <PRE>Stack: ..., value -&gt; ..., result.word1, result.word2</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class F2L extends ConversionInstruction {
+ /** Convert float to long
+ */
+ public F2L() {
+ super(org.apache.bcel.Constants.F2L);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitConversionInstruction(this);
+ v.visitF2L(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/FADD.java b/src/java/org/apache/bcel/generic/FADD.java
new file mode 100644
index 00000000..c7ba2423
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/FADD.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * FADD - Add floats
+ * <PRE>Stack: ..., value1, value2 -&gt; result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class FADD extends ArithmeticInstruction {
+ /** Add floats
+ */
+ public FADD() {
+ super(org.apache.bcel.Constants.FADD);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitFADD(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/FALOAD.java b/src/java/org/apache/bcel/generic/FALOAD.java
new file mode 100644
index 00000000..48d361d5
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/FALOAD.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * FALOAD - Load float from array
+ * <PRE>Stack: ..., arrayref, index -&gt; ..., value</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class FALOAD extends ArrayInstruction implements StackProducer {
+ /** Load float from array
+ */
+ public FALOAD() {
+ super(org.apache.bcel.Constants.FALOAD);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackProducer(this);
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitArrayInstruction(this);
+ v.visitFALOAD(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/FASTORE.java b/src/java/org/apache/bcel/generic/FASTORE.java
new file mode 100644
index 00000000..a6ea273a
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/FASTORE.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * FASTORE - Store into float array
+ * <PRE>Stack: ..., arrayref, index, value -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class FASTORE extends ArrayInstruction implements StackConsumer {
+ /** Store float into array
+ */
+ public FASTORE() {
+ super(org.apache.bcel.Constants.FASTORE);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitArrayInstruction(this);
+ v.visitFASTORE(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/FCMPG.java b/src/java/org/apache/bcel/generic/FCMPG.java
new file mode 100644
index 00000000..de638802
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/FCMPG.java
@@ -0,0 +1,91 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * FCMPG - Compare floats: value1 > value2
+ * <PRE>Stack: ..., value1, value2 -&gt; ..., result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class FCMPG extends Instruction
+ implements TypedInstruction, StackProducer, StackConsumer {
+ public FCMPG() {
+ super(org.apache.bcel.Constants.FCMPG, (short)1);
+ }
+
+ /** @return Type.FLOAT
+ */
+ public Type getType(ConstantPoolGen cp) {
+ return Type.FLOAT;
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitFCMPG(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/FCMPL.java b/src/java/org/apache/bcel/generic/FCMPL.java
new file mode 100644
index 00000000..5f67ce75
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/FCMPL.java
@@ -0,0 +1,91 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * FCMPL - Compare floats: value1 < value2
+ * <PRE>Stack: ..., value1, value2 -&gt; ..., result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class FCMPL extends Instruction
+ implements TypedInstruction, StackProducer, StackConsumer {
+ public FCMPL() {
+ super(org.apache.bcel.Constants.FCMPL, (short)1);
+ }
+
+ /** @return Type.FLOAT
+ */
+ public Type getType(ConstantPoolGen cp) {
+ return Type.FLOAT;
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitFCMPL(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/FCONST.java b/src/java/org/apache/bcel/generic/FCONST.java
new file mode 100644
index 00000000..d90fa28f
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/FCONST.java
@@ -0,0 +1,114 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * FCONST - Push 0.0, 1.0 or 2.0, other values cause an exception
+ *
+ * <PRE>Stack: ... -&gt; ..., <i></PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class FCONST extends Instruction
+ implements ConstantPushInstruction, TypedInstruction {
+ private float value;
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ FCONST() {}
+
+ public FCONST(float f) {
+ super(org.apache.bcel.Constants.FCONST_0, (short)1);
+
+ if(f == 0.0)
+ opcode = org.apache.bcel.Constants.FCONST_0;
+ else if(f == 1.0)
+ opcode = org.apache.bcel.Constants.FCONST_1;
+ else if(f == 2.0)
+ opcode = org.apache.bcel.Constants.FCONST_2;
+ else
+ throw new ClassGenException("FCONST can be used only for 0.0, 1.0 and 2.0: " + f);
+
+ value = f;
+ }
+
+ public Number getValue() { return new Float(value); }
+
+ /** @return Type.FLOAT
+ */
+ public Type getType(ConstantPoolGen cp) {
+ return Type.FLOAT;
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitPushInstruction(this);
+ v.visitStackProducer(this);
+ v.visitTypedInstruction(this);
+ v.visitConstantPushInstruction(this);
+ v.visitFCONST(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/FDIV.java b/src/java/org/apache/bcel/generic/FDIV.java
new file mode 100644
index 00000000..105fe4ec
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/FDIV.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * FDIV - Divide floats
+ * <PRE>Stack: ..., value1, value2 -&gt; result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class FDIV extends ArithmeticInstruction {
+ /** Divide floats
+ */
+ public FDIV() {
+ super(org.apache.bcel.Constants.FDIV);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitFDIV(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/FLOAD.java b/src/java/org/apache/bcel/generic/FLOAD.java
new file mode 100644
index 00000000..ae54b051
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/FLOAD.java
@@ -0,0 +1,92 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * FLOAD - Load float from local variable
+ * <PRE>Stack ... -&gt; ..., result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class FLOAD extends LoadInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ FLOAD() {
+ super(org.apache.bcel.Constants.FLOAD, org.apache.bcel.Constants.FLOAD_0);
+ }
+
+ /** Load float from local variable
+ * @param n index of local variable
+ */
+ public FLOAD(int n) {
+ super(org.apache.bcel.Constants.FLOAD, org.apache.bcel.Constants.FLOAD_0, n);
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ super.accept(v);
+ v.visitFLOAD(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/FMUL.java b/src/java/org/apache/bcel/generic/FMUL.java
new file mode 100644
index 00000000..5bd6ce99
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/FMUL.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * FMUL - Multiply floats
+ * <PRE>Stack: ..., value1, value2 -&gt; result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class FMUL extends ArithmeticInstruction {
+ /** Multiply floats
+ */
+ public FMUL() {
+ super(org.apache.bcel.Constants.FMUL);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitFMUL(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/FNEG.java b/src/java/org/apache/bcel/generic/FNEG.java
new file mode 100644
index 00000000..7d7bb3d6
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/FNEG.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * FNEG - Negate float
+ * <PRE>Stack: ..., value -&gt; ..., result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class FNEG extends ArithmeticInstruction {
+ public FNEG() {
+ super(org.apache.bcel.Constants.FNEG);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitFNEG(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/FREM.java b/src/java/org/apache/bcel/generic/FREM.java
new file mode 100644
index 00000000..a4bc3aba
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/FREM.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * FREM - Remainder of floats
+ * <PRE>Stack: ..., value1, value2 -&gt; result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class FREM extends ArithmeticInstruction {
+ /** Remainder of floats
+ */
+ public FREM() {
+ super(org.apache.bcel.Constants.FREM);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitFREM(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/FRETURN.java b/src/java/org/apache/bcel/generic/FRETURN.java
new file mode 100644
index 00000000..c46f16d8
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/FRETURN.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * FRETURN - Return float from method
+ * <PRE>Stack: ..., value -&gt; &lt;empty&gt;</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class FRETURN extends ReturnInstruction {
+ /** Return float from method
+ */
+ public FRETURN() {
+ super(org.apache.bcel.Constants.FRETURN);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitStackConsumer(this);
+ v.visitReturnInstruction(this);
+ v.visitFRETURN(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/FSTORE.java b/src/java/org/apache/bcel/generic/FSTORE.java
new file mode 100644
index 00000000..6c93ae08
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/FSTORE.java
@@ -0,0 +1,92 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * FSTORE - Store float into local variable
+ * <PRE>Stack: ..., value -&gt; ... </PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class FSTORE extends StoreInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ FSTORE() {
+ super(org.apache.bcel.Constants.FSTORE, org.apache.bcel.Constants.FSTORE_0);
+ }
+
+ /** Store float into local variable
+ * @param n index of local variable
+ */
+ public FSTORE(int n) {
+ super(org.apache.bcel.Constants.FSTORE, org.apache.bcel.Constants.FSTORE_0, n);
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ super.accept(v);
+ v.visitFSTORE(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/FSUB.java b/src/java/org/apache/bcel/generic/FSUB.java
new file mode 100644
index 00000000..842ea1e6
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/FSUB.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * FSUB - Substract floats
+ * <PRE>Stack: ..., value1, value2 -&gt; result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class FSUB extends ArithmeticInstruction {
+ /** Substract floats
+ */
+ public FSUB() {
+ super(org.apache.bcel.Constants.FSUB);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitFSUB(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/FieldGen.java b/src/java/org/apache/bcel/generic/FieldGen.java
new file mode 100644
index 00000000..6f8114c5
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/FieldGen.java
@@ -0,0 +1,310 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import org.apache.bcel.classfile.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * Template class for building up a field. The only extraordinary thing
+ * one can do is to add a constant value attribute to a field (which must of
+ * course be compatible with to the declared type).
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Field
+ */
+public class FieldGen extends FieldGenOrMethodGen {
+ private Object value = null;
+
+ /**
+ * Declare a field. If it is static (isStatic() == true) and has a
+ * basic type like int or String it may have an initial value
+ * associated with it as defined by setInitValue().
+ *
+ * @param access_flags access qualifiers
+ * @param type field type
+ * @param name field name
+ * @param cp constant pool
+ */
+ public FieldGen(int access_flags, Type type, String name, ConstantPoolGen cp) {
+ setAccessFlags(access_flags);
+ setType(type);
+ setName(name);
+ setConstantPool(cp);
+ }
+
+ /**
+ * Instantiate from existing field.
+ *
+ * @param field Field object
+ * @param cp constant pool (must contain the same entries as the field's constant pool)
+ */
+ public FieldGen(Field field, ConstantPoolGen cp) {
+ this(field.getAccessFlags(), Type.getType(field.getSignature()), field.getName(), cp);
+
+ Attribute[] attrs = field.getAttributes();
+
+ for(int i=0; i < attrs.length; i++) {
+ if(attrs[i] instanceof ConstantValue)
+ setValue(((ConstantValue)attrs[i]).getConstantValueIndex());
+ else
+ addAttribute(attrs[i]);
+ }
+ }
+
+ private void setValue(int index) {
+ ConstantPool cp = this.cp.getConstantPool();
+ Constant c = cp.getConstant(index);
+ value = ((ConstantObject)c).getConstantValue(cp);
+ }
+
+ /**
+ * Set (optional) initial value of field, otherwise it will be set to null/0/false
+ * by the JVM automatically.
+ */
+ public void setInitValue(String str) {
+ checkType(new ObjectType("java.lang.String"));
+
+ if(str != null)
+ value = str;
+ }
+
+ public void setInitValue(long l) {
+ checkType(Type.LONG);
+
+ if(l != 0L)
+ value = new Long(l);
+ }
+
+ public void setInitValue(int i) {
+ checkType(Type.INT);
+
+ if(i != 0)
+ value = new Integer(i);
+ }
+
+ public void setInitValue(short s) {
+ checkType(Type.SHORT);
+
+ if(s != 0)
+ value = new Integer(s);
+ }
+
+ public void setInitValue(char c) {
+ checkType(Type.CHAR);
+
+ if(c != 0)
+ value = new Integer(c);
+ }
+
+ public void setInitValue(byte b) {
+ checkType(Type.BYTE);
+
+ if(b != 0)
+ value = new Integer(b);
+ }
+
+ public void setInitValue(boolean b) {
+ checkType(Type.BOOLEAN);
+
+ if(b)
+ value = new Integer(1);
+ }
+
+ public void setInitValue(float f) {
+ checkType(Type.FLOAT);
+
+ if(f != 0.0)
+ value = new Float(f);
+ }
+
+ public void setInitValue(double d) {
+ checkType(Type.DOUBLE);
+
+ if(d != 0.0)
+ value = new Double(d);
+ }
+
+ /** Remove any initial value.
+ */
+ public void cancelInitValue() {
+ value = null;
+ }
+
+ private void checkType(Type atype) {
+ if(type == null)
+ throw new ClassGenException("You haven't defined the type of the field yet");
+
+ if(!isFinal())
+ throw new ClassGenException("Only final fields may have an initial value!");
+
+ if(!type.equals(atype))
+ throw new ClassGenException("Types are not compatible: " + type + " vs. " + atype);
+ }
+
+ /**
+ * Get field object after having set up all necessary values.
+ */
+ public Field getField() {
+ String signature = getSignature();
+ int name_index = cp.addUtf8(name);
+ int signature_index = cp.addUtf8(signature);
+
+ if(value != null) {
+ checkType(type);
+ int index = addConstant();
+ addAttribute(new ConstantValue(cp.addUtf8("ConstantValue"),
+ 2, index, cp.getConstantPool()));
+ }
+
+ return new Field(access_flags, name_index, signature_index, getAttributes(),
+ cp.getConstantPool());
+ }
+
+ private int addConstant() {
+ switch(type.getType()) {
+ case Constants.T_INT: case Constants.T_CHAR: case Constants.T_BYTE:
+ case Constants.T_BOOLEAN: case Constants.T_SHORT:
+ return cp.addInteger(((Integer)value).intValue());
+
+ case Constants.T_FLOAT:
+ return cp.addFloat(((Float)value).floatValue());
+
+ case Constants.T_DOUBLE:
+ return cp.addDouble(((Double)value).doubleValue());
+
+ case Constants.T_LONG:
+ return cp.addLong(((Long)value).longValue());
+
+ case Constants.T_REFERENCE:
+ return cp.addString(((String)value));
+
+ default:
+ throw new RuntimeException("Oops: Unhandled : " + type.getType());
+ }
+ }
+
+ public String getSignature() { return type.getSignature(); }
+
+ private ArrayList observers;
+
+ /** Add observer for this object.
+ */
+ public void addObserver(FieldObserver o) {
+ if(observers == null)
+ observers = new ArrayList();
+
+ observers.add(o);
+ }
+
+ /** Remove observer for this object.
+ */
+ public void removeObserver(FieldObserver o) {
+ if(observers != null)
+ observers.remove(o);
+ }
+
+ /** Call notify() method on all observers. This method is not called
+ * automatically whenever the state has changed, but has to be
+ * called by the user after he has finished editing the object.
+ */
+ public void update() {
+ if(observers != null)
+ for(Iterator e = observers.iterator(); e.hasNext(); )
+ ((FieldObserver)e.next()).notify(this);
+ }
+
+ public String getInitValue() {
+ if(value != null) {
+ return value.toString();
+ } else
+ return null;
+ }
+
+ /**
+ * Return string representation close to declaration format,
+ * `public static final short MAX = 100', e.g..
+ *
+ * @return String representation of field
+ */
+ public final String toString() {
+ String name, signature, access; // Short cuts to constant pool
+
+ access = Utility.accessToString(access_flags);
+ access = access.equals("")? "" : (access + " ");
+ signature = type.toString();
+ name = getName();
+
+ StringBuffer buf = new StringBuffer(access + signature + " " + name);
+ String value = getInitValue();
+
+ if(value != null)
+ buf.append(" = " + value);
+
+ return buf.toString();
+ }
+
+ /** @return deep copy of this field
+ */
+ public FieldGen copy(ConstantPoolGen cp) {
+ FieldGen fg = (FieldGen)clone();
+
+ fg.setConstantPool(cp);
+ return fg;
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/FieldGenOrMethodGen.java b/src/java/org/apache/bcel/generic/FieldGenOrMethodGen.java
new file mode 100644
index 00000000..08ef516b
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/FieldGenOrMethodGen.java
@@ -0,0 +1,129 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.classfile.*;
+import java.util.ArrayList;
+
+/**
+ * Super class for FieldGen and MethodGen objects, since they have
+ * some methods in common!
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public abstract class FieldGenOrMethodGen extends AccessFlags
+ implements NamedAndTyped, Cloneable
+{
+ protected String name;
+ protected Type type;
+ protected ConstantPoolGen cp;
+ private ArrayList attribute_vec = new ArrayList();
+
+ protected FieldGenOrMethodGen() {}
+
+ public void setType(Type type) { this.type = type; }
+ public Type getType() { return type; }
+
+ /** @return name of method/field.
+ */
+ public String getName() { return name; }
+ public void setName(String name) { this.name = name; }
+
+ public ConstantPoolGen getConstantPool() { return cp; }
+ public void setConstantPool(ConstantPoolGen cp) { this.cp = cp; }
+
+ /**
+ * Add an attribute to this method. Currently, the JVM knows about
+ * the `Code', `ConstantValue', `Synthetic' and `Exceptions'
+ * attributes. Other attributes will be ignored by the JVM but do no
+ * harm.
+ *
+ * @param a attribute to be added
+ */
+ public void addAttribute(Attribute a) { attribute_vec.add(a); }
+
+ /**
+ * Remove an attribute.
+ */
+ public void removeAttribute(Attribute a) { attribute_vec.remove(a); }
+
+ /**
+ * Remove all attributes.
+ */
+ public void removeAttributes() { attribute_vec.clear(); }
+
+ /**
+ * @return all attributes of this method.
+ */
+ public Attribute[] getAttributes() {
+ Attribute[] attributes = new Attribute[attribute_vec.size()];
+ attribute_vec.toArray(attributes);
+ return attributes;
+ }
+
+ /** @return signature of method/field.
+ */
+ public abstract String getSignature();
+
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch(CloneNotSupportedException e) {
+ System.err.println(e);
+ return null;
+ }
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/FieldInstruction.java b/src/java/org/apache/bcel/generic/FieldInstruction.java
new file mode 100644
index 00000000..028ed5cf
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/FieldInstruction.java
@@ -0,0 +1,116 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.classfile.ConstantPool;
+import org.apache.bcel.classfile.ConstantUtf8;
+import org.apache.bcel.classfile.ConstantNameAndType;
+import org.apache.bcel.classfile.ConstantCP;
+import org.apache.bcel.classfile.*;
+
+/**
+ * Super class for the GET/PUTxxx family of instructions.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public abstract class FieldInstruction extends FieldOrMethod
+ implements TypedInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ FieldInstruction() {}
+
+ /**
+ * @param index to constant pool
+ */
+ protected FieldInstruction(short opcode, int index) {
+ super(opcode, index);
+ }
+
+ /**
+ * @return mnemonic for instruction with symbolic references resolved
+ */
+ public String toString(ConstantPool cp) {
+ return org.apache.bcel.Constants.OPCODE_NAMES[opcode] + " " +
+ cp.constantToString(index, org.apache.bcel.Constants.CONSTANT_Fieldref);
+ }
+
+ /** @return size of field (1 or 2)
+ */
+ protected int getFieldSize(ConstantPoolGen cpg) {
+ return getType(cpg).getSize();
+ }
+
+ /** @return return type of referenced field
+ */
+ public Type getType(ConstantPoolGen cpg) {
+ return getFieldType(cpg);
+ }
+
+ /** @return type of field
+ */
+ public Type getFieldType(ConstantPoolGen cpg) {
+ return Type.getType(getSignature(cpg));
+ }
+
+ /** @return name of referenced field.
+ */
+ public String getFieldName(ConstantPoolGen cpg) {
+ return getName(cpg);
+ }
+}
+
diff --git a/src/java/org/apache/bcel/generic/FieldObserver.java b/src/java/org/apache/bcel/generic/FieldObserver.java
new file mode 100644
index 00000000..e5593248
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/FieldObserver.java
@@ -0,0 +1,67 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Imnplement this interface if you're interested in changes to a FieldGen object
+ * and register yourself with addObserver().
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public interface FieldObserver {
+ public void notify(FieldGen field);
+}
+
diff --git a/src/java/org/apache/bcel/generic/FieldOrMethod.java b/src/java/org/apache/bcel/generic/FieldOrMethod.java
new file mode 100644
index 00000000..835ff380
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/FieldOrMethod.java
@@ -0,0 +1,117 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import org.apache.bcel.classfile.*;
+
+/**
+ * Super class for InvokeInstruction and FieldInstruction, since they have
+ * some methods in common!
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public abstract class FieldOrMethod extends CPInstruction implements LoadClass {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ FieldOrMethod() {}
+
+ /**
+ * @param index to constant pool
+ */
+ protected FieldOrMethod(short opcode, int index) {
+ super(opcode, index);
+ }
+
+ /** @return signature of referenced method/field.
+ */
+ public String getSignature(ConstantPoolGen cpg) {
+ ConstantPool cp = cpg.getConstantPool();
+ ConstantCP cmr = (ConstantCP)cp.getConstant(index);
+ ConstantNameAndType cnat = (ConstantNameAndType)cp.getConstant(cmr.getNameAndTypeIndex());
+
+ return ((ConstantUtf8)cp.getConstant(cnat.getSignatureIndex())).getBytes();
+ }
+
+ /** @return name of referenced method/field.
+ */
+ public String getName(ConstantPoolGen cpg) {
+ ConstantPool cp = cpg.getConstantPool();
+ ConstantCP cmr = (ConstantCP)cp.getConstant(index);
+ ConstantNameAndType cnat = (ConstantNameAndType)cp.getConstant(cmr.getNameAndTypeIndex());
+ return ((ConstantUtf8)cp.getConstant(cnat.getNameIndex())).getBytes();
+ }
+
+ /** @return name of the referenced class/interface
+ */
+ public String getClassName(ConstantPoolGen cpg) {
+ ConstantPool cp = cpg.getConstantPool();
+ ConstantCP cmr = (ConstantCP)cp.getConstant(index);
+ return cp.getConstantString(cmr.getClassIndex(), org.apache.bcel.Constants.CONSTANT_Class).replace('/', '.');
+ }
+
+ /** @return type of the referenced class/interface
+ */
+ public ObjectType getClassType(ConstantPoolGen cpg) {
+ return new ObjectType(getClassName(cpg));
+ }
+
+ /** @return type of the referenced class/interface
+ */
+ public ObjectType getLoadClassType(ConstantPoolGen cpg) {
+ return getClassType(cpg);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/GETFIELD.java b/src/java/org/apache/bcel/generic/GETFIELD.java
new file mode 100644
index 00000000..c6ec284a
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/GETFIELD.java
@@ -0,0 +1,117 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import org.apache.bcel.ExceptionConstants;
+
+/**
+ * GETFIELD - Fetch field from object
+ * <PRE>Stack: ..., objectref -&gt; ..., value</PRE>
+ * OR
+ * <PRE>Stack: ..., objectref -&gt; ..., value.word1, value.word2</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class GETFIELD extends FieldInstruction
+ implements ExceptionThrower, StackConsumer, StackProducer {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ GETFIELD() {}
+
+ public GETFIELD(int index) {
+ super(Constants.GETFIELD, index);
+ }
+
+ public int produceStack(ConstantPoolGen cpg) { return getFieldSize(cpg); }
+
+ public Class[] getExceptions() {
+ Class[] cs = new Class[2 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length];
+
+ System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0,
+ cs, 0, ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length);
+
+ cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length+1] =
+ ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR;
+ cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] =
+ ExceptionConstants.NULL_POINTER_EXCEPTION;
+
+ return cs;
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitExceptionThrower(this);
+ v.visitStackConsumer(this);
+ v.visitStackProducer(this);
+ v.visitTypedInstruction(this);
+ v.visitLoadClass(this);
+ v.visitCPInstruction(this);
+ v.visitFieldOrMethod(this);
+ v.visitFieldInstruction(this);
+ v.visitGETFIELD(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/GETSTATIC.java b/src/java/org/apache/bcel/generic/GETSTATIC.java
new file mode 100644
index 00000000..c7a783c3
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/GETSTATIC.java
@@ -0,0 +1,113 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import org.apache.bcel.ExceptionConstants;
+
+/**
+ * GETSTATIC - Fetch static field from class
+ * <PRE>Stack: ..., -&gt; ..., value</PRE>
+ * OR
+ * <PRE>Stack: ..., -&gt; ..., value.word1, value.word2</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class GETSTATIC extends FieldInstruction implements PushInstruction, ExceptionThrower {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ GETSTATIC() {}
+
+ public GETSTATIC(int index) {
+ super(Constants.GETSTATIC, index);
+ }
+
+ public int produceStack(ConstantPoolGen cpg) { return getFieldSize(cpg); }
+
+ public Class[] getExceptions() {
+ Class[] cs = new Class[1 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length];
+
+ System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0,
+ cs, 0, ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length);
+ cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] =
+ ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR;
+
+ return cs;
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackProducer(this);
+ v.visitPushInstruction(this);
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitLoadClass(this);
+ v.visitCPInstruction(this);
+ v.visitFieldOrMethod(this);
+ v.visitFieldInstruction(this);
+ v.visitGETSTATIC(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/GOTO.java b/src/java/org/apache/bcel/generic/GOTO.java
new file mode 100644
index 00000000..f77c84ea
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/GOTO.java
@@ -0,0 +1,122 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import java.io.*;
+
+/**
+ * GOTO - Branch always (to relative offset, not absolute address)
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class GOTO extends GotoInstruction implements VariableLengthInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ GOTO() {}
+
+ public GOTO(InstructionHandle target) {
+ super(org.apache.bcel.Constants.GOTO, target);
+ }
+
+ /**
+ * Dump instruction as byte code to stream out.
+ * @param out Output stream
+ */
+ public void dump(DataOutputStream out) throws IOException {
+ index = getTargetOffset();
+ if(opcode == org.apache.bcel.Constants.GOTO)
+ super.dump(out);
+ else { // GOTO_W
+ index = getTargetOffset();
+ out.writeByte(opcode);
+ out.writeInt(index);
+ }
+ }
+
+ /** Called in pass 2 of InstructionList.setPositions() in order to update
+ * the branch target, that may shift due to variable length instructions.
+ */
+ protected int updatePosition(int offset, int max_offset) {
+ int i = getTargetOffset(); // Depending on old position value
+
+ position += offset; // Position may be shifted by preceding expansions
+
+ if(Math.abs(i) >= (32767 - max_offset)) { // to large for short (estimate)
+ opcode = org.apache.bcel.Constants.GOTO_W;
+ length = 5;
+ return 2; // 5 - 3
+ }
+
+ return 0;
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitVariableLengthInstruction(this);
+ v.visitUnconditionalBranch(this);
+ v.visitBranchInstruction(this);
+ v.visitGotoInstruction(this);
+ v.visitGOTO(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/GOTO_W.java b/src/java/org/apache/bcel/generic/GOTO_W.java
new file mode 100644
index 00000000..93a867b4
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/GOTO_W.java
@@ -0,0 +1,110 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import java.io.*;
+import org.apache.bcel.util.ByteSequence;
+
+/**
+ * GOTO_W - Branch always (to relative offset, not absolute address)
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class GOTO_W extends GotoInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ GOTO_W() {}
+
+ public GOTO_W(InstructionHandle target) {
+ super(org.apache.bcel.Constants.GOTO_W, target);
+ length = 5;
+ }
+
+ /**
+ * Dump instruction as byte code to stream out.
+ * @param out Output stream
+ */
+ public void dump(DataOutputStream out) throws IOException {
+ index = getTargetOffset();
+ out.writeByte(opcode);
+ out.writeInt(index);
+ }
+
+ /**
+ * Read needed data (e.g. index) from file.
+ */
+ protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
+ {
+ index = bytes.readInt();
+ length = 5;
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitUnconditionalBranch(this);
+ v.visitBranchInstruction(this);
+ v.visitGotoInstruction(this);
+ v.visitGOTO_W(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/GotoInstruction.java b/src/java/org/apache/bcel/generic/GotoInstruction.java
new file mode 100644
index 00000000..3d768be1
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/GotoInstruction.java
@@ -0,0 +1,75 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Super class for GOTO
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public abstract class GotoInstruction extends BranchInstruction
+ implements UnconditionalBranch
+{
+ GotoInstruction(short opcode, InstructionHandle target) {
+ super(opcode, target);
+ }
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ GotoInstruction(){}
+}
diff --git a/src/java/org/apache/bcel/generic/I2B.java b/src/java/org/apache/bcel/generic/I2B.java
new file mode 100644
index 00000000..9eddff96
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/I2B.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * I2B - Convert int to byte
+ * <PRE>Stack: ..., value -&gt; ..., result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class I2B extends ConversionInstruction {
+ /** Convert int to byte
+ */
+ public I2B() {
+ super(org.apache.bcel.Constants.I2B);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitConversionInstruction(this);
+ v.visitI2B(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/I2C.java b/src/java/org/apache/bcel/generic/I2C.java
new file mode 100644
index 00000000..9d7c36df
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/I2C.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * I2C - Convert int to char
+ * <PRE>Stack: ..., value -&gt; ..., result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class I2C extends ConversionInstruction {
+ /** Convert int to char
+ */
+ public I2C() {
+ super(org.apache.bcel.Constants.I2C);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitConversionInstruction(this);
+ v.visitI2C(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/I2D.java b/src/java/org/apache/bcel/generic/I2D.java
new file mode 100644
index 00000000..c5148551
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/I2D.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * I2D - Convert int to double
+ * <PRE>Stack: ..., value -&gt; ..., result.word1, result.word2</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class I2D extends ConversionInstruction {
+ /** Convert int to double
+ */
+ public I2D() {
+ super(org.apache.bcel.Constants.I2D);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitConversionInstruction(this);
+ v.visitI2D(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/I2F.java b/src/java/org/apache/bcel/generic/I2F.java
new file mode 100644
index 00000000..570bf390
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/I2F.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * I2F - Convert int to float
+ * <PRE>Stack: ..., value -&gt; ..., result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class I2F extends ConversionInstruction {
+ /** Convert int to float
+ */
+ public I2F() {
+ super(org.apache.bcel.Constants.I2F);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitConversionInstruction(this);
+ v.visitI2F(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/I2L.java b/src/java/org/apache/bcel/generic/I2L.java
new file mode 100644
index 00000000..d5d02971
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/I2L.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * I2L - Convert int to long
+ * <PRE>Stack: ..., value -&gt; ..., result.word1, result.word2</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class I2L extends ConversionInstruction {
+ /** Convert int to long
+ */
+ public I2L() {
+ super(org.apache.bcel.Constants.I2L);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitConversionInstruction(this);
+ v.visitI2L(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/I2S.java b/src/java/org/apache/bcel/generic/I2S.java
new file mode 100644
index 00000000..8ab5ff13
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/I2S.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * I2S - Convert int to short
+ * <PRE>Stack: ..., value -&gt; ..., result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class I2S extends ConversionInstruction {
+ public I2S() {
+ super(org.apache.bcel.Constants.I2S);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitConversionInstruction(this);
+ v.visitI2S(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IADD.java b/src/java/org/apache/bcel/generic/IADD.java
new file mode 100644
index 00000000..74b04958
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IADD.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IADD - Add ints
+ * <PRE>Stack: ..., value1, value2 -&gt; result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IADD extends ArithmeticInstruction {
+ /** Add ints
+ */
+ public IADD() {
+ super(org.apache.bcel.Constants.IADD);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitIADD(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IALOAD.java b/src/java/org/apache/bcel/generic/IALOAD.java
new file mode 100644
index 00000000..33936b63
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IALOAD.java
@@ -0,0 +1,88 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IALOAD - Load int from array
+ * <PRE>Stack: ..., arrayref, index -&gt; ..., value</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IALOAD extends ArrayInstruction implements StackProducer {
+ /**
+ * Load int from array
+ */
+ public IALOAD() {
+ super(org.apache.bcel.Constants.IALOAD);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackProducer(this);
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitArrayInstruction(this);
+ v.visitIALOAD(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IAND.java b/src/java/org/apache/bcel/generic/IAND.java
new file mode 100644
index 00000000..ef5b0cab
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IAND.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IAND - Bitwise AND int
+ * <PRE>Stack: ..., value1, value2 -&gt; ..., result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IAND extends ArithmeticInstruction {
+ public IAND() {
+ super(org.apache.bcel.Constants.IAND);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitIAND(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IASTORE.java b/src/java/org/apache/bcel/generic/IASTORE.java
new file mode 100644
index 00000000..2b0a24b4
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IASTORE.java
@@ -0,0 +1,88 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IASTORE - Store into int array
+ * <PRE>Stack: ..., arrayref, index, value -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IASTORE extends ArrayInstruction implements StackConsumer {
+ /**
+ * Store into int array
+ */
+ public IASTORE() {
+ super(org.apache.bcel.Constants.IASTORE);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitArrayInstruction(this);
+ v.visitIASTORE(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/ICONST.java b/src/java/org/apache/bcel/generic/ICONST.java
new file mode 100644
index 00000000..39e08329
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ICONST.java
@@ -0,0 +1,110 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * ICONST - Push value between -1, ..., 5, other values cause an exception
+ *
+ * <PRE>Stack: ... -&gt; ..., <i></PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class ICONST extends Instruction
+ implements ConstantPushInstruction, TypedInstruction {
+ private int value;
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ ICONST() {}
+
+ public ICONST(int i) {
+ super(org.apache.bcel.Constants.ICONST_0, (short)1);
+
+ if((i >= -1) && (i <= 5))
+ opcode = (short)(org.apache.bcel.Constants.ICONST_0 + i); // Even works for i == -1
+ else
+ throw new ClassGenException("ICONST can be used only for value between -1 and 5: " +
+ i);
+ value = i;
+ }
+
+ public Number getValue() { return new Integer(value); }
+
+ /** @return Type.INT
+ */
+ public Type getType(ConstantPoolGen cp) {
+ return Type.INT;
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitPushInstruction(this);
+ v.visitStackProducer(this);
+ v.visitTypedInstruction(this);
+ v.visitConstantPushInstruction(this);
+ v.visitICONST(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IDIV.java b/src/java/org/apache/bcel/generic/IDIV.java
new file mode 100644
index 00000000..60453df9
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IDIV.java
@@ -0,0 +1,94 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IDIV - Divide ints
+ * <PRE>Stack: ..., value1, value2 -&gt; result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IDIV extends ArithmeticInstruction implements ExceptionThrower {
+ /** Divide ints
+ */
+ public IDIV() {
+ super(org.apache.bcel.Constants.IDIV);
+ }
+
+ /** @return exceptions this instruction may cause
+ */
+ public Class[] getExceptions() {
+ return new Class[] { org.apache.bcel.ExceptionConstants.ARITHMETIC_EXCEPTION };
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitIDIV(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IFEQ.java b/src/java/org/apache/bcel/generic/IFEQ.java
new file mode 100644
index 00000000..f9b6cb52
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IFEQ.java
@@ -0,0 +1,98 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IFEQ - Branch if int comparison with zero succeeds
+ *
+ * <PRE>Stack: ..., value -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IFEQ extends IfInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ IFEQ() {}
+
+ public IFEQ(InstructionHandle target) {
+ super(org.apache.bcel.Constants.IFEQ, target);
+ }
+
+ /**
+ * @return negation of instruction, e.g. IFEQ.negate() == IFNE
+ */
+ public IfInstruction negate() {
+ return new IFNE(target);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitBranchInstruction(this);
+ v.visitIfInstruction(this);
+ v.visitIFEQ(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IFGE.java b/src/java/org/apache/bcel/generic/IFGE.java
new file mode 100644
index 00000000..c7b1ff44
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IFGE.java
@@ -0,0 +1,98 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IFGE - Branch if int comparison with zero succeeds
+ *
+ * <PRE>Stack: ..., value -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IFGE extends IfInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ IFGE() {}
+
+ public IFGE(InstructionHandle target) {
+ super(org.apache.bcel.Constants.IFGE, target);
+ }
+
+ /**
+ * @return negation of instruction
+ */
+ public IfInstruction negate() {
+ return new IFLT(target);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitBranchInstruction(this);
+ v.visitIfInstruction(this);
+ v.visitIFGE(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IFGT.java b/src/java/org/apache/bcel/generic/IFGT.java
new file mode 100644
index 00000000..0d0a5ad3
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IFGT.java
@@ -0,0 +1,98 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IFGT - Branch if int comparison with zero succeeds
+ *
+ * <PRE>Stack: ..., value -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IFGT extends IfInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ IFGT() {}
+
+ public IFGT(InstructionHandle target) {
+ super(org.apache.bcel.Constants.IFGT, target);
+ }
+
+ /**
+ * @return negation of instruction
+ */
+ public IfInstruction negate() {
+ return new IFLE(target);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitBranchInstruction(this);
+ v.visitIfInstruction(this);
+ v.visitIFGT(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IFLE.java b/src/java/org/apache/bcel/generic/IFLE.java
new file mode 100644
index 00000000..0a75215d
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IFLE.java
@@ -0,0 +1,98 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IFLE - Branch if int comparison with zero succeeds
+ *
+ * <PRE>Stack: ..., value -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IFLE extends IfInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ IFLE() {}
+
+ public IFLE(InstructionHandle target) {
+ super(org.apache.bcel.Constants.IFLE, target);
+ }
+
+ /**
+ * @return negation of instruction
+ */
+ public IfInstruction negate() {
+ return new IFGT(target);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitBranchInstruction(this);
+ v.visitIfInstruction(this);
+ v.visitIFLE(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IFLT.java b/src/java/org/apache/bcel/generic/IFLT.java
new file mode 100644
index 00000000..a316ee30
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IFLT.java
@@ -0,0 +1,98 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IFLT - Branch if int comparison with zero succeeds
+ *
+ * <PRE>Stack: ..., value -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IFLT extends IfInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ IFLT() {}
+
+ public IFLT(InstructionHandle target) {
+ super(org.apache.bcel.Constants.IFLT, target);
+ }
+
+ /**
+ * @return negation of instruction
+ */
+ public IfInstruction negate() {
+ return new IFGE(target);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitBranchInstruction(this);
+ v.visitIfInstruction(this);
+ v.visitIFLT(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IFNE.java b/src/java/org/apache/bcel/generic/IFNE.java
new file mode 100644
index 00000000..47ed4248
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IFNE.java
@@ -0,0 +1,98 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IFNE - Branch if int comparison with zero succeeds
+ *
+ * <PRE>Stack: ..., value -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IFNE extends IfInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ IFNE() {}
+
+ public IFNE(InstructionHandle target) {
+ super(org.apache.bcel.Constants.IFNE, target);
+ }
+
+ /**
+ * @return negation of instruction
+ */
+ public IfInstruction negate() {
+ return new IFEQ(target);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitBranchInstruction(this);
+ v.visitIfInstruction(this);
+ v.visitIFNE(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IFNONNULL.java b/src/java/org/apache/bcel/generic/IFNONNULL.java
new file mode 100644
index 00000000..75a80d6a
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IFNONNULL.java
@@ -0,0 +1,97 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IFNONNULL - Branch if reference is not null
+ *
+ * <PRE>Stack: ..., reference -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IFNONNULL extends IfInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ IFNONNULL() {}
+
+ public IFNONNULL(InstructionHandle target) {
+ super(org.apache.bcel.Constants.IFNONNULL, target);
+ }
+
+ /**
+ * @return negation of instruction
+ */
+ public IfInstruction negate() {
+ return new IFNULL(target);
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitBranchInstruction(this);
+ v.visitIfInstruction(this);
+ v.visitIFNONNULL(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IFNULL.java b/src/java/org/apache/bcel/generic/IFNULL.java
new file mode 100644
index 00000000..3e1346b7
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IFNULL.java
@@ -0,0 +1,98 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IFNULL - Branch if reference is not null
+ *
+ * <PRE>Stack: ..., reference -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IFNULL extends IfInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ IFNULL() {}
+
+ public IFNULL(InstructionHandle target) {
+ super(org.apache.bcel.Constants.IFNULL, target);
+ }
+
+ /**
+ * @return negation of instruction
+ */
+ public IfInstruction negate() {
+ return new IFNONNULL(target);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitBranchInstruction(this);
+ v.visitIfInstruction(this);
+ v.visitIFNULL(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IF_ACMPEQ.java b/src/java/org/apache/bcel/generic/IF_ACMPEQ.java
new file mode 100644
index 00000000..d8560fb2
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IF_ACMPEQ.java
@@ -0,0 +1,97 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IF_ACMPEQ - Branch if reference comparison succeeds
+ *
+ * <PRE>Stack: ..., value1, value2 -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IF_ACMPEQ extends IfInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ IF_ACMPEQ() {}
+
+ public IF_ACMPEQ(InstructionHandle target) {
+ super(org.apache.bcel.Constants.IF_ACMPEQ, target);
+ }
+
+ /**
+ * @return negation of instruction
+ */
+ public IfInstruction negate() {
+ return new IF_ACMPNE(target);
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitBranchInstruction(this);
+ v.visitIfInstruction(this);
+ v.visitIF_ACMPEQ(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IF_ACMPNE.java b/src/java/org/apache/bcel/generic/IF_ACMPNE.java
new file mode 100644
index 00000000..89cd7f54
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IF_ACMPNE.java
@@ -0,0 +1,98 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IF_ACMPNE - Branch if reference comparison doesn't succeed
+ *
+ * <PRE>Stack: ..., value1, value2 -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IF_ACMPNE extends IfInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ IF_ACMPNE() {}
+
+ public IF_ACMPNE(InstructionHandle target) {
+ super(org.apache.bcel.Constants.IF_ACMPNE, target);
+ }
+
+ /**
+ * @return negation of instruction
+ */
+ public IfInstruction negate() {
+ return new IF_ACMPEQ(target);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitBranchInstruction(this);
+ v.visitIfInstruction(this);
+ v.visitIF_ACMPNE(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IF_ICMPEQ.java b/src/java/org/apache/bcel/generic/IF_ICMPEQ.java
new file mode 100644
index 00000000..c84f244f
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IF_ICMPEQ.java
@@ -0,0 +1,98 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IF_ICMPEQ - Branch if int comparison succeeds
+ *
+ * <PRE>Stack: ..., value1, value2 -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IF_ICMPEQ extends IfInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ IF_ICMPEQ() {}
+
+ public IF_ICMPEQ(InstructionHandle target) {
+ super(org.apache.bcel.Constants.IF_ICMPEQ, target);
+ }
+
+ /**
+ * @return negation of instruction
+ */
+ public IfInstruction negate() {
+ return new IF_ICMPNE(target);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitBranchInstruction(this);
+ v.visitIfInstruction(this);
+ v.visitIF_ICMPEQ(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IF_ICMPGE.java b/src/java/org/apache/bcel/generic/IF_ICMPGE.java
new file mode 100644
index 00000000..354bed13
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IF_ICMPGE.java
@@ -0,0 +1,98 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IF_ICMPGE - Branch if int comparison succeeds
+ *
+ * <PRE>Stack: ..., value1, value2 -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IF_ICMPGE extends IfInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ IF_ICMPGE() {}
+
+ public IF_ICMPGE(InstructionHandle target) {
+ super(org.apache.bcel.Constants.IF_ICMPGE, target);
+ }
+
+ /**
+ * @return negation of instruction
+ */
+ public IfInstruction negate() {
+ return new IF_ICMPLT(target);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitBranchInstruction(this);
+ v.visitIfInstruction(this);
+ v.visitIF_ICMPGE(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IF_ICMPGT.java b/src/java/org/apache/bcel/generic/IF_ICMPGT.java
new file mode 100644
index 00000000..86519ceb
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IF_ICMPGT.java
@@ -0,0 +1,98 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IF_ICMPGT - Branch if int comparison succeeds
+ *
+ * <PRE>Stack: ..., value1, value2 -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IF_ICMPGT extends IfInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ IF_ICMPGT() {}
+
+ public IF_ICMPGT(InstructionHandle target) {
+ super(org.apache.bcel.Constants.IF_ICMPGT, target);
+ }
+
+ /**
+ * @return negation of instruction
+ */
+ public IfInstruction negate() {
+ return new IF_ICMPLE(target);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitBranchInstruction(this);
+ v.visitIfInstruction(this);
+ v.visitIF_ICMPGT(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IF_ICMPLE.java b/src/java/org/apache/bcel/generic/IF_ICMPLE.java
new file mode 100644
index 00000000..d7de2c8e
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IF_ICMPLE.java
@@ -0,0 +1,98 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IF_ICMPLE - Branch if int comparison succeeds
+ *
+ * <PRE>Stack: ..., value1, value2 -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IF_ICMPLE extends IfInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ IF_ICMPLE() {}
+
+ public IF_ICMPLE(InstructionHandle target) {
+ super(org.apache.bcel.Constants.IF_ICMPLE, target);
+ }
+
+ /**
+ * @return negation of instruction
+ */
+ public IfInstruction negate() {
+ return new IF_ICMPGT(target);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitBranchInstruction(this);
+ v.visitIfInstruction(this);
+ v.visitIF_ICMPLE(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IF_ICMPLT.java b/src/java/org/apache/bcel/generic/IF_ICMPLT.java
new file mode 100644
index 00000000..0bb03b4e
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IF_ICMPLT.java
@@ -0,0 +1,98 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IF_ICMPLT - Branch if int comparison succeeds
+ *
+ * <PRE>Stack: ..., value1, value2 -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IF_ICMPLT extends IfInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ IF_ICMPLT() {}
+
+ public IF_ICMPLT(InstructionHandle target) {
+ super(org.apache.bcel.Constants.IF_ICMPLT, target);
+ }
+
+ /**
+ * @return negation of instruction
+ */
+ public IfInstruction negate() {
+ return new IF_ICMPGE(target);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitBranchInstruction(this);
+ v.visitIfInstruction(this);
+ v.visitIF_ICMPLT(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IF_ICMPNE.java b/src/java/org/apache/bcel/generic/IF_ICMPNE.java
new file mode 100644
index 00000000..409e841c
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IF_ICMPNE.java
@@ -0,0 +1,98 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IF_ICMPNE - Branch if int comparison doesn't succeed
+ *
+ * <PRE>Stack: ..., value1, value2 -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IF_ICMPNE extends IfInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ IF_ICMPNE() {}
+
+ public IF_ICMPNE(InstructionHandle target) {
+ super(org.apache.bcel.Constants.IF_ICMPNE, target);
+ }
+
+ /**
+ * @return negation of instruction
+ */
+ public IfInstruction negate() {
+ return new IF_ICMPEQ(target);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitBranchInstruction(this);
+ v.visitIfInstruction(this);
+ v.visitIF_ICMPNE(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IINC.java b/src/java/org/apache/bcel/generic/IINC.java
new file mode 100644
index 00000000..3eebbf90
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IINC.java
@@ -0,0 +1,179 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import java.io.*;
+import org.apache.bcel.util.ByteSequence;
+
+/**
+ * IINC - Increment local variable by constant
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IINC extends LocalVariableInstruction {
+ private boolean wide;
+ private int c;
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ IINC() {}
+
+ public IINC(int n, int c) {
+ super(); // Default behaviour of LocalVariableInstruction causes error
+
+ this.opcode = org.apache.bcel.Constants.IINC;
+ this.length = (short)3;
+
+ setIndex(n); // May set wide as side effect
+ setIncrement(c);
+ }
+
+ /**
+ * Dump instruction as byte code to stream out.
+ * @param out Output stream
+ */
+ public void dump(DataOutputStream out) throws IOException {
+ if(wide) // Need WIDE prefix ?
+ out.writeByte(org.apache.bcel.Constants.WIDE);
+
+ out.writeByte(opcode);
+
+ if(wide) {
+ out.writeShort(n);
+ out.writeShort(c);
+ } else {
+ out.writeByte(n);
+ out.writeByte(c);
+ }
+ }
+
+ private final void setWide() {
+ if(wide = ((n > org.apache.bcel.Constants.MAX_SHORT) ||
+ (Math.abs(c) > Byte.MAX_VALUE)))
+ length = 6; // wide byte included
+ else
+ length = 3;
+ }
+
+ /**
+ * Read needed data (e.g. index) from file.
+ */
+ protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
+ {
+ this.wide = wide;
+
+ if(wide) {
+ length = 6;
+ n = bytes.readUnsignedShort();
+ c = bytes.readShort();
+ } else {
+ length = 3;
+ n = bytes.readUnsignedByte();
+ c = bytes.readByte();
+ }
+ }
+
+ /**
+ * @return mnemonic for instruction
+ */
+ public String toString(boolean verbose) {
+ return super.toString(verbose) + " " + c;
+ }
+
+ /**
+ * Set index of local variable.
+ */
+ public final void setIndex(int n) {
+ if(n < 0)
+ throw new ClassGenException("Negative index value: " + n);
+
+ this.n = n;
+ setWide();
+ }
+
+ /**
+ * @return increment factor
+ */
+ public final int getIncrement() { return c; }
+
+ /**
+ * Set increment factor.
+ */
+ public final void setIncrement(int c) {
+ this.c = c;
+ setWide();
+ }
+
+ /** @return int type
+ */
+ public Type getType(ConstantPoolGen cp) {
+ return Type.INT;
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitLocalVariableInstruction(this);
+ v.visitIINC(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/ILOAD.java b/src/java/org/apache/bcel/generic/ILOAD.java
new file mode 100644
index 00000000..320eb767
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ILOAD.java
@@ -0,0 +1,92 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * ILOAD - Load int from local variable onto stack
+ * <PRE>Stack: ... -&gt; ..., result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class ILOAD extends LoadInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ ILOAD() {
+ super(org.apache.bcel.Constants.ILOAD, org.apache.bcel.Constants.ILOAD_0);
+ }
+
+ /** Load int from local variable
+ * @param n index of local variable
+ */
+ public ILOAD(int n) {
+ super(org.apache.bcel.Constants.ILOAD, org.apache.bcel.Constants.ILOAD_0, n);
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ super.accept(v);
+ v.visitILOAD(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IMPDEP1.java b/src/java/org/apache/bcel/generic/IMPDEP1.java
new file mode 100644
index 00000000..488eff09
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IMPDEP1.java
@@ -0,0 +1,80 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IMPDEP1 - Implementation dependent
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IMPDEP1 extends Instruction {
+ public IMPDEP1() {
+ super(org.apache.bcel.Constants.IMPDEP1, (short)1);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitIMPDEP1(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IMPDEP2.java b/src/java/org/apache/bcel/generic/IMPDEP2.java
new file mode 100644
index 00000000..8663c9e9
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IMPDEP2.java
@@ -0,0 +1,80 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IMPDEP2 - Implementation dependent
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IMPDEP2 extends Instruction {
+ public IMPDEP2() {
+ super(org.apache.bcel.Constants.IMPDEP2, (short)1);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitIMPDEP2(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IMUL.java b/src/java/org/apache/bcel/generic/IMUL.java
new file mode 100644
index 00000000..ef8d337e
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IMUL.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IMUL - Multiply ints
+ * <PRE>Stack: ..., value1, value2 -&gt; result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IMUL extends ArithmeticInstruction {
+ /** Multiply ints
+ */
+ public IMUL() {
+ super(org.apache.bcel.Constants.IMUL);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitIMUL(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/INEG.java b/src/java/org/apache/bcel/generic/INEG.java
new file mode 100644
index 00000000..83b0582c
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/INEG.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * INEG - Negate int
+ * <PRE>Stack: ..., value -&gt; ..., result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class INEG extends ArithmeticInstruction {
+ public INEG() {
+ super(org.apache.bcel.Constants.INEG);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitINEG(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/INSTANCEOF.java b/src/java/org/apache/bcel/generic/INSTANCEOF.java
new file mode 100644
index 00000000..4d147c6c
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/INSTANCEOF.java
@@ -0,0 +1,106 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * INSTANCEOF - Determine if object is of given type
+ * <PRE>Stack: ..., objectref -&gt; ..., result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class INSTANCEOF extends CPInstruction
+ implements LoadClass, ExceptionThrower, StackProducer, StackConsumer {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ INSTANCEOF() {}
+
+ public INSTANCEOF(int index) {
+ super(org.apache.bcel.Constants.INSTANCEOF, index);
+ }
+
+ public Class[] getExceptions() {
+ return org.apache.bcel.ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION;
+ }
+
+ public ObjectType getLoadClassType(ConstantPoolGen cpg) {
+ Type t = getType(cpg);
+
+ if(t instanceof ArrayType)
+ t = ((ArrayType) t).getBasicType();
+
+ return (t instanceof ObjectType)? (ObjectType) t : null;
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitLoadClass(this);
+ v.visitExceptionThrower(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitTypedInstruction(this);
+ v.visitCPInstruction(this);
+ v.visitINSTANCEOF(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/INVOKEINTERFACE.java b/src/java/org/apache/bcel/generic/INVOKEINTERFACE.java
new file mode 100644
index 00000000..f61eca00
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/INVOKEINTERFACE.java
@@ -0,0 +1,163 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import org.apache.bcel.classfile.ConstantPool;
+import org.apache.bcel.Constants;
+import org.apache.bcel.ExceptionConstants;
+
+import java.io.*;
+import org.apache.bcel.util.ByteSequence;
+
+/**
+ * INVOKEINTERFACE - Invoke interface method
+ * <PRE>Stack: ..., objectref, [arg1, [arg2 ...]] -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public final class INVOKEINTERFACE extends InvokeInstruction {
+ private int nargs; // Number of arguments on stack (number of stack slots), called "count" in vmspec2
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ INVOKEINTERFACE() {}
+
+ public INVOKEINTERFACE(int index, int nargs) {
+ super(Constants.INVOKEINTERFACE, index);
+ length = 5;
+
+ if(nargs < 1)
+ throw new ClassGenException("Number of arguments must be > 0 " + nargs);
+
+ this.nargs = nargs;
+ }
+
+ /**
+ * Dump instruction as byte code to stream out.
+ * @param out Output stream
+ */
+ public void dump(DataOutputStream out) throws IOException {
+ out.writeByte(opcode);
+ out.writeShort(index);
+ out.writeByte(nargs);
+ out.writeByte(0);
+ }
+
+ /**
+ * The <B>count</B> argument according to the Java Language Specification,
+ * Second Edition.
+ */
+ public int getCount() { return nargs; }
+
+ /**
+ * Read needed data (i.e., index) from file.
+ */
+ protected void initFromFile(ByteSequence bytes, boolean wide)
+ throws IOException
+ {
+ super.initFromFile(bytes, wide);
+
+ length = 5;
+ nargs = bytes.readUnsignedByte();
+ bytes.readByte(); // Skip 0 byte
+ }
+
+ /**
+ * @return mnemonic for instruction with symbolic references resolved
+ */
+ public String toString(ConstantPool cp) {
+ return super.toString(cp) + " " + nargs;
+ }
+
+ public int consumeStack(ConstantPoolGen cpg) { // nargs is given in byte-code
+ return nargs; // nargs includes this reference
+ }
+
+ public Class[] getExceptions() {
+ Class[] cs = new Class[4 + ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION.length];
+
+ System.arraycopy(ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION, 0,
+ cs, 0, ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION.length);
+
+ cs[ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION.length+3] = ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR;
+ cs[ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION.length+2] = ExceptionConstants.ILLEGAL_ACCESS_ERROR;
+ cs[ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION.length+1] = ExceptionConstants.ABSTRACT_METHOD_ERROR;
+ cs[ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION.length] = ExceptionConstants.UNSATISFIED_LINK_ERROR;
+
+ return cs;
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitStackConsumer(this);
+ v.visitStackProducer(this);
+ v.visitLoadClass(this);
+ v.visitCPInstruction(this);
+ v.visitFieldOrMethod(this);
+ v.visitInvokeInstruction(this);
+ v.visitINVOKEINTERFACE(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/INVOKESPECIAL.java b/src/java/org/apache/bcel/generic/INVOKESPECIAL.java
new file mode 100644
index 00000000..a73d8fab
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/INVOKESPECIAL.java
@@ -0,0 +1,113 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import org.apache.bcel.Constants;
+import org.apache.bcel.ExceptionConstants;
+
+/**
+ * INVOKESPECIAL - Invoke instance method; special handling for superclass, private
+ * and instance initialization method invocations
+ *
+ * <PRE>Stack: ..., objectref, [arg1, [arg2 ...]] -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class INVOKESPECIAL extends InvokeInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ INVOKESPECIAL() {}
+
+ public INVOKESPECIAL(int index) {
+ super(Constants.INVOKESPECIAL, index);
+ }
+
+ public Class[] getExceptions() {
+ Class[] cs = new Class[4 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length];
+
+ System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0,
+ cs, 0, ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length);
+
+ cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length+3] = ExceptionConstants.UNSATISFIED_LINK_ERROR;
+ cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length+2] = ExceptionConstants.ABSTRACT_METHOD_ERROR;
+ cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length+1] = ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR;
+ cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] = ExceptionConstants.NULL_POINTER_EXCEPTION;
+
+ return cs;
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitStackConsumer(this);
+ v.visitStackProducer(this);
+ v.visitLoadClass(this);
+ v.visitCPInstruction(this);
+ v.visitFieldOrMethod(this);
+ v.visitInvokeInstruction(this);
+ v.visitINVOKESPECIAL(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/INVOKESTATIC.java b/src/java/org/apache/bcel/generic/INVOKESTATIC.java
new file mode 100644
index 00000000..01abae76
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/INVOKESTATIC.java
@@ -0,0 +1,110 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import org.apache.bcel.Constants;
+import org.apache.bcel.ExceptionConstants;
+
+/**
+ * INVOKESTATIC - Invoke a class (static) method
+ *
+ * <PRE>Stack: ..., [arg1, [arg2 ...]] -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class INVOKESTATIC extends InvokeInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ INVOKESTATIC() {}
+
+ public INVOKESTATIC(int index) {
+ super(Constants.INVOKESTATIC, index);
+ }
+
+ public Class[] getExceptions() {
+ Class[] cs = new Class[2 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length];
+
+ System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0,
+ cs, 0, ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length);
+
+ cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] = ExceptionConstants.UNSATISFIED_LINK_ERROR;
+ cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length+1] = ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR;
+
+ return cs;
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitStackConsumer(this);
+ v.visitStackProducer(this);
+ v.visitLoadClass(this);
+ v.visitCPInstruction(this);
+ v.visitFieldOrMethod(this);
+ v.visitInvokeInstruction(this);
+ v.visitINVOKESTATIC(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/INVOKEVIRTUAL.java b/src/java/org/apache/bcel/generic/INVOKEVIRTUAL.java
new file mode 100644
index 00000000..dd84d142
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/INVOKEVIRTUAL.java
@@ -0,0 +1,112 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import org.apache.bcel.Constants;
+import org.apache.bcel.ExceptionConstants;
+
+/**
+ * INVOKEVIRTUAL - Invoke instance method; dispatch based on class
+ *
+ * <PRE>Stack: ..., objectref, [arg1, [arg2 ...]] -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class INVOKEVIRTUAL extends InvokeInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ INVOKEVIRTUAL() {}
+
+ public INVOKEVIRTUAL(int index) {
+ super(Constants.INVOKEVIRTUAL, index);
+ }
+
+ public Class[] getExceptions() {
+ Class[] cs = new Class[4 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length];
+
+ System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0,
+ cs, 0, ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length);
+
+ cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length+3] = ExceptionConstants.UNSATISFIED_LINK_ERROR;
+ cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length+2] = ExceptionConstants.ABSTRACT_METHOD_ERROR;
+ cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length+1] = ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR;
+ cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] = ExceptionConstants.NULL_POINTER_EXCEPTION;
+
+ return cs;
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitStackConsumer(this);
+ v.visitStackProducer(this);
+ v.visitLoadClass(this);
+ v.visitCPInstruction(this);
+ v.visitFieldOrMethod(this);
+ v.visitInvokeInstruction(this);
+ v.visitINVOKEVIRTUAL(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IOR.java b/src/java/org/apache/bcel/generic/IOR.java
new file mode 100644
index 00000000..32b92110
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IOR.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IOR - Bitwise OR int
+ * <PRE>Stack: ..., value1, value2 -&gt; ..., result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IOR extends ArithmeticInstruction {
+ public IOR() {
+ super(org.apache.bcel.Constants.IOR);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitIOR(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IREM.java b/src/java/org/apache/bcel/generic/IREM.java
new file mode 100644
index 00000000..27ec0f15
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IREM.java
@@ -0,0 +1,94 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IREM - Remainder of int
+ * <PRE>Stack: ..., value1, value2 -&gt; result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IREM extends ArithmeticInstruction implements ExceptionThrower {
+ /** Remainder of ints
+ */
+ public IREM() {
+ super(org.apache.bcel.Constants.IREM);
+ }
+
+ /** @return exceptions this instruction may cause
+ */
+ public Class[] getExceptions() {
+ return new Class[] { org.apache.bcel.ExceptionConstants.ARITHMETIC_EXCEPTION };
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitIREM(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IRETURN.java b/src/java/org/apache/bcel/generic/IRETURN.java
new file mode 100644
index 00000000..db1d18bc
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IRETURN.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IRETURN - Return int from method
+ * <PRE>Stack: ..., value -&gt; &lt;empty&gt;</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IRETURN extends ReturnInstruction {
+ /** Return int from method
+ */
+ public IRETURN() {
+ super(org.apache.bcel.Constants.IRETURN);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitStackConsumer(this);
+ v.visitReturnInstruction(this);
+ v.visitIRETURN(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/ISHL.java b/src/java/org/apache/bcel/generic/ISHL.java
new file mode 100644
index 00000000..998772bd
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ISHL.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * ISHL - Arithmetic shift left int
+ * <PRE>Stack: ..., value1, value2 -&gt; ..., result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class ISHL extends ArithmeticInstruction {
+ public ISHL() {
+ super(org.apache.bcel.Constants.ISHL);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitISHL(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/ISHR.java b/src/java/org/apache/bcel/generic/ISHR.java
new file mode 100644
index 00000000..97919128
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ISHR.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * ISHR - Arithmetic shift right int
+ * <PRE>Stack: ..., value1, value2 -&gt; ..., result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class ISHR extends ArithmeticInstruction {
+ public ISHR() {
+ super(org.apache.bcel.Constants.ISHR);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitISHR(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/ISTORE.java b/src/java/org/apache/bcel/generic/ISTORE.java
new file mode 100644
index 00000000..efca2fc3
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ISTORE.java
@@ -0,0 +1,92 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * ISTORE - Store int from stack into local variable
+ * <PRE>Stack: ..., value -&gt; ... </PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class ISTORE extends StoreInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ ISTORE() {
+ super(org.apache.bcel.Constants.ISTORE, org.apache.bcel.Constants.ISTORE_0);
+ }
+
+ /** Store int into local variable
+ * @param n index of local variable
+ */
+ public ISTORE(int n) {
+ super(org.apache.bcel.Constants.ISTORE, org.apache.bcel.Constants.ISTORE_0, n);
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ super.accept(v);
+ v.visitISTORE(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/ISUB.java b/src/java/org/apache/bcel/generic/ISUB.java
new file mode 100644
index 00000000..b0c8411f
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ISUB.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * ISUB - Substract ints
+ * <PRE>Stack: ..., value1, value2 -&gt; result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class ISUB extends ArithmeticInstruction {
+ /** Substract ints
+ */
+ public ISUB() {
+ super(org.apache.bcel.Constants.ISUB);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitISUB(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IUSHR.java b/src/java/org/apache/bcel/generic/IUSHR.java
new file mode 100644
index 00000000..c038cfda
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IUSHR.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IUSHR - Logical shift right int
+ * <PRE>Stack: ..., value1, value2 -&gt; ..., result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IUSHR extends ArithmeticInstruction {
+ public IUSHR() {
+ super(org.apache.bcel.Constants.IUSHR);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitIUSHR(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IXOR.java b/src/java/org/apache/bcel/generic/IXOR.java
new file mode 100644
index 00000000..acc44df9
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IXOR.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * IXOR - Bitwise XOR int
+ * <PRE>Stack: ..., value1, value2 -&gt; ..., result</PRE>
+ *
+ * @version $Id$
+ * @authXOR <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class IXOR extends ArithmeticInstruction {
+ public IXOR() {
+ super(org.apache.bcel.Constants.IXOR);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitIXOR(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/IfInstruction.java b/src/java/org/apache/bcel/generic/IfInstruction.java
new file mode 100644
index 00000000..22217fe0
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IfInstruction.java
@@ -0,0 +1,82 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Super class for the IFxxx family of instructions.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public abstract class IfInstruction extends BranchInstruction implements StackConsumer {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ IfInstruction() {}
+
+ /**
+ * @param instruction Target instruction to branch to
+ */
+ protected IfInstruction(short opcode, InstructionHandle target) {
+ super(opcode, target);
+ }
+
+ /**
+ * @return negation of instruction, e.g. IFEQ.negate() == IFNE
+ */
+ public abstract IfInstruction negate();
+}
+
diff --git a/src/java/org/apache/bcel/generic/IndexedInstruction.java b/src/java/org/apache/bcel/generic/IndexedInstruction.java
new file mode 100644
index 00000000..067e7089
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/IndexedInstruction.java
@@ -0,0 +1,68 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Denote entity that refers to an index, e.g. local variable instructions,
+ * RET, CPInstruction, etc.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public interface IndexedInstruction {
+ public int getIndex();
+ public void setIndex(int index);
+}
+
diff --git a/src/java/org/apache/bcel/generic/Instruction.java b/src/java/org/apache/bcel/generic/Instruction.java
new file mode 100644
index 00000000..1dc84b8f
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/Instruction.java
@@ -0,0 +1,276 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import org.apache.bcel.classfile.Utility;
+import org.apache.bcel.classfile.ConstantPool;
+import java.io.*;
+import org.apache.bcel.util.ByteSequence;
+
+/**
+ * Abstract super class for all Java byte codes.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public abstract class Instruction implements Cloneable, Serializable {
+ protected short length = 1; // Length of instruction in bytes
+ protected short opcode = -1; // Opcode number
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ Instruction() {}
+
+ public Instruction(short opcode, short length) {
+ this.length = length;
+ this.opcode = opcode;
+ }
+
+ /**
+ * Dump instruction as byte code to stream out.
+ * @param out Output stream
+ */
+ public void dump(DataOutputStream out) throws IOException {
+ out.writeByte(opcode); // Common for all instructions
+ }
+
+ /**
+ * Long output format:
+ *
+ * &lt;name of opcode&gt; "["&lt;opcode number&gt;"]"
+ * "("&lt;length of instruction&gt;")"
+ *
+ * @param verbose long/short format switch
+ * @return mnemonic for instruction
+ */
+ public String toString(boolean verbose) {
+ if(verbose)
+ return Constants.OPCODE_NAMES[opcode] + "[" + opcode + "](" + length + ")";
+ else
+ return Constants.OPCODE_NAMES[opcode];
+ }
+
+ /**
+ * @return mnemonic for instruction in verbose format
+ */
+ public String toString() {
+ return toString(true);
+ }
+
+ /**
+ * @return mnemonic for instruction with sumbolic references resolved
+ */
+ public String toString(ConstantPool cp) {
+ return toString(false);
+ }
+
+ /**
+ * Use with caution, since `BranchInstruction's have a `target' reference which
+ * is not copied correctly (only basic types are). This also applies for
+ * `Select' instructions with their multiple branch targets.
+ *
+ * @see BranchInstruction
+ * @return (shallow) copy of an instruction
+ */
+ public Instruction copy() {
+ Instruction i = null;
+
+ // "Constant" instruction, no need to duplicate
+ if(InstructionConstants.INSTRUCTIONS[this.getOpcode()] != null)
+ i = this;
+ else {
+ try {
+ i = (Instruction)clone();
+ } catch(CloneNotSupportedException e) {
+ System.err.println(e);
+ }
+ }
+
+ return i;
+ }
+
+ /**
+ * Read needed data (e.g. index) from file.
+ *
+ * @param bytes byte sequence to read from
+ * @param wide "wide" instruction flag
+ */
+ protected void initFromFile(ByteSequence bytes, boolean wide)
+ throws IOException
+ {}
+
+ /**
+ * Read an instruction from (byte code) input stream and return the
+ * appropiate object.
+ *
+ * @param file file to read from
+ * @return instruction object being read
+ */
+ public static final Instruction readInstruction(ByteSequence bytes)
+ throws IOException
+ {
+ boolean wide = false;
+ short opcode = (short)bytes.readUnsignedByte();
+ Instruction obj = null;
+
+ if(opcode == Constants.WIDE) { // Read next opcode after wide byte
+ wide = true;
+ opcode = (short)bytes.readUnsignedByte();
+ }
+
+ if(InstructionConstants.INSTRUCTIONS[opcode] != null)
+ return InstructionConstants.INSTRUCTIONS[opcode]; // Used predefined immutable object, if available
+
+ /* Find appropiate class, instantiate an (empty) instruction object
+ * and initialize it by hand.
+ */
+ Class clazz;
+ try {
+ clazz = Class.forName(className(opcode));
+ }
+ catch (ClassNotFoundException cnfe){
+ // If a class by that name does not exist, the opcode is illegal.
+ // Note that IMPDEP1, IMPDEP2, BREAKPOINT are also illegal in a sense.
+ throw new ClassGenException("Illegal opcode detected.");
+ }
+ try {
+ obj = (Instruction)clazz.newInstance();
+
+ if(wide && !((obj instanceof LocalVariableInstruction) || (obj instanceof IINC) ||
+ (obj instanceof RET)))
+ throw new Exception("Illegal opcode after wide: " + opcode);
+
+ obj.setOpcode(opcode);
+ obj.initFromFile(bytes, wide); // Do further initializations, if any
+ // Byte code offset set in InstructionList
+ } catch(Exception e) { throw new ClassGenException(e.toString()); }
+
+ return obj;
+ }
+
+ private static final String className(short opcode) {
+ String name = Constants.OPCODE_NAMES[opcode].toUpperCase();
+
+ /* ICONST_0, etc. will be shortened to ICONST, etc., since ICONST_0 and the like
+ * are not implemented (directly).
+ */
+ try {
+ int len = name.length();
+ char ch1 = name.charAt(len - 2), ch2 = name.charAt(len - 1);
+
+ if((ch1 == '_') && (ch2 >= '0') && (ch2 <= '5'))
+ name = name.substring(0, len - 2);
+
+ if(name.equals("ICONST_M1")) // Special case
+ name = "ICONST";
+ } catch(StringIndexOutOfBoundsException e) { System.err.println(e); }
+
+ return "org.apache.bcel.generic." + name;
+ }
+
+ /**
+ * This method also gives right results for instructions whose
+ * effect on the stack depends on the constant pool entry they
+ * reference.
+ * @return Number of words consumed from stack by this instruction,
+ * or Constants.UNPREDICTABLE, if this can not be computed statically
+ */
+ public int consumeStack(ConstantPoolGen cpg) {
+ return Constants.CONSUME_STACK[opcode];
+ }
+
+ /**
+ * This method also gives right results for instructions whose
+ * effect on the stack depends on the constant pool entry they
+ * reference.
+ * @return Number of words produced onto stack by this instruction,
+ * or Constants.UNPREDICTABLE, if this can not be computed statically
+ */
+ public int produceStack(ConstantPoolGen cpg) {
+ return Constants.PRODUCE_STACK[opcode];
+ }
+
+ /**
+ * @return this instructions opcode
+ */
+ public short getOpcode() { return opcode; }
+
+ /**
+ * @return length (in bytes) of instruction
+ */
+ public int getLength() { return length; }
+
+ /**
+ * Needed in readInstruction.
+ */
+ private void setOpcode(short opcode) { this.opcode = opcode; }
+
+ /** Some instructions may be reused, so don't do anything by default.
+ */
+ void dispose() { }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public abstract void accept(Visitor v);
+}
diff --git a/src/java/org/apache/bcel/generic/InstructionConstants.java b/src/java/org/apache/bcel/generic/InstructionConstants.java
new file mode 100644
index 00000000..a4bfe225
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/InstructionConstants.java
@@ -0,0 +1,326 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+
+/**
+ * This interface contains shareable instruction objects.
+ *
+ * In order to save memory you can use some instructions multiply,
+ * since they have an immutable state and are directly derived from
+ * Instruction. I.e. they have no instance fields that could be
+ * changed. Since some of these instructions like ICONST_0 occur
+ * very frequently this can save a lot of time and space. This
+ * feature is an adaptation of the FlyWeight design pattern, we
+ * just use an array instead of a factory.
+ *
+ * The Instructions can also accessed directly under their names, so
+ * it's possible to write il.append(Instruction.ICONST_0);
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public interface InstructionConstants {
+ /** Predefined instruction objects
+ */
+ public static final Instruction NOP = new NOP();
+ public static final Instruction ACONST_NULL = new ACONST_NULL();
+ public static final Instruction ICONST_M1 = new ICONST(-1);
+ public static final Instruction ICONST_0 = new ICONST(0);
+ public static final Instruction ICONST_1 = new ICONST(1);
+ public static final Instruction ICONST_2 = new ICONST(2);
+ public static final Instruction ICONST_3 = new ICONST(3);
+ public static final Instruction ICONST_4 = new ICONST(4);
+ public static final Instruction ICONST_5 = new ICONST(5);
+ public static final Instruction LCONST_0 = new LCONST(0);
+ public static final Instruction LCONST_1 = new LCONST(1);
+ public static final Instruction FCONST_0 = new FCONST(0);
+ public static final Instruction FCONST_1 = new FCONST(1);
+ public static final Instruction FCONST_2 = new FCONST(2);
+ public static final Instruction DCONST_0 = new DCONST(0);
+ public static final Instruction DCONST_1 = new DCONST(1);
+ public static final ArrayInstruction IALOAD = new IALOAD();
+ public static final ArrayInstruction LALOAD = new LALOAD();
+ public static final ArrayInstruction FALOAD = new FALOAD();
+ public static final ArrayInstruction DALOAD = new DALOAD();
+ public static final ArrayInstruction AALOAD = new AALOAD();
+ public static final ArrayInstruction BALOAD = new BALOAD();
+ public static final ArrayInstruction CALOAD = new CALOAD();
+ public static final ArrayInstruction SALOAD = new SALOAD();
+ public static final ArrayInstruction IASTORE = new IASTORE();
+ public static final ArrayInstruction LASTORE = new LASTORE();
+ public static final ArrayInstruction FASTORE = new FASTORE();
+ public static final ArrayInstruction DASTORE = new DASTORE();
+ public static final ArrayInstruction AASTORE = new AASTORE();
+ public static final ArrayInstruction BASTORE = new BASTORE();
+ public static final ArrayInstruction CASTORE = new CASTORE();
+ public static final ArrayInstruction SASTORE = new SASTORE();
+ public static final StackInstruction POP = new POP();
+ public static final StackInstruction POP2 = new POP2();
+ public static final StackInstruction DUP = new DUP();
+ public static final StackInstruction DUP_X1 = new DUP_X1();
+ public static final StackInstruction DUP_X2 = new DUP_X2();
+ public static final StackInstruction DUP2 = new DUP2();
+ public static final StackInstruction DUP2_X1 = new DUP2_X1();
+ public static final StackInstruction DUP2_X2 = new DUP2_X2();
+ public static final StackInstruction SWAP = new SWAP();
+ public static final ArithmeticInstruction IADD = new IADD();
+ public static final ArithmeticInstruction LADD = new LADD();
+ public static final ArithmeticInstruction FADD = new FADD();
+ public static final ArithmeticInstruction DADD = new DADD();
+ public static final ArithmeticInstruction ISUB = new ISUB();
+ public static final ArithmeticInstruction LSUB = new LSUB();
+ public static final ArithmeticInstruction FSUB = new FSUB();
+ public static final ArithmeticInstruction DSUB = new DSUB();
+ public static final ArithmeticInstruction IMUL = new IMUL();
+ public static final ArithmeticInstruction LMUL = new LMUL();
+ public static final ArithmeticInstruction FMUL = new FMUL();
+ public static final ArithmeticInstruction DMUL = new DMUL();
+ public static final ArithmeticInstruction IDIV = new IDIV();
+ public static final ArithmeticInstruction LDIV = new LDIV();
+ public static final ArithmeticInstruction FDIV = new FDIV();
+ public static final ArithmeticInstruction DDIV = new DDIV();
+ public static final ArithmeticInstruction IREM = new IREM();
+ public static final ArithmeticInstruction LREM = new LREM();
+ public static final ArithmeticInstruction FREM = new FREM();
+ public static final ArithmeticInstruction DREM = new DREM();
+ public static final ArithmeticInstruction INEG = new INEG();
+ public static final ArithmeticInstruction LNEG = new LNEG();
+ public static final ArithmeticInstruction FNEG = new FNEG();
+ public static final ArithmeticInstruction DNEG = new DNEG();
+ public static final ArithmeticInstruction ISHL = new ISHL();
+ public static final ArithmeticInstruction LSHL = new LSHL();
+ public static final ArithmeticInstruction ISHR = new ISHR();
+ public static final ArithmeticInstruction LSHR = new LSHR();
+ public static final ArithmeticInstruction IUSHR = new IUSHR();
+ public static final ArithmeticInstruction LUSHR = new LUSHR();
+ public static final ArithmeticInstruction IAND = new IAND();
+ public static final ArithmeticInstruction LAND = new LAND();
+ public static final ArithmeticInstruction IOR = new IOR();
+ public static final ArithmeticInstruction LOR = new LOR();
+ public static final ArithmeticInstruction IXOR = new IXOR();
+ public static final ArithmeticInstruction LXOR = new LXOR();
+ public static final ConversionInstruction I2L = new I2L();
+ public static final ConversionInstruction I2F = new I2F();
+ public static final ConversionInstruction I2D = new I2D();
+ public static final ConversionInstruction L2I = new L2I();
+ public static final ConversionInstruction L2F = new L2F();
+ public static final ConversionInstruction L2D = new L2D();
+ public static final ConversionInstruction F2I = new F2I();
+ public static final ConversionInstruction F2L = new F2L();
+ public static final ConversionInstruction F2D = new F2D();
+ public static final ConversionInstruction D2I = new D2I();
+ public static final ConversionInstruction D2L = new D2L();
+ public static final ConversionInstruction D2F = new D2F();
+ public static final ConversionInstruction I2B = new I2B();
+ public static final ConversionInstruction I2C = new I2C();
+ public static final ConversionInstruction I2S = new I2S();
+ public static final Instruction LCMP = new LCMP();
+ public static final Instruction FCMPL = new FCMPL();
+ public static final Instruction FCMPG = new FCMPG();
+ public static final Instruction DCMPL = new DCMPL();
+ public static final Instruction DCMPG = new DCMPG();
+ public static final ReturnInstruction IRETURN = new IRETURN();
+ public static final ReturnInstruction LRETURN = new LRETURN();
+ public static final ReturnInstruction FRETURN = new FRETURN();
+ public static final ReturnInstruction DRETURN = new DRETURN();
+ public static final ReturnInstruction ARETURN = new ARETURN();
+ public static final ReturnInstruction RETURN = new RETURN();
+ public static final Instruction ARRAYLENGTH = new ARRAYLENGTH();
+ public static final Instruction ATHROW = new ATHROW();
+ public static final Instruction MONITORENTER = new MONITORENTER();
+ public static final Instruction MONITOREXIT = new MONITOREXIT();
+
+ /** You can use these constants in multiple places safely, if you can guarantee
+ * that you will never alter their internal values, e.g. call setIndex().
+ */
+ public static final LocalVariableInstruction THIS = new ALOAD(0);
+ public static final LocalVariableInstruction ALOAD_0 = THIS;
+ public static final LocalVariableInstruction ALOAD_1 = new ALOAD(1);
+ public static final LocalVariableInstruction ALOAD_2 = new ALOAD(2);
+ public static final LocalVariableInstruction ILOAD_0 = new ILOAD(0);
+ public static final LocalVariableInstruction ILOAD_1 = new ILOAD(1);
+ public static final LocalVariableInstruction ILOAD_2 = new ILOAD(2);
+ public static final LocalVariableInstruction ASTORE_0 = new ASTORE(0);
+ public static final LocalVariableInstruction ASTORE_1 = new ASTORE(1);
+ public static final LocalVariableInstruction ASTORE_2 = new ASTORE(2);
+ public static final LocalVariableInstruction ISTORE_0 = new ISTORE(0);
+ public static final LocalVariableInstruction ISTORE_1 = new ISTORE(1);
+ public static final LocalVariableInstruction ISTORE_2 = new ISTORE(2);
+
+
+ /** Get object via its opcode, for immutable instructions like
+ * branch instructions entries are set to null.
+ */
+ public static final Instruction[] INSTRUCTIONS = new Instruction[256];
+
+ /** Interfaces may have no static initializers, so we simulate this
+ * with an inner class.
+ */
+ static final Clinit bla = new Clinit();
+
+ static class Clinit {
+ Clinit() {
+ INSTRUCTIONS[Constants.NOP] = NOP;
+ INSTRUCTIONS[Constants.ACONST_NULL] = ACONST_NULL;
+ INSTRUCTIONS[Constants.ICONST_M1] = ICONST_M1;
+ INSTRUCTIONS[Constants.ICONST_0] = ICONST_0;
+ INSTRUCTIONS[Constants.ICONST_1] = ICONST_1;
+ INSTRUCTIONS[Constants.ICONST_2] = ICONST_2;
+ INSTRUCTIONS[Constants.ICONST_3] = ICONST_3;
+ INSTRUCTIONS[Constants.ICONST_4] = ICONST_4;
+ INSTRUCTIONS[Constants.ICONST_5] = ICONST_5;
+ INSTRUCTIONS[Constants.LCONST_0] = LCONST_0;
+ INSTRUCTIONS[Constants.LCONST_1] = LCONST_1;
+ INSTRUCTIONS[Constants.FCONST_0] = FCONST_0;
+ INSTRUCTIONS[Constants.FCONST_1] = FCONST_1;
+ INSTRUCTIONS[Constants.FCONST_2] = FCONST_2;
+ INSTRUCTIONS[Constants.DCONST_0] = DCONST_0;
+ INSTRUCTIONS[Constants.DCONST_1] = DCONST_1;
+ INSTRUCTIONS[Constants.IALOAD] = IALOAD;
+ INSTRUCTIONS[Constants.LALOAD] = LALOAD;
+ INSTRUCTIONS[Constants.FALOAD] = FALOAD;
+ INSTRUCTIONS[Constants.DALOAD] = DALOAD;
+ INSTRUCTIONS[Constants.AALOAD] = AALOAD;
+ INSTRUCTIONS[Constants.BALOAD] = BALOAD;
+ INSTRUCTIONS[Constants.CALOAD] = CALOAD;
+ INSTRUCTIONS[Constants.SALOAD] = SALOAD;
+ INSTRUCTIONS[Constants.IASTORE] = IASTORE;
+ INSTRUCTIONS[Constants.LASTORE] = LASTORE;
+ INSTRUCTIONS[Constants.FASTORE] = FASTORE;
+ INSTRUCTIONS[Constants.DASTORE] = DASTORE;
+ INSTRUCTIONS[Constants.AASTORE] = AASTORE;
+ INSTRUCTIONS[Constants.BASTORE] = BASTORE;
+ INSTRUCTIONS[Constants.CASTORE] = CASTORE;
+ INSTRUCTIONS[Constants.SASTORE] = SASTORE;
+ INSTRUCTIONS[Constants.POP] = POP;
+ INSTRUCTIONS[Constants.POP2] = POP2;
+ INSTRUCTIONS[Constants.DUP] = DUP;
+ INSTRUCTIONS[Constants.DUP_X1] = DUP_X1;
+ INSTRUCTIONS[Constants.DUP_X2] = DUP_X2;
+ INSTRUCTIONS[Constants.DUP2] = DUP2;
+ INSTRUCTIONS[Constants.DUP2_X1] = DUP2_X1;
+ INSTRUCTIONS[Constants.DUP2_X2] = DUP2_X2;
+ INSTRUCTIONS[Constants.SWAP] = SWAP;
+ INSTRUCTIONS[Constants.IADD] = IADD;
+ INSTRUCTIONS[Constants.LADD] = LADD;
+ INSTRUCTIONS[Constants.FADD] = FADD;
+ INSTRUCTIONS[Constants.DADD] = DADD;
+ INSTRUCTIONS[Constants.ISUB] = ISUB;
+ INSTRUCTIONS[Constants.LSUB] = LSUB;
+ INSTRUCTIONS[Constants.FSUB] = FSUB;
+ INSTRUCTIONS[Constants.DSUB] = DSUB;
+ INSTRUCTIONS[Constants.IMUL] = IMUL;
+ INSTRUCTIONS[Constants.LMUL] = LMUL;
+ INSTRUCTIONS[Constants.FMUL] = FMUL;
+ INSTRUCTIONS[Constants.DMUL] = DMUL;
+ INSTRUCTIONS[Constants.IDIV] = IDIV;
+ INSTRUCTIONS[Constants.LDIV] = LDIV;
+ INSTRUCTIONS[Constants.FDIV] = FDIV;
+ INSTRUCTIONS[Constants.DDIV] = DDIV;
+ INSTRUCTIONS[Constants.IREM] = IREM;
+ INSTRUCTIONS[Constants.LREM] = LREM;
+ INSTRUCTIONS[Constants.FREM] = FREM;
+ INSTRUCTIONS[Constants.DREM] = DREM;
+ INSTRUCTIONS[Constants.INEG] = INEG;
+ INSTRUCTIONS[Constants.LNEG] = LNEG;
+ INSTRUCTIONS[Constants.FNEG] = FNEG;
+ INSTRUCTIONS[Constants.DNEG] = DNEG;
+ INSTRUCTIONS[Constants.ISHL] = ISHL;
+ INSTRUCTIONS[Constants.LSHL] = LSHL;
+ INSTRUCTIONS[Constants.ISHR] = ISHR;
+ INSTRUCTIONS[Constants.LSHR] = LSHR;
+ INSTRUCTIONS[Constants.IUSHR] = IUSHR;
+ INSTRUCTIONS[Constants.LUSHR] = LUSHR;
+ INSTRUCTIONS[Constants.IAND] = IAND;
+ INSTRUCTIONS[Constants.LAND] = LAND;
+ INSTRUCTIONS[Constants.IOR] = IOR;
+ INSTRUCTIONS[Constants.LOR] = LOR;
+ INSTRUCTIONS[Constants.IXOR] = IXOR;
+ INSTRUCTIONS[Constants.LXOR] = LXOR;
+ INSTRUCTIONS[Constants.I2L] = I2L;
+ INSTRUCTIONS[Constants.I2F] = I2F;
+ INSTRUCTIONS[Constants.I2D] = I2D;
+ INSTRUCTIONS[Constants.L2I] = L2I;
+ INSTRUCTIONS[Constants.L2F] = L2F;
+ INSTRUCTIONS[Constants.L2D] = L2D;
+ INSTRUCTIONS[Constants.F2I] = F2I;
+ INSTRUCTIONS[Constants.F2L] = F2L;
+ INSTRUCTIONS[Constants.F2D] = F2D;
+ INSTRUCTIONS[Constants.D2I] = D2I;
+ INSTRUCTIONS[Constants.D2L] = D2L;
+ INSTRUCTIONS[Constants.D2F] = D2F;
+ INSTRUCTIONS[Constants.I2B] = I2B;
+ INSTRUCTIONS[Constants.I2C] = I2C;
+ INSTRUCTIONS[Constants.I2S] = I2S;
+ INSTRUCTIONS[Constants.LCMP] = LCMP;
+ INSTRUCTIONS[Constants.FCMPL] = FCMPL;
+ INSTRUCTIONS[Constants.FCMPG] = FCMPG;
+ INSTRUCTIONS[Constants.DCMPL] = DCMPL;
+ INSTRUCTIONS[Constants.DCMPG] = DCMPG;
+ INSTRUCTIONS[Constants.IRETURN] = IRETURN;
+ INSTRUCTIONS[Constants.LRETURN] = LRETURN;
+ INSTRUCTIONS[Constants.FRETURN] = FRETURN;
+ INSTRUCTIONS[Constants.DRETURN] = DRETURN;
+ INSTRUCTIONS[Constants.ARETURN] = ARETURN;
+ INSTRUCTIONS[Constants.RETURN] = RETURN;
+ INSTRUCTIONS[Constants.ARRAYLENGTH] = ARRAYLENGTH;
+ INSTRUCTIONS[Constants.ATHROW] = ATHROW;
+ INSTRUCTIONS[Constants.MONITORENTER] = MONITORENTER;
+ INSTRUCTIONS[Constants.MONITOREXIT] = MONITOREXIT;
+ }
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/InstructionFactory.java b/src/java/org/apache/bcel/generic/InstructionFactory.java
new file mode 100644
index 00000000..01b77695
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/InstructionFactory.java
@@ -0,0 +1,593 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import org.apache.bcel.Constants;
+
+/**
+ * Instances of this class may be used, e.g., to generate typed
+ * versions of instructions. Its main purpose is to be used as the
+ * byte code generating backend of a compiler. You can subclass it to
+ * add your own create methods.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Constants
+ */
+public class InstructionFactory implements InstructionConstants {
+ protected ClassGen cg;
+ protected ConstantPoolGen cp;
+
+ public InstructionFactory(ClassGen cg, ConstantPoolGen cp) {
+ this.cg = cg;
+ this.cp = cp;
+ }
+
+ /** Initialize with ClassGen object
+ */
+ public InstructionFactory(ClassGen cg) {
+ this(cg, cg.getConstantPool());
+ }
+
+ /** Initialize just with ConstantPoolGen object
+ */
+ public InstructionFactory(ConstantPoolGen cp) {
+ this(null, cp);
+ }
+
+ /** Create an invoke instruction.
+ *
+ * @param class_name name of the called class
+ * @param name name of the called method
+ * @param ret_type return type of method
+ * @param arg_types argument types of method
+ * @param kind how to invoke, i.e., INVOKEINTERFACE, INVOKESTATIC, INVOKEVIRTUAL,
+ * or INVOKESPECIAL
+ * @see Constants
+ */
+ public InvokeInstruction createInvoke(String class_name, String name, Type ret_type,
+ Type[] arg_types, short kind) {
+ int index;
+ int nargs = 0;
+ String signature = Type.getMethodSignature(ret_type, arg_types);
+
+ for(int i=0; i < arg_types.length; i++) // Count size of arguments
+ nargs += arg_types[i].getSize();
+
+ if(kind == Constants.INVOKEINTERFACE)
+ index = cp.addInterfaceMethodref(class_name, name, signature);
+ else
+ index = cp.addMethodref(class_name, name, signature);
+
+ switch(kind) {
+ case Constants.INVOKESPECIAL: return new INVOKESPECIAL(index);
+ case Constants.INVOKEVIRTUAL: return new INVOKEVIRTUAL(index);
+ case Constants.INVOKESTATIC: return new INVOKESTATIC(index);
+ case Constants.INVOKEINTERFACE: return new INVOKEINTERFACE(index, nargs + 1);
+ default:
+ throw new RuntimeException("Oops: Unknown invoke kind:" + kind);
+ }
+ }
+
+ /** Create a call to the most popular System.out.println() method.
+ *
+ * @param s the string to print
+ */
+ public InstructionList createPrintln(String s) {
+ InstructionList il = new InstructionList();
+ int out = cp.addFieldref("java.lang.System", "out",
+ "Ljava/io/PrintStream;");
+ int println = cp.addMethodref("java.io.PrintStream", "println",
+ "(Ljava/lang/String;)V");
+
+ il.append(new GETSTATIC(out));
+ il.append(new PUSH(cp, s));
+ il.append(new INVOKEVIRTUAL(println));
+
+ return il;
+ }
+
+ private static class MethodObject {
+ Type[] arg_types;
+ Type result_type;
+ String[] arg_names;
+ String class_name;
+ String name;
+ int access;
+
+ MethodObject(String c, String n, Type r, Type[] a, int acc) {
+ class_name = c;
+ name = n;
+ result_type = r;
+ arg_types = a;
+ access = acc;
+ }
+ }
+
+ private InvokeInstruction createInvoke(MethodObject m, short kind) {
+ return createInvoke(m.class_name, m.name, m.result_type, m.arg_types, kind);
+ }
+
+ private static MethodObject[] append_mos = {
+ new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER,
+ new Type[] { Type.STRING }, Constants.ACC_PUBLIC),
+ new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER,
+ new Type[] { Type.OBJECT }, Constants.ACC_PUBLIC),
+ null, null, // indices 2, 3
+ new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER,
+ new Type[] { Type.BOOLEAN }, Constants.ACC_PUBLIC),
+ new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER,
+ new Type[] { Type.CHAR }, Constants.ACC_PUBLIC),
+ new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER,
+ new Type[] { Type.FLOAT }, Constants.ACC_PUBLIC),
+ new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER,
+ new Type[] { Type.DOUBLE }, Constants.ACC_PUBLIC),
+ new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER,
+ new Type[] { Type.INT }, Constants.ACC_PUBLIC),
+ new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, // No append(byte)
+ new Type[] { Type.INT }, Constants.ACC_PUBLIC),
+ new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, // No append(short)
+ new Type[] { Type.INT }, Constants.ACC_PUBLIC),
+ new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER,
+ new Type[] { Type.LONG }, Constants.ACC_PUBLIC)
+ };
+
+ private static final boolean isString(Type type) {
+ return ((type instanceof ObjectType) &&
+ ((ObjectType)type).getClassName().equals("java.lang.String"));
+ }
+
+ public Instruction createAppend(Type type) {
+ byte t = type.getType();
+
+ if(isString(type))
+ return createInvoke(append_mos[0], Constants.INVOKEVIRTUAL);
+
+ switch(t) {
+ case Constants.T_BOOLEAN:
+ case Constants.T_CHAR:
+ case Constants.T_FLOAT:
+ case Constants.T_DOUBLE:
+ case Constants.T_BYTE:
+ case Constants.T_SHORT:
+ case Constants.T_INT:
+ case Constants.T_LONG
+ : return createInvoke(append_mos[t], Constants.INVOKEVIRTUAL);
+ case Constants.T_ARRAY:
+ case Constants.T_OBJECT:
+ return createInvoke(append_mos[1], Constants.INVOKEVIRTUAL);
+ default:
+ throw new RuntimeException("Oops: No append for this type? " + type);
+ }
+ }
+
+ /** Create a field instruction.
+ *
+ * @param class_name name of the accessed class
+ * @param name name of the referenced field
+ * @param type type of field
+ * @param kind how to access, i.e., GETFIELD, PUTFIELD, GETSTATIC, PUTSTATIC
+ * @see Constants
+ */
+ public FieldInstruction createFieldAccess(String class_name, String name, Type type, short kind) {
+ int index;
+ String signature = type.getSignature();
+
+ index = cp.addFieldref(class_name, name, signature);
+
+ switch(kind) {
+ case Constants.GETFIELD: return new GETFIELD(index);
+ case Constants.PUTFIELD: return new PUTFIELD(index);
+ case Constants.GETSTATIC: return new GETSTATIC(index);
+ case Constants.PUTSTATIC: return new PUTSTATIC(index);
+
+ default:
+ throw new RuntimeException("Oops: Unknown getfield kind:" + kind);
+ }
+ }
+
+ /** Create reference to `this'
+ */
+ public static Instruction createThis() {
+ return new ALOAD(0);
+ }
+
+ /** Create typed return
+ */
+ public static ReturnInstruction createReturn(Type type) {
+ switch(type.getType()) {
+ case Constants.T_ARRAY:
+ case Constants.T_OBJECT: return ARETURN;
+ case Constants.T_INT:
+ case Constants.T_SHORT:
+ case Constants.T_BOOLEAN:
+ case Constants.T_CHAR:
+ case Constants.T_BYTE: return IRETURN;
+ case Constants.T_FLOAT: return FRETURN;
+ case Constants.T_DOUBLE: return DRETURN;
+ case Constants.T_LONG: return LRETURN;
+ case Constants.T_VOID: return RETURN;
+
+ default:
+ throw new RuntimeException("Invalid type: " + type);
+ }
+ }
+
+ private static final ArithmeticInstruction createBinaryIntOp(char first, String op) {
+ switch(first) {
+ case '-' : return ISUB;
+ case '+' : return IADD;
+ case '%' : return IREM;
+ case '*' : return IMUL;
+ case '/' : return IDIV;
+ case '&' : return IAND;
+ case '|' : return IOR;
+ case '^' : return IXOR;
+ case '<' : return ISHL;
+ case '>' : return op.equals(">>>")? (ArithmeticInstruction)IUSHR :
+ (ArithmeticInstruction)ISHR;
+ default: throw new RuntimeException("Invalid operand " + op);
+ }
+ }
+
+ private static final ArithmeticInstruction createBinaryLongOp(char first, String op) {
+ switch(first) {
+ case '-' : return LSUB;
+ case '+' : return LADD;
+ case '%' : return LREM;
+ case '*' : return LMUL;
+ case '/' : return LDIV;
+ case '&' : return LAND;
+ case '|' : return LOR;
+ case '^' : return LXOR;
+ case '<' : return LSHL;
+ case '>' : return op.equals(">>>")? (ArithmeticInstruction)LUSHR :
+ (ArithmeticInstruction)LSHR;
+ default: throw new RuntimeException("Invalid operand " + op);
+ }
+ }
+
+ private static final ArithmeticInstruction createBinaryFloatOp(char op) {
+ switch(op) {
+ case '-' : return FSUB;
+ case '+' : return FADD;
+ case '*' : return FMUL;
+ case '/' : return FDIV;
+ default: throw new RuntimeException("Invalid operand " + op);
+ }
+ }
+
+ private static final ArithmeticInstruction createBinaryDoubleOp(char op) {
+ switch(op) {
+ case '-' : return DSUB;
+ case '+' : return DADD;
+ case '*' : return DMUL;
+ case '/' : return DDIV;
+ default: throw new RuntimeException("Invalid operand " + op);
+ }
+ }
+
+ /**
+ * Create binary operation for simple basic types, such as int and float.
+ *
+ * @param op operation, such as "+", "*", "<<", etc.
+ */
+ public static ArithmeticInstruction createBinaryOperation(String op, Type type) {
+ char first = op.toCharArray()[0];
+
+ switch(type.getType()) {
+ case Constants.T_BYTE:
+ case Constants.T_SHORT:
+ case Constants.T_INT:
+ case Constants.T_CHAR: return createBinaryIntOp(first, op);
+ case Constants.T_LONG: return createBinaryLongOp(first, op);
+ case Constants.T_FLOAT: return createBinaryFloatOp(first);
+ case Constants.T_DOUBLE: return createBinaryDoubleOp(first);
+ default: throw new RuntimeException("Invalid type " + type);
+ }
+ }
+
+ /**
+ * @param size size of operand, either 1 (int, e.g.) or 2 (double)
+ */
+ public static StackInstruction createPop(int size) {
+ return (size == 2)? (StackInstruction)POP2 :
+ (StackInstruction)POP;
+ }
+
+ /**
+ * @param size size of operand, either 1 (int, e.g.) or 2 (double)
+ */
+ public static StackInstruction createDup(int size) {
+ return (size == 2)? (StackInstruction)DUP2 :
+ (StackInstruction)DUP;
+ }
+
+ /**
+ * @param size size of operand, either 1 (int, e.g.) or 2 (double)
+ */
+ public static StackInstruction createDup_2(int size) {
+ return (size == 2)? (StackInstruction)DUP2_X2 :
+ (StackInstruction)DUP_X2;
+ }
+
+ /**
+ * @param size size of operand, either 1 (int, e.g.) or 2 (double)
+ */
+ public static StackInstruction createDup_1(int size) {
+ return (size == 2)? (StackInstruction)DUP2_X1 :
+ (StackInstruction)DUP_X1;
+ }
+
+ /**
+ * @param index index of local variable
+ */
+ public static LocalVariableInstruction createStore(Type type, int index) {
+ switch(type.getType()) {
+ case Constants.T_BOOLEAN:
+ case Constants.T_CHAR:
+ case Constants.T_BYTE:
+ case Constants.T_SHORT:
+ case Constants.T_INT: return new ISTORE(index);
+ case Constants.T_FLOAT: return new FSTORE(index);
+ case Constants.T_DOUBLE: return new DSTORE(index);
+ case Constants.T_LONG: return new LSTORE(index);
+ case Constants.T_ARRAY:
+ case Constants.T_OBJECT: return new ASTORE(index);
+ default: throw new RuntimeException("Invalid type " + type);
+ }
+ }
+
+ /**
+ * @param index index of local variable
+ */
+ public static LocalVariableInstruction createLoad(Type type, int index) {
+ switch(type.getType()) {
+ case Constants.T_BOOLEAN:
+ case Constants.T_CHAR:
+ case Constants.T_BYTE:
+ case Constants.T_SHORT:
+ case Constants.T_INT: return new ILOAD(index);
+ case Constants.T_FLOAT: return new FLOAD(index);
+ case Constants.T_DOUBLE: return new DLOAD(index);
+ case Constants.T_LONG: return new LLOAD(index);
+ case Constants.T_ARRAY:
+ case Constants.T_OBJECT: return new ALOAD(index);
+ default: throw new RuntimeException("Invalid type " + type);
+ }
+ }
+
+ /**
+ * @param type type of elements of array, i.e., array.getElementType()
+ */
+ public static ArrayInstruction createArrayLoad(Type type) {
+ switch(type.getType()) {
+ case Constants.T_BOOLEAN:
+ case Constants.T_BYTE: return BALOAD;
+ case Constants.T_CHAR: return CALOAD;
+ case Constants.T_SHORT: return SALOAD;
+ case Constants.T_INT: return IALOAD;
+ case Constants.T_FLOAT: return FALOAD;
+ case Constants.T_DOUBLE: return DALOAD;
+ case Constants.T_LONG: return LALOAD;
+ case Constants.T_ARRAY:
+ case Constants.T_OBJECT: return AALOAD;
+ default: throw new RuntimeException("Invalid type " + type);
+ }
+ }
+
+ /**
+ * @param type type of elements of array, i.e., array.getElementType()
+ */
+ public static ArrayInstruction createArrayStore(Type type) {
+ switch(type.getType()) {
+ case Constants.T_BOOLEAN:
+ case Constants.T_BYTE: return BASTORE;
+ case Constants.T_CHAR: return CASTORE;
+ case Constants.T_SHORT: return SASTORE;
+ case Constants.T_INT: return IASTORE;
+ case Constants.T_FLOAT: return FASTORE;
+ case Constants.T_DOUBLE: return DASTORE;
+ case Constants.T_LONG: return LASTORE;
+ case Constants.T_ARRAY:
+ case Constants.T_OBJECT: return AASTORE;
+ default: throw new RuntimeException("Invalid type " + type);
+ }
+ }
+
+
+ /** Create conversion operation for two stack operands, this may be an I2C, instruction, e.g.,
+ * if the operands are basic types and CHECKCAST if they are reference types.
+ */
+ public Instruction createCast(Type src_type, Type dest_type) {
+ if((src_type instanceof BasicType) && (dest_type instanceof BasicType)) {
+ byte dest = dest_type.getType();
+ byte src = src_type.getType();
+
+ if(dest == Constants.T_LONG && (src == Constants.T_CHAR || src == Constants.T_BYTE ||
+ src == Constants.T_SHORT))
+ src = Constants.T_INT;
+
+ String[] short_names = { "C", "F", "D", "B", "S", "I", "L" };
+
+ String name = "org.apache.bcel.generic." + short_names[src - Constants.T_CHAR] +
+ "2" + short_names[dest - Constants.T_CHAR];
+
+ Instruction i = null;
+ try {
+ i = (Instruction)java.lang.Class.forName(name).newInstance();
+ } catch(Exception e) {
+ throw new RuntimeException("Could not find instruction: " + name);
+ }
+
+ return i;
+ } else if((src_type instanceof ReferenceType) && (dest_type instanceof ReferenceType)) {
+ if(dest_type instanceof ArrayType)
+ return new CHECKCAST(cp.addArrayClass((ArrayType)dest_type));
+ else
+ return new CHECKCAST(cp.addClass(((ObjectType)dest_type).getClassName()));
+ }
+ else
+ throw new RuntimeException("Can not cast " + src_type + " to " + dest_type);
+ }
+
+ public GETFIELD createGetField(String class_name, String name, Type t) {
+ return new GETFIELD(cp.addFieldref(class_name, name, t.getSignature()));
+ }
+
+ public GETSTATIC createGetStatic(String class_name, String name, Type t) {
+ return new GETSTATIC(cp.addFieldref(class_name, name, t.getSignature()));
+ }
+
+ public PUTFIELD createPutField(String class_name, String name, Type t) {
+ return new PUTFIELD(cp.addFieldref(class_name, name, t.getSignature()));
+ }
+
+ public PUTSTATIC createPutStatic(String class_name, String name, Type t) {
+ return new PUTSTATIC(cp.addFieldref(class_name, name, t.getSignature()));
+ }
+
+ public CHECKCAST createCheckCast(ReferenceType t) {
+ if(t instanceof ArrayType)
+ return new CHECKCAST(cp.addArrayClass((ArrayType)t));
+ else
+ return new CHECKCAST(cp.addClass((ObjectType)t));
+ }
+
+ public NEW createNew(ObjectType t) {
+ return new NEW(cp.addClass(t));
+ }
+
+ public NEW createNew(String s) {
+ return createNew(new ObjectType(s));
+ }
+
+ /** Create new array of given size and type.
+ */
+ public AllocationInstruction createNewArray(Type t, short dim) {
+ if(dim == 1) {
+ if(t instanceof ObjectType)
+ return new ANEWARRAY(cp.addClass((ObjectType)t));
+ else if(t instanceof ArrayType)
+ return new ANEWARRAY(cp.addArrayClass((ArrayType)t));
+ else
+ return new NEWARRAY(((BasicType)t).getType());
+ } else {
+ ArrayType at;
+
+ if(t instanceof ArrayType)
+ at = (ArrayType)t;
+ else
+ at = new ArrayType(t, dim);
+
+ return new MULTIANEWARRAY(cp.addArrayClass(at), dim);
+ }
+ }
+
+ /** Create "null" value for reference types, 0 for basic types like int
+ */
+ public static Instruction createNull(Type type) {
+ switch(type.getType()) {
+ case Constants.T_ARRAY:
+ case Constants.T_OBJECT: return ACONST_NULL;
+ case Constants.T_INT:
+ case Constants.T_SHORT:
+ case Constants.T_BOOLEAN:
+ case Constants.T_CHAR:
+ case Constants.T_BYTE: return ICONST_0;
+ case Constants.T_FLOAT: return FCONST_0;
+ case Constants.T_DOUBLE: return DCONST_0;
+ case Constants.T_LONG: return LCONST_0;
+ case Constants.T_VOID: return NOP;
+
+ default:
+ throw new RuntimeException("Invalid type: " + type);
+ }
+ }
+
+ /** Create branch instruction by given opcode, except LOOKUPSWITCH and TABLESWITCH.
+ * For those you should use the SWITCH compeund instruction.
+ */
+ public static BranchInstruction createBranchInstruction(short opcode, InstructionHandle target) {
+ switch(opcode) {
+ case Constants.IFEQ: return new IFEQ(target);
+ case Constants.IFNE: return new IFNE(target);
+ case Constants.IFLT: return new IFLT(target);
+ case Constants.IFGE: return new IFGE(target);
+ case Constants.IFGT: return new IFGT(target);
+ case Constants.IFLE: return new IFLE(target);
+ case Constants.IF_ICMPEQ: return new IF_ICMPEQ(target);
+ case Constants.IF_ICMPNE: return new IF_ICMPNE(target);
+ case Constants.IF_ICMPLT: return new IF_ICMPLT(target);
+ case Constants.IF_ICMPGE: return new IF_ICMPGE(target);
+ case Constants.IF_ICMPGT: return new IF_ICMPGT(target);
+ case Constants.IF_ICMPLE: return new IF_ICMPLE(target);
+ case Constants.IF_ACMPEQ: return new IF_ACMPEQ(target);
+ case Constants.IF_ACMPNE: return new IF_ACMPNE(target);
+ case Constants.GOTO: return new GOTO(target);
+ case Constants.JSR: return new JSR(target);
+ case Constants.IFNULL: return new IFNULL(target);
+ case Constants.IFNONNULL: return new IFNONNULL(target);
+ case Constants.GOTO_W: return new GOTO_W(target);
+ case Constants.JSR_W: return new JSR_W(target);
+ default:
+ throw new RuntimeException("Invalid opcode: " + opcode);
+ }
+ }
+
+ public void setClassGen(ClassGen c) { cg = c; }
+ public ClassGen getClassGen() { return cg; }
+ public void setConstantPool(ConstantPoolGen c) { cp = c; }
+ public ConstantPoolGen getConstantPool() { return cp; }
+}
diff --git a/src/java/org/apache/bcel/generic/InstructionHandle.java b/src/java/org/apache/bcel/generic/InstructionHandle.java
new file mode 100644
index 00000000..2c6cc548
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/InstructionHandle.java
@@ -0,0 +1,284 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.classfile.Utility;
+import java.util.HashSet;
+import java.util.Collection;
+import java.util.HashMap;
+
+/**
+ * Instances of this class give users a handle to the instructions contained in
+ * an InstructionList. Instruction objects may be used more than once within a
+ * list, this is useful because it saves memory and may be much faster.
+ *
+ * Within an InstructionList an InstructionHandle object is wrapped
+ * around all instructions, i.e., it implements a cell in a
+ * doubly-linked list. From the outside only the next and the
+ * previous instruction (handle) are accessible. One
+ * can traverse the list via an Enumeration returned by
+ * InstructionList.elements().
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Instruction
+ * @see BranchHandle
+ * @see InstructionList
+ */
+public class InstructionHandle implements java.io.Serializable {
+ InstructionHandle next, prev; // Will be set from the outside
+ Instruction instruction;
+ protected int i_position = -1; // byte code offset of instruction
+ private HashSet targeters;
+ private HashMap attributes;
+
+ public final InstructionHandle getNext() { return next; }
+ public final InstructionHandle getPrev() { return prev; }
+ public final Instruction getInstruction() { return instruction; }
+
+ /**
+ * Replace current instruction contained in this handle.
+ * Old instruction is disposed using Instruction.dispose().
+ */
+ public void setInstruction(Instruction i) { // Overridden in BranchHandle
+ if(i == null)
+ throw new ClassGenException("Assigning null to handle");
+
+ if((this.getClass() != BranchHandle.class) && (i instanceof BranchInstruction))
+ throw new ClassGenException("Assigning branch instruction " + i + " to plain handle");
+
+ if(instruction != null)
+ instruction.dispose();
+
+ instruction = i;
+ }
+
+ /**
+ * Temporarily swap the current instruction, without disturbing
+ * anything. Meant to be used by a debugger, implementing
+ * breakpoints. Current instruction is returned.
+ */
+ public Instruction swapInstruction(Instruction i) {
+ Instruction oldInstruction = instruction;
+ instruction = i;
+ return oldInstruction;
+ }
+
+ /*private*/ protected InstructionHandle(Instruction i) {
+ setInstruction(i);
+ }
+
+ private static InstructionHandle ih_list = null; // List of reusable handles
+
+ /** Factory method.
+ */
+ static final InstructionHandle getInstructionHandle(Instruction i) {
+ if(ih_list == null)
+ return new InstructionHandle(i);
+ else {
+ InstructionHandle ih = ih_list;
+ ih_list = ih.next;
+
+ ih.setInstruction(i);
+
+ return ih;
+ }
+ }
+
+ /**
+ * Called by InstructionList.setPositions when setting the position for every
+ * instruction. In the presence of variable length instructions `setPositions()'
+ * performs multiple passes over the instruction list to calculate the
+ * correct (byte) positions and offsets by calling this function.
+ *
+ * @param offset additional offset caused by preceding (variable length) instructions
+ * @param max_offset the maximum offset that may be caused by these instructions
+ * @return additional offset caused by possible change of this instruction's length
+ */
+ protected int updatePosition(int offset, int max_offset) {
+ i_position += offset;
+ return 0;
+ }
+
+ /** @return the position, i.e., the byte code offset of the contained
+ * instruction. This is accurate only after
+ * InstructionList.setPositions() has been called.
+ */
+ public int getPosition() { return i_position; }
+
+ /** Set the position, i.e., the byte code offset of the contained
+ * instruction.
+ */
+ void setPosition(int pos) { i_position = pos; }
+
+ /** Overridden in BranchHandle
+ */
+ protected void addHandle() {
+ next = ih_list;
+ ih_list = this;
+ }
+
+ /**
+ * Delete contents, i.e., remove user access and make handle reusable.
+ */
+ void dispose() {
+ next = prev = null;
+ instruction.dispose();
+ instruction = null;
+ i_position = -1;
+ attributes = null;
+ removeAllTargeters();
+ addHandle();
+ }
+
+ /** Remove all targeters, if any.
+ */
+ public void removeAllTargeters() {
+ if(targeters != null)
+ targeters.clear();
+ }
+
+ /**
+ * Denote this handle isn't referenced anymore by t.
+ */
+ public void removeTargeter(InstructionTargeter t) {
+ targeters.remove(t);
+ }
+
+ /**
+ * Denote this handle is being referenced by t.
+ */
+ public void addTargeter(InstructionTargeter t) {
+ if(targeters == null)
+ targeters = new HashSet();
+
+ //if(!targeters.contains(t))
+ targeters.add(t);
+ }
+
+ public boolean hasTargeters() {
+ return (targeters != null) && (targeters.size() > 0);
+ }
+
+ /**
+ * @return null, if there are no targeters
+ */
+ public InstructionTargeter[] getTargeters() {
+ if(!hasTargeters())
+ return null;
+
+ InstructionTargeter[] t = new InstructionTargeter[targeters.size()];
+ targeters.toArray(t);
+ return t;
+ }
+
+ /** @return a (verbose) string representation of the contained instruction.
+ */
+ public String toString(boolean verbose) {
+ return Utility.format(i_position, 4, false, ' ') + ": " + instruction.toString(verbose);
+ }
+
+ /** @return a string representation of the contained instruction.
+ */
+ public String toString() {
+ return toString(true);
+ }
+
+ /** Add an attribute to an instruction handle.
+ *
+ * @param key the key object to store/retrieve the attribute
+ * @param attr the attribute to associate with this handle
+ */
+ public void addAttribute(Object key, Object attr) {
+ if(attributes == null)
+ attributes = new HashMap(3);
+
+ attributes.put(key, attr);
+ }
+
+ /** Delete an attribute of an instruction handle.
+ *
+ * @param key the key object to retrieve the attribute
+ */
+ public void removeAttribute(Object key) {
+ if(attributes != null)
+ attributes.remove(key);
+ }
+
+ /** Get attribute of an instruction handle.
+ *
+ * @param key the key object to store/retrieve the attribute
+ */
+ public Object getAttribute(Object key) {
+ if(attributes != null)
+ return attributes.get(key);
+
+ return null;
+ }
+
+ /** @return all attributes associated with this handle
+ */
+ public Collection getAttributes() {
+ return attributes.values();
+ }
+
+ /** Convenience method, simply calls accept() on the contained instruction.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ instruction.accept(v);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/InstructionList.java b/src/java/org/apache/bcel/generic/InstructionList.java
new file mode 100644
index 00000000..2d521967
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/InstructionList.java
@@ -0,0 +1,1287 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import org.apache.bcel.classfile.Constant;
+import org.apache.bcel.util.ByteSequence;
+import java.io.*;
+import java.util.Iterator;
+import java.util.HashMap;
+import java.util.ArrayList;
+
+/**
+ * This class is a container for a list of <a
+ * href="Instruction.html">Instruction</a> objects. Instructions can
+ * be appended, inserted, moved, deleted, etc.. Instructions are being
+ * wrapped into <a
+ * href="InstructionHandle.html">InstructionHandles</a> objects that
+ * are returned upon append/insert operations. They give the user
+ * (read only) access to the list structure, such that it can be traversed and
+ * manipulated in a controlled way.
+ *
+ * A list is finally dumped to a byte code array with <a
+ * href="#getByteCode()">getByteCode</a>.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Instruction
+ * @see InstructionHandle
+ * @see BranchHandle
+ */
+public class InstructionList implements Serializable {
+ private InstructionHandle start = null, end = null;
+ private int length = 0; // number of elements in list
+ private int[] byte_positions; // byte code offsets corresponding to instructions
+
+ /**
+ * Create (empty) instruction list.
+ */
+ public InstructionList() {}
+
+ /**
+ * Create instruction list containing one instruction.
+ * @param i initial instruction
+ */
+ public InstructionList(Instruction i) {
+ append(i);
+ }
+
+ /**
+ * Create instruction list containing one instruction.
+ * @param i initial instruction
+ */
+ public InstructionList(BranchInstruction i) {
+ append(i);
+ }
+
+ /**
+ * Initialize list with (nonnull) compound instruction. Consumes argument
+ * list, i.e., it becomes empty.
+ *
+ * @param c compound instruction (list)
+ */
+ public InstructionList(CompoundInstruction c) {
+ append(c.getInstructionList());
+ }
+
+ /**
+ * Test for empty list.
+ */
+ public boolean isEmpty() { return start == null; } // && end == null
+
+ /**
+ * Find the target instruction (handle) that corresponds to the given target
+ * position (byte code offset).
+ *
+ * @param ihs array of instruction handles, i.e. il.getInstructionHandles()
+ * @param pos array of positions corresponding to ihs, i.e. il.getInstructionPositions()
+ * @param count length of arrays
+ * @param target target position to search for
+ * @return target position's instruction handle if available
+ */
+ public static InstructionHandle findHandle(InstructionHandle[] ihs,
+ int[] pos, int count,
+ int target) {
+ int l=0, r = count - 1;
+
+ /* Do a binary search since the pos array is orderd.
+ */
+ do {
+ int i = (l + r) / 2;
+ int j = pos[i];
+
+ if(j == target) // target found
+ return ihs[i];
+ else if(target < j) // else constrain search area
+ r = i - 1;
+ else // target > j
+ l = i + 1;
+ } while(l <= r);
+
+ return null;
+ }
+
+ /**
+ * Get instruction handle for instruction at byte code position pos.
+ * This only works properly, if the list is freshly initialized from a byte array or
+ * setPositions() has been called before this method.
+ *
+ * @param pos byte code position to search for
+ * @return target position's instruction handle if available
+ */
+ public InstructionHandle findHandle(int pos) {
+ InstructionHandle[] ihs = getInstructionHandles();
+ return findHandle(ihs, byte_positions, length, pos);
+ }
+
+ /**
+ * Initialize instruction list from byte array.
+ *
+ * @param code byte array containing the instructions
+ */
+ public InstructionList(byte[] code) {
+ ByteSequence bytes = new ByteSequence(code);
+ InstructionHandle[] ihs = new InstructionHandle[code.length];
+ int[] pos = new int[code.length]; // Can't be more than that
+ int count = 0; // Contains actual length
+
+ /* Pass 1: Create an object for each byte code and append them
+ * to the list.
+ */
+ try {
+ while(bytes.available() > 0) {
+ // Remember byte offset and associate it with the instruction
+ int off = bytes.getIndex();
+ pos[count] = off;
+
+ /* Read one instruction from the byte stream, the byte position is set
+ * accordingly.
+ */
+ Instruction i = Instruction.readInstruction(bytes);
+ InstructionHandle ih;
+ if(i instanceof BranchInstruction) // Use proper append() method
+ ih = append((BranchInstruction)i);
+ else
+ ih = append(i);
+
+ ih.setPosition(off);
+ ihs[count] = ih;
+
+ count++;
+ }
+ } catch(IOException e) { throw new ClassGenException(e.toString()); }
+
+ byte_positions = new int[count]; // Trim to proper size
+ System.arraycopy(pos, 0, byte_positions, 0, count);
+
+ /* Pass 2: Look for BranchInstruction and update their targets, i.e.,
+ * convert offsets to instruction handles.
+ */
+ for(int i=0; i < count; i++) {
+ if(ihs[i] instanceof BranchHandle) {
+ BranchInstruction bi = (BranchInstruction)ihs[i].instruction;
+ int target = bi.position + bi.getIndex(); /* Byte code position:
+ * relative -> absolute. */
+ // Search for target position
+ InstructionHandle ih = findHandle(ihs, pos, count, target);
+
+ if(ih == null) // Search failed
+ throw new ClassGenException("Couldn't find target for branch: " + bi);
+
+ bi.setTarget(ih); // Update target
+
+ // If it is a Select instruction, update all branch targets
+ if(bi instanceof Select) { // Either LOOKUPSWITCH or TABLESWITCH
+ Select s = (Select)bi;
+ int[] indices = s.getIndices();
+
+ for(int j=0; j < indices.length; j++) {
+ target = bi.position + indices[j];
+ ih = findHandle(ihs, pos, count, target);
+
+ if(ih == null) // Search failed
+ throw new ClassGenException("Couldn't find target for switch: " + bi);
+
+ s.setTarget(j, ih); // Update target
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Append another list after instruction (handle) ih contained in this list.
+ * Consumes argument list, i.e., it becomes empty.
+ *
+ * @param ih where to append the instruction list
+ * @param il Instruction list to append to this one
+ * @return instruction handle pointing to the <B>first</B> appended instruction
+ */
+ public InstructionHandle append(InstructionHandle ih, InstructionList il) {
+ if(il == null)
+ throw new ClassGenException("Appending null InstructionList");
+
+ if(il.isEmpty()) // Nothing to do
+ return ih;
+
+ InstructionHandle next = ih.next, ret = il.start;
+
+ ih.next = il.start;
+ il.start.prev = ih;
+
+ il.end.next = next;
+
+ if(next != null) // i == end ?
+ next.prev = il.end;
+ else
+ end = il.end; // Update end ...
+
+ length += il.length; // Update length
+
+ il.clear();
+
+ return ret;
+ }
+
+ /**
+ * Append another list after instruction i contained in this list.
+ * Consumes argument list, i.e., it becomes empty.
+ *
+ * @param i where to append the instruction list
+ * @param il Instruction list to append to this one
+ * @return instruction handle pointing to the <B>first</B> appended instruction
+ */
+ public InstructionHandle append(Instruction i, InstructionList il) {
+ InstructionHandle ih;
+
+ if((ih = findInstruction2(i)) == null) // Also applies for empty list
+ throw new ClassGenException("Instruction " + i +
+ " is not contained in this list.");
+
+ return append(ih, il);
+ }
+
+ /**
+ * Append another list to this one.
+ * Consumes argument list, i.e., it becomes empty.
+ *
+ * @param il list to append to end of this list
+ * @return instruction handle of the <B>first</B> appended instruction
+ */
+ public InstructionHandle append(InstructionList il) {
+ if(il == null)
+ throw new ClassGenException("Appending null InstructionList");
+
+ if(il.isEmpty()) // Nothing to do
+ return null;
+
+ if(isEmpty()) {
+ start = il.start;
+ end = il.end;
+ length = il.length;
+
+ il.clear();
+
+ return start;
+ } else
+ return append(end, il); // was end.instruction
+ }
+
+ /**
+ * Append an instruction to the end of this list.
+ *
+ * @param ih instruction to append
+ */
+ private void append(InstructionHandle ih) {
+ if(isEmpty()) {
+ start = end = ih;
+ ih.next = ih.prev = null;
+ }
+ else {
+ end.next = ih;
+ ih.prev = end;
+ ih.next = null;
+ end = ih;
+ }
+
+ length++; // Update length
+ }
+
+ /**
+ * Append an instruction to the end of this list.
+ *
+ * @param i instruction to append
+ * @return instruction handle of the appended instruction
+ */
+ public InstructionHandle append(Instruction i) {
+ InstructionHandle ih = InstructionHandle.getInstructionHandle(i);
+ append(ih);
+
+ return ih;
+ }
+
+ /**
+ * Append a branch instruction to the end of this list.
+ *
+ * @param i branch instruction to append
+ * @return branch instruction handle of the appended instruction
+ */
+ public BranchHandle append(BranchInstruction i) {
+ BranchHandle ih = BranchHandle.getBranchHandle(i);
+ append(ih);
+
+ return ih;
+ }
+
+ /**
+ * Append a single instruction j after another instruction i, which
+ * must be in this list of course!
+ *
+ * @param i Instruction in list
+ * @param j Instruction to append after i in list
+ * @return instruction handle of the first appended instruction
+ */
+ public InstructionHandle append(Instruction i, Instruction j) {
+ return append(i, new InstructionList(j));
+ }
+
+ /**
+ * Append a compound instruction, after instruction i.
+ *
+ * @param i Instruction in list
+ * @param c The composite instruction (containing an InstructionList)
+ * @return instruction handle of the first appended instruction
+ */
+ public InstructionHandle append(Instruction i, CompoundInstruction c) {
+ return append(i, c.getInstructionList());
+ }
+
+ /**
+ * Append a compound instruction.
+ *
+ * @param c The composite instruction (containing an InstructionList)
+ * @return instruction handle of the first appended instruction
+ */
+ public InstructionHandle append(CompoundInstruction c) {
+ return append(c.getInstructionList());
+ }
+
+ /**
+ * Append a compound instruction.
+ *
+ * @param ih where to append the instruction list
+ * @param c The composite instruction (containing an InstructionList)
+ * @return instruction handle of the first appended instruction
+ */
+ public InstructionHandle append(InstructionHandle ih, CompoundInstruction c) {
+ return append(ih, c.getInstructionList());
+ }
+
+ /**
+ * Append an instruction after instruction (handle) ih contained in this list.
+ *
+ * @param ih where to append the instruction list
+ * @param i Instruction to append
+ * @return instruction handle pointing to the <B>first</B> appended instruction
+ */
+ public InstructionHandle append(InstructionHandle ih, Instruction i) {
+ return append(ih, new InstructionList(i));
+ }
+
+ /**
+ * Append an instruction after instruction (handle) ih contained in this list.
+ *
+ * @param ih where to append the instruction list
+ * @param i Instruction to append
+ * @return instruction handle pointing to the <B>first</B> appended instruction
+ */
+ public BranchHandle append(InstructionHandle ih, BranchInstruction i) {
+ BranchHandle bh = BranchHandle.getBranchHandle(i);
+ InstructionList il = new InstructionList();
+ il.append(bh);
+
+ append(ih, il);
+
+ return bh;
+ }
+
+ /**
+ * Insert another list before Instruction handle ih contained in this list.
+ * Consumes argument list, i.e., it becomes empty.
+ *
+ * @param i where to append the instruction list
+ * @param il Instruction list to insert
+ * @return instruction handle of the first inserted instruction
+ */
+ public InstructionHandle insert(InstructionHandle ih, InstructionList il) {
+ if(il == null)
+ throw new ClassGenException("Inserting null InstructionList");
+
+ if(il.isEmpty()) // Nothing to do
+ return ih;
+
+ InstructionHandle prev = ih.prev, ret = il.start;
+
+ ih.prev = il.end;
+ il.end.next = ih;
+
+ il.start.prev = prev;
+
+ if(prev != null) // ih == start ?
+ prev.next = il.start;
+ else
+ start = il.start; // Update start ...
+
+ length += il.length; // Update length
+
+ il.clear();
+
+ return ret;
+ }
+
+ /**
+ * Insert another list.
+ *
+ * @param il list to insert before start of this list
+ * @return instruction handle of the first inserted instruction
+ */
+ public InstructionHandle insert(InstructionList il) {
+ if(isEmpty()) {
+ append(il); // Code is identical for this case
+ return start;
+ }
+ else
+ return insert(start, il);
+ }
+
+ /**
+ * Insert an instruction at start of this list.
+ *
+ * @param ih instruction to insert
+ */
+ private void insert(InstructionHandle ih) {
+ if(isEmpty()) {
+ start = end = ih;
+ ih.next = ih.prev = null;
+ } else {
+ start.prev = ih;
+ ih.next = start;
+ ih.prev = null;
+ start = ih;
+ }
+
+ length++;
+ }
+
+ /**
+ * Insert another list before Instruction i contained in this list.
+ * Consumes argument list, i.e., it becomes empty.
+ *
+ * @param i where to append the instruction list
+ * @param il Instruction list to insert
+ * @return instruction handle pointing to the first inserted instruction,
+ * i.e., il.getStart()
+ */
+ public InstructionHandle insert(Instruction i, InstructionList il) {
+ InstructionHandle ih;
+
+ if((ih = findInstruction1(i)) == null)
+ throw new ClassGenException("Instruction " + i +
+ " is not contained in this list.");
+
+ return insert(ih, il);
+ }
+
+ /**
+ * Insert an instruction at start of this list.
+ *
+ * @param i instruction to insert
+ * @return instruction handle of the inserted instruction
+ */
+ public InstructionHandle insert(Instruction i) {
+ InstructionHandle ih = InstructionHandle.getInstructionHandle(i);
+ insert(ih);
+
+ return ih;
+ }
+
+ /**
+ * Insert a branch instruction at start of this list.
+ *
+ * @param i branch instruction to insert
+ * @return branch instruction handle of the appended instruction
+ */
+ public BranchHandle insert(BranchInstruction i) {
+ BranchHandle ih = BranchHandle.getBranchHandle(i);
+ insert(ih);
+ return ih;
+ }
+
+ /**
+ * Insert a single instruction j before another instruction i, which
+ * must be in this list of course!
+ *
+ * @param i Instruction in list
+ * @param j Instruction to insert before i in list
+ * @return instruction handle of the first inserted instruction
+ */
+ public InstructionHandle insert(Instruction i, Instruction j) {
+ return insert(i, new InstructionList(j));
+ }
+
+ /**
+ * Insert a compound instruction before instruction i.
+ *
+ * @param i Instruction in list
+ * @param c The composite instruction (containing an InstructionList)
+ * @return instruction handle of the first inserted instruction
+ */
+ public InstructionHandle insert(Instruction i, CompoundInstruction c) {
+ return insert(i, c.getInstructionList());
+ }
+
+ /**
+ * Insert a compound instruction.
+ *
+ * @param c The composite instruction (containing an InstructionList)
+ * @return instruction handle of the first inserted instruction
+ */
+ public InstructionHandle insert(CompoundInstruction c) {
+ return insert(c.getInstructionList());
+ }
+
+ /**
+ * Insert an instruction before instruction (handle) ih contained in this list.
+ *
+ * @param ih where to insert to the instruction list
+ * @param i Instruction to insert
+ * @return instruction handle of the first inserted instruction
+ */
+ public InstructionHandle insert(InstructionHandle ih, Instruction i) {
+ return insert(ih, new InstructionList(i));
+ }
+
+ /**
+ * Insert a compound instruction.
+ *
+ * @param ih where to insert the instruction list
+ * @param c The composite instruction (containing an InstructionList)
+ * @return instruction handle of the first inserted instruction
+ */
+ public InstructionHandle insert(InstructionHandle ih, CompoundInstruction c) {
+ return insert(ih, c.getInstructionList());
+ }
+
+ /**
+ * Insert an instruction before instruction (handle) ih contained in this list.
+ *
+ * @param ih where to insert to the instruction list
+ * @param i Instruction to insert
+ * @return instruction handle of the first inserted instruction
+ */
+ public BranchHandle insert(InstructionHandle ih, BranchInstruction i) {
+ BranchHandle bh = BranchHandle.getBranchHandle(i);
+ InstructionList il = new InstructionList();
+ il.append(bh);
+
+ insert(ih, il);
+
+ return bh;
+ }
+
+ /**
+ * Take all instructions (handles) from "start" to "end" and append them after the
+ * new location "target". Of course, "end" must be after "start" and target must
+ * not be located withing this range. If you want to move something to the start of
+ * the list use null as value for target.<br>
+ * Any instruction targeters pointing to handles within the block, keep their targets.
+ *
+ * @param start of moved block
+ * @param end of moved block
+ * @param target of moved block
+ */
+ public void move(InstructionHandle start, InstructionHandle end, InstructionHandle target) {
+ // Step 1: Check constraints
+
+ if((start == null) || (end == null))
+ throw new ClassGenException("Invalid null handle: From " + start + " to " + end);
+
+ if((target == start) || (target == end))
+ throw new ClassGenException("Invalid range: From " + start + " to " + end +
+ " contains target " + target);
+
+ for(InstructionHandle ih = start; ih != end.next; ih = ih.next) {
+ if(ih == null) // At end of list, end not found yet
+ throw new ClassGenException("Invalid range: From " + start + " to " + end);
+ else if(ih == target) // target may be null
+ throw new ClassGenException("Invalid range: From " + start + " to " + end +
+ " contains target " + target);
+ }
+
+ // Step 2: Temporarily remove the given instructions from the list
+
+ InstructionHandle prev = start.prev, next = end.next;
+
+ if(prev != null)
+ prev.next = next;
+ else // start == this.start!
+ this.start = next;
+
+ if(next != null)
+ next.prev = prev;
+ else // end == this.end!
+ this.end = prev;
+
+ start.prev = end.next = null;
+
+ // Step 3: append after target
+
+ if(target == null) { // append to start of list
+ end.next = this.start;
+ this.start = start;
+ } else {
+ next = target.next;
+
+ target.next = start;
+ start.prev = target;
+ end.next = next;
+
+ if(next != null)
+ next.prev = end;
+ }
+ }
+
+ /**
+ * Move a single instruction (handle) to a new location.
+ *
+ * @param ih moved instruction
+ * @param target new location of moved instruction
+ */
+ public void move(InstructionHandle ih, InstructionHandle target) {
+ move(ih, ih, target);
+ }
+
+ /**
+ * Remove from instruction `prev' to instruction `next' both contained
+ * in this list. Throws TargetLostException when one of the removed instruction handles
+ * is still being targeted.
+ *
+ * @param prev where to start deleting (predecessor, exclusive)
+ * @param next where to end deleting (successor, exclusive)
+ */
+ private void remove(InstructionHandle prev, InstructionHandle next)
+ throws TargetLostException
+ {
+ InstructionHandle first, last; // First and last deleted instruction
+
+ if((prev == null) && (next == null)) { // singleton list
+ first = last = start;
+ start = end = null;
+ } else {
+ if(prev == null) { // At start of list
+ first = start;
+ start = next;
+ } else {
+ first = prev.next;
+ prev.next = next;
+ }
+
+ if(next == null) { // At end of list
+ last = end;
+ end = prev;
+ } else {
+ last = next.prev;
+ next.prev = prev;
+ }
+ }
+
+ first.prev = null; // Completely separated from rest of list
+ last.next = null;
+
+ ArrayList target_vec = new ArrayList();
+
+ for(InstructionHandle ih=first; ih != null; ih = ih.next)
+ ih.getInstruction().dispose(); // e.g. BranchInstructions release their targets
+
+ StringBuffer buf = new StringBuffer("{ ");
+ for(InstructionHandle ih=first; ih != null; ih = next) {
+ next = ih.next;
+ length--;
+
+ if(ih.hasTargeters()) { // Still got targeters?
+ target_vec.add(ih);
+ buf.append(ih.toString(true) + " ");
+ ih.next = ih.prev = null;
+ } else
+ ih.dispose();
+ }
+
+ buf.append("}");
+
+ if(!target_vec.isEmpty()) {
+ InstructionHandle[] targeted = new InstructionHandle[target_vec.size()];
+ target_vec.toArray(targeted);
+ throw new TargetLostException(targeted, buf.toString());
+ }
+ }
+
+ /**
+ * Remove instruction from this list. The corresponding Instruction
+ * handles must not be reused!
+ *
+ * @param ih instruction (handle) to remove
+ */
+ public void delete(InstructionHandle ih) throws TargetLostException {
+ remove(ih.prev, ih.next);
+ }
+
+ /**
+ * Remove instruction from this list. The corresponding Instruction
+ * handles must not be reused!
+ *
+ * @param i instruction to remove
+ */
+ public void delete(Instruction i) throws TargetLostException {
+ InstructionHandle ih;
+
+ if((ih = findInstruction1(i)) == null)
+ throw new ClassGenException("Instruction " + i +
+ " is not contained in this list.");
+ delete(ih);
+ }
+
+ /**
+ * Remove instructions from instruction `from' to instruction `to' contained
+ * in this list. The user must ensure that `from' is an instruction before
+ * `to', or risk havoc. The corresponding Instruction handles must not be reused!
+ *
+ * @param from where to start deleting (inclusive)
+ * @param to where to end deleting (inclusive)
+ */
+ public void delete(InstructionHandle from, InstructionHandle to)
+ throws TargetLostException
+ {
+ remove(from.prev, to.next);
+ }
+
+ /**
+ * Remove instructions from instruction `from' to instruction `to' contained
+ * in this list. The user must ensure that `from' is an instruction before
+ * `to', or risk havoc. The corresponding Instruction handles must not be reused!
+ *
+ * @param from where to start deleting (inclusive)
+ * @param to where to end deleting (inclusive)
+ */
+ public void delete(Instruction from, Instruction to) throws TargetLostException {
+ InstructionHandle from_ih, to_ih;
+
+ if((from_ih = findInstruction1(from)) == null)
+ throw new ClassGenException("Instruction " + from +
+ " is not contained in this list.");
+
+ if((to_ih = findInstruction2(to)) == null)
+ throw new ClassGenException("Instruction " + to +
+ " is not contained in this list.");
+ delete(from_ih, to_ih);
+ }
+
+ /**
+ * Search for given Instruction reference, start at beginning of list.
+ *
+ * @param i instruction to search for
+ * @return instruction found on success, null otherwise
+ */
+ private InstructionHandle findInstruction1(Instruction i) {
+ for(InstructionHandle ih=start; ih != null; ih = ih.next)
+ if(ih.instruction == i)
+ return ih;
+
+ return null;
+ }
+
+ /**
+ * Search for given Instruction reference, start at end of list
+ *
+ * @param i instruction to search for
+ * @return instruction found on success, null otherwise
+ */
+ private InstructionHandle findInstruction2(Instruction i) {
+ for(InstructionHandle ih=end; ih != null; ih = ih.prev)
+ if(ih.instruction == i)
+ return ih;
+
+ return null;
+ }
+
+ public boolean contains(InstructionHandle i) {
+ if(i == null)
+ return false;
+
+ for(InstructionHandle ih=start; ih != null; ih = ih.next)
+ if(ih == i)
+ return true;
+
+ return false;
+ }
+
+ public boolean contains(Instruction i) {
+ return findInstruction1(i) != null;
+ }
+
+ public void setPositions() {
+ setPositions(false);
+ }
+
+ /**
+ * Give all instructions their position number (offset in byte stream), i.e.,
+ * make the list ready to be dumped.
+ *
+ * @param check Perform sanity checks, e.g. if all targeted instructions really belong
+ * to this list
+ */
+ public void setPositions(boolean check) {
+ int max_additional_bytes = 0, additional_bytes = 0;
+ int index = 0, count = 0;
+ int[] pos = new int[length];
+
+ /* Pass 0: Sanity checks
+ */
+ if(check) {
+ for(InstructionHandle ih=start; ih != null; ih = ih.next) {
+ Instruction i = ih.instruction;
+
+ if(i instanceof BranchInstruction) { // target instruction within list?
+ Instruction inst = ((BranchInstruction)i).getTarget().instruction;
+ if(!contains(inst))
+ throw new ClassGenException("Branch target of " +
+ Constants.OPCODE_NAMES[i.opcode] + ":" +
+ inst + " not in instruction list");
+
+ if(i instanceof Select) {
+ InstructionHandle[] targets = ((Select)i).getTargets();
+
+ for(int j=0; j < targets.length; j++) {
+ inst = targets[j].instruction;
+ if(!contains(inst))
+ throw new ClassGenException("Branch target of " +
+ Constants.OPCODE_NAMES[i.opcode] + ":" +
+ inst + " not in instruction list");
+ }
+ }
+
+ if(!(ih instanceof BranchHandle))
+ throw new ClassGenException("Branch instruction " +
+ Constants.OPCODE_NAMES[i.opcode] + ":" +
+ inst + " not contained in BranchHandle.");
+
+ }
+ }
+ }
+
+ /* Pass 1: Set position numbers and sum up the maximum number of bytes an
+ * instruction may be shifted.
+ */
+ for(InstructionHandle ih=start; ih != null; ih = ih.next) {
+ Instruction i = ih.instruction;
+
+ ih.setPosition(index);
+ pos[count++] = index;
+
+ /* Get an estimate about how many additional bytes may be added, because
+ * BranchInstructions may have variable length depending on the target
+ * offset (short vs. int) or alignment issues (TABLESWITCH and
+ * LOOKUPSWITCH).
+ */
+ switch(i.getOpcode()) {
+ case Constants.JSR: case Constants.GOTO:
+ max_additional_bytes += 2;
+ break;
+
+ case Constants.TABLESWITCH: case Constants.LOOKUPSWITCH:
+ max_additional_bytes += 3;
+ break;
+ }
+
+ index += i.getLength();
+ }
+
+ /* Pass 2: Expand the variable-length (Branch)Instructions depending on
+ * the target offset (short or int) and ensure that branch targets are
+ * within this list.
+ */
+ for(InstructionHandle ih=start; ih != null; ih = ih.next)
+ additional_bytes += ih.updatePosition(additional_bytes, max_additional_bytes);
+
+ /* Pass 3: Update position numbers (which may have changed due to the
+ * preceding expansions), like pass 1.
+ */
+ index=count=0;
+ for(InstructionHandle ih=start; ih != null; ih = ih.next) {
+ Instruction i = ih.instruction;
+
+ ih.setPosition(index);
+ pos[count++] = index;
+ index += i.getLength();
+ }
+
+ byte_positions = new int[count]; // Trim to proper size
+ System.arraycopy(pos, 0, byte_positions, 0, count);
+ }
+
+ /**
+ * When everything is finished, use this method to convert the instruction
+ * list into an array of bytes.
+ *
+ * @return the byte code ready to be dumped
+ */
+ public byte[] getByteCode() {
+ // Update position indices of instructions
+ setPositions();
+
+ ByteArrayOutputStream b = new ByteArrayOutputStream();
+ DataOutputStream out = new DataOutputStream(b);
+
+ try {
+ for(InstructionHandle ih=start; ih != null; ih = ih.next) {
+ Instruction i = ih.instruction;
+ i.dump(out); // Traverse list
+ }
+ } catch(IOException e) {
+ System.err.println(e);
+ return null;
+ }
+
+ return b.toByteArray();
+ }
+
+ /**
+ * @return an array of instructions without target information for branch instructions.
+ */
+ public Instruction[] getInstructions() {
+ ByteSequence bytes = new ByteSequence(getByteCode());
+ ArrayList instructions = new ArrayList();
+
+ try {
+ while(bytes.available() > 0) {
+ instructions.add(Instruction.readInstruction(bytes));
+ }
+ } catch(IOException e) { throw new ClassGenException(e.toString()); }
+
+ Instruction[] result = new Instruction[instructions.size()];
+ instructions.toArray(result);
+ return result;
+ }
+
+ public String toString() {
+ return toString(true);
+ }
+
+ /**
+ * @param verbose toggle output format
+ * @return String containing all instructions in this list.
+ */
+ public String toString(boolean verbose) {
+ StringBuffer buf = new StringBuffer();
+
+ for(InstructionHandle ih=start; ih != null; ih = ih.next) {
+ buf.append(ih.toString(verbose) + "\n");
+ }
+
+ return buf.toString();
+ }
+
+ /**
+ * @return Enumeration that lists all instructions (handles)
+ */
+ public Iterator iterator() {
+ return new Iterator() {
+ private InstructionHandle ih = start;
+
+ public Object next() {
+ InstructionHandle i = ih;
+ ih = ih.next;
+ return i;
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean hasNext() { return ih != null; }
+ };
+ }
+
+ /**
+ * @return array containing all instructions (handles)
+ */
+ public InstructionHandle[] getInstructionHandles() {
+ InstructionHandle[] ihs = new InstructionHandle[length];
+ InstructionHandle ih = start;
+
+ for(int i=0; i < length; i++) {
+ ihs[i] = ih;
+ ih = ih.next;
+ }
+
+ return ihs;
+ }
+
+ /**
+ * Get positions (offsets) of all instructions in the list. This relies on that
+ * the list has been freshly created from an byte code array, or that setPositions()
+ * has been called. Otherwise this may be inaccurate.
+ *
+ * @return array containing all instruction's offset in byte code
+ */
+ public int[] getInstructionPositions() { return byte_positions; }
+
+ /**
+ * @return complete, i.e., deep copy of this list
+ */
+ public InstructionList copy() {
+ HashMap map = new HashMap();
+ InstructionList il = new InstructionList();
+
+ /* Pass 1: Make copies of all instructions, append them to the new list
+ * and associate old instruction references with the new ones, i.e.,
+ * a 1:1 mapping.
+ */
+ for(InstructionHandle ih=start; ih != null; ih = ih.next) {
+ Instruction i = ih.instruction;
+ Instruction c = i.copy(); // Use clone for shallow copy
+
+ if(c instanceof BranchInstruction)
+ map.put(ih, il.append((BranchInstruction)c));
+ else
+ map.put(ih, il.append(c));
+ }
+
+ /* Pass 2: Update branch targets.
+ */
+ InstructionHandle ih=start;
+ InstructionHandle ch=il.start;
+
+ while(ih != null) {
+ Instruction i = ih.instruction;
+ Instruction c = ch.instruction;
+
+ if(i instanceof BranchInstruction) {
+ BranchInstruction bi = (BranchInstruction)i;
+ BranchInstruction bc = (BranchInstruction)c;
+ InstructionHandle itarget = bi.getTarget(); // old target
+
+ // New target is in hash map
+ bc.setTarget((InstructionHandle)map.get(itarget));
+
+ if(bi instanceof Select) { // Either LOOKUPSWITCH or TABLESWITCH
+ InstructionHandle[] itargets = ((Select)bi).getTargets();
+ InstructionHandle[] ctargets = ((Select)bc).getTargets();
+
+ for(int j=0; j < itargets.length; j++) { // Update all targets
+ ctargets[j] = (InstructionHandle)map.get(itargets[j]);
+ }
+ }
+ }
+
+ ih = ih.next;
+ ch = ch.next;
+ }
+
+ return il;
+ }
+
+ /** Replace all references to the old constant pool with references to the new
+ * constant pool
+ */
+ public void replaceConstantPool(ConstantPoolGen old_cp, ConstantPoolGen new_cp) {
+ for(InstructionHandle ih=start; ih != null; ih = ih.next) {
+ Instruction i = ih.instruction;
+
+ if(i instanceof CPInstruction) {
+ CPInstruction ci = (CPInstruction)i;
+ Constant c = old_cp.getConstant(ci.getIndex());
+ ci.setIndex(new_cp.addConstant(c, old_cp));
+ }
+ }
+ }
+
+ private void clear() {
+ start = end = null;
+ length = 0;
+ }
+
+ /**
+ * Delete contents of list. Provides besser memory utilization,
+ * because the system then may reuse the instruction handles. This
+ * method is typically called right after
+ * <href="MethodGen.html#getMethod()">MethodGen.getMethod()</a>.
+ */
+ public void dispose() {
+ // Traverse in reverse order, because ih.next is overwritten
+ for(InstructionHandle ih=end; ih != null; ih = ih.prev)
+ /* Causes BranchInstructions to release target and targeters, because it
+ * calls dispose() on the contained instruction.
+ */
+ ih.dispose();
+
+ clear();
+ }
+
+ /**
+ * @return start of list
+ */
+ public InstructionHandle getStart() { return start; }
+
+ /**
+ * @return end of list
+ */
+ public InstructionHandle getEnd() { return end; }
+
+ /**
+ * @return length of list (Number of instructions, not bytes)
+ */
+ public int getLength() { return length; }
+
+ /**
+ * @return length of list (Number of instructions, not bytes)
+ */
+ public int size() { return length; }
+
+ /**
+ * Redirect all references from old_target to new_target, i.e., update targets
+ * of branch instructions.
+ *
+ * @param old_target the old target instruction handle
+ * @param new_target the new target instruction handle
+ */
+ public void redirectBranches(InstructionHandle old_target,
+ InstructionHandle new_target) {
+ for(InstructionHandle ih = start; ih != null; ih = ih.next) {
+ Instruction i = ih.getInstruction();
+
+ if(i instanceof BranchInstruction) {
+ BranchInstruction b = (BranchInstruction)i;
+ InstructionHandle target = b.getTarget();
+
+ if(target == old_target)
+ b.setTarget(new_target);
+
+ if(b instanceof Select) { // Either LOOKUPSWITCH or TABLESWITCH
+ InstructionHandle[] targets = ((Select)b).getTargets();
+
+ for(int j=0; j < targets.length; j++) // Update targets
+ if(targets[j] == old_target)
+ ((Select)b).setTarget(j, new_target);
+ }
+ }
+ }
+ }
+
+ /**
+ * Redirect all references of local variables from old_target to new_target.
+ *
+ * @@param lg array of local variables
+ * @@param old_target the old target instruction handle
+ * @@param new_target the new target instruction handle
+ * @@see MethodGen
+ */
+ public void redirectLocalVariables(LocalVariableGen[] lg,
+ InstructionHandle old_target,
+ InstructionHandle new_target) {
+ for(int i=0; i < lg.length; i++) {
+ InstructionHandle start = lg[i].getStart();
+ InstructionHandle end = lg[i].getEnd();
+
+ if(start == old_target)
+ lg[i].setStart(new_target);
+
+ if(end == old_target)
+ lg[i].setEnd(new_target);
+ }
+ }
+
+ /**
+ * Redirect all references of exception handlers from old_target to new_target.
+ *
+ * @@param exceptions array of exception handlers
+ * @@param old_target the old target instruction handle
+ * @@param new_target the new target instruction handle
+ * @@see MethodGen
+ */
+ public void redirectExceptionHandlers(CodeExceptionGen[] exceptions,
+ InstructionHandle old_target,
+ InstructionHandle new_target) {
+ for(int i=0; i < exceptions.length; i++) {
+ if(exceptions[i].getStartPC() == old_target)
+ exceptions[i].setStartPC(new_target);
+
+ if(exceptions[i].getEndPC() == old_target)
+ exceptions[i].setEndPC(new_target);
+
+ if(exceptions[i].getHandlerPC() == old_target)
+ exceptions[i].setHandlerPC(new_target);
+ }
+ }
+
+ private ArrayList observers;
+
+ /** Add observer for this object.
+ */
+ public void addObserver(InstructionListObserver o) {
+ if(observers == null)
+ observers = new ArrayList();
+
+ observers.add(o);
+ }
+
+ /** Remove observer for this object.
+ */
+ public void removeObserver(InstructionListObserver o) {
+ if(observers != null)
+ observers.remove(o);
+ }
+
+ /** Call notify() method on all observers. This method is not called
+ * automatically whenever the state has changed, but has to be
+ * called by the user after he has finished editing the object.
+ */
+ public void update() {
+ if(observers != null)
+ for(Iterator e = observers.iterator(); e.hasNext(); )
+ ((InstructionListObserver)e.next()).notify(this);
+ }
+}
+
diff --git a/src/java/org/apache/bcel/generic/InstructionListObserver.java b/src/java/org/apache/bcel/generic/InstructionListObserver.java
new file mode 100644
index 00000000..96bc647f
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/InstructionListObserver.java
@@ -0,0 +1,67 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Implement this interface if you're interested in changes to an InstructionList object
+ * and register yourself with addObserver().
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public interface InstructionListObserver {
+ public void notify(InstructionList list);
+}
+
diff --git a/src/java/org/apache/bcel/generic/InstructionTargeter.java b/src/java/org/apache/bcel/generic/InstructionTargeter.java
new file mode 100644
index 00000000..77e03adf
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/InstructionTargeter.java
@@ -0,0 +1,70 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Denote that a class targets InstructionHandles within an InstructionList. Namely
+ * the following implementers:
+ *
+ * @see BranchHandle
+ * @see LocalVariableGen
+ * @see CodeExceptionGen
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public interface InstructionTargeter {
+ public boolean containsTarget(InstructionHandle ih);
+ public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih);
+}
diff --git a/src/java/org/apache/bcel/generic/InvokeInstruction.java b/src/java/org/apache/bcel/generic/InvokeInstruction.java
new file mode 100644
index 00000000..70981203
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/InvokeInstruction.java
@@ -0,0 +1,146 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import org.apache.bcel.Constants;
+import org.apache.bcel.classfile.*;
+import java.util.StringTokenizer;
+
+/**
+ * Super class for the INVOKExxx family of instructions.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public abstract class InvokeInstruction extends FieldOrMethod
+ implements ExceptionThrower, TypedInstruction, StackConsumer, StackProducer {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ InvokeInstruction() {}
+
+ /**
+ * @param index to constant pool
+ */
+ protected InvokeInstruction(short opcode, int index) {
+ super(opcode, index);
+ }
+
+ /**
+ * @return mnemonic for instruction with symbolic references resolved
+ */
+ public String toString(ConstantPool cp) {
+ Constant c = cp.getConstant(index);
+ StringTokenizer tok = new StringTokenizer(cp.constantToString(c));
+
+ return Constants.OPCODE_NAMES[opcode] + " " +
+ tok.nextToken().replace('.', '/') + tok.nextToken();
+ }
+
+ /**
+ * Also works for instructions whose stack effect depends on the
+ * constant pool entry they reference.
+ * @return Number of words consumed from stack by this instruction
+ */
+ public int consumeStack(ConstantPoolGen cpg) {
+ String signature = getSignature(cpg);
+ Type[] args = Type.getArgumentTypes(signature);
+ int sum;
+
+ if(opcode == Constants.INVOKESTATIC)
+ sum = 0;
+ else
+ sum = 1; // this reference
+
+ int n = args.length;
+ for (int i = 0; i < n; i++)
+ sum += args[i].getSize();
+
+ return sum;
+ }
+
+ /**
+ * Also works for instructions whose stack effect depends on the
+ * constant pool entry they reference.
+ * @return Number of words produced onto stack by this instruction
+ */
+ public int produceStack(ConstantPoolGen cpg) {
+ return getReturnType(cpg).getSize();
+ }
+
+ /** @return return type of referenced method.
+ */
+ public Type getType(ConstantPoolGen cpg) {
+ return getReturnType(cpg);
+ }
+
+ /** @return name of referenced method.
+ */
+ public String getMethodName(ConstantPoolGen cpg) {
+ return getName(cpg);
+ }
+
+ /** @return return type of referenced method.
+ */
+ public Type getReturnType(ConstantPoolGen cpg) {
+ return Type.getReturnType(getSignature(cpg));
+ }
+
+ /** @return argument types of referenced method.
+ */
+ public Type[] getArgumentTypes(ConstantPoolGen cpg) {
+ return Type.getArgumentTypes(getSignature(cpg));
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/JSR.java b/src/java/org/apache/bcel/generic/JSR.java
new file mode 100644
index 00000000..920e14d5
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/JSR.java
@@ -0,0 +1,119 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import java.io.*;
+
+/**
+ * JSR - Jump to subroutine
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class JSR extends JsrInstruction implements VariableLengthInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ JSR() {}
+
+ public JSR(InstructionHandle target) {
+ super(org.apache.bcel.Constants.JSR, target);
+ }
+
+ /**
+ * Dump instruction as byte code to stream out.
+ * @param out Output stream
+ */
+ public void dump(DataOutputStream out) throws IOException {
+ index = getTargetOffset();
+ if(opcode == org.apache.bcel.Constants.JSR)
+ super.dump(out);
+ else { // JSR_W
+ index = getTargetOffset();
+ out.writeByte(opcode);
+ out.writeInt(index);
+ }
+ }
+
+ protected int updatePosition(int offset, int max_offset) {
+ int i = getTargetOffset(); // Depending on old position value
+
+ position += offset; // Position may be shifted by preceding expansions
+
+ if(Math.abs(i) >= (32767 - max_offset)) { // to large for short (estimate)
+ opcode = org.apache.bcel.Constants.JSR_W;
+ length = 5;
+ return 2; // 5 - 3
+ }
+
+ return 0;
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackProducer(this);
+ v.visitVariableLengthInstruction(this);
+ v.visitBranchInstruction(this);
+ v.visitJsrInstruction(this);
+ v.visitJSR(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/JSR_W.java b/src/java/org/apache/bcel/generic/JSR_W.java
new file mode 100644
index 00000000..789ef037
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/JSR_W.java
@@ -0,0 +1,110 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import java.io.*;
+import org.apache.bcel.util.ByteSequence;
+
+/**
+ * JSR_W - Jump to subroutine
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class JSR_W extends JsrInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ JSR_W() {}
+
+ public JSR_W(InstructionHandle target) {
+ super(org.apache.bcel.Constants.JSR_W, target);
+ length = 5;
+ }
+
+ /**
+ * Dump instruction as byte code to stream out.
+ * @param out Output stream
+ */
+ public void dump(DataOutputStream out) throws IOException {
+ index = getTargetOffset();
+ out.writeByte(opcode);
+ out.writeInt(index);
+ }
+
+ /**
+ * Read needed data (e.g. index) from file.
+ */
+ protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
+ {
+ index = bytes.readInt();
+ length = 5;
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackProducer(this);
+ v.visitBranchInstruction(this);
+ v.visitJsrInstruction(this);
+ v.visitJSR_W(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/JsrInstruction.java b/src/java/org/apache/bcel/generic/JsrInstruction.java
new file mode 100644
index 00000000..e5a4a4f8
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/JsrInstruction.java
@@ -0,0 +1,116 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Super class for JSR - Jump to subroutine
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public abstract class JsrInstruction extends BranchInstruction
+ implements UnconditionalBranch, TypedInstruction, StackProducer
+{
+ JsrInstruction(short opcode, InstructionHandle target) {
+ super(opcode, target);
+ }
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ JsrInstruction(){}
+
+ /** @return return address type
+ */
+ public Type getType(ConstantPoolGen cp) {
+ return new ReturnaddressType(physicalSuccessor());
+ }
+
+
+ /**
+ * Returns an InstructionHandle to the physical successor
+ * of this JsrInstruction. <B>For this method to work,
+ * this JsrInstruction object must not be shared between
+ * multiple InstructionHandle objects!</B>
+ * Formally, there must not be InstructionHandle objects
+ * i, j where i != j and i.getInstruction() == this ==
+ * j.getInstruction().
+ * @return an InstructionHandle to the "next" instruction that
+ * will be executed when RETurned from a subroutine.
+ */
+ public InstructionHandle physicalSuccessor(){
+ InstructionHandle ih = this.target;
+
+ // Rewind!
+ while(ih.getPrev() != null)
+ ih = ih.getPrev();
+
+ // Find the handle for "this" JsrInstruction object.
+ while(ih.getInstruction() != this)
+ ih = ih.getNext();
+
+ InstructionHandle toThis = ih;
+
+ while(ih != null){
+ ih = ih.getNext();
+ if ((ih != null) && (ih.getInstruction() == this))
+ throw new RuntimeException("physicalSuccessor() called on a shared JsrInstruction.");
+ }
+
+ // Return the physical successor
+ return toThis.getNext();
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/L2D.java b/src/java/org/apache/bcel/generic/L2D.java
new file mode 100644
index 00000000..8edc5e02
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/L2D.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * L2D - Convert long to double
+ * <PRE>Stack: ..., value.word1, value.word2 -&gt; ..., result.word1, result.word2</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class L2D extends ConversionInstruction {
+ public L2D() {
+ super(org.apache.bcel.Constants.L2D);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitConversionInstruction(this);
+ v.visitL2D(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/L2F.java b/src/java/org/apache/bcel/generic/L2F.java
new file mode 100644
index 00000000..c996dc68
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/L2F.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * L2F - Convert long to float
+ * <PRE>Stack: ..., value.word1, value.word2 -&gt; ..., result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class L2F extends ConversionInstruction {
+ public L2F() {
+ super(org.apache.bcel.Constants.L2F);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitConversionInstruction(this);
+ v.visitL2F(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/L2I.java b/src/java/org/apache/bcel/generic/L2I.java
new file mode 100644
index 00000000..c52d346d
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/L2I.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * L2I - Convert long to int
+ * <PRE>Stack: ..., value.word1, value.word2 -&gt; ..., result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class L2I extends ConversionInstruction {
+ public L2I() {
+ super(org.apache.bcel.Constants.L2I);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitConversionInstruction(this);
+ v.visitL2I(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/LADD.java b/src/java/org/apache/bcel/generic/LADD.java
new file mode 100644
index 00000000..006adaaf
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LADD.java
@@ -0,0 +1,86 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * LADD - Add longs
+ * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;</PRE>
+ * ..., result.word1, result.word2
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class LADD extends ArithmeticInstruction {
+ public LADD() {
+ super(org.apache.bcel.Constants.LADD);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitLADD(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/LALOAD.java b/src/java/org/apache/bcel/generic/LALOAD.java
new file mode 100644
index 00000000..a61d37a4
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LALOAD.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * LALOAD - Load long from array
+ * <PRE>Stack: ..., arrayref, index -&gt; ..., value1, value2</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class LALOAD extends ArrayInstruction implements StackProducer {
+ /** Load long from array
+ */
+ public LALOAD() {
+ super(org.apache.bcel.Constants.LALOAD);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackProducer(this);
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitArrayInstruction(this);
+ v.visitLALOAD(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/LAND.java b/src/java/org/apache/bcel/generic/LAND.java
new file mode 100644
index 00000000..ab56ad50
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LAND.java
@@ -0,0 +1,86 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * LAND - Bitwise AND longs
+ * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;</PRE>
+ * ..., result.word1, result.word2
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class LAND extends ArithmeticInstruction {
+ public LAND() {
+ super(org.apache.bcel.Constants.LAND);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitLAND(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/LASTORE.java b/src/java/org/apache/bcel/generic/LASTORE.java
new file mode 100644
index 00000000..7aff0803
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LASTORE.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * LASTORE - Store into long array
+ * <PRE>Stack: ..., arrayref, index, value.word1, value.word2 -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class LASTORE extends ArrayInstruction implements StackConsumer {
+ /** Store long into array
+ */
+ public LASTORE() {
+ super(org.apache.bcel.Constants.LASTORE);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitArrayInstruction(this);
+ v.visitLASTORE(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/LCMP.java b/src/java/org/apache/bcel/generic/LCMP.java
new file mode 100644
index 00000000..b5b707bf
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LCMP.java
@@ -0,0 +1,82 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * LCMP - Compare longs:
+ * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;</PRE>
+ * ..., result <= -1, 0, 1>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class LCMP extends Instruction {
+ public LCMP() {
+ super(org.apache.bcel.Constants.LCMP, (short)1);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitLCMP(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/LCONST.java b/src/java/org/apache/bcel/generic/LCONST.java
new file mode 100644
index 00000000..a0ca5433
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LCONST.java
@@ -0,0 +1,112 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * LCONST - Push 0 or 1, other values cause an exception
+ *
+ * <PRE>Stack: ... -&gt; ..., <i></PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class LCONST extends Instruction
+ implements ConstantPushInstruction, TypedInstruction {
+ private long value;
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ LCONST() {}
+
+ public LCONST(long l) {
+ super(org.apache.bcel.Constants.LCONST_0, (short)1);
+
+ if(l == 0)
+ opcode = org.apache.bcel.Constants.LCONST_0;
+ else if(l == 1)
+ opcode = org.apache.bcel.Constants.LCONST_1;
+ else
+ throw new ClassGenException("LCONST can be used only for 0 and 1: " + l);
+
+ value = l;
+ }
+
+ public Number getValue() { return new Long(value); }
+
+ /** @return Type.LONG
+ */
+ public Type getType(ConstantPoolGen cp) {
+ return Type.LONG;
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitPushInstruction(this);
+ v.visitStackProducer(this);
+ v.visitTypedInstruction(this);
+ v.visitConstantPushInstruction(this);
+ v.visitLCONST(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/LDC.java b/src/java/org/apache/bcel/generic/LDC.java
new file mode 100644
index 00000000..2782ccd9
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LDC.java
@@ -0,0 +1,172 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import java.io.*;
+import org.apache.bcel.util.ByteSequence;
+
+/**
+ * LDC - Push item from constant pool.
+ *
+ * <PRE>Stack: ... -&gt; ..., item</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class LDC extends CPInstruction
+ implements PushInstruction, ExceptionThrower, TypedInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ LDC() {}
+
+ public LDC(int index) {
+ super(org.apache.bcel.Constants.LDC_W, index);
+ setSize();
+ }
+
+ // Adjust to proper size
+ protected final void setSize() {
+ if(index <= org.apache.bcel.Constants.MAX_BYTE) { // Fits in one byte?
+ opcode = org.apache.bcel.Constants.LDC;
+ length = 2;
+ } else {
+ opcode = org.apache.bcel.Constants.LDC_W;
+ length = 3;
+ }
+ }
+
+ /**
+ * Dump instruction as byte code to stream out.
+ * @param out Output stream
+ */
+ public void dump(DataOutputStream out) throws IOException {
+ out.writeByte(opcode);
+
+ if(length == 2)
+ out.writeByte(index);
+ else // Applies for LDC_W
+ out.writeShort(index);
+ }
+
+ /**
+ * Set the index to constant pool and adjust size.
+ */
+ public final void setIndex(int index) {
+ super.setIndex(index);
+ setSize();
+ }
+
+ /**
+ * Read needed data (e.g. index) from file.
+ */
+ protected void initFromFile(ByteSequence bytes, boolean wide)
+ throws IOException
+ {
+ length = 2;
+ index = bytes.readUnsignedByte();
+ }
+
+ public Object getValue(ConstantPoolGen cpg) {
+ org.apache.bcel.classfile.Constant c = cpg.getConstantPool().getConstant(index);
+
+ switch(c.getTag()) {
+ case org.apache.bcel.Constants.CONSTANT_String:
+ int i = ((org.apache.bcel.classfile.ConstantString)c).getStringIndex();
+ c = cpg.getConstantPool().getConstant(i);
+ return ((org.apache.bcel.classfile.ConstantUtf8)c).getBytes();
+
+ case org.apache.bcel.Constants.CONSTANT_Float:
+ return new Float(((org.apache.bcel.classfile.ConstantFloat)c).getBytes());
+
+ case org.apache.bcel.Constants.CONSTANT_Integer:
+ return new Integer(((org.apache.bcel.classfile.ConstantInteger)c).getBytes());
+
+ default: // Never reached
+ throw new RuntimeException("Unknown or invalid constant type at " + index);
+ }
+ }
+
+ public Type getType(ConstantPoolGen cpg) {
+ switch(cpg.getConstantPool().getConstant(index).getTag()) {
+ case org.apache.bcel.Constants.CONSTANT_String: return Type.STRING;
+ case org.apache.bcel.Constants.CONSTANT_Float: return Type.FLOAT;
+ case org.apache.bcel.Constants.CONSTANT_Integer: return Type.INT;
+ default: // Never reached
+ throw new RuntimeException("Unknown or invalid constant type at " + index);
+ }
+ }
+
+ public Class[] getExceptions() {
+ return org.apache.bcel.ExceptionConstants.EXCS_STRING_RESOLUTION;
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackProducer(this);
+ v.visitPushInstruction(this);
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitCPInstruction(this);
+ v.visitLDC(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/LDC2_W.java b/src/java/org/apache/bcel/generic/LDC2_W.java
new file mode 100644
index 00000000..d576767d
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LDC2_W.java
@@ -0,0 +1,116 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * LDC2_W - Push long or double from constant pool
+ *
+ * <PRE>Stack: ... -&gt; ..., item.word1, item.word2</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class LDC2_W extends CPInstruction
+ implements PushInstruction, TypedInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ LDC2_W() {}
+
+ public LDC2_W(int index) {
+ super(org.apache.bcel.Constants.LDC2_W, index);
+ }
+
+ public Type getType(ConstantPoolGen cpg) {
+ switch(cpg.getConstantPool().getConstant(index).getTag()) {
+ case org.apache.bcel.Constants.CONSTANT_Long: return Type.LONG;
+ case org.apache.bcel.Constants.CONSTANT_Double: return Type.DOUBLE;
+ default: // Never reached
+ throw new RuntimeException("Unknown constant type " + opcode);
+ }
+ }
+
+ public Number getValue(ConstantPoolGen cpg) {
+ org.apache.bcel.classfile.Constant c = cpg.getConstantPool().getConstant(index);
+
+ switch(c.getTag()) {
+ case org.apache.bcel.Constants.CONSTANT_Long:
+ return new Long(((org.apache.bcel.classfile.ConstantLong)c).getBytes());
+
+ case org.apache.bcel.Constants.CONSTANT_Double:
+ return new Double(((org.apache.bcel.classfile.ConstantDouble)c).getBytes());
+
+ default: // Never reached
+ throw new RuntimeException("Unknown or invalid constant type at " + index);
+ }
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackProducer(this);
+ v.visitPushInstruction(this);
+ v.visitTypedInstruction(this);
+ v.visitCPInstruction(this);
+ v.visitLDC2_W(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/LDC_W.java b/src/java/org/apache/bcel/generic/LDC_W.java
new file mode 100644
index 00000000..1e658dea
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LDC_W.java
@@ -0,0 +1,87 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import java.io.IOException;
+import org.apache.bcel.util.ByteSequence;
+
+/**
+ * LDC_W - Push item from constant pool (wide index)
+ *
+ * <PRE>Stack: ... -&gt; ..., item.word1, item.word2</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class LDC_W extends LDC {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ LDC_W() {}
+
+ public LDC_W(int index) {
+ super(index);
+ }
+
+ /**
+ * Read needed data (i.e., index) from file.
+ */
+ protected void initFromFile(ByteSequence bytes, boolean wide)
+ throws IOException
+ {
+ setIndex(bytes.readUnsignedShort());
+ length = 3;
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/LDIV.java b/src/java/org/apache/bcel/generic/LDIV.java
new file mode 100644
index 00000000..fad7a9a8
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LDIV.java
@@ -0,0 +1,91 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * LDIV - Divide longs
+ * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;</PRE>
+ * ..., result.word1, result.word2
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class LDIV extends ArithmeticInstruction implements ExceptionThrower {
+ public LDIV() {
+ super(org.apache.bcel.Constants.LDIV);
+ }
+
+ public Class[] getExceptions() {
+ return new Class[] { org.apache.bcel.ExceptionConstants.ARITHMETIC_EXCEPTION };
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitLDIV(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/LLOAD.java b/src/java/org/apache/bcel/generic/LLOAD.java
new file mode 100644
index 00000000..bd61c2bd
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LLOAD.java
@@ -0,0 +1,89 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * LLOAD - Load long from local variable
+ *<PRE>Stack ... -&GT; ..., result.word1, result.word2</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class LLOAD extends LoadInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ LLOAD() {
+ super(org.apache.bcel.Constants.LLOAD, org.apache.bcel.Constants.LLOAD_0);
+ }
+
+ public LLOAD(int n) {
+ super(org.apache.bcel.Constants.LLOAD, org.apache.bcel.Constants.LLOAD_0, n);
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ super.accept(v);
+ v.visitLLOAD(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/LMUL.java b/src/java/org/apache/bcel/generic/LMUL.java
new file mode 100644
index 00000000..c7c6dd50
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LMUL.java
@@ -0,0 +1,86 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * LMUL - Multiply longs
+ * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;</PRE>
+ * ..., result.word1, result.word2
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class LMUL extends ArithmeticInstruction {
+ public LMUL() {
+ super(org.apache.bcel.Constants.LMUL);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitLMUL(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/LNEG.java b/src/java/org/apache/bcel/generic/LNEG.java
new file mode 100644
index 00000000..ae43ce81
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LNEG.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * LNEG - Negate long
+ * <PRE>Stack: ..., value.word1, value.word2 -&gt; ..., result.word1, result.word2</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class LNEG extends ArithmeticInstruction {
+ public LNEG() {
+ super(org.apache.bcel.Constants.LNEG);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitLNEG(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/LOOKUPSWITCH.java b/src/java/org/apache/bcel/generic/LOOKUPSWITCH.java
new file mode 100644
index 00000000..af87245a
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LOOKUPSWITCH.java
@@ -0,0 +1,133 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import java.io.*;
+import org.apache.bcel.util.ByteSequence;
+
+/**
+ * LOOKUPSWITCH - Switch with unordered set of values
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see SWITCH
+ */
+public class LOOKUPSWITCH extends Select {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ LOOKUPSWITCH() {}
+
+ public LOOKUPSWITCH(int[] match, InstructionHandle[] targets,
+ InstructionHandle target) {
+ super(org.apache.bcel.Constants.LOOKUPSWITCH, match, targets, target);
+
+ length = (short)(9 + match_length * 8); /* alignment remainder assumed
+ * 0 here, until dump time. */
+ fixed_length = length;
+ }
+
+ /**
+ * Dump instruction as byte code to stream out.
+ * @param out Output stream
+ */
+ public void dump(DataOutputStream out) throws IOException {
+ super.dump(out);
+ out.writeInt(match_length); // npairs
+
+ for(int i=0; i < match_length; i++) {
+ out.writeInt(match[i]); // match-offset pairs
+ out.writeInt(indices[i] = getTargetOffset(targets[i]));
+ }
+ }
+
+ /**
+ * Read needed data (e.g. index) from file.
+ */
+ protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
+ {
+ super.initFromFile(bytes, wide); // reads padding
+
+ match_length = bytes.readInt();
+ fixed_length = (short)(9 + match_length * 8);
+ length = (short)(fixed_length + padding);
+
+ match = new int[match_length];
+ indices = new int[match_length];
+ targets = new InstructionHandle[match_length];
+
+ for(int i=0; i < match_length; i++) {
+ match[i] = bytes.readInt();
+ indices[i] = bytes.readInt();
+ }
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitVariableLengthInstruction(this);
+ v.visitStackProducer(this);
+ v.visitBranchInstruction(this);
+ v.visitSelect(this);
+ v.visitLOOKUPSWITCH(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/LOR.java b/src/java/org/apache/bcel/generic/LOR.java
new file mode 100644
index 00000000..4eda00d1
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LOR.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * LOR - Bitwise OR long
+ * <PRE>Stack: ..., value1, value2 -&gt; ..., result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class LOR extends ArithmeticInstruction {
+ public LOR() {
+ super(org.apache.bcel.Constants.LOR);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitLOR(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/LREM.java b/src/java/org/apache/bcel/generic/LREM.java
new file mode 100644
index 00000000..f985c275
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LREM.java
@@ -0,0 +1,88 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * LREM - Remainder of long
+ * <PRE>Stack: ..., value1, value2 -&gt; result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class LREM extends ArithmeticInstruction implements ExceptionThrower {
+ public LREM() {
+ super(org.apache.bcel.Constants.LREM);
+ }
+
+ public Class[] getExceptions() { return new Class[] { org.apache.bcel.ExceptionConstants.ARITHMETIC_EXCEPTION }; }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitLREM(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/LRETURN.java b/src/java/org/apache/bcel/generic/LRETURN.java
new file mode 100644
index 00000000..090206a6
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LRETURN.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * LRETURN - Return long from method
+ * <PRE>Stack: ..., value.word1, value.word2 -&gt; &lt;empty&gt;</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class LRETURN extends ReturnInstruction {
+ public LRETURN() {
+ super(org.apache.bcel.Constants.LRETURN);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitStackConsumer(this);
+ v.visitReturnInstruction(this);
+ v.visitLRETURN(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/LSHL.java b/src/java/org/apache/bcel/generic/LSHL.java
new file mode 100644
index 00000000..25eb8a36
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LSHL.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * LSHL - Arithmetic shift left long
+ * <PRE>Stack: ..., value1.word1, value1.word2, value2 -&gt; ..., result.word1, result.word2</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class LSHL extends ArithmeticInstruction {
+ public LSHL() {
+ super(org.apache.bcel.Constants.LSHL);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitLSHL(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/LSHR.java b/src/java/org/apache/bcel/generic/LSHR.java
new file mode 100644
index 00000000..73fdc0a1
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LSHR.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * LSHR - Arithmetic shift right long
+ * <PRE>Stack: ..., value1.word1, value1.word2, value2 -&gt; ..., result.word1, result.word2</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class LSHR extends ArithmeticInstruction {
+ public LSHR() {
+ super(org.apache.bcel.Constants.LSHR);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitLSHR(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/LSTORE.java b/src/java/org/apache/bcel/generic/LSTORE.java
new file mode 100644
index 00000000..0f9ad29d
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LSTORE.java
@@ -0,0 +1,89 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * LSTORE - Store long into local variable
+ * <PRE>Stack: ..., value.word1, value.word2 -&gt; ... </PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class LSTORE extends StoreInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ LSTORE() {
+ super(org.apache.bcel.Constants.LSTORE, org.apache.bcel.Constants.LSTORE_0);
+ }
+
+ public LSTORE(int n) {
+ super(org.apache.bcel.Constants.LSTORE, org.apache.bcel.Constants.LSTORE_0, n);
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ super.accept(v);
+ v.visitLSTORE(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/LSUB.java b/src/java/org/apache/bcel/generic/LSUB.java
new file mode 100644
index 00000000..1863abfe
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LSUB.java
@@ -0,0 +1,86 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * LSUB - Substract longs
+ * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;</PRE>
+ * ..., result.word1, result.word2
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class LSUB extends ArithmeticInstruction {
+ public LSUB() {
+ super(org.apache.bcel.Constants.LSUB);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitLSUB(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/LUSHR.java b/src/java/org/apache/bcel/generic/LUSHR.java
new file mode 100644
index 00000000..fdc2f97d
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LUSHR.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * LUSHR - Logical shift right long
+ * <PRE>Stack: ..., value1, value2 -&gt; ..., result</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class LUSHR extends ArithmeticInstruction {
+ public LUSHR() {
+ super(org.apache.bcel.Constants.LUSHR);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitLUSHR(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/LXOR.java b/src/java/org/apache/bcel/generic/LXOR.java
new file mode 100644
index 00000000..8e72cf12
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LXOR.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * LXOR - Bitwise XOR long
+ * <PRE>Stack: ..., value1, value2 -&gt; ..., result</PRE>
+ *
+ * @version $Id$
+ * @authXOR <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class LXOR extends ArithmeticInstruction {
+ public LXOR() {
+ super(org.apache.bcel.Constants.LXOR);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitTypedInstruction(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitArithmeticInstruction(this);
+ v.visitLXOR(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/LineNumberGen.java b/src/java/org/apache/bcel/generic/LineNumberGen.java
new file mode 100644
index 00000000..38ed2fa0
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LineNumberGen.java
@@ -0,0 +1,130 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import org.apache.bcel.classfile.*;
+
+/**
+ * This class represents a line number within a method, i.e., give an instruction
+ * a line number corresponding to the source code line.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see LineNumber
+ * @see MethodGen
+ */
+public class LineNumberGen implements InstructionTargeter, Cloneable {
+ private InstructionHandle ih;
+ private int src_line;
+
+ /**
+ * Create a line number.
+ *
+ * @param ih instruction handle to reference
+ * @return new line number object
+ */
+ public LineNumberGen(InstructionHandle ih, int src_line) {
+ setInstruction(ih);
+ setSourceLine(src_line);
+ }
+
+ /**
+ * @return true, if ih is target of this line number
+ */
+ public boolean containsTarget(InstructionHandle ih) {
+ return this.ih == ih;
+ }
+
+ /**
+ * @param old_ih old target
+ * @param new_ih new target
+ */
+ public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) {
+ if(old_ih != ih)
+ throw new ClassGenException("Not targeting " + old_ih + ", but " + ih + "}");
+ else
+ setInstruction(new_ih);
+ }
+
+ /**
+ * Get LineNumber attribute .
+ *
+ * This relies on that the instruction list has already been dumped to byte code or
+ * or that the `setPositions' methods has been called for the instruction list.
+ */
+ public LineNumber getLineNumber() {
+ return new LineNumber(ih.getPosition(), src_line);
+ }
+
+ public void setInstruction(InstructionHandle ih) {
+ BranchInstruction.notifyTarget(this.ih, ih, this);
+
+ this.ih = ih;
+ }
+
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch(CloneNotSupportedException e) {
+ System.err.println(e);
+ return null;
+ }
+ }
+
+ public InstructionHandle getInstruction() { return ih; }
+ public void setSourceLine(int src_line) { this.src_line = src_line; }
+ public int getSourceLine() { return src_line; }
+}
diff --git a/src/java/org/apache/bcel/generic/LoadClass.java b/src/java/org/apache/bcel/generic/LoadClass.java
new file mode 100644
index 00000000..7226d56a
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LoadClass.java
@@ -0,0 +1,86 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Denotes that an instruction may start the process of loading and resolving
+ * the referenced class in the Virtual Machine.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public interface LoadClass {
+ /**
+ * Returns the ObjectType of the referenced class or interface
+ * that may be loaded and resolved.
+ * @return object type that may be loaded or null if a primitive is
+ * referenced
+ */
+ public ObjectType getLoadClassType(ConstantPoolGen cpg);
+
+ /**
+ * Returns the type associated with this instruction.
+ * LoadClass instances are always typed, but this type
+ * does not always refer to the type of the class or interface
+ * that it possibly forces to load. For example, GETFIELD would
+ * return the type of the field and not the type of the class
+ * where the field is defined.
+ * If no class is forced to be loaded, <B>null</B> is returned.
+ * An example for this is an ANEWARRAY instruction that creates
+ * an int[][].
+ * @see #getLoadClassType(ConstantPoolGen)
+ */
+ public Type getType(ConstantPoolGen cpg);
+}
diff --git a/src/java/org/apache/bcel/generic/LoadInstruction.java b/src/java/org/apache/bcel/generic/LoadInstruction.java
new file mode 100644
index 00000000..34f20ad1
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LoadInstruction.java
@@ -0,0 +1,101 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Denotes an unparameterized instruction to load a value from a local
+ * variable, e.g. ILOAD.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public abstract class LoadInstruction extends LocalVariableInstruction
+ implements PushInstruction
+{
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ * tag and length are defined in readInstruction and initFromFile, respectively.
+ */
+ LoadInstruction(short canon_tag, short c_tag) {
+ super(canon_tag, c_tag);
+ }
+
+ /**
+ * @param opcode Instruction opcode
+ * @param c_tag Instruction number for compact version, ALOAD_0, e.g.
+ * @param n local variable index (unsigned short)
+ */
+ protected LoadInstruction(short opcode, short c_tag, int n) {
+ super(opcode, c_tag, n);
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackProducer(this);
+ v.visitPushInstruction(this);
+ v.visitTypedInstruction(this);
+ v.visitLocalVariableInstruction(this);
+ v.visitLoadInstruction(this);
+ }
+}
+
diff --git a/src/java/org/apache/bcel/generic/LocalVariableGen.java b/src/java/org/apache/bcel/generic/LocalVariableGen.java
new file mode 100644
index 00000000..482848ff
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LocalVariableGen.java
@@ -0,0 +1,191 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import org.apache.bcel.classfile.*;
+
+/**
+ * This class represents a local variable within a method. It contains its
+ * scope, name and type. The generated LocalVariable object can be obtained
+ * with getLocalVariable which needs the instruction list and the constant
+ * pool as parameters.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see LocalVariable
+ * @see MethodGen
+ */
+public class LocalVariableGen implements InstructionTargeter, NamedAndTyped, Cloneable {
+ private int index;
+ private String name;
+ private Type type;
+ private InstructionHandle start, end;
+
+ /**
+ * Generate a local variable that with index `index'. Note that double and long
+ * variables need two indexs. Index indices have to be provided by the user.
+ *
+ * @param index index of local variable
+ * @param name its name
+ * @param type its type
+ * @param start from where the instruction is valid (null means from the start)
+ * @param end until where the instruction is valid (null means to the end)
+ */
+ public LocalVariableGen(int index, String name, Type type,
+ InstructionHandle start, InstructionHandle end) {
+ if((index < 0) || (index > Constants.MAX_SHORT))
+ throw new ClassGenException("Invalid index index: " + index);
+
+ this.name = name;
+ this.type = type;
+ this.index = index;
+ setStart(start);
+ setEnd(end);
+ }
+
+ /**
+ * Get LocalVariable object.
+ *
+ * This relies on that the instruction list has already been dumped to byte code or
+ * or that the `setPositions' methods has been called for the instruction list.
+ *
+ * @param il instruction list (byte code) which this variable belongs to
+ * @param cp constant pool
+ */
+ public LocalVariable getLocalVariable(ConstantPoolGen cp) {
+ int start_pc = start.getPosition();
+ int length = end.getPosition() - start_pc;
+ int name_index = cp.addUtf8(name);
+ int signature_index = cp.addUtf8(type.getSignature());
+
+ return new LocalVariable(start_pc, length, name_index,
+ signature_index, index, cp.getConstantPool());
+ }
+
+ public void setIndex(int index) { this.index = index; }
+ public int getIndex() { return index; }
+ public void setName(String name) { this.name = name; }
+ public String getName() { return name; }
+ public void setType(Type type) { this.type = type; }
+ public Type getType() { return type; }
+
+ public InstructionHandle getStart() { return start; }
+ public InstructionHandle getEnd() { return end; }
+
+ public void setStart(InstructionHandle start) {
+ BranchInstruction.notifyTarget(this.start, start, this);
+ this.start = start;
+ }
+
+ public void setEnd(InstructionHandle end) {
+ BranchInstruction.notifyTarget(this.end, end, this);
+ this.end = end;
+ }
+
+ /**
+ * @param old_ih old target, either start or end
+ * @param new_ih new target
+ */
+ public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) {
+ boolean targeted = false;
+
+ if(start == old_ih) {
+ targeted = true;
+ setStart(new_ih);
+ }
+
+ if(end == old_ih) {
+ targeted = true;
+ setEnd(new_ih);
+ }
+
+ if(!targeted)
+ throw new ClassGenException("Not targeting " + old_ih + ", but {" + start + ", " +
+ end + "}");
+ }
+
+ /**
+ * @return true, if ih is target of this variable
+ */
+ public boolean containsTarget(InstructionHandle ih) {
+ return (start == ih) || (end == ih);
+ }
+
+ /**
+ * We consider to local variables to be equal, if the use the same index and
+ * are valid in the same range.
+ */
+ public boolean equals(Object o) {
+ if(!(o instanceof LocalVariableGen))
+ return false;
+
+ LocalVariableGen l = (LocalVariableGen)o;
+ return (l.index == index) && (l.start == start) && (l.end == end);
+ }
+
+ public String toString() {
+ return "LocalVariableGen(" + name + ", " + type + ", " + start + ", " + end + ")";
+ }
+
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch(CloneNotSupportedException e) {
+ System.err.println(e);
+ return null;
+ }
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/LocalVariableInstruction.java b/src/java/org/apache/bcel/generic/LocalVariableInstruction.java
new file mode 100644
index 00000000..74db9c2b
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/LocalVariableInstruction.java
@@ -0,0 +1,227 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import java.io.*;
+import org.apache.bcel.util.ByteSequence;
+import org.apache.bcel.classfile.Utility;
+import org.apache.bcel.Constants;
+
+/**
+ * Abstract super class for instructions dealing with local variables.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public abstract class LocalVariableInstruction extends Instruction
+ implements TypedInstruction, IndexedInstruction {
+ protected int n = -1; // index of referenced variable
+ private short c_tag = -1; // compact version, such as ILOAD_0
+ private short canon_tag = -1; // canonical tag such as ILOAD
+
+ private final boolean wide() { return n > Constants.MAX_BYTE; }
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ * tag and length are defined in readInstruction and initFromFile, respectively.
+ */
+ LocalVariableInstruction(short canon_tag, short c_tag) {
+ super();
+ this.canon_tag = canon_tag;
+ this.c_tag = c_tag;
+ }
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Also used by IINC()!
+ */
+ LocalVariableInstruction() {
+ }
+
+ /**
+ * @param opcode Instruction opcode
+ * @param c_tag Instruction number for compact version, ALOAD_0, e.g.
+ * @param n local variable index (unsigned short)
+ */
+ protected LocalVariableInstruction(short opcode, short c_tag, int n) {
+ super(opcode, (short)2);
+
+ this.c_tag = c_tag;
+ canon_tag = opcode;
+
+ setIndex(n);
+ }
+
+ /**
+ * Dump instruction as byte code to stream out.
+ * @param out Output stream
+ */
+ public void dump(DataOutputStream out) throws IOException {
+ if(wide()) // Need WIDE prefix ?
+ out.writeByte(Constants.WIDE);
+
+ out.writeByte(opcode);
+
+ if(length > 1) { // Otherwise ILOAD_n, instruction, e.g.
+ if(wide())
+ out.writeShort(n);
+ else
+ out.writeByte(n);
+ }
+ }
+
+ /**
+ * Long output format:
+ *
+ * &lt;name of opcode&gt; "["&lt;opcode number&gt;"]"
+ * "("&lt;length of instruction&gt;")" "&lt;"&lt; local variable index&gt;"&gt;"
+ *
+ * @param verbose long/short format switch
+ * @return mnemonic for instruction
+ */
+ public String toString(boolean verbose) {
+ if(((opcode >= Constants.ILOAD_0) &&
+ (opcode <= Constants.ALOAD_3)) ||
+ ((opcode >= Constants.ISTORE_0) &&
+ (opcode <= Constants.ASTORE_3)))
+ return super.toString(verbose);
+ else
+ return super.toString(verbose) + " " + n;
+ }
+
+ /**
+ * Read needed data (e.g. index) from file.
+ * PRE: (ILOAD <= tag <= ALOAD_3) || (ISTORE <= tag <= ASTORE_3)
+ */
+ protected void initFromFile(ByteSequence bytes, boolean wide)
+ throws IOException
+ {
+ if(wide) {
+ n = bytes.readUnsignedShort();
+ length = 4;
+ } else if(((opcode >= Constants.ILOAD) &&
+ (opcode <= Constants.ALOAD)) ||
+ ((opcode >= Constants.ISTORE) &&
+ (opcode <= Constants.ASTORE))) {
+ n = bytes.readUnsignedByte();
+ length = 2;
+ } else if(opcode <= Constants.ALOAD_3) { // compact load instruction such as ILOAD_2
+ n = (opcode - Constants.ILOAD_0) % 4;
+ length = 1;
+ } else { // Assert ISTORE_0 <= tag <= ASTORE_3
+ n = (opcode - Constants.ISTORE_0) % 4;
+ length = 1;
+ }
+ }
+
+ /**
+ * @return local variable index referred by this instruction.
+ */
+ public final int getIndex() { return n; }
+
+ /**
+ * Set the local variable index
+ */
+ public void setIndex(int n) {
+ if((n < 0) || (n > Constants.MAX_SHORT))
+ throw new ClassGenException("Illegal value: " + n);
+
+ this.n = n;
+
+ if(n >= 0 && n <= 3) { // Use more compact instruction xLOAD_n
+ opcode = (short)(c_tag + n);
+ length = 1;
+ } else {
+ opcode = canon_tag;
+
+ if(wide()) // Need WIDE prefix ?
+ length = 4;
+ else
+ length = 2;
+ }
+ }
+
+ /** @return canonical tag for instruction, e.g., ALOAD for ALOAD_0
+ */
+ public short getCanonicalTag() {
+ return canon_tag;
+ }
+
+ /**
+ * Returns the type associated with the instruction -
+ * in case of ALOAD or ASTORE Type.OBJECT is returned.
+ * This is just a bit incorrect, because ALOAD and ASTORE
+ * may work on every ReferenceType (including Type.NULL) and
+ * ASTORE may even work on a ReturnaddressType .
+ * @return type associated with the instruction
+ */
+ public Type getType(ConstantPoolGen cp) {
+ switch(canon_tag) {
+ case Constants.ILOAD: case Constants.ISTORE:
+ return Type.INT;
+ case Constants.LLOAD: case Constants.LSTORE:
+ return Type.LONG;
+ case Constants.DLOAD: case Constants.DSTORE:
+ return Type.DOUBLE;
+ case Constants.FLOAD: case Constants.FSTORE:
+ return Type.FLOAT;
+ case Constants.ALOAD: case Constants.ASTORE:
+ return Type.OBJECT;
+
+ default: throw new ClassGenException("Oops: unknown case in switch" + canon_tag);
+ }
+ }
+}
+
diff --git a/src/java/org/apache/bcel/generic/MONITORENTER.java b/src/java/org/apache/bcel/generic/MONITORENTER.java
new file mode 100644
index 00000000..5f023f47
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/MONITORENTER.java
@@ -0,0 +1,88 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * MONITORENTER - Enter monitor for object
+ * <PRE>Stack: ..., objectref -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class MONITORENTER extends Instruction
+ implements ExceptionThrower, StackConsumer {
+ public MONITORENTER() {
+ super(org.apache.bcel.Constants.MONITORENTER, (short)1);
+ }
+
+ public Class[] getExceptions() {
+ return new Class[] { org.apache.bcel.ExceptionConstants.NULL_POINTER_EXCEPTION };
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitExceptionThrower(this);
+ v.visitStackConsumer(this);
+ v.visitMONITORENTER(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/MONITOREXIT.java b/src/java/org/apache/bcel/generic/MONITOREXIT.java
new file mode 100644
index 00000000..c3bb27a6
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/MONITOREXIT.java
@@ -0,0 +1,88 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * MONITOREXIT - Exit monitor for object
+ * <PRE>Stack: ..., objectref -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class MONITOREXIT extends Instruction
+ implements ExceptionThrower, StackConsumer {
+ public MONITOREXIT() {
+ super(org.apache.bcel.Constants.MONITOREXIT, (short)1);
+ }
+
+ public Class[] getExceptions() {
+ return new Class[] { org.apache.bcel.ExceptionConstants.NULL_POINTER_EXCEPTION };
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitExceptionThrower(this);
+ v.visitStackConsumer(this);
+ v.visitMONITOREXIT(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/MULTIANEWARRAY.java b/src/java/org/apache/bcel/generic/MULTIANEWARRAY.java
new file mode 100644
index 00000000..039c4ece
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/MULTIANEWARRAY.java
@@ -0,0 +1,172 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import java.io.*;
+import org.apache.bcel.util.ByteSequence;
+import org.apache.bcel.classfile.ConstantPool;
+import org.apache.bcel.ExceptionConstants;
+
+/**
+ * MULTIANEWARRAY - Create new mutidimensional array of references
+ * <PRE>Stack: ..., count1, [count2, ...] -&gt; ..., arrayref</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class MULTIANEWARRAY extends CPInstruction implements LoadClass, AllocationInstruction, ExceptionThrower {
+ private short dimensions;
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ MULTIANEWARRAY() {}
+
+ public MULTIANEWARRAY(int index, short dimensions) {
+ super(org.apache.bcel.Constants.MULTIANEWARRAY, index);
+
+ if(dimensions < 1)
+ throw new ClassGenException("Invalid dimensions value: " + dimensions);
+
+ this.dimensions = dimensions;
+ length = 4;
+ }
+
+ /**
+ * Dump instruction as byte code to stream out.
+ * @param out Output stream
+ */
+ public void dump(DataOutputStream out) throws IOException {
+ out.writeByte(opcode);
+ out.writeShort(index);
+ out.writeByte(dimensions);
+ }
+
+ /**
+ * Read needed data (i.e., no. dimension) from file.
+ */
+ protected void initFromFile(ByteSequence bytes, boolean wide)
+ throws IOException
+ {
+ super.initFromFile(bytes, wide);
+ dimensions = bytes.readByte();
+ length = 4;
+ }
+
+ /**
+ * @return number of dimensions to be created
+ */
+ public final short getDimensions() { return dimensions; }
+
+ /**
+ * @return mnemonic for instruction
+ */
+ public String toString(boolean verbose) {
+ return super.toString(verbose) + " " + index + " " + dimensions;
+ }
+
+ /**
+ * @return mnemonic for instruction with symbolic references resolved
+ */
+ public String toString(ConstantPool cp) {
+ return super.toString(cp) + " " + dimensions;
+ }
+
+ /**
+ * Also works for instructions whose stack effect depends on the
+ * constant pool entry they reference.
+ * @return Number of words consumed from stack by this instruction
+ */
+ public int consumeStack(ConstantPoolGen cpg) { return dimensions; }
+
+ public Class[] getExceptions() {
+ Class[] cs = new Class[2 + ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length];
+
+ System.arraycopy(ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION, 0,
+ cs, 0, ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length);
+
+ cs[ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length+1] = ExceptionConstants.NEGATIVE_ARRAY_SIZE_EXCEPTION;
+ cs[ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length] = ExceptionConstants.ILLEGAL_ACCESS_ERROR;
+
+ return cs;
+ }
+
+ public ObjectType getLoadClassType(ConstantPoolGen cpg) {
+ Type t = getType(cpg);
+
+ if (t instanceof ArrayType){
+ t = ((ArrayType) t).getBasicType();
+ }
+
+ return (t instanceof ObjectType)? (ObjectType) t : null;
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitLoadClass(this);
+ v.visitAllocationInstruction(this);
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitCPInstruction(this);
+ v.visitMULTIANEWARRAY(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/MethodGen.java b/src/java/org/apache/bcel/generic/MethodGen.java
new file mode 100644
index 00000000..fb379a00
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/MethodGen.java
@@ -0,0 +1,938 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import org.apache.bcel.classfile.*;
+import java.util.*;
+
+/**
+ * Template class for building up a method. This is done by defining exception
+ * handlers, adding thrown exceptions, local variables and attributes, whereas
+ * the `LocalVariableTable' and `LineNumberTable' attributes will be set
+ * automatically for the code. Use stripAttributes() if you don't like this.
+ *
+ * While generating code it may be necessary to insert NOP operations. You can
+ * use the `removeNOPs' method to get rid off them.
+ * The resulting method object can be obtained via the `getMethod()' method.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @author <A HREF="http://www.vmeng.com/beard">Patrick C. Beard</A>
+ * @see InstructionList
+ * @see Method
+ */
+public class MethodGen extends FieldGenOrMethodGen {
+ private String class_name;
+ private Type[] arg_types;
+ private String[] arg_names;
+ private int max_locals;
+ private int max_stack;
+ private InstructionList il;
+ private boolean strip_attributes;
+
+ private ArrayList variable_vec = new ArrayList();
+ private ArrayList line_number_vec = new ArrayList();
+ private ArrayList exception_vec = new ArrayList();
+ private ArrayList throws_vec = new ArrayList();
+ private ArrayList code_attrs_vec = new ArrayList();
+
+ /**
+ * Declare method. If the method is non-static the constructor
+ * automatically declares a local variable `$this' in slot 0. The
+ * actual code is contained in the `il' parameter, which may further
+ * manipulated by the user. But he must take care not to remove any
+ * instruction (handles) that are still referenced from this object.
+ *
+ * For example one may not add a local variable and later remove the
+ * instructions it refers to without causing havoc. It is safe
+ * however if you remove that local variable, too.
+ *
+ * @param access_flags access qualifiers
+ * @param return_type method type
+ * @param arg_types argument types
+ * @param arg_names argument names (if this is null, default names will be provided
+ * for them)
+ * @param method_name name of method
+ * @param class_name class name containing this method (may be null, if you don't care)
+ * @param il instruction list associated with this method, may be null only for
+ * abstract or native methods
+ * @param cp constant pool
+ */
+ public MethodGen(int access_flags, Type return_type, Type[] arg_types,
+ String[] arg_names, String method_name, String class_name,
+ InstructionList il, ConstantPoolGen cp) {
+ setAccessFlags(access_flags);
+ setType(return_type);
+ setArgumentTypes(arg_types);
+ setArgumentNames(arg_names);
+ setName(method_name);
+ setClassName(class_name);
+ setInstructionList(il);
+ setConstantPool(cp);
+
+ if((access_flags & (Constants.ACC_ABSTRACT | Constants.ACC_NATIVE)) == 0) {
+ InstructionHandle start = il.getStart();
+ InstructionHandle end = il.getEnd();
+
+ /* Add local variables, namely the implicit `this' and the arguments
+ */
+ if(!isStatic() && (class_name != null)) // Instance method -> `this' is local var 0
+ addLocalVariable("this", new ObjectType(class_name), start, end);
+
+ if(arg_types != null) {
+ int size = arg_types.length;
+
+ if(arg_names != null) { // Names for variables provided?
+ if(size != arg_names.length)
+ throw new ClassGenException("Mismatch in argument array lengths: " +
+ size + " vs. " + arg_names.length);
+ } else { // Give them dummy names
+ arg_names = new String[size];
+
+ for(int i=0; i < size; i++)
+ arg_names[i] = "arg" + i;
+
+ setArgumentNames(arg_names);
+ }
+
+ for(int i=0; i < size; i++)
+ addLocalVariable(arg_names[i], arg_types[i], start, end);
+ }
+ }
+ }
+
+ /**
+ * Instantiate from existing method.
+ *
+ * @param m method
+ * @param class_name class name containing this method
+ * @param cp constant pool
+ */
+ public MethodGen(Method m, String class_name, ConstantPoolGen cp) {
+ this(m.getAccessFlags(), Type.getReturnType(m.getSignature()),
+ Type.getArgumentTypes(m.getSignature()), null /* may be overridden anyway */,
+ m.getName(), class_name,
+ ((m.getAccessFlags() & (Constants.ACC_ABSTRACT | Constants.ACC_NATIVE)) == 0)?
+ new InstructionList(m.getCode().getCode()) : null,
+ cp);
+
+ Attribute[] attributes = m.getAttributes();
+ for(int i=0; i < attributes.length; i++) {
+ Attribute a = attributes[i];
+
+ if(a instanceof Code) {
+ Code c = (Code)a;
+ setMaxStack(c.getMaxStack());
+ setMaxLocals(c.getMaxLocals());
+
+ CodeException[] ces = c.getExceptionTable();
+
+ if(ces != null) {
+ for(int j=0; j < ces.length; j++) {
+ CodeException ce = ces[j];
+ int type = ce.getCatchType();
+ ObjectType c_type = null;
+
+ if(type > 0) {
+ String cen = m.getConstantPool().getConstantString(type, Constants.CONSTANT_Class);
+ c_type = new ObjectType(cen);
+ }
+
+ int end_pc = ce.getEndPC();
+ int length = m.getCode().getCode().length;
+
+ InstructionHandle end;
+
+ if(length == end_pc) { // May happen, because end_pc is exclusive
+ end = il.getEnd();
+ } else {
+ end = il.findHandle(end_pc);
+ end = end.getPrev(); // Make it inclusive
+ }
+
+ addExceptionHandler(il.findHandle(ce.getStartPC()), end,
+ il.findHandle(ce.getHandlerPC()), c_type);
+ }
+ }
+
+ Attribute[] c_attributes = c.getAttributes();
+ for(int j=0; j < c_attributes.length; j++) {
+ a = c_attributes[j];
+
+ if(a instanceof LineNumberTable) {
+ LineNumber[] ln = ((LineNumberTable)a).getLineNumberTable();
+ for(int k=0; k < ln.length; k++) {
+ LineNumber l = ln[k];
+ addLineNumber(il.findHandle(l.getStartPC()), l.getLineNumber());
+ }
+ } else if(a instanceof LocalVariableTable) {
+ LocalVariable[] lv = ((LocalVariableTable)a).getLocalVariableTable();
+ for(int k=0; k < lv.length; k++) {
+ LocalVariable l = lv[k];
+ InstructionHandle start = il.findHandle(l.getStartPC());
+ InstructionHandle end = il.findHandle(l.getStartPC() + l.getLength());
+
+ // Repair malformed handles
+ if(start == null)
+ start = il.getStart();
+ if(end == null)
+ end = il.getEnd();
+
+ addLocalVariable(l.getName(), Type.getType(l.getSignature()),
+ l.getIndex(), start, end);
+ }
+ } else
+ addCodeAttribute(a);
+ }
+ } else if(a instanceof ExceptionTable) {
+ String[] names = ((ExceptionTable)a).getExceptionNames();
+ for(int j=0; j < names.length; j++)
+ addException(names[j]);
+ } else
+ addAttribute(a);
+ }
+ }
+
+ /**
+ * Adds a local variable to this method.
+ *
+ * @param name variable name
+ * @param type variable type
+ * @param slot the index of the local variable, if type is long or double, the next available
+ * index is slot+2
+ * @param start from where the variable is valid
+ * @param end until where the variable is valid
+ * @return new local variable object
+ * @see LocalVariable
+ */
+ public LocalVariableGen addLocalVariable(String name, Type type, int slot,
+ InstructionHandle start,
+ InstructionHandle end) {
+ byte t = type.getType();
+ int add = type.getSize();
+
+ if(slot + add > max_locals)
+ max_locals = slot + add;
+
+ LocalVariableGen l = new LocalVariableGen(slot, name, type, start, end);
+ int i;
+
+ if((i = variable_vec.indexOf(l)) >= 0) // Overwrite if necessary
+ variable_vec.set(i, l);
+ else
+ variable_vec.add(l);
+ return l;
+ }
+
+ /**
+ * Adds a local variable to this method and assigns an index automatically.
+ *
+ * @param name variable name
+ * @param type variable type
+ * @param start from where the variable is valid, if this is null,
+ * it is valid from the start
+ * @param end until where the variable is valid, if this is null,
+ * it is valid to the end
+ * @return new local variable object
+ * @see LocalVariable
+ */
+ public LocalVariableGen addLocalVariable(String name, Type type,
+ InstructionHandle start,
+ InstructionHandle end) {
+ return addLocalVariable(name, type, max_locals, start, end);
+ }
+
+ /**
+ * Remove a local variable, its slot will not be reused, if you do not use addLocalVariable
+ * with an explicit index argument.
+ */
+ public void removeLocalVariable(LocalVariableGen l) {
+ variable_vec.remove(l);
+ }
+
+ /**
+ * Remove all local variables.
+ */
+ public void removeLocalVariables() {
+ variable_vec.clear();
+ }
+
+ /**
+ * Sort local variables by index
+ */
+ private static final void sort(LocalVariableGen[] vars, int l, int r) {
+ int i = l, j = r;
+ int m = vars[(l + r) / 2].getIndex();
+ LocalVariableGen h;
+
+ do {
+ while(vars[i].getIndex() < m) i++;
+ while(m < vars[j].getIndex()) j--;
+
+ if(i <= j) {
+ h=vars[i]; vars[i]=vars[j]; vars[j]=h; // Swap elements
+ i++; j--;
+ }
+ } while(i <= j);
+
+ if(l < j) sort(vars, l, j);
+ if(i < r) sort(vars, i, r);
+ }
+
+ /*
+ * If the range of the variable has not been set yet, it will be set to be valid from
+ * the start to the end of the instruction list.
+ *
+ * @return array of declared local variables sorted by index
+ */
+ public LocalVariableGen[] getLocalVariables() {
+ int size = variable_vec.size();
+ LocalVariableGen[] lg = new LocalVariableGen[size];
+ variable_vec.toArray(lg);
+
+ for(int i=0; i < size; i++) {
+ if(lg[i].getStart() == null)
+ lg[i].setStart(il.getStart());
+
+ if(lg[i].getEnd() == null)
+ lg[i].setEnd(il.getEnd());
+ }
+
+ if(size > 1)
+ sort(lg, 0, size - 1);
+
+ return lg;
+ }
+
+ /**
+ * @return `LocalVariableTable' attribute of all the local variables of this method.
+ */
+ public LocalVariableTable getLocalVariableTable(ConstantPoolGen cp) {
+ LocalVariableGen[] lg = getLocalVariables();
+ int size = lg.length;
+ LocalVariable[] lv = new LocalVariable[size];
+
+ for(int i=0; i < size; i++)
+ lv[i] = lg[i].getLocalVariable(cp);
+
+ return new LocalVariableTable(cp.addUtf8("LocalVariableTable"),
+ 2 + lv.length * 10, lv, cp.getConstantPool());
+ }
+
+ /**
+ * Give an instruction a line number corresponding to the source code line.
+ *
+ * @param ih instruction to tag
+ * @return new line number object
+ * @see LineNumber
+ */
+ public LineNumberGen addLineNumber(InstructionHandle ih, int src_line) {
+ LineNumberGen l = new LineNumberGen(ih, src_line);
+ line_number_vec.add(l);
+ return l;
+ }
+
+ /**
+ * Remove a line number.
+ */
+ public void removeLineNumber(LineNumberGen l) {
+ line_number_vec.remove(l);
+ }
+
+ /**
+ * Remove all line numbers.
+ */
+ public void removeLineNumbers() {
+ line_number_vec.clear();
+ }
+
+ /*
+ * @return array of line numbers
+ */
+ public LineNumberGen[] getLineNumbers() {
+ LineNumberGen[] lg = new LineNumberGen[line_number_vec.size()];
+ line_number_vec.toArray(lg);
+ return lg;
+ }
+
+ /**
+ * @return `LineNumberTable' attribute of all the local variables of this method.
+ */
+ public LineNumberTable getLineNumberTable(ConstantPoolGen cp) {
+ int size = line_number_vec.size();
+ LineNumber[] ln = new LineNumber[size];
+
+ try {
+ for(int i=0; i < size; i++)
+ ln[i] = ((LineNumberGen)line_number_vec.get(i)).getLineNumber();
+ } catch(ArrayIndexOutOfBoundsException e) {} // Never occurs
+
+ return new LineNumberTable(cp.addUtf8("LineNumberTable"),
+ 2 + ln.length * 4, ln, cp.getConstantPool());
+ }
+
+ /**
+ * Add an exception handler, i.e., specify region where a handler is active and an
+ * instruction where the actual handling is done.
+ *
+ * @param start_pc Start of region (inclusive)
+ * @param end_pc End of region (inclusive)
+ * @param handler_pc Where handling is done
+ * @param catch_type fully qualified class name of handled exception or null if any
+ * exception is handled
+ * @return new exception handler object
+ */
+ public CodeExceptionGen addExceptionHandler(InstructionHandle start_pc,
+ InstructionHandle end_pc,
+ InstructionHandle handler_pc,
+ ObjectType catch_type) {
+ if((start_pc == null) || (end_pc == null) || (handler_pc == null))
+ throw new ClassGenException("Exception handler target is null instruction");
+
+ CodeExceptionGen c = new CodeExceptionGen(start_pc, end_pc,
+ handler_pc, catch_type);
+ exception_vec.add(c);
+ return c;
+ }
+
+ /**
+ * Remove an exception handler.
+ */
+ public void removeExceptionHandler(CodeExceptionGen c) {
+ exception_vec.remove(c);
+ }
+
+ /**
+ * Remove all line numbers.
+ */
+ public void removeExceptionHandlers() {
+ exception_vec.clear();
+ }
+
+ /*
+ * @return array of declared exception handlers
+ */
+ public CodeExceptionGen[] getExceptionHandlers() {
+ CodeExceptionGen[] cg = new CodeExceptionGen[exception_vec.size()];
+ exception_vec.toArray(cg);
+ return cg;
+ }
+
+ /**
+ * @return code exceptions for `Code' attribute
+ */
+ private CodeException[] getCodeExceptions() {
+ int size = exception_vec.size();
+ CodeException[] c_exc = new CodeException[size];
+
+ try {
+ for(int i=0; i < size; i++) {
+ CodeExceptionGen c = (CodeExceptionGen)exception_vec.get(i);
+ c_exc[i] = c.getCodeException(cp);
+ }
+ } catch(ArrayIndexOutOfBoundsException e) {}
+
+ return c_exc;
+ }
+
+ /**
+ * Add an exception possibly thrown by this method.
+ *
+ * @param class_name (fully qualified) name of exception
+ */
+ public void addException(String class_name) {
+ throws_vec.add(class_name);
+ }
+
+ /**
+ * Remove an exception.
+ */
+ public void removeException(String c) {
+ throws_vec.remove(c);
+ }
+
+ /**
+ * Remove all exceptions.
+ */
+ public void removeExceptions() {
+ throws_vec.clear();
+ }
+
+ /*
+ * @return array of thrown exceptions
+ */
+ public String[] getExceptions() {
+ String[] e = new String[throws_vec.size()];
+ throws_vec.toArray(e);
+ return e;
+ }
+
+ /**
+ * @return `Exceptions' attribute of all the exceptions thrown by this method.
+ */
+ private ExceptionTable getExceptionTable(ConstantPoolGen cp) {
+ int size = throws_vec.size();
+ int[] ex = new int[size];
+
+ try {
+ for(int i=0; i < size; i++)
+ ex[i] = cp.addClass((String)throws_vec.get(i));
+ } catch(ArrayIndexOutOfBoundsException e) {}
+
+ return new ExceptionTable(cp.addUtf8("Exceptions"),
+ 2 + 2 * size, ex, cp.getConstantPool());
+ }
+
+ /**
+ * Add an attribute to the code. Currently, the JVM knows about the
+ * LineNumberTable, LocalVariableTable and StackMap attributes,
+ * where the former two will be generated automatically and the
+ * latter is used for the MIDP only. Other attributes will be
+ * ignored by the JVM but do no harm.
+ *
+ * @param a attribute to be added
+ */
+ public void addCodeAttribute(Attribute a) { code_attrs_vec.add(a); }
+
+ /**
+ * Remove a code attribute.
+ */
+ public void removeCodeAttribute(Attribute a) { code_attrs_vec.remove(a); }
+
+ /**
+ * Remove all code attributes.
+ */
+ public void removeCodeAttributes() {
+ code_attrs_vec.clear();
+ }
+
+ /**
+ * @return all attributes of this method.
+ */
+ public Attribute[] getCodeAttributes() {
+ Attribute[] attributes = new Attribute[code_attrs_vec.size()];
+ code_attrs_vec.toArray(attributes);
+ return attributes;
+ }
+
+ /**
+ * Get method object. Never forget to call setMaxStack() or setMaxStack(max), respectively,
+ * before calling this method (the same applies for max locals).
+ *
+ * @return method object
+ */
+ public Method getMethod() {
+ String signature = getSignature();
+ int name_index = cp.addUtf8(name);
+ int signature_index = cp.addUtf8(signature);
+
+ /* Also updates positions of instructions, i.e., their indices
+ */
+ byte[] byte_code = null;
+
+ if(il != null)
+ byte_code = il.getByteCode();
+
+
+ LineNumberTable lnt = null;
+ LocalVariableTable lvt = null;
+
+ /* Create LocalVariableTable and LineNumberTable attributes (for debuggers, e.g.)
+ */
+ if((variable_vec.size() > 0) && !strip_attributes)
+ addCodeAttribute(lvt = getLocalVariableTable(cp));
+
+ if((line_number_vec.size() > 0) && !strip_attributes)
+ addCodeAttribute(lnt = getLineNumberTable(cp));
+
+ Attribute[] code_attrs = getCodeAttributes();
+
+ /* Each attribute causes 6 additional header bytes
+ */
+ int attrs_len = 0;
+ for(int i=0; i < code_attrs.length; i++)
+ attrs_len += (code_attrs[i].getLength() + 6);
+
+ CodeException[] c_exc = getCodeExceptions();
+ int exc_len = c_exc.length * 8; // Every entry takes 8 bytes
+
+ Code code = null;
+ if((il != null) && !isAbstract()) {
+ code = new Code(cp.addUtf8("Code"),
+ 8 + byte_code.length + // prologue byte code
+ 2 + exc_len + // exceptions
+ 2 + attrs_len, // attributes
+ max_stack, max_locals,
+ byte_code, c_exc,
+ code_attrs,
+ cp.getConstantPool());
+
+ addAttribute(code);
+ }
+
+ ExceptionTable et = null;
+
+ if(throws_vec.size() > 0)
+ addAttribute(et = getExceptionTable(cp)); // Add `Exceptions' if there are "throws" clauses
+
+ Method m = new Method(access_flags, name_index, signature_index,
+ getAttributes(), cp.getConstantPool());
+
+ // Undo effects of adding attributes
+ if(lvt != null) removeCodeAttribute(lvt);
+ if(lnt != null) removeCodeAttribute(lnt);
+ if(code != null) removeAttribute(code);
+ if(et != null) removeAttribute(et);
+
+ return m;
+ }
+
+ /**
+ * Remove all NOPs from the instruction list (if possible) and update every
+ * object refering to them, i.e., branch instructions, local variables and
+ * exception handlers.
+ */
+ public void removeNOPs() {
+ if(il != null) {
+ InstructionHandle next;
+ /* Check branch instructions.
+ */
+ for(InstructionHandle ih = il.getStart(); ih != null; ih = next) {
+ next = ih.next;
+
+ if((next != null) && (ih.getInstruction() instanceof NOP)) {
+ try {
+ il.delete(ih);
+ } catch(TargetLostException e) {
+ InstructionHandle[] targets = e.getTargets();
+
+ 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);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Set maximum number of local variables.
+ */
+ public void setMaxLocals(int m) { max_locals = m; }
+ public int getMaxLocals() { return max_locals; }
+
+ /**
+ * Set maximum stack size for this method.
+ */
+ public void setMaxStack(int m) { max_stack = m; }
+ public int getMaxStack() { return max_stack; }
+
+ /** @return class that contains this method
+ */
+ public String getClassName() { return class_name; }
+ public void setClassName(String class_name) { this.class_name = class_name; }
+
+ public void setReturnType(Type return_type) { setType(return_type); }
+ public Type getReturnType() { return getType(); }
+
+ public void setArgumentTypes(Type[] arg_types) { this.arg_types = arg_types; }
+ public Type[] getArgumentTypes() { return (Type[])arg_types.clone(); }
+ public void setArgumentType(int i, Type type) { arg_types[i] = type; }
+ public Type getArgumentType(int i) { return arg_types[i]; }
+
+ public void setArgumentNames(String[] arg_names) { this.arg_names = arg_names; }
+ public String[] getArgumentNames() { return (String[])arg_names.clone(); }
+ public void setArgumentName(int i, String name) { arg_names[i] = name; }
+ public String getArgumentName(int i) { return arg_names[i]; }
+
+ public InstructionList getInstructionList() { return il; }
+ public void setInstructionList(InstructionList il) { this.il = il; }
+
+ public String getSignature() {
+ return Type.getMethodSignature(type, arg_types);
+ }
+
+ /**
+ * Computes max. stack size by performing control flow analysis.
+ * @author <A HREF="http://www.vmeng.com/beard">Patrick C. Beard</A>
+ */
+ public void setMaxStack() {
+ if(il != null)
+ max_stack = getMaxStack(cp, il, getExceptionHandlers());
+ else
+ max_stack = 0;
+ }
+
+ /**
+ * Compute maximum number of local variables.
+ */
+ public void setMaxLocals() {
+ if(il != null) {
+ int max = isStatic()? 0 : 1;
+
+ if(arg_types != null)
+ for(int i=0; i < arg_types.length; i++)
+ max += arg_types[i].getSize();
+
+ for(InstructionHandle ih = il.getStart(); ih != null; ih = ih.getNext()) {
+ Instruction ins = ih.getInstruction();
+
+ if((ins instanceof LocalVariableInstruction) ||
+ (ins instanceof RET) || (ins instanceof IINC))
+ {
+ int index = ((IndexedInstruction)ins).getIndex() +
+ ((TypedInstruction)ins).getType(cp).getSize();
+
+ if(index > max)
+ max = index;
+ }
+ }
+
+ max_locals = max;
+ } else
+ max_locals = 0;
+ }
+
+ /** Do not/Do produce attributes code attributesLineNumberTable and
+ * LocalVariableTable, like javac -O
+ */
+ public void stripAttributes(boolean flag) { strip_attributes = flag; }
+
+ static final class BranchTarget {
+ InstructionHandle target;
+ int stackDepth;
+
+ BranchTarget(InstructionHandle target, int stackDepth) {
+ this.target = target;
+ this.stackDepth = stackDepth;
+ }
+ }
+
+ static final class BranchStack {
+ Stack branchTargets = new Stack();
+ Hashtable visitedTargets = new Hashtable();
+
+ public void push(InstructionHandle target, int stackDepth) {
+ if(visited(target))
+ return;
+
+ branchTargets.push(visit(target, stackDepth));
+ }
+
+ public BranchTarget pop() {
+ if(!branchTargets.empty()) {
+ BranchTarget bt = (BranchTarget) branchTargets.pop();
+ return bt;
+ }
+
+ return null;
+ }
+
+ private final BranchTarget visit(InstructionHandle target, int stackDepth) {
+ BranchTarget bt = new BranchTarget(target, stackDepth);
+ visitedTargets.put(target, bt);
+
+ return bt;
+ }
+
+ private final boolean visited(InstructionHandle target) {
+ return (visitedTargets.get(target) != null);
+ }
+ }
+
+ /**
+ * Computes stack usage of an instruction list by performing control flow analysis.
+ *
+ * @return maximum stack depth used by method
+ */
+ public static int getMaxStack(ConstantPoolGen cp, InstructionList il, CodeExceptionGen[] et) {
+ BranchStack branchTargets = new BranchStack();
+
+ /* Initially, populate the branch stack with the exception
+ * handlers, because these aren't (necessarily) branched to
+ * explicitly. in each case, the stack will have depth 1,
+ * containing the exception object.
+ */
+ for (int i = 0; i < et.length; i++) {
+ InstructionHandle handler_pc = et[i].getHandlerPC();
+ if (handler_pc != null)
+ branchTargets.push(handler_pc, 1);
+ }
+
+ int stackDepth = 0, maxStackDepth = 0;
+ InstructionHandle ih = il.getStart();
+
+ while(ih != null) {
+ Instruction instruction = ih.getInstruction();
+ short opcode = instruction.getOpcode();
+ int delta = instruction.produceStack(cp) - instruction.consumeStack(cp);
+
+ stackDepth += delta;
+ if(stackDepth > maxStackDepth)
+ maxStackDepth = stackDepth;
+
+ // choose the next instruction based on whether current is a branch.
+ if(instruction instanceof BranchInstruction) {
+ BranchInstruction branch = (BranchInstruction) instruction;
+ if(instruction instanceof Select) {
+ // explore all of the select's targets. the default target is handled below.
+ Select select = (Select) branch;
+ InstructionHandle[] targets = select.getTargets();
+ for (int i = 0; i < targets.length; i++)
+ branchTargets.push(targets[i], stackDepth);
+ // nothing to fall through to.
+ ih = null;
+ } else if(!(branch instanceof IfInstruction)) {
+ // if an instruction that comes back to following PC,
+ // push next instruction, with stack depth reduced by 1.
+ if(opcode == Constants.JSR || opcode == Constants.JSR_W)
+ branchTargets.push(ih.getNext(), stackDepth - 1);
+ ih = null;
+ }
+ // for all branches, the target of the branch is pushed on the branch stack.
+ // conditional branches have a fall through case, selects don't, and
+ // jsr/jsr_w return to the next instruction.
+ branchTargets.push(branch.getTarget(), stackDepth);
+ } else {
+ // check for instructions that terminate the method.
+ if(opcode == Constants.ATHROW || opcode == Constants.RET ||
+ (opcode >= Constants.IRETURN && opcode <= Constants.RETURN))
+ ih = null;
+ }
+ // normal case, go to the next instruction.
+ if(ih != null)
+ ih = ih.getNext();
+ // if we have no more instructions, see if there are any deferred branches to explore.
+ if(ih == null) {
+ BranchTarget bt = branchTargets.pop();
+ if (bt != null) {
+ ih = bt.target;
+ stackDepth = bt.stackDepth;
+ }
+ }
+ }
+
+ return maxStackDepth;
+ }
+
+ private ArrayList observers;
+
+ /** Add observer for this object.
+ */
+ public void addObserver(MethodObserver o) {
+ if(observers == null)
+ observers = new ArrayList();
+
+ observers.add(o);
+ }
+
+ /** Remove observer for this object.
+ */
+ public void removeObserver(MethodObserver o) {
+ if(observers != null)
+ observers.remove(o);
+ }
+
+ /** Call notify() method on all observers. This method is not called
+ * automatically whenever the state has changed, but has to be
+ * called by the user after he has finished editing the object.
+ */
+ public void update() {
+ if(observers != null)
+ for(Iterator e = observers.iterator(); e.hasNext(); )
+ ((MethodObserver)e.next()).notify(this);
+ }
+
+ /**
+ * Return string representation close to declaration format,
+ * `public static void main(String[]) throws IOException', e.g.
+ *
+ * @return String representation of the method.
+ */
+ public final String toString() {
+ String access = Utility.accessToString(access_flags);
+ String signature = Type.getMethodSignature(type, arg_types);
+
+ signature = Utility.methodSignatureToString(signature, name, access,
+ true, getLocalVariableTable(cp));
+
+ StringBuffer buf = new StringBuffer(signature);
+
+ if(throws_vec.size() > 0) {
+ for(Iterator e = throws_vec.iterator(); e.hasNext(); )
+ buf.append("\n\t\tthrows " + e.next());
+ }
+
+ return buf.toString();
+ }
+
+ /** @return deep copy of this method
+ */
+ public MethodGen copy(String class_name, ConstantPoolGen cp) {
+ Method m = ((MethodGen)clone()).getMethod();
+ MethodGen mg = new MethodGen(m, class_name, this.cp);
+
+ if(this.cp != cp) {
+ mg.setConstantPool(cp);
+ mg.getInstructionList().replaceConstantPool(this.cp, cp);
+ }
+
+ return mg;
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/MethodObserver.java b/src/java/org/apache/bcel/generic/MethodObserver.java
new file mode 100644
index 00000000..eab665eb
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/MethodObserver.java
@@ -0,0 +1,67 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Implement this interface if you're interested in changes to a MethodGen object
+ * and register yourself with addObserver().
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public interface MethodObserver {
+ public void notify(MethodGen method);
+}
+
diff --git a/src/java/org/apache/bcel/generic/NEW.java b/src/java/org/apache/bcel/generic/NEW.java
new file mode 100644
index 00000000..f59e4633
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/NEW.java
@@ -0,0 +1,111 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import java.io.*;
+import org.apache.bcel.ExceptionConstants;
+
+/**
+ * NEW - Create new object
+ * <PRE>Stack: ... -&gt; ..., objectref</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class NEW extends CPInstruction
+ implements LoadClass, AllocationInstruction, ExceptionThrower, StackProducer {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ NEW() {}
+
+ public NEW(int index) {
+ super(org.apache.bcel.Constants.NEW, index);
+ }
+
+ public Class[] getExceptions(){
+ Class[] cs = new Class[2 + ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length];
+
+ System.arraycopy(ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION, 0,
+ cs, 0, ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length);
+
+ cs[ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length+1] = ExceptionConstants.INSTANTIATION_ERROR;
+ cs[ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length] = ExceptionConstants.ILLEGAL_ACCESS_ERROR;
+
+ return cs;
+ }
+
+ public ObjectType getLoadClassType(ConstantPoolGen cpg) {
+ return (ObjectType)getType(cpg);
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitLoadClass(this);
+ v.visitAllocationInstruction(this);
+ v.visitExceptionThrower(this);
+ v.visitStackProducer(this);
+ v.visitTypedInstruction(this);
+ v.visitCPInstruction(this);
+ v.visitNEW(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/NEWARRAY.java b/src/java/org/apache/bcel/generic/NEWARRAY.java
new file mode 100644
index 00000000..97dfb74a
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/NEWARRAY.java
@@ -0,0 +1,141 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import java.io.*;
+import org.apache.bcel.util.ByteSequence;
+
+/**
+ * NEWARRAY - Create new array of basic type (int, short, ...)
+ * <PRE>Stack: ..., count -&gt; ..., arrayref</PRE>
+ * type must be one of T_INT, T_SHORT, ...
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class NEWARRAY extends Instruction
+ implements AllocationInstruction, ExceptionThrower, StackProducer {
+ private byte type;
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ NEWARRAY() {}
+
+ public NEWARRAY(byte type) {
+ super(org.apache.bcel.Constants.NEWARRAY, (short)2);
+ this.type = type;
+ }
+
+ public NEWARRAY(BasicType type) {
+ this(type.getType());
+ }
+
+ /**
+ * Dump instruction as byte code to stream out.
+ * @param out Output stream
+ */
+ public void dump(DataOutputStream out) throws IOException {
+ out.writeByte(opcode);
+ out.writeByte(type);
+ }
+
+ /**
+ * @return numeric code for basic element type
+ */
+ public final byte getTypecode() { return type; }
+
+ /**
+ * @return type of constructed array
+ */
+ public final Type getType() {
+ return new ArrayType(BasicType.getType(type), 1);
+ }
+
+ /**
+ * @return mnemonic for instruction
+ */
+ public String toString(boolean verbose) {
+ return super.toString(verbose) + " " + org.apache.bcel.Constants.TYPE_NAMES[type];
+ }
+ /**
+ * Read needed data (e.g. index) from file.
+ */
+ protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
+ {
+ type = bytes.readByte();
+ length = 2;
+ }
+
+ public Class[] getExceptions() {
+ return new Class[] { org.apache.bcel.ExceptionConstants.NEGATIVE_ARRAY_SIZE_EXCEPTION };
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitAllocationInstruction(this);
+ v.visitExceptionThrower(this);
+ v.visitStackProducer(this);
+ v.visitNEWARRAY(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/NOP.java b/src/java/org/apache/bcel/generic/NOP.java
new file mode 100644
index 00000000..c670e3c6
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/NOP.java
@@ -0,0 +1,80 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * NOP - Do nothing
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class NOP extends Instruction {
+ public NOP() {
+ super(org.apache.bcel.Constants.NOP, (short)1);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitNOP(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/NamedAndTyped.java b/src/java/org/apache/bcel/generic/NamedAndTyped.java
new file mode 100644
index 00000000..a789e3bf
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/NamedAndTyped.java
@@ -0,0 +1,71 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Denote entity that has both name and type. This is true for local variables,
+ * methods and fields.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public interface NamedAndTyped {
+ public String getName();
+ public Type getType();
+ public void setName(String name);
+ public void setType(Type type);
+
+}
+
diff --git a/src/java/org/apache/bcel/generic/ObjectType.java b/src/java/org/apache/bcel/generic/ObjectType.java
new file mode 100644
index 00000000..d4476770
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ObjectType.java
@@ -0,0 +1,136 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import org.apache.bcel.Constants;
+import org.apache.bcel.Repository;
+import org.apache.bcel.classfile.JavaClass;
+
+/**
+ * Denotes reference such as java.lang.String.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public final class ObjectType extends ReferenceType {
+ private String class_name; // Class name of type
+
+ /**
+ * @param class_name fully qualified class name, e.g. java.lang.String
+ */
+ public ObjectType(String class_name) {
+ super(Constants.T_REFERENCE, "L" + class_name.replace('.', '/') + ";");
+ this.class_name = class_name.replace('/', '.');
+ }
+
+ /** @return name of referenced class
+ */
+ public String getClassName() { return class_name; }
+
+ /** @return a hash code value for the object.
+ */
+ public int hashCode() { return class_name.hashCode(); }
+
+ /** @return true if both type objects refer to the same class.
+ */
+ public boolean equals(Object type) {
+ return (type instanceof ObjectType)?
+ ((ObjectType)type).class_name.equals(class_name) : false;
+ }
+
+ /**
+ * If "this" doesn't reference a class, it references an interface
+ * or a non-existant entity.
+ */
+ public boolean referencesClass(){
+ JavaClass jc = Repository.lookupClass(class_name);
+ if (jc == null)
+ return false;
+ else
+ return jc.isClass();
+ }
+
+ /**
+ * If "this" doesn't reference an interface, it references a class
+ * or a non-existant entity.
+ */
+ public boolean referencesInterface(){
+ JavaClass jc = Repository.lookupClass(class_name);
+ if (jc == null)
+ return false;
+ else
+ return !jc.isClass();
+ }
+
+ public boolean subclassOf(ObjectType superclass){
+ if (this.referencesInterface() || superclass.referencesInterface())
+ return false;
+
+ return Repository.instanceOf(this.class_name, superclass.class_name);
+ }
+
+ /**
+ * Java Virtual Machine Specification edition 2, § 5.4.4 Access Control
+ */
+ public boolean accessibleTo(ObjectType accessor) {
+ JavaClass jc = Repository.lookupClass(class_name);
+
+ if(jc.isPublic()) {
+ return true;
+ } else {
+ JavaClass acc = Repository.lookupClass(accessor.class_name);
+ return acc.getPackageName().equals(jc.getPackageName());
+ }
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/POP.java b/src/java/org/apache/bcel/generic/POP.java
new file mode 100644
index 00000000..c5dac2c5
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/POP.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * POP - Pop top operand stack word
+ *
+ * <PRE>Stack: ..., word -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class POP extends StackInstruction implements PopInstruction {
+ public POP() {
+ super(org.apache.bcel.Constants.POP);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitPopInstruction(this);
+ v.visitStackInstruction(this);
+ v.visitPOP(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/POP2.java b/src/java/org/apache/bcel/generic/POP2.java
new file mode 100644
index 00000000..8a7faeba
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/POP2.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * POP2 - Pop two top operand stack words
+ *
+ * <PRE>Stack: ..., word2, word1 -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class POP2 extends StackInstruction implements PopInstruction {
+ public POP2() {
+ super(org.apache.bcel.Constants.POP2);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitPopInstruction(this);
+ v.visitStackInstruction(this);
+ v.visitPOP2(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/PUSH.java b/src/java/org/apache/bcel/generic/PUSH.java
new file mode 100644
index 00000000..7a77a1d2
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/PUSH.java
@@ -0,0 +1,196 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import org.apache.bcel.Constants;
+import java.io.*;
+
+/**
+ * Wrapper class for push operations, which are implemented either as BIPUSH,
+ * LDC or xCONST_n instructions.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public final class PUSH
+ implements CompoundInstruction, VariableLengthInstruction, InstructionConstants
+{
+ private Instruction instruction;
+
+ /**
+ * This constructor also applies for values of type short, char, byte
+ *
+ * @param cp Constant pool
+ * @param value to be pushed
+ */
+ public PUSH(ConstantPoolGen cp, int value) {
+ if((value >= -1) && (value <= 5)) // Use ICONST_n
+ instruction = INSTRUCTIONS[Constants.ICONST_0 + value];
+ else if((value >= -128) && (value <= 127)) // Use BIPUSH
+ instruction = new BIPUSH((byte)value);
+ else if((value >= -32768) && (value <= 32767)) // Use SIPUSH
+ instruction = new SIPUSH((short)value);
+ else // If everything fails create a Constant pool entry
+ instruction = new LDC(cp.addInteger(value));
+ }
+
+ /**
+ * @param cp Constant pool
+ * @param value to be pushed
+ */
+ public PUSH(ConstantPoolGen cp, boolean value) {
+ instruction = INSTRUCTIONS[Constants.ICONST_0 + (value? 1 : 0)];
+ }
+
+ /**
+ * @param cp Constant pool
+ * @param value to be pushed
+ */
+ public PUSH(ConstantPoolGen cp, float value) {
+ if(value == 0.0)
+ instruction = FCONST_0;
+ else if(value == 1.0)
+ instruction = FCONST_1;
+ else if(value == 2.0)
+ instruction = FCONST_2;
+ else // Create a Constant pool entry
+ instruction = new LDC(cp.addFloat(value));
+ }
+
+ /**
+ * @param cp Constant pool
+ * @param value to be pushed
+ */
+ public PUSH(ConstantPoolGen cp, long value) {
+ if(value == 0)
+ instruction = LCONST_0;
+ else if(value == 1)
+ instruction = LCONST_1;
+ else // Create a Constant pool entry
+ instruction = new LDC2_W(cp.addLong(value));
+ }
+
+ /**
+ * @param cp Constant pool
+ * @param value to be pushed
+ */
+ public PUSH(ConstantPoolGen cp, double value) {
+ if(value == 0.0)
+ instruction = DCONST_0;
+ else if(value == 1.0)
+ instruction = DCONST_1;
+ else // Create a Constant pool entry
+ instruction = new LDC2_W(cp.addDouble(value));
+ }
+
+ /**
+ * @param cp Constant pool
+ * @param value to be pushed
+ */
+ public PUSH(ConstantPoolGen cp, String value) {
+ if(value == null)
+ instruction = ACONST_NULL;
+ else // Create a Constant pool entry
+ instruction = new LDC(cp.addString(value));
+ }
+
+ /**
+ * @param cp Constant pool
+ * @param value to be pushed
+ */
+ public PUSH(ConstantPoolGen cp, Number value) {
+ if((value instanceof Integer) || (value instanceof Short) || (value instanceof Byte))
+ instruction = new PUSH(cp, value.intValue()).instruction;
+ else if(value instanceof Double)
+ instruction = new PUSH(cp, value.doubleValue()).instruction;
+ else if(value instanceof Float)
+ instruction = new PUSH(cp, value.floatValue()).instruction;
+ else if(value instanceof Long)
+ instruction = new PUSH(cp, value.longValue()).instruction;
+ else
+ throw new ClassGenException("What's this: " + value);
+ }
+
+ /**
+ * @param cp Constant pool
+ * @param value to be pushed
+ */
+ public PUSH(ConstantPoolGen cp, Character value) {
+ this(cp, (int)value.charValue());
+ }
+
+ /**
+ * @param cp Constant pool
+ * @param value to be pushed
+ */
+ public PUSH(ConstantPoolGen cp, Boolean value) {
+ this(cp, value.booleanValue());
+ }
+
+ public final InstructionList getInstructionList() {
+ return new InstructionList(instruction);
+ }
+
+ public final Instruction getInstruction() {
+ return instruction;
+ }
+
+ /**
+ * @return mnemonic for instruction
+ */
+ public String toString() {
+ return instruction.toString() + " (PUSH)";
+ }
+}
+
diff --git a/src/java/org/apache/bcel/generic/PUTFIELD.java b/src/java/org/apache/bcel/generic/PUTFIELD.java
new file mode 100644
index 00000000..ad5bee3e
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/PUTFIELD.java
@@ -0,0 +1,114 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import org.apache.bcel.ExceptionConstants;
+
+/**
+ * PUTFIELD - Put field in object
+ * <PRE>Stack: ..., objectref, value -&gt; ...</PRE>
+ * OR
+ * <PRE>Stack: ..., objectref, value.word1, value.word2 -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class PUTFIELD extends FieldInstruction implements ExceptionThrower{
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ PUTFIELD() {}
+
+ public PUTFIELD(int index) {
+ super(Constants.PUTFIELD, index);
+ }
+
+ public int consumeStack(ConstantPoolGen cpg) { return getFieldSize(cpg) + 1; }
+
+ public Class[] getExceptions() {
+ Class[] cs = new Class[2 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length];
+
+ System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0,
+ cs, 0, ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length);
+
+ cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length+1] =
+ ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR;
+ cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] =
+ ExceptionConstants.NULL_POINTER_EXCEPTION;
+
+ return cs;
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitLoadClass(this);
+ v.visitCPInstruction(this);
+ v.visitFieldOrMethod(this);
+ v.visitFieldInstruction(this);
+ v.visitPUTFIELD(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/PUTSTATIC.java b/src/java/org/apache/bcel/generic/PUTSTATIC.java
new file mode 100644
index 00000000..b3da2ec7
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/PUTSTATIC.java
@@ -0,0 +1,114 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import org.apache.bcel.ExceptionConstants;
+
+/**
+ * PUTSTATIC - Put static field in class
+ * <PRE>Stack: ..., objectref, value -&gt; ...</PRE>
+ * OR
+ * <PRE>Stack: ..., objectref, value.word1, value.word2 -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class PUTSTATIC extends FieldInstruction
+ implements ExceptionThrower, PopInstruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ PUTSTATIC() {}
+
+ public PUTSTATIC(int index) {
+ super(Constants.PUTSTATIC, index);
+ }
+
+ public int consumeStack(ConstantPoolGen cpg) { return getFieldSize(cpg); }
+
+ public Class[] getExceptions() {
+ Class[] cs = new Class[1 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length];
+
+ System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0,
+ cs, 0, ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length);
+ cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] =
+ ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR;
+
+ return cs;
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitExceptionThrower(this);
+ v.visitStackConsumer(this);
+ v.visitPopInstruction(this);
+ v.visitTypedInstruction(this);
+ v.visitLoadClass(this);
+ v.visitCPInstruction(this);
+ v.visitFieldOrMethod(this);
+ v.visitFieldInstruction(this);
+ v.visitPUTSTATIC(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/PopInstruction.java b/src/java/org/apache/bcel/generic/PopInstruction.java
new file mode 100644
index 00000000..df9cf3a0
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/PopInstruction.java
@@ -0,0 +1,68 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Denotes an unparameterized instruction to pop a value on top from the stack,
+ * such as ISTORE, POP, PUTSTATIC.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see ISTORE
+ * @see POP
+ */
+public interface PopInstruction extends StackConsumer {
+}
+
diff --git a/src/java/org/apache/bcel/generic/PushInstruction.java b/src/java/org/apache/bcel/generic/PushInstruction.java
new file mode 100644
index 00000000..9b600441
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/PushInstruction.java
@@ -0,0 +1,73 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Denotes an unparameterized instruction to produce a value on top of the stack,
+ * such as ILOAD, LDC, SIPUSH, DUP, ICONST, etc.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+
+ * @see ILOAD
+ * @see ICONST
+ * @see LDC
+ * @see DUP
+ * @see SIPUSH
+ * @see GETSTATIC
+ */
+public interface PushInstruction extends StackProducer {
+}
+
diff --git a/src/java/org/apache/bcel/generic/RET.java b/src/java/org/apache/bcel/generic/RET.java
new file mode 100644
index 00000000..c916e0b2
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/RET.java
@@ -0,0 +1,161 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import java.io.*;
+import org.apache.bcel.util.ByteSequence;
+
+/**
+ * RET - Return from subroutine
+ *
+ * <PRE>Stack: ..., -&gt; ..., address</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class RET extends Instruction implements IndexedInstruction, TypedInstruction {
+ private boolean wide;
+ private int index; // index to local variable containg the return address
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ RET() {}
+
+ public RET(int index) {
+ super(org.apache.bcel.Constants.RET, (short)2);
+ setIndex(index); // May set wide as side effect
+ }
+
+ /**
+ * Dump instruction as byte code to stream out.
+ * @param out Output stream
+ */
+ public void dump(DataOutputStream out) throws IOException {
+ if(wide)
+ out.writeByte(org.apache.bcel.Constants.WIDE);
+
+ out.writeByte(opcode);
+
+ if(wide)
+ out.writeShort(index);
+ else
+ out.writeByte(index);
+ }
+
+ private final void setWide() {
+ if(wide = index > org.apache.bcel.Constants.MAX_BYTE)
+ length = 4; // Including the wide byte
+ else
+ length = 2;
+ }
+
+ /**
+ * Read needed data (e.g. index) from file.
+ */
+ protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
+ {
+ this.wide = wide;
+
+ if(wide) {
+ index = bytes.readUnsignedShort();
+ length = 4;
+ } else {
+ index = bytes.readUnsignedByte();
+ length = 2;
+ }
+ }
+
+ /**
+ * @return index of local variable containg the return address
+ */
+ public final int getIndex() { return index; }
+
+ /**
+ * Set index of local variable containg the return address
+ */
+ public final void setIndex(int n) {
+ if(n < 0)
+ throw new ClassGenException("Negative index value: " + n);
+
+ index = n;
+ setWide();
+ }
+
+ /**
+ * @return mnemonic for instruction
+ */
+ public String toString(boolean verbose) {
+ return super.toString(verbose) + " " + index;
+ }
+
+ /** @return return address type
+ */
+ public Type getType(ConstantPoolGen cp) {
+ return ReturnaddressType.NO_TARGET;
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitRET(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/RETURN.java b/src/java/org/apache/bcel/generic/RETURN.java
new file mode 100644
index 00000000..d8f4084c
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/RETURN.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * RETURN - Return from void method
+ * <PRE>Stack: ... -&gt; &lt;empty&gt;</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class RETURN extends ReturnInstruction {
+ public RETURN() {
+ super(org.apache.bcel.Constants.RETURN);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitStackConsumer(this);
+ v.visitReturnInstruction(this);
+ v.visitRETURN(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/ReferenceType.java b/src/java/org/apache/bcel/generic/ReferenceType.java
new file mode 100644
index 00000000..dd958fa1
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ReferenceType.java
@@ -0,0 +1,258 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import org.apache.bcel.Constants;
+import org.apache.bcel.Repository;
+import org.apache.bcel.classfile.JavaClass;
+
+/**
+ * Super class for objects and arrays.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class ReferenceType extends Type {
+ protected ReferenceType(byte t, String s) {
+ super(t, s);
+ }
+
+ /** Class is non-abstract but not instantiable from the outside
+ */
+ ReferenceType() {
+ super(Constants.T_OBJECT, "<null object>");
+ }
+
+ /**
+ * Return true iff this type is castable to another type t as defined in
+ * the JVM specification. The case where this is Type.NULL is not
+ * defined (see the CHECKCAST definition in the JVM specification).
+ * However, because e.g. CHECKCAST doesn't throw a
+ * ClassCastException when casting a null reference to any Object,
+ * true is returned in this case.
+ */
+ public boolean isCastableTo(Type t){
+ if(this.equals(Type.NULL))
+ return true; // If this is ever changed in isAssignmentCompatible()
+
+ return isAssignmentCompatibleWith(t); /* Yes, it's true: It's the same definition.
+ * See vmspec2 AASTORE / CHECKCAST definitions.
+ */
+ }
+
+ /**
+ * Return true iff this is assignment compatible with another type t
+ * as defined in the JVM specification; see the AASTORE definition
+ * there.
+ */
+ public boolean isAssignmentCompatibleWith(Type t) {
+ if(!(t instanceof ReferenceType))
+ return false;
+
+ ReferenceType T = (ReferenceType)t;
+
+ if(this.equals(Type.NULL))
+ return true; // This is not explicitely stated, but clear. Isn't it?
+
+ /* If this is a class type then
+ */
+ if((this instanceof ObjectType) && (((ObjectType) this).referencesClass())) {
+ /* If T is a class type, then this must be the same class as T,
+ or this must be a subclass of T;
+ */
+ if((T instanceof ObjectType) && (((ObjectType) T).referencesClass())) {
+ if(this.equals(T))
+ return true;
+
+ if(Repository.instanceOf( ((ObjectType) this).getClassName(),
+ ((ObjectType) T).getClassName()))
+ return true;
+ }
+
+ /* If T is an interface type, this must implement interface T.
+ */
+ if ((T instanceof ObjectType) && (((ObjectType) T).referencesInterface())) {
+ if (Repository.implementationOf( ((ObjectType) this).getClassName(),
+ ((ObjectType) T).getClassName() ))
+ return true;
+ }
+ }
+
+ /* If this is an interface type, then:
+ */
+ if ((this instanceof ObjectType) && (((ObjectType) this).referencesInterface())){
+ /* If T is a class type, then T must be Object (§2.4.7).
+ */
+ if ((T instanceof ObjectType) && (((ObjectType) T).referencesClass())){
+ if (T.equals(Type.OBJECT)) return true;
+ }
+
+ /* If T is an interface type, then T must be the same interface
+ as this or a superinterface of this (§2.13.2).
+ */
+ if ((T instanceof ObjectType) && (((ObjectType) T).referencesInterface())){
+ if (this.equals(T)) return true;
+ if (Repository.implementationOf( ((ObjectType) this).getClassName(),
+ ((ObjectType) T).getClassName() )) return true;
+ }
+ }
+
+ /* If this is an array type, namely, the type SC[], that is, an
+ array of components of type SC, then:
+ */
+ if(this instanceof ArrayType){
+ /* If T is a class type, then T must be Object (§2.4.7).
+ */
+ if ((T instanceof ObjectType) && (((ObjectType) T).referencesClass())){
+ if (T.equals(Type.OBJECT)) return true;
+ }
+
+ /* If T is an array type TC[], that is, an array of components
+ of type TC, then one of the following must be true:
+ */
+ if (T instanceof ArrayType) {
+ /* TC and SC are the same primitive type (§2.4.1).
+ */
+ Type sc = ((ArrayType) this).getElementType();
+ Type tc = ((ArrayType) this).getElementType();
+
+ if (sc instanceof BasicType && tc instanceof BasicType && sc.equals(tc))
+ return true;
+
+ /* TC and SC are reference types (§2.4.6), and type SC is
+ assignable to TC by these runtime rules.*/
+ if (tc instanceof ReferenceType && sc instanceof ReferenceType &&
+ ((ReferenceType) sc).isAssignmentCompatibleWith((ReferenceType) tc)) return true;
+ }
+
+ /* If T is an interface type, T must be one of the interfaces implemented by arrays (§2.15). */
+ // TODO: Check if this is still valid or find a way to dynamically find out which
+ // interfaces arrays implement. However, as of the JVM specification edition 2, there
+ // are at least two different pages where assignment compatibility is defined and
+ // on one of them "interfaces implemented by arrays" is exchanged with "'Cloneable' or
+ // 'java.io.Serializable'"
+ if ((T instanceof ObjectType) && (((ObjectType) T).referencesInterface())){
+ for (int ii=0; ii<Constants.INTERFACES_IMPLEMENTED_BY_ARRAYS.length; ii++){
+ if (T.equals(new ObjectType(Constants.INTERFACES_IMPLEMENTED_BY_ARRAYS[ii]))) return true;
+ }
+ }
+ }
+ return false; // default.
+ }
+
+ /**
+ * This commutative operation returns the first common superclass (narrowest ReferenceType
+ * referencing a class, not an interface).
+ * If one of the types is a superclass of the other, the former is returned.
+ * If "this" is Type.NULL, then t is returned.
+ * If t is Type.NULL, then "this" is returned.
+ * If "this" equals t ['this.equals(t)'] "this" is returned.
+ * If "this" or t is an ArrayType, then Type.OBJECT is returned.
+ * If "this" or t is a ReferenceType referencing an interface, then Type.OBJECT is returned.
+ * If not all of the two classes' superclasses cannot be found, "null" is returned.
+ * See the JVM specification edition 2, "§4.9.2 The Bytecode Verifier".
+ */
+ public ReferenceType firstCommonSuperclass(ReferenceType t){
+ if (this.equals(Type.NULL)) return t;
+
+ if (t.equals(Type.NULL)) return this;
+
+ if (this.equals(t)) return this;
+
+ // TODO: This sounds a little arbitrary. On the other hand, there is
+ // no object referenced by Type.NULL so we can also say all the objects
+ // referenced by Type.NULL were derived from java.lang.Object.
+ // However, the Java Language's "instanceof" operator proves us wrong:
+ // "null" is not referring to an instance of java.lang.Object :)
+
+ if ((this instanceof ArrayType) || (t instanceof ArrayType))
+ return Type.OBJECT;
+ // TODO: Is there a proof of OBJECT being the direct ancestor of every ArrayType?
+
+ if ( ((this instanceof ObjectType) && ((ObjectType) this).referencesInterface()) ||
+ (( t instanceof ObjectType) && ((ObjectType) t).referencesInterface()) )
+ return Type.OBJECT;
+ // TODO: The above line is correct comparing to the vmspec2. But one could
+ // make class file verification a bit stronger here by using the notion of
+ // superinterfaces or even castability or assignment compatibility.
+
+
+ // this and t are ObjectTypes, see above.
+ ObjectType thiz = (ObjectType) this;
+ ObjectType other = (ObjectType) t;
+ JavaClass[] thiz_sups = Repository.getSuperClasses( thiz.getClassName());
+ JavaClass[] other_sups = Repository.getSuperClasses(other.getClassName());
+
+ if ((thiz_sups == null) || (other_sups==null)){
+ return null;
+ }
+
+ // Waaahh...
+ JavaClass[] this_sups = new JavaClass[thiz_sups.length+1];
+ JavaClass[] t_sups = new JavaClass[other_sups.length+1];
+ System.arraycopy( thiz_sups, 0, this_sups, 1, thiz_sups.length);
+ System.arraycopy(other_sups, 0, t_sups , 1, other_sups.length);
+ this_sups[0] = Repository.lookupClass(thiz.getClassName());
+ t_sups[0] = Repository.lookupClass(other.getClassName());
+
+ for (int i=0; i<t_sups.length; i++){
+ for (int j=0; j<this_sups.length; j++){
+ if (this_sups[j].equals(t_sups[i])) return new ObjectType(this_sups[j].getClassName());
+ }
+ }
+
+ // Huh? Did you ask for Type.OBJECT's superclass??
+ return null;
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/ReturnInstruction.java b/src/java/org/apache/bcel/generic/ReturnInstruction.java
new file mode 100644
index 00000000..abe1675f
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ReturnInstruction.java
@@ -0,0 +1,104 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import org.apache.bcel.Constants;
+import org.apache.bcel.ExceptionConstants;
+
+/**
+ * Super class for the xRETURN family of instructions.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public abstract class ReturnInstruction extends Instruction
+ implements ExceptionThrower, TypedInstruction, StackConsumer {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ ReturnInstruction() {}
+
+ /**
+ * @param opcode of instruction
+ */
+ protected ReturnInstruction(short opcode) {
+ super(opcode, (short)1);
+ }
+
+ public Type getType() {
+ switch(opcode) {
+ case Constants.IRETURN: return Type.INT;
+ case Constants.LRETURN: return Type.LONG;
+ case Constants.FRETURN: return Type.FLOAT;
+ case Constants.DRETURN: return Type.DOUBLE;
+ case Constants.ARETURN: return Type.OBJECT;
+ case Constants.RETURN: return Type.VOID;
+
+ default: // Never reached
+ throw new ClassGenException("Unknown type " + opcode);
+ }
+ }
+
+ public Class[] getExceptions() {
+ return new Class[] { ExceptionConstants.ILLEGAL_MONITOR_STATE };
+ }
+
+ /** @return type associated with the instruction
+ */
+ public Type getType(ConstantPoolGen cp) {
+ return getType();
+ }
+}
+
diff --git a/src/java/org/apache/bcel/generic/ReturnaddressType.java b/src/java/org/apache/bcel/generic/ReturnaddressType.java
new file mode 100644
index 00000000..4a1b4c57
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/ReturnaddressType.java
@@ -0,0 +1,102 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import org.apache.bcel.Constants;
+import org.apache.bcel.generic.InstructionHandle;
+
+/**
+ * Returnaddress, the type JSR or JSR_W instructions push upon the stack.
+ *
+ * see vmspec2 §3.3.3
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase">Enver Haase</A>
+ */
+public class ReturnaddressType extends Type {
+
+ public static final ReturnaddressType NO_TARGET = new ReturnaddressType();
+ private InstructionHandle returnTarget;
+
+ /**
+ * A Returnaddress [that doesn't know where to return to].
+ */
+ private ReturnaddressType(){
+ super(Constants.T_ADDRESS, "<return address>");
+ }
+
+ /**
+ * Creates a ReturnaddressType object with a target.
+ */
+ public ReturnaddressType(InstructionHandle returnTarget) {
+ super(Constants.T_ADDRESS, "<return address targeting "+returnTarget+">");
+ this.returnTarget = returnTarget;
+ }
+
+ /**
+ * Returns if the two Returnaddresses refer to the same target.
+ */
+ public boolean equals(Object rat){
+ if(!(rat instanceof ReturnaddressType))
+ return false;
+
+ return ((ReturnaddressType)rat).returnTarget.equals(this.returnTarget);
+ }
+
+ /**
+ * @return the target of this ReturnaddressType
+ */
+ public InstructionHandle getTarget(){
+ return returnTarget;
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/SALOAD.java b/src/java/org/apache/bcel/generic/SALOAD.java
new file mode 100644
index 00000000..17f18f74
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/SALOAD.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * SALOAD - Load short from array
+ * <PRE>Stack: ..., arrayref, index -&gt; ..., value</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class SALOAD extends ArrayInstruction implements StackProducer {
+ public SALOAD() {
+ super(org.apache.bcel.Constants.SALOAD);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackProducer(this);
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitArrayInstruction(this);
+ v.visitSALOAD(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/SASTORE.java b/src/java/org/apache/bcel/generic/SASTORE.java
new file mode 100644
index 00000000..cc3088f3
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/SASTORE.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * SASTORE - Store into short array
+ * <PRE>Stack: ..., arrayref, index, value -&gt; ...</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class SASTORE extends ArrayInstruction implements StackConsumer {
+ public SASTORE() {
+ super(org.apache.bcel.Constants.SASTORE);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitArrayInstruction(this);
+ v.visitSASTORE(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/SIPUSH.java b/src/java/org/apache/bcel/generic/SIPUSH.java
new file mode 100644
index 00000000..e1e216b9
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/SIPUSH.java
@@ -0,0 +1,129 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import java.io.*;
+import org.apache.bcel.util.ByteSequence;
+
+/**
+ * SIPUSH - Push short
+ *
+ * <PRE>Stack: ... -&gt; ..., value</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class SIPUSH extends Instruction implements ConstantPushInstruction {
+ private short b;
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ SIPUSH() {}
+
+ public SIPUSH(short b) {
+ super(org.apache.bcel.Constants.SIPUSH, (short)3);
+ this.b = b;
+ }
+
+ /**
+ * Dump instruction as short code to stream out.
+ */
+ public void dump(DataOutputStream out) throws IOException {
+ super.dump(out);
+ out.writeShort(b);
+ }
+
+ /**
+ * @return mnemonic for instruction
+ */
+ public String toString(boolean verbose) {
+ return super.toString(verbose) + " " + b;
+ }
+
+ /**
+ * Read needed data (e.g. index) from file.
+ */
+ protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
+ {
+ length = 3;
+ b = bytes.readShort();
+ }
+
+ public Number getValue() { return new Integer(b); }
+
+ /** @return Type.SHORT
+ */
+ public Type getType(ConstantPoolGen cp) {
+ return Type.SHORT;
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitPushInstruction(this);
+ v.visitStackProducer(this);
+ v.visitTypedInstruction(this);
+ v.visitConstantPushInstruction(this);
+ v.visitSIPUSH(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/SWAP.java b/src/java/org/apache/bcel/generic/SWAP.java
new file mode 100644
index 00000000..9b23edc1
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/SWAP.java
@@ -0,0 +1,84 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * SWAP - Swa top operand stack word
+ * <PRE>Stack: ..., word2, word1 -&gt; ..., word1, word2</PRE>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class SWAP extends StackInstruction implements StackConsumer, StackProducer {
+ public SWAP() {
+ super(org.apache.bcel.Constants.SWAP);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitStackProducer(this);
+ v.visitStackInstruction(this);
+ v.visitSWAP(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/SWITCH.java b/src/java/org/apache/bcel/generic/SWITCH.java
new file mode 100644
index 00000000..d47bd2a1
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/SWITCH.java
@@ -0,0 +1,183 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * SWITCH - Branch depending on int value, generates either LOOKUPSWITCH or
+ * TABLESWITCH instruction, depending on whether the match values (int[]) can be
+ * sorted with no gaps between the numbers.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public final class SWITCH implements CompoundInstruction {
+ private int[] match;
+ private InstructionHandle[] targets;
+ private Select instruction;
+ private int match_length;
+
+ /**
+ * Template for switch() constructs. If the match array can be
+ * sorted in ascending order with gaps no larger than max_gap
+ * between the numbers, a TABLESWITCH instruction is generated, and
+ * a LOOKUPSWITCH otherwise. The former may be more efficient, but
+ * needs more space.
+ *
+ * Note, that the key array always will be sorted, though we leave
+ * the original arrays unaltered.
+ *
+ * @param match array of match values (case 2: ... case 7: ..., etc.)
+ * @param targets the instructions to be branched to for each case
+ * @param target the default target
+ * @param max_gap maximum gap that may between case branches
+ */
+ public SWITCH(int[] match, InstructionHandle[] targets,
+ InstructionHandle target, int max_gap) {
+ this.match = (int[])match.clone();
+ this.targets = (InstructionHandle[])targets.clone();
+
+ if((match_length = match.length) < 2) // (almost) empty switch, or just default
+ instruction = new TABLESWITCH(match, targets, target);
+ else {
+ sort(0, match_length - 1);
+
+ if(matchIsOrdered(max_gap)) {
+ fillup(max_gap, target);
+
+ instruction = new TABLESWITCH(this.match, this.targets, target);
+ }
+ else
+ instruction = new LOOKUPSWITCH(this.match, this.targets, target);
+ }
+ }
+
+ public SWITCH(int[] match, InstructionHandle[] targets,
+ InstructionHandle target) {
+ this(match, targets, target, 1);
+ }
+
+ private final void fillup(int max_gap, InstructionHandle target) {
+ int max_size = match_length + match_length * max_gap;
+ int[] m_vec = new int[max_size];
+ InstructionHandle[] t_vec = new InstructionHandle[max_size];
+ int count = 1;
+
+ m_vec[0] = match[0];
+ t_vec[0] = targets[0];
+
+ for(int i=1; i < match_length; i++) {
+ int prev = match[i-1];
+ int gap = match[i] - prev;
+
+ for(int j=1; j < gap; j++) {
+ m_vec[count] = prev + j;
+ t_vec[count] = target;
+ count++;
+ }
+
+ m_vec[count] = match[i];
+ t_vec[count] = targets[i];
+ count++;
+ }
+
+ match = new int[count];
+ targets = new InstructionHandle[count];
+
+ System.arraycopy(m_vec, 0, match, 0, count);
+ System.arraycopy(t_vec, 0, targets, 0, count);
+ }
+
+ /**
+ * Sort match and targets array with QuickSort.
+ */
+ private final void sort(int l, int r) {
+ int i = l, j = r;
+ int h, m = match[(l + r) / 2];
+ InstructionHandle h2;
+
+ do {
+ while(match[i] < m) i++;
+ while(m < match[j]) j--;
+
+ if(i <= j) {
+ h=match[i]; match[i]=match[j]; match[j]=h; // Swap elements
+ h2=targets[i]; targets[i]=targets[j]; targets[j]=h2; // Swap instructions, too
+ i++; j--;
+ }
+ } while(i <= j);
+
+ if(l < j) sort(l, j);
+ if(i < r) sort(i, r);
+ }
+
+ /**
+ * @return match is sorted in ascending order with no gap bigger than max_gap?
+ */
+ private final boolean matchIsOrdered(int max_gap) {
+ for(int i=1; i < match_length; i++)
+ if(match[i] - match[i-1] > max_gap)
+ return false;
+
+ return true;
+ }
+
+ public final InstructionList getInstructionList() {
+ return new InstructionList(instruction);
+ }
+
+ public final Instruction getInstruction() {
+ return instruction;
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/Select.java b/src/java/org/apache/bcel/generic/Select.java
new file mode 100644
index 00000000..c56f6903
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/Select.java
@@ -0,0 +1,256 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import java.io.*;
+import org.apache.bcel.util.ByteSequence;
+
+/**
+ * Select - Abstract super class for LOOKUPSWITCH and TABLESWITCH instructions.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see LOOKUPSWITCH
+ * @see TABLESWITCH
+ * @see InstructionList
+ */
+public abstract class Select extends BranchInstruction
+ implements VariableLengthInstruction, StackProducer
+{
+ protected int[] match; // matches, i.e., case 1: ...
+ protected int[] indices; // target offsets
+ protected InstructionHandle[] targets; // target objects in instruction list
+ protected int fixed_length; // fixed length defined by subclasses
+ protected int match_length; // number of cases
+ protected int padding = 0; // number of pad bytes for alignment
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ Select() {}
+
+ /**
+ * (Match, target) pairs for switch.
+ * `Match' and `targets' must have the same length of course.
+ *
+ * @param match array of matching values
+ * @param targets instruction targets
+ * @param target default instruction target
+ */
+ Select(short opcode, int[] match, InstructionHandle[] targets,
+ InstructionHandle target) {
+ super(opcode, target);
+
+ this.targets = targets;
+ for(int i=0; i < targets.length; i++)
+ notifyTarget(null, targets[i], this);
+
+ this.match = match;
+
+ if((match_length = match.length) != targets.length)
+ throw new ClassGenException("Match and target array have not the same length");
+
+ indices = new int[match_length];
+ }
+
+ /**
+ * Since this is a variable length instruction, it may shift the following
+ * instructions which then need to update their position.
+ *
+ * Called by InstructionList.setPositions when setting the position for every
+ * instruction. In the presence of variable length instructions `setPositions'
+ * performs multiple passes over the instruction list to calculate the
+ * correct (byte) positions and offsets by calling this function.
+ *
+ * @param offset additional offset caused by preceding (variable length) instructions
+ * @param max_offset the maximum offset that may be caused by these instructions
+ * @return additional offset caused by possible change of this instruction's length
+ */
+ protected int updatePosition(int offset, int max_offset) {
+ position += offset; // Additional offset caused by preceding SWITCHs, GOTOs, etc.
+
+ short old_length = length;
+
+ /* Alignment on 4-byte-boundary, + 1, because of tag byte.
+ */
+ padding = (4 - ((position + 1) % 4)) % 4;
+ length = (short)(fixed_length + padding); // Update length
+
+ return length - old_length;
+ }
+
+ /**
+ * Dump instruction as byte code to stream out.
+ * @param out Output stream
+ */
+ public void dump(DataOutputStream out) throws IOException {
+ out.writeByte(opcode);
+
+ for(int i=0; i < padding; i++) // Padding bytes
+ out.writeByte(0);
+
+ index = getTargetOffset(); // Write default target offset
+ out.writeInt(index);
+ }
+
+ /**
+ * Read needed data (e.g. index) from file.
+ */
+ protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
+ {
+ padding = (4 - (bytes.getIndex() % 4)) % 4; // Compute number of pad bytes
+
+ for(int i=0; i < padding; i++) {
+ byte b;
+ if((b=bytes.readByte()) != 0)
+ throw new ClassGenException("Padding byte != 0: " + b);
+ }
+
+ // Default branch target common for both cases (TABLESWITCH, LOOKUPSWITCH)
+ index = bytes.readInt();
+ }
+
+ /**
+ * @return mnemonic for instruction
+ */
+ public String toString(boolean verbose) {
+ StringBuffer buf = new StringBuffer(super.toString(verbose));
+
+ if(verbose) {
+ for(int i=0; i < match_length; i++) {
+ String s = "null";
+
+ if(targets[i] != null)
+ s = targets[i].getInstruction().toString();
+
+ buf.append("(" + match[i] + ", " + s + " = {" + indices[i] + "})");
+ }
+ }
+ else
+ buf.append(" ...");
+
+ return buf.toString();
+ }
+
+ /**
+ * Set branch target for `i'th case
+ */
+ public void setTarget(int i, InstructionHandle target) {
+ notifyTarget(targets[i], target, this);
+ targets[i] = target;
+ }
+
+ /**
+ * @param old_ih old target
+ * @param new_ih new target
+ */
+ public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) {
+ boolean targeted = false;
+
+ if(target == old_ih) {
+ targeted = true;
+ setTarget(new_ih);
+ }
+
+ for(int i=0; i < targets.length; i++) {
+ if(targets[i] == old_ih) {
+ targeted = true;
+ setTarget(i, new_ih);
+ }
+ }
+
+ if(!targeted)
+ throw new ClassGenException("Not targeting " + old_ih);
+ }
+
+ /**
+ * @return true, if ih is target of this instruction
+ */
+ public boolean containsTarget(InstructionHandle ih) {
+ if(target == ih)
+ return true;
+
+ for(int i=0; i < targets.length; i++)
+ if(targets[i] == ih)
+ return true;
+
+ return false;
+ }
+
+ /**
+ * Inform targets that they're not targeted anymore.
+ */
+ void dispose() {
+ super.dispose();
+
+ for(int i=0; i < targets.length; i++)
+ targets[i].removeTargeter(this);
+ }
+
+ /**
+ * @return array of match indices
+ */
+ public int[] getMatchs() { return match; }
+
+ /**
+ * @return array of match target offsets
+ */
+ public int[] getIndices() { return indices; }
+
+ /**
+ * @return array of match targets
+ */
+ public InstructionHandle[] getTargets() { return targets; }
+}
diff --git a/src/java/org/apache/bcel/generic/StackConsumer.java b/src/java/org/apache/bcel/generic/StackConsumer.java
new file mode 100644
index 00000000..fd97f60b
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/StackConsumer.java
@@ -0,0 +1,68 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Denote an instruction that may consume a value from the stack.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public interface StackConsumer {
+ /** @return how many words are consumed from stack
+ */
+ public int consumeStack(ConstantPoolGen cpg);
+}
+
diff --git a/src/java/org/apache/bcel/generic/StackInstruction.java b/src/java/org/apache/bcel/generic/StackInstruction.java
new file mode 100644
index 00000000..03a488e5
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/StackInstruction.java
@@ -0,0 +1,83 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Super class for stack operations like DUP and POP.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public abstract class StackInstruction extends Instruction {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ StackInstruction() {}
+
+ /**
+ * @param opcode instruction opcode
+ */
+ protected StackInstruction(short opcode) {
+ super(opcode, (short)1);
+ }
+
+ /** @return Type.UNKNOWN
+ */
+ public Type getType(ConstantPoolGen cp) {
+ return Type.UNKNOWN;
+ }
+}
+
diff --git a/src/java/org/apache/bcel/generic/StackProducer.java b/src/java/org/apache/bcel/generic/StackProducer.java
new file mode 100644
index 00000000..955b9c07
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/StackProducer.java
@@ -0,0 +1,69 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Denote an instruction that may produce a value on top of the stack
+ * (this excludes DUP_X1, e.g.)
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public interface StackProducer {
+ /** @return how many words are produced on stack
+ */
+ public int produceStack(ConstantPoolGen cpg);
+}
+
diff --git a/src/java/org/apache/bcel/generic/StoreInstruction.java b/src/java/org/apache/bcel/generic/StoreInstruction.java
new file mode 100644
index 00000000..a24249e0
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/StoreInstruction.java
@@ -0,0 +1,102 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Denotes an unparameterized instruction to store a value into a local variable,
+ * e.g. ISTORE.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public abstract class StoreInstruction extends LocalVariableInstruction
+ implements PopInstruction
+{
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ * tag and length are defined in readInstruction and initFromFile, respectively.
+ */
+ StoreInstruction(short canon_tag, short c_tag) {
+ super(canon_tag, c_tag);
+ }
+
+ /**
+ * @param opcode Instruction opcode
+ * @param c_tag Instruction number for compact version, ASTORE_0, e.g.
+ * @param n local variable index (unsigned short)
+ */
+ protected StoreInstruction(short opcode, short c_tag, int n) {
+ super(opcode, c_tag, n);
+ }
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitStackConsumer(this);
+ v.visitPopInstruction(this);
+ v.visitStoreInstruction(this);
+ v.visitTypedInstruction(this);
+ v.visitLocalVariableInstruction(this);
+ v.visitStoreInstruction(this);
+ }
+}
+
diff --git a/src/java/org/apache/bcel/generic/TABLESWITCH.java b/src/java/org/apache/bcel/generic/TABLESWITCH.java
new file mode 100644
index 00000000..a2ef8d9b
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/TABLESWITCH.java
@@ -0,0 +1,147 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import java.io.*;
+import org.apache.bcel.util.ByteSequence;
+
+/**
+ * TABLESWITCH - Switch within given range of values, i.e., low..high
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see SWITCH
+ */
+public class TABLESWITCH extends Select {
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ TABLESWITCH() {}
+
+ /**
+ * @param match sorted array of match values, match[0] must be low value,
+ * match[match_length - 1] high value
+ * @param targets where to branch for matched values
+ * @param target default branch
+ */
+ public TABLESWITCH(int[] match, InstructionHandle[] targets,
+ InstructionHandle target) {
+ super(org.apache.bcel.Constants.TABLESWITCH, match, targets, target);
+
+ length = (short)(13 + match_length * 4); /* Alignment remainder assumed
+ * 0 here, until dump time */
+ fixed_length = length;
+ }
+
+ /**
+ * Dump instruction as byte code to stream out.
+ * @param out Output stream
+ */
+ public void dump(DataOutputStream out) throws IOException {
+ super.dump(out);
+
+ int low = (match_length > 0)? match[0] : 0;
+ out.writeInt(low);
+
+ int high = (match_length > 0)? match[match_length - 1] : 0;
+ out.writeInt(high);
+
+ for(int i=0; i < match_length; i++) // jump offsets
+ out.writeInt(indices[i] = getTargetOffset(targets[i]));
+ }
+
+ /**
+ * Read needed data (e.g. index) from file.
+ */
+ protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
+ {
+ super.initFromFile(bytes, wide);
+
+ int low = bytes.readInt();
+ int high = bytes.readInt();
+
+ match_length = high - low + 1;
+ fixed_length = (short)(13 + match_length * 4);
+ length = (short)(fixed_length + padding);
+
+ match = new int[match_length];
+ indices = new int[match_length];
+ targets = new InstructionHandle[match_length];
+
+ for(int i=low; i <= high; i++)
+ match[i - low] = i;
+
+ for(int i=0; i < match_length; i++) {
+ indices[i] = bytes.readInt();
+ }
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept(Visitor v) {
+ v.visitVariableLengthInstruction(this);
+ v.visitStackProducer(this);
+ v.visitBranchInstruction(this);
+ v.visitSelect(this);
+ v.visitTABLESWITCH(this);
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/TargetLostException.java b/src/java/org/apache/bcel/generic/TargetLostException.java
new file mode 100644
index 00000000..3caf528f
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/TargetLostException.java
@@ -0,0 +1,100 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Thrown by InstructionList.remove() when one or multiple disposed instruction
+ * are still being referenced by a InstructionTargeter object. I.e. the
+ * InstructionTargeter has to be notified that (one of) the InstructionHandle it
+ * is referencing is being removed from the InstructionList and thus not valid anymore.
+ *
+ * Making this an exception instead of a return value forces the user to handle
+ * these case explicitely in a try { ... } catch. The following code illustrates
+ * how this may be done:
+ *
+ * <PRE>
+ * ...
+ * try {
+ * il.delete(start_ih, end_ih);
+ * } catch(TargetLostException e) {
+ * InstructionHandle[] targets = e.getTargets();
+ * 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], new_target);
+ * }
+ * }
+ * </PRE>
+ *
+ * @see InstructionHandle
+ * @see InstructionList
+ * @see InstructionTargeter
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public final class TargetLostException extends Exception {
+ private InstructionHandle[] targets;
+
+ TargetLostException(InstructionHandle[] t, String mesg) {
+ super(mesg);
+ targets = t;
+ }
+
+ /**
+ * @return list of instructions still being targeted.
+ */
+ public InstructionHandle[] getTargets() { return targets; }
+}
diff --git a/src/java/org/apache/bcel/generic/Type.java b/src/java/org/apache/bcel/generic/Type.java
new file mode 100644
index 00000000..2d1aacc9
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/Type.java
@@ -0,0 +1,232 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import org.apache.bcel.classfile.*;
+import java.io.*;
+import java.util.ArrayList;
+
+/**
+ * Abstract super class for all possible java types, namely basic types
+ * such as int, object types like String and array types, e.g. int[]
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public abstract class Type {
+ protected byte type;
+ protected String signature; // signature for the type
+
+ /** Predefined constants
+ */
+ public static final BasicType VOID = new BasicType(Constants.T_VOID);
+ public static final BasicType BOOLEAN = new BasicType(Constants.T_BOOLEAN);
+ public static final BasicType INT = new BasicType(Constants.T_INT);
+ public static final BasicType SHORT = new BasicType(Constants.T_SHORT);
+ public static final BasicType BYTE = new BasicType(Constants.T_BYTE);
+ public static final BasicType LONG = new BasicType(Constants.T_LONG);
+ public static final BasicType DOUBLE = new BasicType(Constants.T_DOUBLE);
+ public static final BasicType FLOAT = new BasicType(Constants.T_FLOAT);
+ public static final BasicType CHAR = new BasicType(Constants.T_CHAR);
+ public static final ObjectType OBJECT = new ObjectType("java.lang.Object");
+ public static final ObjectType STRING = new ObjectType("java.lang.String");
+ public static final ObjectType STRINGBUFFER = new ObjectType("java.lang.StringBuffer");
+ public static final ObjectType THROWABLE = new ObjectType("java.lang.Throwable");
+ public static final Type[] NO_ARGS = new Type[0];
+ public static final ReferenceType NULL = new ReferenceType();
+ public static final Type UNKNOWN = new Type(Constants.T_UNKNOWN,
+ "<unknown object>"){};
+
+ protected Type(byte t, String s) {
+ type = t;
+ signature = s;
+ }
+
+ /**
+ * @return signature for given type.
+ */
+ public String getSignature() { return signature; }
+
+ /**
+ * @return type as defined in Constants
+ */
+ public byte getType() { return type; }
+
+ /**
+ * @return stack size of this type (2 for long and double, 0 for void, 1 otherwise)
+ */
+ public int getSize() {
+ switch(type) {
+ case Constants.T_DOUBLE:
+ case Constants.T_LONG: return 2;
+ case Constants.T_VOID: return 0;
+ default: return 1;
+ }
+ }
+
+ /**
+ * @return Type string, e.g. `int[]'
+ */
+ public String toString() {
+ return ((this.equals(Type.NULL) || (type >= Constants.T_UNKNOWN)))? signature :
+ Utility.signatureToString(signature, false);
+ }
+
+ /**
+ * Convert type to Java method signature, e.g. int[] f(java.lang.String x)
+ * becomes (Ljava/lang/String;)[I
+ *
+ * @param return_type what the method returns
+ * @param arg_types what are the argument types
+ * @return method signature for given type(s).
+ */
+ public static String getMethodSignature(Type return_type, Type[] arg_types) {
+ StringBuffer buf = new StringBuffer("(");
+ int length = (arg_types == null)? 0 : arg_types.length;
+
+ for(int i=0; i < length; i++)
+ buf.append(arg_types[i].getSignature());
+
+ buf.append(')');
+ buf.append(return_type.getSignature());
+
+ return buf.toString();
+ }
+
+ private static int consumed_chars=0; // Remember position in string, see getArgumentTypes
+
+ /**
+ * Convert signature to a Type object.
+ * @param signature signature string such as Ljava/lang/String;
+ * @return type object
+ */
+ public static final Type getType(String signature)
+ throws StringIndexOutOfBoundsException
+ {
+ byte type = Utility.typeOfSignature(signature);
+
+ if(type <= Constants.T_VOID) {
+ consumed_chars = 1;
+ return BasicType.getType(type);
+ } else if(type == Constants.T_ARRAY) {
+ int dim=0;
+ do { // Count dimensions
+ dim++;
+ } while(signature.charAt(dim) == '[');
+
+ // Recurse, but just once, if the signature is ok
+ Type t = getType(signature.substring(dim));
+
+ consumed_chars += dim; // update counter
+
+ return new ArrayType(t, dim);
+ } else { // type == T_REFERENCE
+ int index = signature.indexOf(';'); // Look for closing `;'
+
+ if(index < 0)
+ throw new ClassFormatError("Invalid signature: " + signature);
+
+ consumed_chars = index + 1; // "Lblabla;" `L' and `;' are removed
+
+ return new ObjectType(signature.substring(1, index).replace('/', '.'));
+ }
+ }
+
+ /**
+ * Convert return value of a method (signature) to a Type object.
+ *
+ * @param signature signature string such as (Ljava/lang/String;)V
+ * @return return type
+ */
+ public static Type getReturnType(String signature) {
+ try {
+ // Read return type after `)'
+ int index = signature.lastIndexOf(')') + 1;
+ return getType(signature.substring(index));
+ } catch(StringIndexOutOfBoundsException e) { // Should never occur
+ throw new ClassFormatError("Invalid method signature: " + signature);
+ }
+ }
+
+ /**
+ * Convert arguments of a method (signature) to an array of Type objects.
+ * @param signature signature string such as (Ljava/lang/String;)V
+ * @return array of argument types
+ */
+ public static Type[] getArgumentTypes(String signature) {
+ ArrayList vec = new ArrayList();
+ int index;
+ Type[] types;
+
+ try { // Read all declarations between for `(' and `)'
+ if(signature.charAt(0) != '(')
+ throw new ClassFormatError("Invalid method signature: " + signature);
+
+ index = 1; // current string position
+
+ while(signature.charAt(index) != ')') {
+ vec.add(getType(signature.substring(index)));
+ index += consumed_chars; // update position
+ }
+ } catch(StringIndexOutOfBoundsException e) { // Should never occur
+ throw new ClassFormatError("Invalid method signature: " + signature);
+ }
+
+ types = new Type[vec.size()];
+ vec.toArray(types);
+ return types;
+ }
+}
diff --git a/src/java/org/apache/bcel/generic/TypedInstruction.java b/src/java/org/apache/bcel/generic/TypedInstruction.java
new file mode 100644
index 00000000..a2043d02
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/TypedInstruction.java
@@ -0,0 +1,67 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Get the type associated with an instruction, int for ILOAD, or the type
+ * of the field of a PUTFIELD instruction, e.g..
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public interface TypedInstruction {
+ public Type getType(ConstantPoolGen cpg);
+}
+
diff --git a/src/java/org/apache/bcel/generic/UnconditionalBranch.java b/src/java/org/apache/bcel/generic/UnconditionalBranch.java
new file mode 100644
index 00000000..17d23f12
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/UnconditionalBranch.java
@@ -0,0 +1,67 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Denotes an instruction to perform an unconditional branch, i.e., GOTO, JSR.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+
+ * @see GOTO
+ * @see JSR
+ */
+public interface UnconditionalBranch {}
+
diff --git a/src/java/org/apache/bcel/generic/VariableLengthInstruction.java b/src/java/org/apache/bcel/generic/VariableLengthInstruction.java
new file mode 100644
index 00000000..e08a2e1e
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/VariableLengthInstruction.java
@@ -0,0 +1,70 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Denotes an instruction to be a variable length instruction, such as
+ * GOTO, JSR, LOOKUPSWITCH and TABLESWITCH.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+
+ * @see GOTO
+ * @see JSR
+ * @see LOOKUPSWITCH
+ * @see TABLESWITCH
+ */
+public interface VariableLengthInstruction {}
+
diff --git a/src/java/org/apache/bcel/generic/Visitor.java b/src/java/org/apache/bcel/generic/Visitor.java
new file mode 100644
index 00000000..836d9f93
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/Visitor.java
@@ -0,0 +1,247 @@
+package org.apache.bcel.generic;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Interface implementing the Visitor pattern programming style.
+ * I.e., a class that implements this interface can handle all types of
+ * instructions with the properly typed methods just by calling the accept()
+ * method.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public interface Visitor {
+ public void visitStackInstruction(StackInstruction obj);
+ public void visitLocalVariableInstruction(LocalVariableInstruction obj);
+ public void visitBranchInstruction(BranchInstruction obj);
+ public void visitLoadClass(LoadClass obj);
+ public void visitFieldInstruction(FieldInstruction obj);
+ public void visitIfInstruction(IfInstruction obj);
+ public void visitConversionInstruction(ConversionInstruction obj);
+ public void visitPopInstruction(PopInstruction obj);
+ public void visitStoreInstruction(StoreInstruction obj);
+ public void visitTypedInstruction(TypedInstruction obj);
+ public void visitSelect(Select obj);
+ public void visitJsrInstruction(JsrInstruction obj);
+ public void visitGotoInstruction(GotoInstruction obj);
+ public void visitUnconditionalBranch(UnconditionalBranch obj);
+ public void visitPushInstruction(PushInstruction obj);
+ public void visitArithmeticInstruction(ArithmeticInstruction obj);
+ public void visitCPInstruction(CPInstruction obj);
+ public void visitInvokeInstruction(InvokeInstruction obj);
+ public void visitArrayInstruction(ArrayInstruction obj);
+ public void visitAllocationInstruction(AllocationInstruction obj);
+ public void visitReturnInstruction(ReturnInstruction obj);
+ public void visitFieldOrMethod(FieldOrMethod obj);
+ public void visitConstantPushInstruction(ConstantPushInstruction obj);
+ public void visitExceptionThrower(ExceptionThrower obj);
+ public void visitLoadInstruction(LoadInstruction obj);
+ public void visitVariableLengthInstruction(VariableLengthInstruction obj);
+ public void visitStackProducer(StackProducer obj);
+ public void visitStackConsumer(StackConsumer obj);
+ public void visitACONST_NULL(ACONST_NULL obj);
+ public void visitGETSTATIC(GETSTATIC obj);
+ public void visitIF_ICMPLT(IF_ICMPLT obj);
+ public void visitMONITOREXIT(MONITOREXIT obj);
+ public void visitIFLT(IFLT obj);
+ public void visitLSTORE(LSTORE obj);
+ public void visitPOP2(POP2 obj);
+ public void visitBASTORE(BASTORE obj);
+ public void visitISTORE(ISTORE obj);
+ public void visitCHECKCAST(CHECKCAST obj);
+ public void visitFCMPG(FCMPG obj);
+ public void visitI2F(I2F obj);
+ public void visitATHROW(ATHROW obj);
+ public void visitDCMPL(DCMPL obj);
+ public void visitARRAYLENGTH(ARRAYLENGTH obj);
+ public void visitDUP(DUP obj);
+ public void visitINVOKESTATIC(INVOKESTATIC obj);
+ public void visitLCONST(LCONST obj);
+ public void visitDREM(DREM obj);
+ public void visitIFGE(IFGE obj);
+ public void visitCALOAD(CALOAD obj);
+ public void visitLASTORE(LASTORE obj);
+ public void visitI2D(I2D obj);
+ public void visitDADD(DADD obj);
+ public void visitINVOKESPECIAL(INVOKESPECIAL obj);
+ public void visitIAND(IAND obj);
+ public void visitPUTFIELD(PUTFIELD obj);
+ public void visitILOAD(ILOAD obj);
+ public void visitDLOAD(DLOAD obj);
+ public void visitDCONST(DCONST obj);
+ public void visitNEW(NEW obj);
+ public void visitIFNULL(IFNULL obj);
+ public void visitLSUB(LSUB obj);
+ public void visitL2I(L2I obj);
+ public void visitISHR(ISHR obj);
+ public void visitTABLESWITCH(TABLESWITCH obj);
+ public void visitIINC(IINC obj);
+ public void visitDRETURN(DRETURN obj);
+ public void visitFSTORE(FSTORE obj);
+ public void visitDASTORE(DASTORE obj);
+ public void visitIALOAD(IALOAD obj);
+ public void visitDDIV(DDIV obj);
+ public void visitIF_ICMPGE(IF_ICMPGE obj);
+ public void visitLAND(LAND obj);
+ public void visitIDIV(IDIV obj);
+ public void visitLOR(LOR obj);
+ public void visitCASTORE(CASTORE obj);
+ public void visitFREM(FREM obj);
+ public void visitLDC(LDC obj);
+ public void visitBIPUSH(BIPUSH obj);
+ public void visitDSTORE(DSTORE obj);
+ public void visitF2L(F2L obj);
+ public void visitFMUL(FMUL obj);
+ public void visitLLOAD(LLOAD obj);
+ public void visitJSR(JSR obj);
+ public void visitFSUB(FSUB obj);
+ public void visitSASTORE(SASTORE obj);
+ public void visitALOAD(ALOAD obj);
+ public void visitDUP2_X2(DUP2_X2 obj);
+ public void visitRETURN(RETURN obj);
+ public void visitDALOAD(DALOAD obj);
+ public void visitSIPUSH(SIPUSH obj);
+ public void visitDSUB(DSUB obj);
+ public void visitL2F(L2F obj);
+ public void visitIF_ICMPGT(IF_ICMPGT obj);
+ public void visitF2D(F2D obj);
+ public void visitI2L(I2L obj);
+ public void visitIF_ACMPNE(IF_ACMPNE obj);
+ public void visitPOP(POP obj);
+ public void visitI2S(I2S obj);
+ public void visitIFEQ(IFEQ obj);
+ public void visitSWAP(SWAP obj);
+ public void visitIOR(IOR obj);
+ public void visitIREM(IREM obj);
+ public void visitIASTORE(IASTORE obj);
+ public void visitNEWARRAY(NEWARRAY obj);
+ public void visitINVOKEINTERFACE(INVOKEINTERFACE obj);
+ public void visitINEG(INEG obj);
+ public void visitLCMP(LCMP obj);
+ public void visitJSR_W(JSR_W obj);
+ public void visitMULTIANEWARRAY(MULTIANEWARRAY obj);
+ public void visitDUP_X2(DUP_X2 obj);
+ public void visitSALOAD(SALOAD obj);
+ public void visitIFNONNULL(IFNONNULL obj);
+ public void visitDMUL(DMUL obj);
+ public void visitIFNE(IFNE obj);
+ public void visitIF_ICMPLE(IF_ICMPLE obj);
+ public void visitLDC2_W(LDC2_W obj);
+ public void visitGETFIELD(GETFIELD obj);
+ public void visitLADD(LADD obj);
+ public void visitNOP(NOP obj);
+ public void visitFALOAD(FALOAD obj);
+ public void visitINSTANCEOF(INSTANCEOF obj);
+ public void visitIFLE(IFLE obj);
+ public void visitLXOR(LXOR obj);
+ public void visitLRETURN(LRETURN obj);
+ public void visitFCONST(FCONST obj);
+ public void visitIUSHR(IUSHR obj);
+ public void visitBALOAD(BALOAD obj);
+ public void visitDUP2(DUP2 obj);
+ public void visitIF_ACMPEQ(IF_ACMPEQ obj);
+ public void visitIMPDEP1(IMPDEP1 obj);
+ public void visitMONITORENTER(MONITORENTER obj);
+ public void visitLSHL(LSHL obj);
+ public void visitDCMPG(DCMPG obj);
+ public void visitD2L(D2L obj);
+ public void visitIMPDEP2(IMPDEP2 obj);
+ public void visitL2D(L2D obj);
+ public void visitRET(RET obj);
+ public void visitIFGT(IFGT obj);
+ public void visitIXOR(IXOR obj);
+ public void visitINVOKEVIRTUAL(INVOKEVIRTUAL obj);
+ public void visitFASTORE(FASTORE obj);
+ public void visitIRETURN(IRETURN obj);
+ public void visitIF_ICMPNE(IF_ICMPNE obj);
+ public void visitFLOAD(FLOAD obj);
+ public void visitLDIV(LDIV obj);
+ public void visitPUTSTATIC(PUTSTATIC obj);
+ public void visitAALOAD(AALOAD obj);
+ public void visitD2I(D2I obj);
+ public void visitIF_ICMPEQ(IF_ICMPEQ obj);
+ public void visitAASTORE(AASTORE obj);
+ public void visitARETURN(ARETURN obj);
+ public void visitDUP2_X1(DUP2_X1 obj);
+ public void visitFNEG(FNEG obj);
+ public void visitGOTO_W(GOTO_W obj);
+ public void visitD2F(D2F obj);
+ public void visitGOTO(GOTO obj);
+ public void visitISUB(ISUB obj);
+ public void visitF2I(F2I obj);
+ public void visitDNEG(DNEG obj);
+ public void visitICONST(ICONST obj);
+ public void visitFDIV(FDIV obj);
+ public void visitI2B(I2B obj);
+ public void visitLNEG(LNEG obj);
+ public void visitLREM(LREM obj);
+ public void visitIMUL(IMUL obj);
+ public void visitIADD(IADD obj);
+ public void visitLSHR(LSHR obj);
+ public void visitLOOKUPSWITCH(LOOKUPSWITCH obj);
+ public void visitDUP_X1(DUP_X1 obj);
+ public void visitFCMPL(FCMPL obj);
+ public void visitI2C(I2C obj);
+ public void visitLMUL(LMUL obj);
+ public void visitLUSHR(LUSHR obj);
+ public void visitISHL(ISHL obj);
+ public void visitLALOAD(LALOAD obj);
+ public void visitASTORE(ASTORE obj);
+ public void visitANEWARRAY(ANEWARRAY obj);
+ public void visitFRETURN(FRETURN obj);
+ public void visitFADD(FADD obj);
+ public void visitBREAKPOINT(BREAKPOINT obj);
+}
diff --git a/src/java/org/apache/bcel/generic/package.html b/src/java/org/apache/bcel/generic/package.html
new file mode 100644
index 00000000..2ae21266
--- /dev/null
+++ b/src/java/org/apache/bcel/generic/package.html
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+$Id$
+-->
+</head>
+<body bgcolor="white">
+<p>
+This package contains the "generic" part of the
+<a href="http://jakarta.apache.org/bcel/">Byte Code Engineering
+Library</a>, i.e., classes to dynamically modify class objects and
+byte code instructions.
+</p>
+</body>
+</html>
diff --git a/src/java/org/apache/bcel/package.html b/src/java/org/apache/bcel/package.html
new file mode 100644
index 00000000..0ea9520c
--- /dev/null
+++ b/src/java/org/apache/bcel/package.html
@@ -0,0 +1,17 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+$Id$
+-->
+</head>
+<body bgcolor="white">
+<p>
+This package contains basic classes for the
+<a href="http://jakarta.apache.org/bcel/">Byte Code Engineering Library</a>
+ and constants defined by the
+<a href="http://www.javasoft.com/docs/books/vmspec/index.html">
+ JVM specification</a>.
+</p>
+</body>
+</html>
diff --git a/src/java/org/apache/bcel/util/AttributeHTML.java b/src/java/org/apache/bcel/util/AttributeHTML.java
new file mode 100644
index 00000000..aef1284f
--- /dev/null
+++ b/src/java/org/apache/bcel/util/AttributeHTML.java
@@ -0,0 +1,256 @@
+package org.apache.bcel.util;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.classfile.*;
+import java.io.*;
+
+/**
+ * Convert found attributes into HTML file.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ *
+ */
+final class AttributeHTML implements org.apache.bcel.Constants {
+ private String class_name; // name of current class
+ private PrintWriter file; // file to write to
+ private int attr_count = 0;
+ private ConstantHTML constant_html;
+ private ConstantPool constant_pool;
+
+ AttributeHTML(String dir, String class_name, ConstantPool constant_pool,
+ ConstantHTML constant_html) throws IOException
+ {
+ this.class_name = class_name;
+ this.constant_pool = constant_pool;
+ this.constant_html = constant_html;
+
+ file = new PrintWriter(new FileOutputStream(dir + class_name + "_attributes.html"));
+ file.println("<HTML><BODY BGCOLOR=\"#C0C0C0\"><TABLE BORDER=0>");
+ }
+
+ private final String codeLink(int link, int method_number) {
+ return "<A HREF=\"" + class_name + "_code.html#code" +
+ method_number + "@" + link + "\" TARGET=Code>" +
+ link + "</A>";
+ }
+
+ final void close() {
+ file.println("</TABLE></BODY></HTML>");
+ file.close();
+ }
+
+ final void writeAttribute(Attribute attribute, String anchor) throws IOException {
+ writeAttribute(attribute, anchor, 0);
+ }
+
+ final void writeAttribute(Attribute attribute, String anchor, int method_number) throws IOException {
+ byte tag = attribute.getTag();
+ int index;
+
+ if(tag == ATTR_UNKNOWN) // Don't know what to do about this one
+ return;
+
+ attr_count++; // Increment number of attributes found so far
+
+ if(attr_count % 2 == 0)
+ file.print("<TR BGCOLOR=\"#C0C0C0\"><TD>");
+ else
+ file.print("<TR BGCOLOR=\"#A0A0A0\"><TD>");
+
+ file.println("<H4><A NAME=\"" + anchor + "\">" + attr_count + " " + ATTRIBUTE_NAMES[tag] + "</A></H4>");
+
+ /* Handle different attributes
+ */
+ switch(tag) {
+ case ATTR_CODE:
+ Code c = (Code)attribute;
+ Attribute[] attributes = c.getAttributes();
+
+ // Some directly printable values
+ file.print("<UL><LI>Maximum stack size = " + c.getMaxStack() +
+ "</LI>\n<LI>Number of local variables = " +
+ c.getMaxLocals() + "</LI>\n<LI><A HREF=\"" + class_name +
+ "_code.html#method" + method_number + "\" TARGET=Code>Byte code</A></LI></UL>\n");
+
+ // Get handled exceptions and list them
+ CodeException[] ce = c.getExceptionTable();
+ int len = ce.length;
+
+ if(len > 0) {
+ file.print("<P><B>Exceptions handled</B><UL>");
+
+ for(int i=0; i < len; i++) {
+ int catch_type = ce[i].getCatchType(); // Index in constant pool
+
+ file.print("<LI>");
+
+ if(catch_type != 0)
+ file.print(constant_html.referenceConstant(catch_type)); // Create Link to _cp.html
+ else
+ file.print("Any Exception");
+
+ file.print("<BR>(Ranging from lines " + codeLink(ce[i].getStartPC(), method_number) +
+ " to " + codeLink(ce[i].getEndPC(), method_number) + ", handled at line " +
+ codeLink(ce[i].getHandlerPC(), method_number) + ")</LI>");
+ }
+ file.print("</UL>");
+ }
+ break;
+
+ case ATTR_CONSTANT_VALUE:
+ index = ((ConstantValue)attribute).getConstantValueIndex();
+
+ // Reference _cp.html
+ file.print("<UL><LI><A HREF=\"" + class_name + "_cp.html#cp" + index +
+ "\" TARGET=\"ConstantPool\">Constant value index(" + index +")</A></UL>\n");
+ break;
+
+ case ATTR_SOURCE_FILE:
+ index = ((SourceFile)attribute).getSourceFileIndex();
+
+ // Reference _cp.html
+ file.print("<UL><LI><A HREF=\"" + class_name + "_cp.html#cp" + index +
+ "\" TARGET=\"ConstantPool\">Source file index(" + index +")</A></UL>\n");
+ break;
+
+ case ATTR_EXCEPTIONS:
+ // List thrown exceptions
+ int[] indices = ((ExceptionTable)attribute).getExceptionIndexTable();
+
+ file.print("<UL>");
+
+ for(int i=0; i < indices.length; i++)
+ file.print("<LI><A HREF=\"" + class_name + "_cp.html#cp" + indices[i] +
+ "\" TARGET=\"ConstantPool\">Exception class index(" + indices[i] + ")</A>\n");
+
+ file.print("</UL>\n");
+ break;
+
+ case ATTR_LINE_NUMBER_TABLE:
+ LineNumber[] line_numbers =((LineNumberTable)attribute).getLineNumberTable();
+
+ // List line number pairs
+ file.print("<P>");
+
+ for(int i=0; i < line_numbers.length; i++) {
+ file.print("(" + line_numbers[i].getStartPC() + ",&nbsp;" + line_numbers[i].getLineNumber() + ")");
+
+ if(i < line_numbers.length - 1)
+ file.print(", "); // breakable
+ }
+ break;
+
+ case ATTR_LOCAL_VARIABLE_TABLE:
+ LocalVariable[] vars = ((LocalVariableTable)attribute).getLocalVariableTable();
+
+ // List name, range and type
+ file.print("<UL>");
+
+ for(int i=0; i < vars.length; i++) {
+ index = vars[i].getSignatureIndex();
+ String signature = ((ConstantUtf8)constant_pool.getConstant(index, CONSTANT_Utf8)).getBytes();
+ signature = Utility.signatureToString(signature, false);
+ int start = vars[i].getStartPC();
+ int end = (start + vars[i].getLength());
+
+ file.println("<LI>" + Class2HTML.referenceType(signature) +
+ "&nbsp;<B>" + vars[i].getName() + "</B> in slot %" + vars[i].getIndex() +
+ "<BR>Valid from lines " +
+ "<A HREF=\"" + class_name + "_code.html#code" + method_number + "@" + start + "\" TARGET=Code>" +
+ start + "</A> to " +
+ "<A HREF=\"" + class_name + "_code.html#code" + method_number + "@" + end + "\" TARGET=Code>" +
+ end + "</A></LI>");
+ }
+ file.print("</UL>\n");
+
+ break;
+
+ case ATTR_INNER_CLASSES:
+ InnerClass[] classes = ((InnerClasses)attribute).getInnerClasses();
+
+ // List inner classes
+ file.print("<UL>");
+
+ for(int i=0; i < classes.length; i++) {
+ String name, access;
+
+ index = classes[i].getInnerNameIndex();
+ if(index > 0)
+ name =((ConstantUtf8)constant_pool.getConstant(index, CONSTANT_Utf8)).getBytes();
+ else
+ name = "&lt;anonymous&gt;";
+
+ access = Utility.accessToString(classes[i].getInnerAccessFlags());
+
+ file.print("<LI><FONT COLOR=\"#FF0000\">" + access + "</FONT> "+
+ constant_html.referenceConstant(classes[i].getInnerClassIndex()) +
+ " in&nbsp;class " +
+ constant_html.referenceConstant(classes[i].getOuterClassIndex()) +
+ " named " + name + "</LI>\n");
+ }
+
+ file.print("</UL>\n");
+ break;
+
+ default: // Such as Unknown attribute or Deprecated
+ file.print("<P>" + attribute.toString());
+ }
+
+ file.println("</TD></TR>");
+ file.flush();
+ }
+}
diff --git a/src/java/org/apache/bcel/util/ByteSequence.java b/src/java/org/apache/bcel/util/ByteSequence.java
new file mode 100644
index 00000000..db293414
--- /dev/null
+++ b/src/java/org/apache/bcel/util/ByteSequence.java
@@ -0,0 +1,82 @@
+package org.apache.bcel.util;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import java.io.*;
+
+/**
+ * Utility class that implements a sequence of bytes which can be read
+ * via the `readByte()' method. This is used to implement a wrapper for the
+ * Java byte code stream to gain some more readability.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public final class ByteSequence extends DataInputStream {
+ private ByteArrayStream byte_stream;
+
+ public ByteSequence(byte[] bytes) {
+ super(new ByteArrayStream(bytes));
+ byte_stream = (ByteArrayStream)in;
+ }
+
+ public final int getIndex() { return byte_stream.getPosition(); }
+ final void unreadByte() { byte_stream.unreadByte(); }
+
+ private static final class ByteArrayStream extends ByteArrayInputStream {
+ ByteArrayStream(byte[] bytes) { super(bytes); }
+ final int getPosition() { return pos; } // is protected in ByteArrayInputStream
+ final void unreadByte() { if(pos > 0) pos--; }
+ }
+}
diff --git a/src/java/org/apache/bcel/util/Class2HTML.java b/src/java/org/apache/bcel/util/Class2HTML.java
new file mode 100644
index 00000000..f7442f25
--- /dev/null
+++ b/src/java/org/apache/bcel/util/Class2HTML.java
@@ -0,0 +1,262 @@
+package org.apache.bcel.util;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import java.io.*;
+import java.util.BitSet;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.Constants;
+
+/**
+ * Read class file(s) and convert them into HTML files.
+ *
+ * Given a JavaClass object "class" that is in package "package" five files
+ * will be created in the specified directory.
+ *
+ * <OL>
+ * <LI> "package"."class".html as the main file which defines the frames for
+ * the following subfiles.
+ * <LI> "package"."class"_attributes.html contains all (known) attributes found in the file
+ * <LI> "package"."class"_cp.html contains the constant pool
+ * <LI> "package"."class"_code.html contains the byte code
+ * <LI> "package"."class"_methods.html contains references to all methods and fields of the class
+ * </OL>
+ *
+ * All subfiles reference each other appropiately, e.g. clicking on a
+ * method in the Method's frame will jump to the appropiate method in
+ * the Code frame.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+*/
+public class Class2HTML implements Constants
+{
+ private JavaClass java_class; // current class object
+ private String dir;
+
+ private static String class_package; // name of package, unclean to make it static, but ...
+ private static String class_name; // name of current class, dito
+ private static ConstantPool constant_pool;
+
+ /**
+ * Write contents of the given JavaClass into HTML files.
+ *
+ * @param java_class The class to write
+ * @param dir The directory to put the files in
+ */
+ public Class2HTML(JavaClass java_class, String dir) throws IOException {
+ Method[] methods = java_class.getMethods();
+
+ this.java_class = java_class;
+ this.dir = dir;
+ class_name = java_class.getClassName(); // Remember full name
+ constant_pool = java_class.getConstantPool();
+
+ // Get package name by tacking off everything after the last `.'
+ int index = class_name.lastIndexOf('.');
+ if(index > -1)
+ class_package = class_name.substring(0, index);
+ else
+ class_package = ""; // default package
+
+ ConstantHTML constant_html = new ConstantHTML(dir, class_name, class_package, methods,
+ constant_pool);
+
+ /* Attributes can't be written in one step, so we just open a file
+ * which will be written consequently.
+ */
+ AttributeHTML attribute_html = new AttributeHTML(dir, class_name, constant_pool, constant_html);
+
+ MethodHTML method_html = new MethodHTML(dir, class_name, methods, java_class.getFields(),
+ constant_html, attribute_html);
+ // Write main file (with frames, yuk)
+ writeMainHTML(attribute_html);
+ new CodeHTML(dir, class_name, methods, constant_pool, constant_html);
+ attribute_html.close();
+ }
+
+ public static void main(String argv[])
+ {
+ String[] file_name = new String[argv.length];
+ int files=0;
+ ClassParser parser=null;
+ JavaClass java_class=null;
+ String zip_file = null;
+ char sep = System.getProperty("file.separator").toCharArray()[0];
+ String dir = "." + sep; // Where to store HTML files
+
+ try {
+ /* Parse command line arguments.
+ */
+ for(int i=0; i < argv.length; i++) {
+ if(argv[i].charAt(0) == '-') { // command line switch
+ if(argv[i].equals("-d")) { // Specify target directory, default `.´
+ dir = argv[++i];
+
+ if(!dir.endsWith("" + sep))
+ dir = dir + sep;
+
+ new File(dir).mkdirs(); // Create target directory if necessary
+ }
+ else if(argv[i].equals("-zip"))
+ zip_file = argv[++i];
+ else
+ System.out.println("Unknown option " + argv[i]);
+ }
+ else // add file name to list */
+ file_name[files++] = argv[i];
+ }
+
+ if(files == 0)
+ System.err.println("Class2HTML: No input files specified.");
+ else { // Loop through files ...
+ for(int i=0; i < files; i++) {
+ System.out.print("Processing " + file_name[i] + "...");
+ if(zip_file == null)
+ parser = new ClassParser(file_name[i]); // Create parser object from file
+ else
+ parser = new ClassParser(zip_file, file_name[i]); // Create parser object from zip file
+
+ java_class = parser.parse();
+ new Class2HTML(java_class, dir);
+ System.out.println("Done.");
+ }
+ }
+ } catch(Exception e) {
+ System.out.println(e);
+ e.printStackTrace(System.out);
+ }
+ }
+
+ /**
+ * Utility method that converts a class reference in the constant pool,
+ * i.e., an index to a string.
+ */
+ static String referenceClass(int index) {
+ String str = constant_pool.getConstantString(index, CONSTANT_Class);
+ str = Utility.compactClassName(str);
+ str = Utility.compactClassName(str, class_package + ".", true);
+
+ return "<A HREF=\"" + class_name + "_cp.html#cp" + index +
+ "\" TARGET=ConstantPool>" + str + "</A>";
+ }
+
+ static final String referenceType(String type) {
+ String short_type = Utility.compactClassName(type);
+ short_type = Utility.compactClassName(short_type, class_package + ".", true);
+
+ int index = type.indexOf('['); // Type is an array?
+ if(index > -1)
+ type = type.substring(0, index); // Tack of the `['
+
+ // test for basic type
+ if(type.equals("int") || type.equals("short") || type.equals("boolean") || type.equals("void") ||
+ type.equals("char") || type.equals("byte") || type.equals("long") || type.equals("double") ||
+ type.equals("float"))
+ return "<FONT COLOR=\"#00FF00\">" + type + "</FONT>";
+ else
+ return "<A HREF=\"" + type + ".html\" TARGET=_top>" + short_type + "</A>";
+ }
+
+ static String toHTML(String str) {
+ StringBuffer buf = new StringBuffer();
+
+ try { // Filter any characters HTML doesn't like such as < and > in particular
+ for(int i=0; i < str.length(); i++) {
+ char ch;
+
+ switch(ch=str.charAt(i)) {
+ case '<': buf.append("&lt;"); break;
+ case '>': buf.append("&gt;"); break;
+ case '\n': buf.append("\\n"); break;
+ case '\r': buf.append("\\r"); break;
+ default: buf.append(ch);
+ }
+ }
+ } catch(StringIndexOutOfBoundsException e) {} // Never occurs
+
+ return buf.toString();
+ }
+
+ private void writeMainHTML(AttributeHTML attribute_html) throws IOException {
+ PrintWriter file = new PrintWriter(new FileOutputStream(dir + class_name + ".html"));
+ Attribute[] attributes = java_class.getAttributes();
+
+ file.println("<HTML>\n" + "<HEAD><TITLE>Documentation for " + class_name + "</TITLE>" +
+ "</HEAD>\n" +
+ "<FRAMESET BORDER=1 cols=\"30%,*\">\n" +
+ "<FRAMESET BORDER=1 rows=\"80%,*\">\n" +
+
+ "<FRAME NAME=\"ConstantPool\" SRC=\"" + class_name + "_cp.html" + "\"\n MARGINWIDTH=\"0\" " +
+ "MARGINHEIGHT=\"0\" FRAMEBORDER=\"1\" SCROLLING=\"AUTO\">\n" +
+ "<FRAME NAME=\"Attributes\" SRC=\"" + class_name + "_attributes.html" +
+ "\"\n MARGINWIDTH=\"0\" " +
+ "MARGINHEIGHT=\"0\" FRAMEBORDER=\"1\" SCROLLING=\"AUTO\">\n" +
+ "</FRAMESET>\n" +
+
+ "<FRAMESET BORDER=1 rows=\"80%,*\">\n" +
+ "<FRAME NAME=\"Code\" SRC=\"" + class_name + "_code.html\"\n MARGINWIDTH=0 " +
+ "MARGINHEIGHT=0 FRAMEBORDER=1 SCROLLING=\"AUTO\">\n" +
+ "<FRAME NAME=\"Methods\" SRC=\"" + class_name + "_methods.html\"\n MARGINWIDTH=0 " +
+ "MARGINHEIGHT=0 FRAMEBORDER=1 SCROLLING=\"AUTO\">\n" +
+ "</FRAMESET></FRAMESET></HTML>"
+ );
+
+ file.close();
+
+ for(int i=0; i < attributes.length; i++)
+ attribute_html.writeAttribute(attributes[i], "class" + i);
+ }
+}
diff --git a/src/java/org/apache/bcel/util/ClassLoader.java b/src/java/org/apache/bcel/util/ClassLoader.java
new file mode 100644
index 00000000..0af6a7a0
--- /dev/null
+++ b/src/java/org/apache/bcel/util/ClassLoader.java
@@ -0,0 +1,200 @@
+package org.apache.bcel.util;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import java.util.Hashtable;
+import java.io.*;
+import java.util.zip.*;
+import org.apache.bcel.*;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.generic.*;
+
+/**
+ * <p>Drop in replacement for the standard class loader of the JVM. You can use it
+ * in conjunction with the JavaWrapper to dynamically modify/create classes
+ * as they're requested.</p>
+ *
+ * <p>This class loader recognizes special requests in a distinct
+ * format, i.e., when the name of the requested class contains with
+ * "$$BCEL$$" it calls the createClass() method with that name
+ * (everything bevor the $$BCEL$$ is considered to be the package
+ * name. You can subclass the class loader and override that
+ * method. "Normal" classes class can be modified by overriding the
+ * modifyClass() method which is called just before defineClass().</p>
+ *
+ * <p>There may be a number of packages where you have to use the default
+ * class loader (which may also be faster). You can define the set of packages
+ * where to use the system class loader in the constructor. The default value contains
+ * "java.", "sun.", "javax."</p>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see JavaWrapper
+ * @see ClassPath
+ */
+public class ClassLoader extends java.lang.ClassLoader {
+ private Hashtable classes = new Hashtable(); // Hashtable is synchronized thus thread-safe
+ private String[] ignored_packages = {
+ "java.", "javax.", "sun."
+ };
+
+ public ClassLoader() {
+ }
+
+ /** @param ignored_packages classes contained in these packages will be loaded
+ * with the system class loader
+ */
+ public ClassLoader(String[] ignored_packages) {
+ String[] new_p = new String[ignored_packages.length + this.ignored_packages.length];
+
+ System.arraycopy(this.ignored_packages, 0, new_p, 0, this.ignored_packages.length);
+ System.arraycopy(ignored_packages, 0, new_p, this.ignored_packages.length,
+ ignored_packages.length);
+
+ this.ignored_packages = new_p;
+ }
+
+ protected Class loadClass(String class_name, boolean resolve)
+ throws ClassNotFoundException
+ {
+ Class cl = null;
+
+ /* First try: lookup hash table.
+ */
+ if((cl=(Class)classes.get(class_name)) == null) {
+ /* Second try: Load system class using system class loader. You better
+ * don't mess around with them.
+ */
+ for(int i=0; i < ignored_packages.length; i++) {
+ if(class_name.startsWith(ignored_packages[i])) {
+ cl = Class.forName(class_name);
+ break;
+ }
+ }
+
+ if(cl == null) {
+ JavaClass clazz = null;
+
+ /* Third try: Special request?
+ */
+ if(class_name.indexOf("$$BCEL$$") >= 0)
+ clazz = createClass(class_name);
+ else // Fourth try: Load classes via repository
+ clazz = modifyClass(Repository.lookupClass(class_name));
+
+ if(clazz != null) {
+ byte[] bytes = clazz.getBytes();
+ cl = defineClass(class_name, bytes, 0, bytes.length);
+ } else // Fourth try: Use default class loader
+ cl = Class.forName(class_name);
+ }
+
+ if(resolve)
+ resolveClass(cl);
+ }
+
+ classes.put(class_name, cl);
+
+ return cl;
+ }
+
+ /** Override this method if you want to alter a class before it gets actually
+ * loaded. Does nothing by default.
+ */
+ protected JavaClass modifyClass(JavaClass clazz) {
+ return clazz;
+ }
+
+ /**
+ * Override this method to create you own classes on the fly. The
+ * name contains the special token $$BCEL$$. Everything before that
+ * token is consddered to be a package name. You can encode you own
+ * arguments into the subsequent string. You must regard however not
+ * to use any "illegal" characters, i.e., characters that may not
+ * appear in a Java class name too<br>
+ *
+ * The default implementation interprets the string as a encoded compressed
+ * Java class, unpacks and decodes it with the Utility.decode() method, and
+ * parses thee resulting byte array and returns the resulting JavaClass object.
+ *
+ * @param class_name compressed byte code with "$$BCEL$$" in it
+ */
+ protected JavaClass createClass(String class_name) {
+ int index = class_name.indexOf("$$BCEL$$");
+ String real_name = class_name.substring(index + 8);
+
+ JavaClass clazz = null;
+ try {
+ byte[] bytes = Utility.decode(real_name, true);
+ ClassParser parser = new ClassParser(new ByteArrayInputStream(bytes), "foo");
+
+ clazz = parser.parse();
+ } catch(Throwable e) {
+ e.printStackTrace();
+ return null;
+ }
+
+ // Adapt the class name to the passed value
+ ConstantPool cp = clazz.getConstantPool();
+
+ ConstantClass cl = (ConstantClass)cp.getConstant(clazz.getClassNameIndex(),
+ Constants.CONSTANT_Class);
+ ConstantUtf8 name = (ConstantUtf8)cp.getConstant(cl.getNameIndex(),
+ Constants.CONSTANT_Utf8);
+ name.setBytes(class_name.replace('.', '/'));
+
+ return clazz;
+ }
+}
diff --git a/src/java/org/apache/bcel/util/ClassPath.java b/src/java/org/apache/bcel/util/ClassPath.java
new file mode 100644
index 00000000..c4d77724
--- /dev/null
+++ b/src/java/org/apache/bcel/util/ClassPath.java
@@ -0,0 +1,322 @@
+package org.apache.bcel.util;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import java.util.*;
+import java.util.zip.*;
+import java.io.*;
+
+/**
+ * Responsible for loading (class) files from the CLASSPATH. Inspired by
+ * sun.tools.ClassPath.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ */
+public class ClassPath {
+ private PathEntry[] paths;
+
+ /**
+ * Search for classes in given path.
+ */
+ public ClassPath(String class_path) {
+ ArrayList vec = new ArrayList();
+
+ for(StringTokenizer tok=new StringTokenizer(class_path,
+ System.getProperty("path.separator"));
+ tok.hasMoreTokens();)
+ {
+ String path = tok.nextToken();
+
+ if(!path.equals("")) {
+ File file = new File(path);
+
+ try {
+ if(file.exists()) {
+ if(file.isDirectory())
+ vec.add(new Dir(path));
+ else
+ vec.add(new Zip(new ZipFile(file)));
+ }
+ } catch(IOException e) {
+ System.err.println("CLASSPATH component " + file + ": " + e);
+ }
+ }
+ }
+
+ paths = new PathEntry[vec.size()];
+ vec.toArray(paths);
+ }
+
+ /**
+ * Search for classes in CLASSPATH.
+ */
+ public ClassPath() {
+ this(getClassPath());
+ }
+
+ private static final void getPathComponents(String path, ArrayList list) {
+ if(path != null) {
+ StringTokenizer tok = new StringTokenizer(path, File.pathSeparator);
+
+ while(tok.hasMoreTokens()) {
+ String name = tok.nextToken();
+ File file = new File(name);
+
+ if(file.exists())
+ list.add(name);
+ }
+ }
+ }
+
+ private static final String getClassPath() {
+ String class_path = System.getProperty("java.class.path");
+ String boot_path = System.getProperty("sun.boot.class.path");
+ String ext_path = System.getProperty("java.ext.dirs");
+
+ ArrayList list = new ArrayList();
+
+ getPathComponents(class_path, list);
+ getPathComponents(boot_path, list);
+
+ ArrayList dirs = new ArrayList();
+ getPathComponents(ext_path, dirs);
+
+ for(Iterator e = dirs.iterator(); e.hasNext(); ) {
+ File ext_dir = new File((String)e.next());
+ String[] extensions = ext_dir.list(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ name = name.toLowerCase();
+ return name.endsWith(".zip") || name.endsWith(".jar");
+ }
+ });
+
+ if(extensions != null)
+ for(int i=0; i < extensions.length; i++)
+ list.add(ext_path + File.separatorChar + extensions[i]);
+ }
+
+ StringBuffer buf = new StringBuffer();
+
+ for(Iterator e = list.iterator(); e.hasNext(); ) {
+ buf.append((String)e.next());
+
+ if(e.hasNext())
+ buf.append(File.pathSeparatorChar);
+ }
+
+ return buf.toString();
+ }
+
+ /**
+ * @param name fully qualified class name, e.g. java.lang.String
+ * @return input stream for class
+ */
+ public InputStream getInputStream(String name) throws IOException {
+ return getInputStream(name, ".class");
+ }
+
+ /**
+ * @param name fully qualified file name, e.g. java/lang/String
+ * @param suffix file name ends with suff, e.g. .java
+ * @return input stream for file on class path
+ */
+ public InputStream getInputStream(String name, String suffix) throws IOException {
+ return getClassFile(name, suffix).getInputStream();
+ }
+
+ /**
+ * @param name fully qualified file name, e.g. java/lang/String
+ * @param suffix file name ends with suff, e.g. .java
+ * @return class file for the java class
+ */
+ public ClassFile getClassFile(String name, String suffix) throws IOException {
+ for(int i=0; i < paths.length; i++) {
+ ClassFile cf;
+
+ if((cf = paths[i].getClassFile(name, suffix)) != null)
+ return cf;
+ }
+
+ throw new IOException("Couldn't find: " + name + suffix);
+ }
+
+ /**
+ * @param name fully qualified class name, e.g. java.lang.String
+ * @return input stream for class
+ */
+ public ClassFile getClassFile(String name) throws IOException {
+ return getClassFile(name, ".class");
+ }
+
+ /**
+ * @param name fully qualified file name, e.g. java/lang/String
+ * @param suffix file name ends with suffix, e.g. .java
+ * @return byte array for file on class path
+ */
+ public byte[] getBytes(String name, String suffix) throws IOException {
+ InputStream is = getInputStream(name, suffix);
+
+ if(is == null)
+ throw new IOException("Couldn't find: " + name + suffix);
+
+ DataInputStream dis = new DataInputStream(is);
+ byte[] bytes = new byte[is.available()];
+ dis.readFully(bytes);
+ dis.close(); is.close();
+
+ return bytes;
+ }
+
+ /**
+ * @return byte array for class
+ */
+ public byte[] getBytes(String name) throws IOException {
+ return getBytes(name, ".class");
+ }
+
+ /**
+ * @param name name of file to search for, e.g. java/lang/String.java
+ * @return full (canonical) path for file
+ */
+ public String getPath(String name) throws IOException {
+ int index = name.lastIndexOf('.');
+ String suffix = "";
+
+ if(index > 0) {
+ suffix = name.substring(index);
+ name = name.substring(0, index);
+ }
+
+ return getPath(name, suffix);
+ }
+
+ /**
+ * @param name name of file to search for, e.g. java/lang/String
+ * @param suffix file name suffix, e.g. .java
+ * @return full (canonical) path for file, if it exists
+ */
+ public String getPath(String name, String suffix) throws IOException {
+ return getClassFile(name, suffix).getPath();
+ }
+
+ private static abstract class PathEntry {
+ abstract ClassFile getClassFile(String name, String suffix) throws IOException;
+ }
+
+ /** Contains information about file/ZIP entry of the Java class.
+ */
+ public abstract static class ClassFile {
+ /** @return input stream for class file.
+ */
+ public abstract InputStream getInputStream() throws IOException;
+
+ /** @return canonical path to class file.
+ */
+ public abstract String getPath();
+
+ /** @return modification time of class file.
+ */
+ public abstract long getTime();
+
+ /** @return size of class file.
+ */
+ public abstract long getSize();
+ }
+
+ private static class Dir extends PathEntry {
+ private String dir;
+
+ Dir(String d) { dir = d; }
+
+ ClassFile getClassFile(String name, String suffix) throws IOException {
+ final File file = new File(dir + File.separatorChar +
+ name.replace('.', File.separatorChar) + suffix);
+
+ return file.exists()? new ClassFile() {
+ public InputStream getInputStream() throws IOException { return new FileInputStream(file); }
+
+ public String getPath() { try {
+ return file.getCanonicalPath();
+ } catch(IOException e) { return null; }
+
+ }
+ public long getTime() { return file.lastModified(); }
+ public long getSize() { return file.length(); }
+ } : null;
+ }
+
+ public String toString() { return dir; }
+ }
+
+ private static class Zip extends PathEntry {
+ private ZipFile zip;
+
+ Zip(ZipFile z) { zip = z; }
+
+ ClassFile getClassFile(String name, String suffix) throws IOException {
+ final ZipEntry entry = zip.getEntry(name.replace('.', '/') + suffix);
+
+ return (entry != null)? new ClassFile() {
+ public InputStream getInputStream() throws IOException { return zip.getInputStream(entry); }
+ public String getPath() { return entry.toString(); }
+ public long getTime() { return entry.getTime(); }
+ public long getSize() { return entry.getSize(); }
+ } : null;
+ }
+ }
+}
+
+
diff --git a/src/java/org/apache/bcel/util/ClassQueue.java b/src/java/org/apache/bcel/util/ClassQueue.java
new file mode 100644
index 00000000..e543917e
--- /dev/null
+++ b/src/java/org/apache/bcel/util/ClassQueue.java
@@ -0,0 +1,78 @@
+package org.apache.bcel.util;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import java.util.ArrayList;
+import org.apache.bcel.classfile.JavaClass;
+
+/**
+ * Utility class implementing a (typesafe) queue of JavaClass
+ * objects.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see ClassVector
+*/
+public class ClassQueue {
+ protected int left = 0;
+ private ArrayList vec = new ArrayList();
+
+ public void enqueue(JavaClass clazz) { vec.add(clazz); }
+ public JavaClass dequeue() {
+ JavaClass clazz = (JavaClass)vec.get(left);
+ vec.remove(left++);
+ return clazz;
+ }
+ public boolean empty() { return vec.size() <= left; }
+}
diff --git a/src/java/org/apache/bcel/util/ClassStack.java b/src/java/org/apache/bcel/util/ClassStack.java
new file mode 100644
index 00000000..79b0af05
--- /dev/null
+++ b/src/java/org/apache/bcel/util/ClassStack.java
@@ -0,0 +1,73 @@
+package org.apache.bcel.util;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import java.util.Stack;
+import org.apache.bcel.classfile.JavaClass;
+
+/**
+ * Utility class implementing a (typesafe) stack of JavaClass objects.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Stack
+*/
+public class ClassStack {
+ private Stack stack = new Stack();
+
+ public void push(JavaClass clazz) { stack.push(clazz); }
+ public JavaClass pop() { return (JavaClass)stack.pop(); }
+ public JavaClass top() { return (JavaClass)stack.peek(); }
+ public boolean empty() { return stack.empty(); }
+}
diff --git a/src/java/org/apache/bcel/util/ClassVector.java b/src/java/org/apache/bcel/util/ClassVector.java
new file mode 100644
index 00000000..a04f0721
--- /dev/null
+++ b/src/java/org/apache/bcel/util/ClassVector.java
@@ -0,0 +1,79 @@
+package org.apache.bcel.util;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import java.util.ArrayList;
+import org.apache.bcel.classfile.JavaClass;
+
+/**
+ * Utility class implementing a (typesafe) collection of JavaClass
+ * objects. Contains the most important methods of a Vector.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see ClassQueue
+*/
+public class ClassVector {
+ protected ArrayList vec = new ArrayList();
+
+ public void addElement(JavaClass clazz) { vec.add(clazz); }
+ public JavaClass elementAt(int index) { return (JavaClass)vec.get(index); }
+ public void removeElementAt(int index) { vec.remove(index); }
+
+ public JavaClass[] toArray() {
+ JavaClass[] classes = new JavaClass[vec.size()];
+ vec.toArray(classes);
+ return classes;
+ }
+}
diff --git a/src/java/org/apache/bcel/util/CodeHTML.java b/src/java/org/apache/bcel/util/CodeHTML.java
new file mode 100644
index 00000000..38a442c7
--- /dev/null
+++ b/src/java/org/apache/bcel/util/CodeHTML.java
@@ -0,0 +1,618 @@
+package org.apache.bcel.util;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.classfile.*;
+import java.io.*;
+import java.util.BitSet;
+
+/**
+ * Convert code into HTML file.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ *
+ */
+final class CodeHTML implements org.apache.bcel.Constants {
+ private String class_name; // name of current class
+ private Method[] methods; // Methods to print
+ private PrintWriter file; // file to write to
+ private BitSet goto_set;
+ private ConstantPool constant_pool;
+ private ConstantHTML constant_html;
+ private static boolean wide=false;
+
+ CodeHTML(String dir, String class_name,
+ Method[] methods, ConstantPool constant_pool,
+ ConstantHTML constant_html) throws IOException
+ {
+ this.class_name = class_name;
+ this.methods = methods;
+ this.constant_pool = constant_pool;
+ this.constant_html = constant_html;
+
+ file = new PrintWriter(new FileOutputStream(dir + class_name + "_code.html"));
+ file.println("<HTML><BODY BGCOLOR=\"#C0C0C0\">");
+
+ for(int i=0; i < methods.length; i++)
+ writeMethod(methods[i], i);
+
+ file.println("</BODY></HTML>");
+ file.close();
+ }
+
+ /**
+ * Disassemble a stream of byte codes and return the
+ * string representation.
+ *
+ * @param stream data input stream
+ * @return String representation of byte code
+ */
+ private final String codeToHTML(ByteSequence bytes, int method_number)
+ throws IOException
+ {
+ short opcode = (short)bytes.readUnsignedByte();
+ StringBuffer buf;
+ String name, sig, signature;
+ int default_offset=0, low, high;
+ int index, class_index, vindex, constant;
+ int[] jump_table;
+ int no_pad_bytes=0, offset;
+
+ buf = new StringBuffer("<TT>" + OPCODE_NAMES[opcode] + "</TT></TD><TD>");
+
+ /* Special case: Skip (0-3) padding bytes, i.e., the
+ * following bytes are 4-byte-aligned
+ */
+ if((opcode == TABLESWITCH) || (opcode == LOOKUPSWITCH)) {
+ int remainder = bytes.getIndex() % 4;
+ no_pad_bytes = (remainder == 0)? 0 : 4 - remainder;
+
+ for(int i=0; i < no_pad_bytes; i++)
+ bytes.readByte();
+
+ // Both cases have a field default_offset in common
+ default_offset = bytes.readInt();
+ }
+
+ switch(opcode) {
+ case TABLESWITCH:
+ low = bytes.readInt();
+ high = bytes.readInt();
+
+ offset = bytes.getIndex() - 12 - no_pad_bytes - 1;
+ default_offset += offset;
+
+ buf.append("<TABLE BORDER=1><TR>");
+
+ // Print switch indices in first row (and default)
+ jump_table = new int[high - low + 1];
+ for(int i=0; i < jump_table.length; i++) {
+ jump_table[i] = offset + bytes.readInt();
+
+ buf.append("<TH>" + (low + i) + "</TH>");
+ }
+ buf.append("<TH>default</TH></TR>\n<TR>");
+
+ // Print target and default indices in second row
+ for(int i=0; i < jump_table.length; i++)
+ buf.append("<TD><A HREF=\"#code" + method_number + "@" +
+ jump_table[i] + "\">" + jump_table[i] + "</A></TD>");
+ buf.append("<TD><A HREF=\"#code" + method_number + "@" +
+ default_offset + "\">" + default_offset + "</A></TD></TR>\n</TABLE>\n");
+
+ break;
+
+ /* Lookup switch has variable length arguments.
+ */
+ case LOOKUPSWITCH:
+ int npairs = bytes.readInt();
+ offset = bytes.getIndex() - 8 - no_pad_bytes - 1;
+ jump_table = new int[npairs];
+ default_offset += offset;
+
+ buf.append("<TABLE BORDER=1><TR>");
+
+ // Print switch indices in first row (and default)
+ for(int i=0; i < npairs; i++) {
+ int match = bytes.readInt();
+
+ jump_table[i] = offset + bytes.readInt();
+ buf.append("<TH>" + match + "</TH>");
+ }
+ buf.append("<TH>default</TH></TR>\n<TR>");
+
+ // Print target and default indices in second row
+ for(int i=0; i < npairs; i++)
+ buf.append("<TD><A HREF=\"#code" + method_number + "@" +
+ jump_table[i] + "\">" + jump_table[i] + "</A></TD>");
+ buf.append("<TD><A HREF=\"#code" + method_number + "@" +
+ default_offset + "\">" + default_offset + "</A></TD></TR>\n</TABLE>\n");
+ break;
+
+ /* Two address bytes + offset from start of byte stream form the
+ * jump target.
+ */
+ case GOTO: case IFEQ: case IFGE: case IFGT:
+ case IFLE: case IFLT:
+ case IFNE: case IFNONNULL: case IFNULL: case IF_ACMPEQ:
+ case IF_ACMPNE: case IF_ICMPEQ: case IF_ICMPGE: case IF_ICMPGT:
+ case IF_ICMPLE: case IF_ICMPLT: case IF_ICMPNE: case JSR:
+
+ index = (int)(bytes.getIndex() + bytes.readShort() - 1);
+
+ buf.append("<A HREF=\"#code" + method_number + "@" + index + "\">" + index + "</A>");
+ break;
+
+ /* Same for 32-bit wide jumps
+ */
+ case GOTO_W: case JSR_W:
+ int windex = bytes.getIndex() + bytes.readInt() - 1;
+ buf.append("<A HREF=\"#code" + method_number + "@" + windex + "\">" +
+ windex + "</A>");
+ break;
+
+ /* Index byte references local variable (register)
+ */
+ case ALOAD: case ASTORE: case DLOAD: case DSTORE: case FLOAD:
+ case FSTORE: case ILOAD: case ISTORE: case LLOAD: case LSTORE:
+ case RET:
+ if(wide) {
+ vindex = bytes.readShort();
+ wide=false; // Clear flag
+ }
+ else
+ vindex = bytes.readUnsignedByte();
+
+ buf.append("%" + vindex);
+ break;
+
+ /*
+ * Remember wide byte which is used to form a 16-bit address in the
+ * following instruction. Relies on that the method is called again with
+ * the following opcode.
+ */
+ case WIDE:
+ wide = true;
+ buf.append("(wide)");
+ break;
+
+ /* Array of basic type.
+ */
+ case NEWARRAY:
+ buf.append("<FONT COLOR=\"#00FF00\">" + TYPE_NAMES[bytes.readByte()] + "</FONT>");
+ break;
+
+ /* Access object/class fields.
+ */
+ case GETFIELD: case GETSTATIC: case PUTFIELD: case PUTSTATIC:
+ index = bytes.readShort();
+ ConstantFieldref c1 = (ConstantFieldref)constant_pool.getConstant(index, CONSTANT_Fieldref);
+
+ class_index = c1.getClassIndex();
+ name = constant_pool.getConstantString(class_index, CONSTANT_Class);
+ name = Utility.compactClassName(name, false);
+
+ index = c1.getNameAndTypeIndex();
+ String field_name = constant_pool.constantToString(index, CONSTANT_NameAndType);
+
+ if(name.equals(class_name)) { // Local field
+ buf.append("<A HREF=\"" + class_name + "_methods.html#field" + field_name +
+ "\" TARGET=Methods>" + field_name + "</A>\n");
+ }
+ else
+ buf.append(constant_html.referenceConstant(class_index) + "." + field_name);
+
+ break;
+
+ /* Operands are references to classes in constant pool
+ */
+ case CHECKCAST: case INSTANCEOF: case NEW:
+ index = bytes.readShort();
+ buf.append(constant_html.referenceConstant(index));
+ break;
+
+ /* Operands are references to methods in constant pool
+ */
+ case INVOKESPECIAL: case INVOKESTATIC: case INVOKEVIRTUAL: case INVOKEINTERFACE:
+ int m_index = bytes.readShort();
+ String str;
+
+ if(opcode == INVOKEINTERFACE) { // Special treatment needed
+ int nargs = bytes.readUnsignedByte(); // Redundant
+ int reserved = bytes.readUnsignedByte(); // Reserved
+
+ ConstantInterfaceMethodref c=(ConstantInterfaceMethodref)constant_pool.getConstant(m_index, CONSTANT_InterfaceMethodref);
+
+ class_index = c.getClassIndex();
+ str = constant_pool.constantToString(c);
+ index = c.getNameAndTypeIndex();
+ }
+ else {
+ ConstantMethodref c = (ConstantMethodref)constant_pool.getConstant(m_index, CONSTANT_Methodref);
+ class_index = c.getClassIndex();
+
+ str = constant_pool.constantToString(c);
+ index = c.getNameAndTypeIndex();
+ }
+
+ name = Class2HTML.referenceClass(class_index);
+ str = Class2HTML.toHTML(constant_pool.constantToString(constant_pool.getConstant(index, CONSTANT_NameAndType)));
+
+ // Get signature, i.e., types
+ ConstantNameAndType c2 = (ConstantNameAndType)constant_pool.
+ getConstant(index, CONSTANT_NameAndType);
+ signature = constant_pool.constantToString(c2.getSignatureIndex(),
+ CONSTANT_Utf8);
+ String[] args = Utility.methodSignatureArgumentTypes(signature, false);
+ String type = Utility.methodSignatureReturnType(signature, false);
+
+ buf.append(name + ".<A HREF=\"" + class_name + "_cp.html#cp" + m_index +
+ "\" TARGET=ConstantPool>" + str + "</A>" + "(");
+
+ // List arguments
+ for(int i=0; i < args.length; i++) {
+ buf.append(Class2HTML.referenceType(args[i]));
+
+ if(i < args.length - 1)
+ buf.append(", ");
+ }
+ // Attach return type
+ buf.append("):" + Class2HTML.referenceType(type));
+
+ break;
+
+ /* Operands are references to items in constant pool
+ */
+ case LDC_W: case LDC2_W:
+ index = bytes.readShort();
+
+ buf.append("<A HREF=\"" + class_name + "_cp.html#cp" + index +
+ "\" TARGET=\"ConstantPool\">" +
+ Class2HTML.toHTML(constant_pool.constantToString(index,
+ constant_pool.
+ getConstant(index).getTag()))+
+ "</a>");
+ break;
+
+ case LDC:
+ index = bytes.readUnsignedByte();
+ buf.append("<A HREF=\"" + class_name + "_cp.html#cp" + index +
+ "\" TARGET=\"ConstantPool\">" +
+ Class2HTML.toHTML(constant_pool.constantToString(index,
+ constant_pool.
+ getConstant(index).getTag()))+
+ "</a>");
+ break;
+
+ /* Array of references.
+ */
+ case ANEWARRAY:
+ index = bytes.readShort();
+
+ buf.append(constant_html.referenceConstant(index));
+ break;
+
+ /* Multidimensional array of references.
+ */
+ case MULTIANEWARRAY:
+ index = bytes.readShort();
+ int dimensions = bytes.readByte();
+ buf.append(constant_html.referenceConstant(index) + ":" + dimensions + "-dimensional");
+ break;
+
+ /* Increment local variable.
+ */
+ case IINC:
+ if(wide) {
+ vindex = bytes.readShort();
+ constant = bytes.readShort();
+ wide = false;
+ }
+ else {
+ vindex = bytes.readUnsignedByte();
+ constant = bytes.readByte();
+ }
+ buf.append("%" + vindex + " " + constant);
+ break;
+
+ default:
+ if(NO_OF_OPERANDS[opcode] > 0) {
+ for(int i=0; i < TYPE_OF_OPERANDS[opcode].length; i++) {
+ switch(TYPE_OF_OPERANDS[opcode][i]) {
+ case T_BYTE:
+ buf.append(bytes.readUnsignedByte());
+ break;
+
+ case T_SHORT: // Either branch or index
+ buf.append(bytes.readShort());
+ break;
+
+ case T_INT:
+ buf.append(bytes.readInt());
+ break;
+
+ default: // Never reached
+ System.err.println("Unreachable default case reached!");
+ System.exit(-1);
+ }
+ buf.append("&nbsp;");
+ }
+ }
+ }
+
+ buf.append("</TD>");
+ return buf.toString();
+ }
+
+ /**
+ * Find all target addresses in code, so that they can be marked
+ * with &lt;A NAME = ...&gt;. Target addresses are kept in an BitSet object.
+ */
+ private final void findGotos(ByteSequence bytes, Method method, Code code)
+ throws IOException
+ {
+ int index;
+ goto_set = new BitSet(bytes.available());
+ int opcode;
+
+ /* First get Code attribute from method and the exceptions handled
+ * (try .. catch) in this method. We only need the line number here.
+ */
+
+ if(code != null) {
+ CodeException[] ce = code.getExceptionTable();
+ int len = ce.length;
+
+ for(int i=0; i < len; i++) {
+ goto_set.set(ce[i].getStartPC());
+ goto_set.set(ce[i].getEndPC());
+ goto_set.set(ce[i].getHandlerPC());
+ }
+
+ // Look for local variables and their range
+ Attribute[] attributes = code.getAttributes();
+ for(int i=0; i < attributes.length; i++) {
+ if(attributes[i].getTag() == ATTR_LOCAL_VARIABLE_TABLE) {
+ LocalVariable[] vars = ((LocalVariableTable)attributes[i]).getLocalVariableTable();
+
+ for(int j=0; j < vars.length; j++) {
+ int start = vars[j].getStartPC();
+ int end = (int)(start + vars[j].getLength());
+ goto_set.set(start);
+ goto_set.set(end);
+ }
+ break;
+ }
+ }
+ }
+
+ // Get target addresses from GOTO, JSR, TABLESWITCH, etc.
+ for(int i=0; bytes.available() > 0; i++) {
+ opcode = bytes.readUnsignedByte();
+ //System.out.println(OPCODE_NAMES[opcode]);
+ switch(opcode) {
+ case TABLESWITCH: case LOOKUPSWITCH:
+ //bytes.readByte(); // Skip already read byte
+
+ int remainder = bytes.getIndex() % 4;
+ int no_pad_bytes = (remainder == 0)? 0 : 4 - remainder;
+ int default_offset, offset;
+
+ for(int j=0; j < no_pad_bytes; j++)
+ bytes.readByte();
+
+ // Both cases have a field default_offset in common
+ default_offset = bytes.readInt();
+
+ if(opcode == TABLESWITCH) {
+ int low = bytes.readInt();
+ int high = bytes.readInt();
+
+ offset = bytes.getIndex() - 12 - no_pad_bytes - 1;
+ default_offset += offset;
+ goto_set.set(default_offset);
+
+ for(int j=0; j < (high - low + 1); j++) {
+ index = offset + bytes.readInt();
+ goto_set.set(index);
+ }
+ }
+ else { // LOOKUPSWITCH
+ int npairs = bytes.readInt();
+
+ offset = bytes.getIndex() - 8 - no_pad_bytes - 1;
+ default_offset += offset;
+ goto_set.set(default_offset);
+
+ for(int j=0; j < npairs; j++) {
+ int match = bytes.readInt();
+
+ index = offset + bytes.readInt();
+ goto_set.set(index);
+ }
+ }
+ break;
+
+ case GOTO: case IFEQ: case IFGE: case IFGT:
+ case IFLE: case IFLT:
+ case IFNE: case IFNONNULL: case IFNULL: case IF_ACMPEQ:
+ case IF_ACMPNE: case IF_ICMPEQ: case IF_ICMPGE: case IF_ICMPGT:
+ case IF_ICMPLE: case IF_ICMPLT: case IF_ICMPNE: case JSR:
+ //bytes.readByte(); // Skip already read byte
+ index = bytes.getIndex() + bytes.readShort() - 1;
+
+ goto_set.set(index);
+ break;
+
+ case GOTO_W: case JSR_W:
+ //bytes.readByte(); // Skip already read byte
+ index = bytes.getIndex() + bytes.readInt() - 1;
+ goto_set.set(index);
+ break;
+
+ default:
+ bytes.unreadByte();
+ codeToHTML(bytes, 0); // Ignore output
+ }
+ }
+ }
+
+ /**
+ * Write a single method with the byte code associated with it.
+ */
+ private void writeMethod(Method method, int method_number)
+ throws IOException
+ {
+ // Get raw signature
+ String signature = method.getSignature();
+ // Get array of strings containing the argument types
+ String[] args = Utility.methodSignatureArgumentTypes(signature, false);
+ // Get return type string
+ String type = Utility.methodSignatureReturnType(signature, false);
+ // Get method name
+ String name = method.getName();
+ String html_name = Class2HTML.toHTML(name);
+ // Get method's access flags
+ String access = Utility.accessToString(method.getAccessFlags());
+ access = Utility.replace(access, " ", "&nbsp;");
+ // Get the method's attributes, the Code Attribute in particular
+ Attribute[] attributes= method.getAttributes();
+
+ file.print("<P><B><FONT COLOR=\"#FF0000\">" + access + "</FONT>&nbsp;" +
+ "<A NAME=method" + method_number + ">" + Class2HTML.referenceType(type) +
+ "</A>&nbsp<A HREF=\"" + class_name + "_methods.html#method" + method_number +
+ "\" TARGET=Methods>" + html_name + "</A>(");
+
+ for(int i=0; i < args.length; i++) {
+ file.print(Class2HTML.referenceType(args[i]));
+ if(i < args.length - 1)
+ file.print(",&nbsp;");
+ }
+
+ file.println(")</B></P>");
+
+ Code c=null;
+ byte[] code=null;
+
+ if(attributes.length > 0) {
+ file.print("<H4>Attributes</H4><UL>\n");
+ for(int i=0; i < attributes.length; i++) {
+ byte tag = attributes[i].getTag();
+
+ if(tag != ATTR_UNKNOWN)
+ file.print("<LI><A HREF=\"" + class_name + "_attributes.html#method" + method_number + "@" + i +
+ "\" TARGET=Attributes>" + ATTRIBUTE_NAMES[tag] + "</A></LI>\n");
+ else
+ file.print("<LI>" + attributes[i] + "</LI>");
+
+ if(tag == ATTR_CODE) {
+ c = (Code)attributes[i];
+ Attribute[] attributes2 = c.getAttributes();
+ code = c.getCode();
+
+ file.print("<UL>");
+ for(int j=0; j < attributes2.length; j++) {
+ tag = attributes2[j].getTag();
+ file.print("<LI><A HREF=\"" + class_name + "_attributes.html#" +
+ "method" + method_number + "@" + i + "@" + j + "\" TARGET=Attributes>" +
+ ATTRIBUTE_NAMES[tag] + "</A></LI>\n");
+
+ }
+ file.print("</UL>");
+ }
+ }
+ file.println("</UL>");
+ }
+
+ if(code != null) { // No code, an abstract method, e.g.
+ //System.out.println(name + "\n" + Utility.codeToString(code, constant_pool, 0, -1));
+
+ // Print the byte code
+ ByteSequence stream = new ByteSequence(code);
+ stream.mark(stream.available());
+ findGotos(stream, method, c);
+ stream.reset();
+
+ file.println("<TABLE BORDER=0><TR><TH ALIGN=LEFT>Byte<BR>offset</TH>" +
+ "<TH ALIGN=LEFT>Instruction</TH><TH ALIGN=LEFT>Argument</TH>");
+
+ for(int i=0; stream.available() > 0; i++) {
+ int offset = stream.getIndex();
+ String str = codeToHTML(stream, method_number);
+ String anchor = "";
+
+ /* Set an anchor mark if this line is targetted by a goto, jsr, etc.
+ * Defining an anchor for every line is very inefficient!
+ */
+ if(goto_set.get(offset))
+ anchor = "<A NAME=code" + method_number + "@" + offset + "></A>";
+
+ String anchor2;
+ if(stream.getIndex() == code.length) // last loop
+ anchor2 = "<A NAME=code" + method_number + "@" + code.length + ">" + offset + "</A>";
+ else
+ anchor2 = "" + offset;
+
+ file.println("<TR VALIGN=TOP><TD>" + anchor2 + "</TD><TD>" + anchor + str + "</TR>");
+ }
+
+ // Mark last line, may be targetted from Attributes window
+ file.println("<TR><TD> </A></TD></TR>");
+ file.println("</TABLE>");
+ }
+
+ }
+}
diff --git a/src/java/org/apache/bcel/util/ConstantHTML.java b/src/java/org/apache/bcel/util/ConstantHTML.java
new file mode 100644
index 00000000..5c5819f2
--- /dev/null
+++ b/src/java/org/apache/bcel/util/ConstantHTML.java
@@ -0,0 +1,262 @@
+
+package org.apache.bcel.util;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.classfile.*;
+import java.io.*;
+
+/**
+ * Convert constant pool into HTML file.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ *
+ */
+final class ConstantHTML implements org.apache.bcel.Constants {
+ private String class_name; // name of current class
+ private String class_package; // name of package
+ private ConstantPool constant_pool; // reference to constant pool
+ private PrintWriter file; // file to write to
+ private String[] constant_ref; // String to return for cp[i]
+ private Constant[] constants; // The constants in the cp
+ private Method[] methods;
+
+ ConstantHTML(String dir, String class_name, String class_package, Method[] methods,
+ ConstantPool constant_pool) throws IOException
+ {
+ this.class_name = class_name;
+ this.class_package = class_package;
+ this.constant_pool = constant_pool;
+ this.methods = methods;
+ constants = constant_pool.getConstantPool();
+ file = new PrintWriter(new FileOutputStream(dir + class_name + "_cp.html"));
+ constant_ref = new String[constants.length];
+ constant_ref[0] = "&lt;unknown&gt;";
+
+ file.println("<HTML><BODY BGCOLOR=\"#C0C0C0\"><TABLE BORDER=0>");
+
+ // Loop through constants, constants[0] is reserved
+ for(int i=1; i < constants.length; i++) {
+ if(i % 2 == 0)
+ file.print("<TR BGCOLOR=\"#C0C0C0\"><TD>");
+ else
+ file.print("<TR BGCOLOR=\"#A0A0A0\"><TD>");
+
+ if(constants[i] != null)
+ writeConstant(i);
+
+ file.print("</TD></TR>\n");
+ }
+
+ file.println("</TABLE></BODY></HTML>");
+ file.close();
+ }
+
+ String referenceConstant(int index) {
+ return constant_ref[index];
+ }
+
+ private void writeConstant(int index) {
+ byte tag = constants[index].getTag();
+ int class_index, name_index;
+ String ref;
+
+ // The header is always the same
+ file.println("<H4> <A NAME=cp" + index + ">" + index + "</A> " + CONSTANT_NAMES[tag] + "</H4>");
+
+ /* For every constant type get the needed parameters and print them appropiately
+ */
+ switch(tag) {
+ case CONSTANT_InterfaceMethodref:
+ case CONSTANT_Methodref:
+ // Get class_index and name_and_type_index, depending on type
+ if(tag == CONSTANT_Methodref) {
+ ConstantMethodref c = (ConstantMethodref)constant_pool.getConstant(index, CONSTANT_Methodref);
+ class_index = c.getClassIndex();
+ name_index = c.getNameAndTypeIndex();
+ }
+ else {
+ ConstantInterfaceMethodref c1 = (ConstantInterfaceMethodref)constant_pool.getConstant(index, CONSTANT_InterfaceMethodref);
+ class_index = c1.getClassIndex();
+ name_index = c1.getNameAndTypeIndex();
+ }
+
+ // Get method name and its class
+ String method_name = constant_pool.constantToString(name_index, CONSTANT_NameAndType);
+ String html_method_name = Class2HTML.toHTML(method_name);
+
+ // Partially compacted class name, i.e., / -> .
+ String method_class = constant_pool.constantToString(class_index, CONSTANT_Class);
+ String short_method_class = Utility.compactClassName(method_class); // I.e., remove java.lang.
+ short_method_class = Utility.compactClassName(method_class); // I.e., remove java.lang.
+ short_method_class = Utility.compactClassName(short_method_class, class_package + ".", true); // Remove class package prefix
+
+ // Get method signature
+ ConstantNameAndType c2 = (ConstantNameAndType)constant_pool.getConstant(name_index, CONSTANT_NameAndType);
+ String signature = constant_pool.constantToString(c2.getSignatureIndex(), CONSTANT_Utf8);
+ // Get array of strings containing the argument types
+ String[] args = Utility.methodSignatureArgumentTypes(signature, false);
+
+ // Get return type string
+ String type = Utility.methodSignatureReturnType(signature, false);
+ String ret_type = Class2HTML.referenceType(type);
+
+ StringBuffer buf = new StringBuffer("(");
+ for(int i=0; i < args.length; i++) {
+ buf.append(Class2HTML.referenceType(args[i]));
+ if(i < args.length - 1)
+ buf.append(",&nbsp;");
+ }
+ buf.append(")");
+
+ String arg_types = buf.toString();
+
+ if(method_class.equals(class_name)) // Method is local to class
+ ref = "<A HREF=\"" + class_name + "_code.html#method" + getMethodNumber(method_name + signature) +
+ "\" TARGET=Code>" + html_method_name + "</A>";
+ else
+ ref = "<A HREF=\"" + method_class + ".html" + "\" TARGET=_top>" + short_method_class +
+ "</A>." + html_method_name;
+
+ constant_ref[index] = ret_type + "&nbsp;<A HREF=\"" + class_name + "_cp.html#cp" + class_index +
+ "\" TARGET=Constants>" +
+ short_method_class + "</A>.<A HREF=\"" + class_name + "_cp.html#cp" +
+ index + "\" TARGET=ConstantPool>" + html_method_name + "</A>&nbsp;" + arg_types;
+
+ file.println("<P><TT>" + ret_type + "&nbsp;" + ref + arg_types + "&nbsp;</TT>\n<UL>" +
+ "<LI><A HREF=\"#cp" + class_index + "\">Class index(" + class_index + ")</A>\n" +
+ "<LI><A HREF=\"#cp" + name_index + "\">NameAndType index(" + name_index + ")</A></UL>");
+ break;
+
+ case CONSTANT_Fieldref:
+ // Get class_index and name_and_type_index
+ ConstantFieldref c3 = (ConstantFieldref)constant_pool.getConstant(index, CONSTANT_Fieldref);
+ class_index = c3.getClassIndex();
+ name_index = c3.getNameAndTypeIndex();
+
+ // Get method name and its class (compacted)
+ String field_class = constant_pool.constantToString(class_index, CONSTANT_Class);
+ String short_field_class = Utility.compactClassName(field_class); // I.e., remove java.lang.
+ short_field_class = Utility.compactClassName(short_field_class, class_package + ".", true); // Remove class package prefix
+
+ String field_name = constant_pool.constantToString(name_index, CONSTANT_NameAndType);
+
+ if(field_class.equals(class_name)) // Field is local to class
+ ref = "<A HREF=\"" + field_class + "_methods.html#field" +
+ field_name + "\" TARGET=Methods>" + field_name + "</A>";
+ else
+ ref = "<A HREF=\"" + field_class + ".html\" TARGET=_top>" +
+ short_field_class + "</A>." + field_name + "\n";
+
+ constant_ref[index] = "<A HREF=\"" + class_name + "_cp.html#cp" + class_index + "\" TARGET=Constants>" +
+ short_field_class + "</A>.<A HREF=\"" + class_name + "_cp.html#cp" +
+ index + "\" TARGET=ConstantPool>" + field_name + "</A>";
+
+ file.println("<P><TT>" + ref + "</TT><BR>\n" + "<UL>" +
+ "<LI><A HREF=\"#cp" + class_index + "\">Class(" + class_index + ")</A><BR>\n" +
+ "<LI><A HREF=\"#cp" + name_index + "\">NameAndType(" + name_index + ")</A></UL>");
+ break;
+
+ case CONSTANT_Class:
+ ConstantClass c4 = (ConstantClass)constant_pool.getConstant(index, CONSTANT_Class);
+ name_index = c4.getNameIndex();
+ String class_name2 = constant_pool.constantToString(index, tag); // / -> .
+ String short_class_name = Utility.compactClassName(class_name2); // I.e., remove java.lang.
+ short_class_name = Utility.compactClassName(short_class_name, class_package + ".", true); // Remove class package prefix
+
+ ref = "<A HREF=\"" + class_name2 + ".html\" TARGET=_top>" + short_class_name + "</A>";
+ constant_ref[index] = "<A HREF=\"" + class_name + "_cp.html#cp" + index +
+ "\" TARGET=ConstantPool>" + short_class_name + "</A>";
+
+ file.println("<P><TT>" + ref + "</TT><UL>" +
+ "<LI><A HREF=\"#cp" + name_index + "\">Name index(" + name_index + ")</A></UL>\n");
+ break;
+
+ case CONSTANT_String:
+ ConstantString c5 = (ConstantString)constant_pool.getConstant(index, CONSTANT_String);
+ name_index = c5.getStringIndex();
+
+ String str = Class2HTML.toHTML(constant_pool.constantToString(index, tag));
+
+ file.println("<P><TT>" + str + "</TT><UL>" +
+ "<LI><A HREF=\"#cp" + name_index + "\">Name index(" + name_index + ")</A></UL>\n");
+ break;
+
+ case CONSTANT_NameAndType:
+ ConstantNameAndType c6 = (ConstantNameAndType)constant_pool.getConstant(index, CONSTANT_NameAndType);
+ name_index = c6.getNameIndex();
+ int signature_index = c6.getSignatureIndex();
+
+ file.println("<P><TT>" + Class2HTML.toHTML(constant_pool.constantToString(index, tag)) + "</TT><UL>" +
+ "<LI><A HREF=\"#cp" + name_index + "\">Name index(" + name_index + ")</A>\n" +
+ "<LI><A HREF=\"#cp" + signature_index + "\">Signature index(" +
+ signature_index + ")</A></UL>\n");
+ break;
+
+ default:
+ file.println("<P><TT>" + Class2HTML.toHTML(constant_pool.constantToString(index, tag)) + "</TT>\n");
+ } // switch
+ }
+
+ private final int getMethodNumber(String str) {
+ for(int i=0; i < methods.length; i++) {
+ String cmp = methods[i].getName() + methods[i].getSignature();
+ if(cmp.equals(str))
+ return i;
+ }
+ return -1;
+ }
+}
diff --git a/src/java/org/apache/bcel/util/InstructionFinder.java b/src/java/org/apache/bcel/util/InstructionFinder.java
new file mode 100644
index 00000000..4e3370bb
--- /dev/null
+++ b/src/java/org/apache/bcel/util/InstructionFinder.java
@@ -0,0 +1,440 @@
+package org.apache.bcel.util;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import java.util.*;
+import org.apache.bcel.Constants;
+import org.apache.bcel.generic.*;
+import org.apache.regexp.*;
+
+/**
+ * InstructionFinder is a tool to search for given instructions patterns,
+ * i.e., match sequences of instructions in an instruction list via
+ * regular expressions. This can be used, e.g., in order to implement
+ * a peep hole optimizer that looks for code patterns and replaces
+ * them with faster equivalents.
+ *
+ * <p>This class internally uses the <a href="http://jakarta.apache.org/regexp/">
+ * Regexp</a> package to search for regular expressions.
+ *
+ * A typical application would look like this:
+<pre>
+ InstructionFinder f = new InstructionFinder(il);
+ String pat = "IfInstruction ICONST_0 GOTO ICONST_1 NOP (IFEQ|IFNE)";
+
+ for(Iterator i = f.search(pat, constraint); i.hasNext(); ) {
+ InstructionHandle[] match = (InstructionHandle[])i.next();
+ ...
+ il.delete(match[1], match[5]);
+ ...
+ }
+</pre>
+ * @version $Id$
+ * @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A>
+ * @see Instruction
+ * @see InstructionList
+ */
+public class InstructionFinder {
+ private static final int OFFSET = 32767; // char + OFFSET is outside of LATIN-1
+ private static final int NO_OPCODES = 256; // Potential number, some are not used
+
+ private static final HashMap map = new HashMap(); // Map<String,Pattern>
+
+ private InstructionList il;
+ private String il_string; // instruction list as string
+ private InstructionHandle[] handles; // map instruction list to array
+
+ /**
+ * @param il instruction list to search for given patterns
+ */
+ public InstructionFinder(InstructionList il) {
+ this.il = il;
+ reread();
+ }
+
+ /**
+ * Reread the instruction list, e.g., after you've altered the list upon a match.
+ */
+ public final void reread() {
+ int size = il.getLength();
+ char[] buf = new char[size]; // Create a string with length equal to il length
+ handles = il.getInstructionHandles();
+
+ // Map opcodes to characters
+ for(int i=0; i < size; i++)
+ buf[i] = makeChar(handles[i].getInstruction().getOpcode());
+
+ il_string = new String(buf);
+ }
+
+ /**
+ * Map symbolic instruction names like "getfield" to a single character.
+ *
+ * @param pattern instruction pattern in lower case
+ * @return encoded string for a pattern such as "BranchInstruction".
+ */
+ private static final String mapName(String pattern) {
+ String result = (String)map.get(pattern);
+
+ if(result != null)
+ return result;
+
+ for(short i=0; i < NO_OPCODES; i++)
+ if(pattern.equals(Constants.OPCODE_NAMES[i]))
+ return "" + makeChar(i);
+
+ throw new RuntimeException("Instruction unknown: " + pattern);
+ }
+
+ /**
+ * Replace symbolic names of instructions with the appropiate character and remove
+ * all white space from string. Meta characters such as +, * are ignored.
+ *
+ * @param pattern The pattern to compile
+ * @return translated regular expression string
+ */
+ private static final String compilePattern(String pattern) {
+ String lower = pattern.toLowerCase();
+ StringBuffer buf = new StringBuffer();
+ int size = pattern.length();
+
+ for(int i=0; i < size; i++) {
+ char ch = lower.charAt(i);
+
+ if(Character.isLetterOrDigit(ch)) {
+ StringBuffer name = new StringBuffer();
+
+ while((Character.isLetterOrDigit(ch) || ch == '_') && i < size) {
+ name.append(ch);
+
+ if(++i < size)
+ ch = lower.charAt(i);
+ else
+ break;
+ }
+
+ i--;
+
+ buf.append(mapName(name.toString()));
+ } else if(!Character.isWhitespace(ch))
+ buf.append(ch);
+ }
+
+ return buf.toString();
+ }
+
+ /**
+ * @return the matched piece of code as an array of instruction (handles)
+ */
+ private InstructionHandle[] getMatch(int matched_from, int match_length) {
+ InstructionHandle[] match = new InstructionHandle[match_length];
+ System.arraycopy(handles, matched_from, match, 0, match_length);
+
+ return match;
+ }
+
+ /**
+ * Search for the given pattern in the instruction list. You can search for any valid
+ * opcode via its symbolic name, e.g. "istore". You can also use a super class or
+ * an interface name to match a whole set of instructions, e.g. "BranchInstruction" or
+ * "LoadInstruction". "istore" is also an alias for all "istore_x" instructions. Additional
+ * aliases are "if" for "ifxx", "if_icmp" for "if_icmpxx", "if_acmp" for "if_acmpxx".
+ *
+ * Consecutive instruction names must be separated by white space which will be removed
+ * during the compilation of the pattern.
+ *
+ * For the rest the usual pattern matching rules for regular expressions apply.<P>
+ * Example pattern:
+ * <pre>
+ search("BranchInstruction NOP ((IfInstruction|GOTO)+ ISTORE Instruction)*");
+ * </pre>
+ *
+ * <p>If you alter the instruction list upon a match such that other
+ * matching areas are affected, you should call reread() to update
+ * the finder and call search() again, because the matches are cached.
+ *
+ * @param pattern the instruction pattern to search for, where case is ignored
+ * @param from where to start the search in the instruction list
+ * @param constraint optional CodeConstraint to check the found code pattern for
+ * user-defined constraints
+ * @return iterator of matches where e.nextElement() returns an array of instruction handles
+ * describing the matched area
+ */
+ public final Iterator search(String pattern, InstructionHandle from,
+ CodeConstraint constraint)
+ {
+ String search = compilePattern(pattern);
+ int start = -1;
+
+ for(int i=0; i < handles.length; i++) {
+ if(handles[i] == from) {
+ start = i; // Where to start search from (index)
+ break;
+ }
+ }
+
+ if(start == -1)
+ throw new ClassGenException("Instruction handle " + from +
+ " not found in instruction list.");
+ try {
+ RE regex = new RE(search);
+ ArrayList matches = new ArrayList();
+
+ while(start < il_string.length() && regex.match(il_string, start)) {
+ int startExpr = regex.getParenStart(0);
+ int endExpr = regex.getParenEnd(0);
+ int lenExpr = regex.getParenLength(0);
+
+ InstructionHandle[] match = getMatch(startExpr, lenExpr);
+
+ if((constraint == null) || constraint.checkCode(match))
+ matches.add(match);
+ start = endExpr;
+ }
+
+ return matches.iterator();
+ } catch(RESyntaxException e) {
+ System.err.println(e);
+ }
+
+ return null;
+ }
+
+ /**
+ * Start search beginning from the start of the given instruction list.
+ *
+ * @param pattern the instruction pattern to search for, where case is ignored
+ * @return iterator of matches where e.nextElement()
+ * returns an array of instruction handles describing the matched
+ * area
+ */
+ public final Iterator search(String pattern) {
+ return search(pattern, il.getStart(), null);
+ }
+
+ /**
+ * Start search beginning from `from'.
+ *
+ * @param pattern the instruction pattern to search for, where case is ignored
+ * @param from where to start the search in the instruction list
+ * @return iterator of matches where e.nextElement() returns an array of instruction handles
+ * describing the matched area
+ */
+ public final Iterator search(String pattern, InstructionHandle from) {
+ return search(pattern, from, null);
+ }
+
+ /**
+ * Start search beginning from the start of the given instruction list.
+ * Check found matches with the constraint object.
+ *
+ * @param pattern the instruction pattern to search for, case is ignored
+ * @param constraint constraints to be checked on matching code
+ * @return instruction handle or `null' if the match failed
+ */
+ public final Iterator search(String pattern, CodeConstraint constraint) {
+ return search(pattern, il.getStart(), constraint);
+ }
+
+ /**
+ * Convert opcode number to char.
+ */
+ private static final char makeChar(short opcode) {
+ return (char)(opcode + OFFSET);
+ }
+
+ /**
+ * @return the inquired instruction list
+ */
+ public final InstructionList getInstructionList() { return il; }
+
+ /**
+ * Code patterns found may be checked using an additional
+ * user-defined constraint object whether they really match the needed criterion.
+ * I.e., check constraints that can not expressed with regular expressions.
+ *
+ */
+ public interface CodeConstraint {
+ /**
+ * @param match array of instructions matching the requested pattern
+ * @return true if the matched area is really useful
+ */
+ public boolean checkCode(InstructionHandle[] match);
+ }
+
+ // Initialize pattern map
+
+ static {
+ map.put("arithmeticinstruction", "(irem|lrem|iand|ior|ineg|isub|lneg|fneg|fmul|ldiv|fadd|lxor|frem|idiv|land|ixor|ishr|fsub|lshl|fdiv|iadd|lor|dmul|lsub|ishl|imul|lmul|lushr|dneg|iushr|lshr|ddiv|drem|dadd|ladd|dsub)");
+ map.put("invokeinstruction", "(invokevirtual|invokeinterface|invokestatic|invokespecial)");
+ map.put("arrayinstruction", "(baload|aastore|saload|caload|fastore|lastore|iaload|castore|iastore|aaload|bastore|sastore|faload|laload|daload|dastore)");
+ map.put("gotoinstruction", "(goto|goto_w)");
+ map.put("conversioninstruction", "(d2l|l2d|i2s|d2i|l2i|i2b|l2f|d2f|f2i|i2d|i2l|f2d|i2c|f2l|i2f)");
+ map.put("localvariableinstruction", "(fstore|iinc|lload|dstore|dload|iload|aload|astore|istore|fload|lstore)");
+ map.put("loadinstruction", "(fload|dload|lload|iload|aload)");
+ map.put("fieldinstruction", "(getfield|putstatic|getstatic|putfield)");
+ map.put("cpinstruction", "(ldc2_w|invokeinterface|multianewarray|putstatic|instanceof|getstatic|checkcast|getfield|invokespecial|ldc_w|invokestatic|invokevirtual|putfield|ldc|new|anewarray)");
+ map.put("stackinstruction", "(dup2|swap|dup2_x2|pop|pop2|dup|dup2_x1|dup_x2|dup_x1)");
+ map.put("branchinstruction", "(ifle|if_acmpne|if_icmpeq|if_acmpeq|ifnonnull|goto_w|iflt|ifnull|if_icmpne|tableswitch|if_icmple|ifeq|if_icmplt|jsr_w|if_icmpgt|ifgt|jsr|goto|ifne|ifge|lookupswitch|if_icmpge)");
+ map.put("returninstruction", "(lreturn|ireturn|freturn|dreturn|areturn|return)");
+ map.put("storeinstruction", "(istore|fstore|dstore|astore|lstore)");
+ map.put("select", "(tableswitch|lookupswitch)");
+ map.put("ifinstruction", "(ifeq|ifgt|if_icmpne|if_icmpeq|ifge|ifnull|ifne|if_icmple|if_icmpge|if_acmpeq|if_icmplt|if_acmpne|ifnonnull|iflt|if_icmpgt|ifle)");
+ map.put("jsrinstruction", "(jsr|jsr_w)");
+ map.put("variablelengthinstruction", "(tableswitch|jsr|goto|lookupswitch)");
+ map.put("unconditionalbranch", "(goto|jsr|jsr_w|athrow|goto_w)");
+ map.put("constantpushinstruction", "(dconst|bipush|sipush|fconst|iconst|lconst)");
+ map.put("typedinstruction", "(imul|lsub|aload|fload|lor|new|aaload|fcmpg|iand|iaload|lrem|idiv|d2l|isub|dcmpg|dastore|ret|f2d|f2i|drem|iinc|i2c|checkcast|frem|lreturn|astore|lushr|daload|dneg|fastore|istore|lshl|ldiv|lstore|areturn|ishr|ldc_w|invokeinterface|aastore|lxor|ishl|l2d|i2f|return|faload|sipush|iushr|caload|instanceof|invokespecial|putfield|fmul|ireturn|laload|d2f|lneg|ixor|i2l|fdiv|lastore|multianewarray|i2b|getstatic|i2d|putstatic|fcmpl|saload|ladd|irem|dload|jsr_w|dconst|dcmpl|fsub|freturn|ldc|aconst_null|castore|lmul|ldc2_w|dadd|iconst|f2l|ddiv|dstore|land|jsr|anewarray|dmul|bipush|dsub|sastore|d2i|i2s|lshr|iadd|l2i|lload|bastore|fstore|fneg|iload|fadd|baload|fconst|ior|ineg|dreturn|l2f|lconst|getfield|invokevirtual|invokestatic|iastore)");
+ map.put("popinstruction", "(fstore|dstore|pop|pop2|astore|putstatic|istore|lstore)");
+ map.put("allocationinstruction", "(multianewarray|new|anewarray|newarray)");
+ map.put("indexedinstruction", "(lload|lstore|fload|ldc2_w|invokeinterface|multianewarray|astore|dload|putstatic|instanceof|getstatic|checkcast|getfield|invokespecial|dstore|istore|iinc|ldc_w|ret|fstore|invokestatic|iload|putfield|invokevirtual|ldc|new|aload|anewarray)");
+ map.put("pushinstruction", "(dup|lload|dup2|bipush|fload|ldc2_w|sipush|lconst|fconst|dload|getstatic|ldc_w|aconst_null|dconst|iload|ldc|iconst|aload)");
+ map.put("stackproducer", "(imul|lsub|aload|fload|lor|new|aaload|fcmpg|iand|iaload|lrem|idiv|d2l|isub|dcmpg|dup|f2d|f2i|drem|i2c|checkcast|frem|lushr|daload|dneg|lshl|ldiv|ishr|ldc_w|invokeinterface|lxor|ishl|l2d|i2f|faload|sipush|iushr|caload|instanceof|invokespecial|fmul|laload|d2f|lneg|ixor|i2l|fdiv|getstatic|i2b|swap|i2d|dup2|fcmpl|saload|ladd|irem|dload|jsr_w|dconst|dcmpl|fsub|ldc|arraylength|aconst_null|tableswitch|lmul|ldc2_w|iconst|dadd|f2l|ddiv|land|jsr|anewarray|dmul|bipush|dsub|d2i|newarray|i2s|lshr|iadd|lload|l2i|fneg|iload|fadd|baload|fconst|lookupswitch|ior|ineg|lconst|l2f|getfield|invokevirtual|invokestatic)");
+ map.put("stackconsumer", "(imul|lsub|lor|iflt|fcmpg|if_icmpgt|iand|ifeq|if_icmplt|lrem|ifnonnull|idiv|d2l|isub|dcmpg|dastore|if_icmpeq|f2d|f2i|drem|i2c|checkcast|frem|lreturn|astore|lushr|pop2|monitorexit|dneg|fastore|istore|lshl|ldiv|lstore|areturn|if_icmpge|ishr|monitorenter|invokeinterface|aastore|lxor|ishl|l2d|i2f|return|iushr|instanceof|invokespecial|fmul|ireturn|d2f|lneg|ixor|pop|i2l|ifnull|fdiv|lastore|i2b|if_acmpeq|ifge|swap|i2d|putstatic|fcmpl|ladd|irem|dcmpl|fsub|freturn|ifgt|castore|lmul|dadd|f2l|ddiv|dstore|land|if_icmpne|if_acmpne|dmul|dsub|sastore|ifle|d2i|i2s|lshr|iadd|l2i|bastore|fstore|fneg|fadd|ior|ineg|ifne|dreturn|l2f|if_icmple|getfield|invokevirtual|invokestatic|iastore)");
+ map.put("exceptionthrower", "(irem|lrem|laload|putstatic|baload|dastore|areturn|getstatic|ldiv|anewarray|iastore|castore|idiv|saload|lastore|fastore|putfield|lreturn|caload|getfield|return|aastore|freturn|newarray|instanceof|multianewarray|athrow|faload|iaload|aaload|dreturn|monitorenter|checkcast|bastore|arraylength|new|invokevirtual|sastore|ldc_w|ireturn|invokespecial|monitorexit|invokeinterface|ldc|invokestatic|daload)");
+ map.put("loadclass", "(multianewarray|invokeinterface|instanceof|invokespecial|putfield|checkcast|putstatic|invokevirtual|new|getstatic|invokestatic|getfield|anewarray)");
+ map.put("instructiontargeter", "(ifle|if_acmpne|if_icmpeq|if_acmpeq|ifnonnull|goto_w|iflt|ifnull|if_icmpne|tableswitch|if_icmple|ifeq|if_icmplt|jsr_w|if_icmpgt|ifgt|jsr|goto|ifne|ifge|lookupswitch|if_icmpge)");
+
+ // Some aliases
+ map.put("if_icmp", "(if_icmpne|if_icmpeq|if_icmple|if_icmpge|if_icmplt|if_icmpgt)");
+ map.put("if_acmp", "(if_acmpeq|if_acmpne)");
+ map.put("if", "(ifeq|ifne|iflt|ifge|ifgt|ifle)");
+
+ // Precompile some aliases first
+ map.put("iconst", precompile(Constants.ICONST_0, Constants.ICONST_5, Constants.ICONST_M1));
+ map.put("lconst", new String(new char[] { '(', makeChar(Constants.LCONST_0), '|',
+ makeChar(Constants.LCONST_1), ')' }));
+ map.put("dconst", new String(new char[] { '(', makeChar(Constants.DCONST_0), '|',
+ makeChar(Constants.DCONST_1), ')' }));
+ map.put("fconst", new String(new char[] { '(', makeChar(Constants.FCONST_0), '|',
+ makeChar(Constants.FCONST_1), ')' }));
+
+ map.put("iload", precompile(Constants.ILOAD_0, Constants.ILOAD_3, Constants.ILOAD));
+ map.put("dload", precompile(Constants.DLOAD_0, Constants.DLOAD_3, Constants.DLOAD));
+ map.put("fload", precompile(Constants.FLOAD_0, Constants.FLOAD_3, Constants.FLOAD));
+ map.put("aload", precompile(Constants.ALOAD_0, Constants.ALOAD_3, Constants.ALOAD));
+
+ map.put("istore", precompile(Constants.ISTORE_0, Constants.ISTORE_3, Constants.ISTORE));
+ map.put("dstore", precompile(Constants.DSTORE_0, Constants.DSTORE_3, Constants.DSTORE));
+ map.put("fstore", precompile(Constants.FSTORE_0, Constants.FSTORE_3, Constants.FSTORE));
+ map.put("astore", precompile(Constants.ASTORE_0, Constants.ASTORE_3, Constants.ASTORE));
+
+ // Compile strings
+
+ for(Iterator i = map.keySet().iterator(); i.hasNext(); ) {
+ String key = (String)i.next();
+ String value = (String)map.get(key);
+
+ char ch = value.charAt(1); // Omit already precompiled patterns
+ if(ch < OFFSET) {
+ map.put(key, compilePattern(value)); // precompile all patterns
+ }
+ }
+
+ // Add instruction alias to match anything
+
+ StringBuffer buf = new StringBuffer("(");
+
+ for(short i=0; i < NO_OPCODES; i++) {
+ if(Constants.NO_OF_OPERANDS[i] != Constants.UNDEFINED) { // Not an invalid opcode
+ buf.append(makeChar(i));
+
+ if(i < NO_OPCODES - 1)
+ buf.append('|');
+ }
+ }
+ buf.append(')');
+
+ map.put("instruction", buf.toString());
+ }
+
+ private static String precompile(short from, short to, short extra) {
+ StringBuffer buf = new StringBuffer("(");
+
+ for(short i=from; i <= to; i++) {
+ buf.append(makeChar(i));
+ buf.append('|');
+ }
+
+ buf.append(makeChar(extra));
+ buf.append(")");
+ return buf.toString();
+ }
+
+ /*
+ * Internal debugging routines.
+ */
+ private static final String pattern2string(String pattern) {
+ return pattern2string(pattern, true);
+ }
+
+ private static final String pattern2string(String pattern, boolean make_string) {
+ StringBuffer buf = new StringBuffer();
+
+ for(int i=0; i < pattern.length(); i++) {
+ char ch = pattern.charAt(i);
+
+ if(ch >= OFFSET) {
+ if(make_string)
+ buf.append(Constants.OPCODE_NAMES[ch - OFFSET]);
+ else
+ buf.append((int)(ch - OFFSET));
+ } else
+ buf.append(ch);
+ }
+
+ return buf.toString();
+ }
+}
diff --git a/src/java/org/apache/bcel/util/JavaWrapper.java b/src/java/org/apache/bcel/util/JavaWrapper.java
new file mode 100644
index 00000000..89cd9736
--- /dev/null
+++ b/src/java/org/apache/bcel/util/JavaWrapper.java
@@ -0,0 +1,152 @@
+package org.apache.bcel.util;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import java.lang.reflect.*;
+
+/**
+ * Java interpreter replacement, i.e., wrapper that uses its own ClassLoader
+ * to modify/generate classes as they're requested. You can take this as a template
+ * for your own applications.<br>
+ * Call this wrapper with
+ * <pre>java org.apache.bcel.util.JavaWrapper &lt;real.class.name&gt; [arguments]</pre>
+ * <p>
+ * To use your own class loader you can set the "bcel.classloader" system property
+ * which defaults to "org.apache.bcel.util.ClassLoader", e.g., with
+ * <pre>java org.apache.bcel.util.JavaWrapper -Dbcel.classloader=foo.MyLoader &lt;real.class.name&gt; [arguments]</pre>
+ * </p>
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see ClassLoader
+ */
+public class JavaWrapper {
+ private java.lang.ClassLoader loader;
+
+ private static java.lang.ClassLoader getClassLoader() {
+ String s = System.getProperty("bcel.classloader");
+
+ if((s == null) || "".equals(s))
+ s = "org.apache.bcel.util.ClassLoader";
+
+ try {
+ return (java.lang.ClassLoader)Class.forName(s).newInstance();
+ } catch(Exception e) {
+ throw new RuntimeException(e.toString());
+ }
+ }
+
+ public JavaWrapper(java.lang.ClassLoader loader) {
+ this.loader = loader;
+ }
+
+ public JavaWrapper() {
+ this(getClassLoader());
+ }
+
+ /** Runs the main method of the given class with the arguments passed in argv
+ *
+ * @param class_name the fully qualified class name
+ * @param argv the arguments just as you would pass them directly
+ */
+ public void runMain(String class_name, String[] argv) throws ClassNotFoundException
+ {
+ Class cl = loader.loadClass(class_name);
+ Method method = null;
+
+ try {
+ method = cl.getMethod("main", new Class[] { argv.getClass() });
+
+ /* Method main is sane ?
+ */
+ int m = method.getModifiers();
+ Class r = method.getReturnType();
+
+ if(!(Modifier.isPublic(m) && Modifier.isStatic(m)) ||
+ Modifier.isAbstract(m) || (r != Void.TYPE))
+ throw new NoSuchMethodException();
+ } catch(NoSuchMethodException no) {
+ System.out.println("In class " + class_name +
+ ": public static void main(String[] argv) is not defined");
+ return;
+ }
+
+ try {
+ method.invoke(null, new Object[] { argv });
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ /** Default main method used as wrapper, expects the fully qualified class name
+ * of the real class as the first argument.
+ */
+ public static void main(String[] argv) throws Exception {
+ /* Expects class name as first argument, other arguments are by-passed.
+ */
+ if(argv.length == 0) {
+ System.out.println("Missing class name.");
+ return;
+ }
+
+ String class_name = argv[0];
+ String[] new_argv = new String[argv.length - 1];
+ System.arraycopy(argv, 1, new_argv, 0, new_argv.length);
+
+ JavaWrapper wrapper = new JavaWrapper();
+ wrapper.runMain(class_name, new_argv);
+ }
+}
+
diff --git a/src/java/org/apache/bcel/util/MethodHTML.java b/src/java/org/apache/bcel/util/MethodHTML.java
new file mode 100644
index 00000000..d7991940
--- /dev/null
+++ b/src/java/org/apache/bcel/util/MethodHTML.java
@@ -0,0 +1,199 @@
+package org.apache.bcel.util;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.classfile.*;
+import java.io.*;
+
+/**
+ * Convert methods and fields into HTML file.
+ *
+ * @version $Id$
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ *
+ */
+final class MethodHTML implements org.apache.bcel.Constants {
+ private String class_name; // name of current class
+ private PrintWriter file; // file to write to
+ private ConstantHTML constant_html;
+ private AttributeHTML attribute_html;
+
+ MethodHTML(String dir, String class_name,
+ Method[] methods, Field[] fields,
+ ConstantHTML constant_html, AttributeHTML attribute_html) throws IOException
+ {
+ this.class_name = class_name;
+ this.attribute_html = attribute_html;
+ this.constant_html = constant_html;
+
+ file = new PrintWriter(new FileOutputStream(dir + class_name + "_methods.html"));
+
+ file.println("<HTML><BODY BGCOLOR=\"#C0C0C0\"><TABLE BORDER=0>");
+ file.println("<TR><TH ALIGN=LEFT>Access&nbsp;flags</TH><TH ALIGN=LEFT>Type</TH>" +
+ "<TH ALIGN=LEFT>Field&nbsp;name</TH></TR>");
+ for(int i=0; i < fields.length; i++)
+ writeField(fields[i]);
+ file.println("</TABLE>");
+
+ file.println("<TABLE BORDER=0><TR><TH ALIGN=LEFT>Access&nbsp;flags</TH>" +
+ "<TH ALIGN=LEFT>Return&nbsp;type</TH><TH ALIGN=LEFT>Method&nbsp;name</TH>" +
+ "<TH ALIGN=LEFT>Arguments</TH></TR>");
+ for(int i=0; i < methods.length; i++)
+ writeMethod(methods[i], i);
+
+ file.println("</TABLE></BODY></HTML>");
+ file.close();
+ }
+
+ /**
+ * Print field of class.
+ *
+ * @param field field to print
+ * @exception java.io.IOException
+ */
+ private void writeField(Field field) throws IOException {
+ String type = Utility.signatureToString(field.getSignature());
+ String name = field.getName();
+ String access = Utility.accessToString(field.getAccessFlags());
+ Attribute[] attributes;
+
+ access = Utility.replace(access, " ", "&nbsp;");
+
+ file.print("<TR><TD><FONT COLOR=\"#FF0000\">" + access + "</FONT></TD>\n<TD>" +
+ Class2HTML.referenceType(type) + "</TD><TD><A NAME=\"field" + name + "\">" +
+ name + "</A></TD>");
+
+ attributes = field.getAttributes();
+
+ // Write them to the Attributes.html file with anchor "<name>[<i>]"
+ for(int i=0; i < attributes.length; i++)
+ attribute_html.writeAttribute(attributes[i], name + "@" + i);
+
+ for(int i=0; i < attributes.length; i++) {
+ if(attributes[i].getTag() == ATTR_CONSTANT_VALUE) { // Default value
+ String str = ((ConstantValue)attributes[i]).toString();
+
+ // Reference attribute in _attributes.html
+ file.print("<TD>= <A HREF=\"" + class_name + "_attributes.html#" +
+ name + "@" + i + "\" TARGET=\"Attributes\">" + str + "</TD>\n");
+ break;
+ }
+ }
+
+ file.println("</TR>");
+ }
+
+ private final void writeMethod(Method method, int method_number) throws IOException {
+ // Get raw signature
+ String signature = method.getSignature();
+ // Get array of strings containing the argument types
+ String[] args = Utility.methodSignatureArgumentTypes(signature, false);
+ // Get return type string
+ String type = Utility.methodSignatureReturnType(signature, false);
+ // Get method name
+ String name = method.getName(), html_name;
+ // Get method's access flags
+ String access = Utility.accessToString(method.getAccessFlags());
+ // Get the method's attributes, the Code Attribute in particular
+ Attribute[] attributes = method.getAttributes();
+
+ /* HTML doesn't like names like <clinit> and spaces are places to break
+ * lines. Both we don't want...
+ */
+ access = Utility.replace(access, " ", "&nbsp;");
+ html_name = Class2HTML.toHTML(name);
+
+ file.print("<TR VALIGN=TOP><TD><FONT COLOR=\"#FF0000\"><A NAME=method" + method_number + ">" +
+ access + "</A></FONT></TD>");
+
+ file.print("<TD>" + Class2HTML.referenceType(type) + "</TD><TD>" +
+ "<A HREF=" + class_name + "_code.html#method" + method_number +
+ " TARGET=Code>" + html_name + "</A></TD>\n<TD>(");
+
+ for(int i=0; i < args.length; i++) {
+ file.print(Class2HTML.referenceType(args[i]));
+ if(i < args.length - 1)
+ file.print(", ");
+ }
+
+ file.print(")</TD></TR>");
+
+ // Check for thrown exceptions
+ for(int i=0; i < attributes.length; i++) {
+ attribute_html.writeAttribute(attributes[i], "method" + method_number + "@" + i,
+ method_number);
+
+ byte tag = attributes[i].getTag();
+ if(tag == ATTR_EXCEPTIONS) {
+ file.print("<TR VALIGN=TOP><TD COLSPAN=2></TD><TH ALIGN=LEFT>throws</TH><TD>");
+ int[] exceptions = ((ExceptionTable)attributes[i]).getExceptionIndexTable();
+
+ for(int j=0; j < exceptions.length; j++) {
+ file.print(constant_html.referenceConstant(exceptions[j]));
+
+ if(j < exceptions.length - 1)
+ file.print(", ");
+ }
+ file.println("</TD></TR>");
+ } else if(tag == ATTR_CODE) {
+ Attribute[] c_a = ((Code)attributes[i]).getAttributes();
+
+ for(int j=0; j < c_a.length; j++)
+ attribute_html.writeAttribute(c_a[j], "method" + method_number + "@" + i + "@" + j,
+ method_number);
+ }
+ }
+ }
+}
diff --git a/src/java/org/apache/bcel/util/package.html b/src/java/org/apache/bcel/util/package.html
new file mode 100644
index 00000000..62e9c8b0
--- /dev/null
+++ b/src/java/org/apache/bcel/util/package.html
@@ -0,0 +1,25 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+$Id$
+-->
+</head>
+<body bgcolor="white">
+<p>
+This package contains utility classes for the
+<a href="http://jakarta.apache.org/bcel/">Byte Code Engineering
+Library</a>, namely:
+</p>
+<p>
+<ul>
+<li>Collection classes for JavaClass objects</li>
+<li>A converter for class files to HTML</li>
+<li>A tool to find instructions patterns via regular expressions</li>
+<li>A class to find classes as defined in the CLASSPATH</li>
+<li>A class loader that allows to create clases at run time</li>
+</ul>
+
+</p>
+</body>
+</html>
diff --git a/src/java/org/apache/bcel/verifier/GraphicalVerifier.java b/src/java/org/apache/bcel/verifier/GraphicalVerifier.java
new file mode 100644
index 00000000..e8f729ef
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/GraphicalVerifier.java
@@ -0,0 +1,109 @@
+package org.apache.bcel.verifier;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import javax.swing.UIManager;
+import java.awt.*;
+import org.apache.bcel.verifier.*;
+import org.apache.bcel.generic.*;
+
+
+/**
+ * A graphical user interface application demonstrating JustIce.
+ *
+ * @version $Id$
+ * @author Enver Haase
+ */
+public class GraphicalVerifier {
+ boolean packFrame = false;
+
+ /** Constructor. */
+ public GraphicalVerifier() {
+ VerifierAppFrame frame = new VerifierAppFrame();
+ //Frames überprüfen, die voreingestellte Größe haben
+ //Frames packen, die nutzbare bevorzugte Größeninformationen enthalten, z.B. aus ihrem Layout
+ if (packFrame) {
+ frame.pack();
+ }
+ else {
+ frame.validate();
+ }
+ //Das Fenster zentrieren
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ Dimension frameSize = frame.getSize();
+ if (frameSize.height > screenSize.height) {
+ frameSize.height = screenSize.height;
+ }
+ if (frameSize.width > screenSize.width) {
+ frameSize.width = screenSize.width;
+ }
+ frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
+ frame.setVisible(true);
+
+ frame.classNamesJList.setModel(new VerifierFactoryListModel());
+ VerifierFactory.getVerifier(Type.OBJECT.getClassName()); // Fill list with java.lang.Object
+ frame.classNamesJList.setSelectedIndex(0); // default, will verify java.lang.Object
+ }
+ /** Main method. */
+ public static void main(String[] args) {
+ try {
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ }
+ new GraphicalVerifier();
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/NativeVerifier.java b/src/java/org/apache/bcel/verifier/NativeVerifier.java
new file mode 100644
index 00000000..2e8bef41
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/NativeVerifier.java
@@ -0,0 +1,116 @@
+package org.apache.bcel.verifier;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * The NativeVerifier class implements a main(String[] args) method that's
+ * roughly compatible to the one in the Verifier class, but that uses the
+ * JVM's internal verifier for its class file verification.
+ * This can be used for comparison runs between the JVM-internal verifier
+ * and JustIce.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public abstract class NativeVerifier{
+
+ /**
+ * This class must not be instantiated.
+ */
+ private NativeVerifier(){
+ }
+
+ /**
+ * Works only on the first argument.
+ */
+ public static void main(String [] args){
+ if (args.length != 1){
+ System.out.println("Verifier front-end: need exactly one argument.");
+ System.exit(1);
+ }
+
+ int dotclasspos = args[0].lastIndexOf(".class");
+ if (dotclasspos != -1) args[0] = args[0].substring(0,dotclasspos);
+ args[0] = args[0].replace('/','.');
+ //System.out.println(args[0]);
+
+
+ try{
+ Class.forName(args[0]);
+ }
+ catch(ExceptionInInitializerError eiie){ //subclass of LinkageError!
+ System.out.println("NativeVerifier: ExceptionInInitializerError encountered on '"+args[0]+"'.");
+ System.out.println(eiie);
+ System.exit(1);
+ }
+ catch(LinkageError le){
+ System.out.println("NativeVerifier: LinkageError encountered on '"+args[0]+"'.");
+ System.out.println(le);
+ System.exit(1);
+ }
+ catch(ClassNotFoundException cnfe){
+ System.out.println("NativeVerifier: FILE NOT FOUND: '"+args[0]+"'.");
+ System.exit(1);
+ }
+ catch(Throwable t){
+ System.out.println("NativeVerifier: Unspecified verification error on'"+args[0]+"'.");
+ System.exit(1);
+ }
+
+ System.out.println("NativeVerifier: Class file '"+args[0]+"' seems to be okay.");
+ System.exit(0);
+
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/PassVerifier.java b/src/java/org/apache/bcel/verifier/PassVerifier.java
new file mode 100644
index 00000000..6e35d857
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/PassVerifier.java
@@ -0,0 +1,143 @@
+package org.apache.bcel.verifier;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import java.util.ArrayList;
+
+/**
+ * A PassVerifier actually verifies a class file; it is instantiated
+ * by a Verifier.
+ * The verification should conform with a certain pass as described
+ * in The Java Virtual Machine Specification, 2nd edition.
+ * This book describes four passes. Pass one means loading the
+ * class and verifying a few static constraints. Pass two actually
+ * verifies some other constraints that could enforce loading in
+ * referenced class files. Pass three is the first pass that actually
+ * checks constraints in the code array of a method in the class file;
+ * it has two parts with the first verifying static constraints and
+ * the second part verifying structural constraints (where a data flow
+ * analysis is used for). The fourth pass, finally, performs checks
+ * that can only be done at run-time.
+ * JustIce does not have a run-time pass, but certain constraints that
+ * are usually delayed until run-time for performance reasons are also
+ * checked during the second part of pass three.
+ * PassVerifier instances perform caching.
+ * That means, if you really want a new verification run of a certain
+ * pass you must use a new instance of a given PassVerifier.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ * @see org.apache.bcel.verifier.Verifier
+ * @see #verify()
+ */
+public abstract class PassVerifier{
+
+ /** The (warning) messages. */
+ private ArrayList messages = new ArrayList(); //Type of elements: String
+
+ /** The VerificationResult cache. */
+ private VerificationResult verificationResult = null;
+
+ /**
+ * This method runs a verification pass conforming to the
+ * Java Virtual Machine Specification, 2nd edition, on a
+ * class file.
+ * PassVerifier instances perform caching;
+ * i.e. if the verify() method once determined a VerificationResult,
+ * then this result may be returned after every invocation of this
+ * method instead of running the verification pass anew; likewise with
+ * the result of getMessages().
+ *
+ * @see #getMessages()
+ * @see #addMessage(String)
+ */
+ public VerificationResult verify(){
+ if (verificationResult == null){
+ verificationResult = do_verify();
+ }
+ return verificationResult;
+ }
+
+ /** Does the real verification work, uncached. */
+ public abstract VerificationResult do_verify();
+
+ /**
+ * This method adds a (warning) message to the message pool of this
+ * PassVerifier. This method is normally only internally used by
+ * BCEL's class file verifier "JustIce" and should not be used from
+ * the outside.
+ *
+ * @see #getMessages()
+ */
+ public void addMessage(String message){
+ messages.add(message);
+ }
+
+ /**
+ * Returns the (warning) messages that this PassVerifier accumulated
+ * during its do_verify()ing work.
+ *
+ * @see #addMessage(String)
+ * @see #do_verify()
+ */
+ public String[] getMessages(){
+ verify(); // create messages if not already done (cached!)
+ String[] ret = new String[messages.size()];
+ for (int i=0; i<messages.size(); i++){
+ ret[i] = (String) messages.get(i);
+ }
+ return ret;
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/TransitiveHull.java b/src/java/org/apache/bcel/verifier/TransitiveHull.java
new file mode 100644
index 00000000..f450a4c2
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/TransitiveHull.java
@@ -0,0 +1,138 @@
+package org.apache.bcel.verifier;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.verifier.*;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.*;
+
+/**
+ * This class has a main method implementing a demonstration program
+ * of how to use the VerifierFactoryObserver. It transitively verifies
+ * all class files encountered; this may take up a lot of time and,
+ * more notably, memory.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public class TransitiveHull implements VerifierFactoryObserver{
+
+ /** Used for indentation. */
+ private int indent = 0;
+
+ /** Not publicly instantiable. */
+ private TransitiveHull(){
+ }
+
+ /* Implementing VerifierFactoryObserver. */
+ public void update(String classname){
+
+ System.gc(); // avoid swapping if possible.
+
+ for (int i=0; i<indent; i++){
+ System.out.print(" ");
+ }
+ System.out.println(classname);
+ indent += 1;
+
+ Verifier v = VerifierFactory.getVerifier(classname);
+
+ VerificationResult vr;
+ vr = v.doPass1();
+ if (vr != VerificationResult.VR_OK) //System.exit(1);
+ System.out.println("Pass 1:\n"+vr);
+
+ vr = v.doPass2();
+ if (vr != VerificationResult.VR_OK) //System.exit(1);
+ System.out.println("Pass 2:\n"+vr);
+
+ if (vr == VerificationResult.VR_OK){
+ JavaClass jc = Repository.lookupClass(v.getClassName());
+ for (int i=0; i<jc.getMethods().length; i++){
+ vr = v.doPass3a(i);
+ if (vr != VerificationResult.VR_OK) //System.exit(1);
+ System.out.println(v.getClassName()+", Pass 3a, method "+i+" ['"+jc.getMethods()[i]+"']:\n"+vr);
+
+ vr = v.doPass3b(i);
+ if (vr != VerificationResult.VR_OK) //System.exit(1);
+ System.out.println(v.getClassName()+", Pass 3b, method "+i+" ['"+jc.getMethods()[i]+"']:\n"+vr);
+ }
+ }
+
+ indent -= 1;
+ }
+
+ /**
+ * This method implements a demonstration program
+ * of how to use the VerifierFactoryObserver. It transitively verifies
+ * all class files encountered; this may take up a lot of time and,
+ * more notably, memory.
+ */
+ public static void main(String[] args){
+ if (args.length != 1){
+ System.out.println("Need exactly one argument: The root class to verify.");
+ System.exit(1);
+ }
+
+ int dotclasspos = args[0].lastIndexOf(".class");
+ if (dotclasspos != -1) args[0] = args[0].substring(0,dotclasspos);
+ args[0] = args[0].replace('/', '.');
+
+ TransitiveHull th = new TransitiveHull();
+ VerifierFactory.attach(th);
+ VerifierFactory.getVerifier(args[0]); // the observer is called back and does the actual trick.
+ VerifierFactory.detach(th);
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/VerificationResult.java b/src/java/org/apache/bcel/verifier/VerificationResult.java
new file mode 100644
index 00000000..b296e1f6
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/VerificationResult.java
@@ -0,0 +1,138 @@
+package org.apache.bcel.verifier;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * A VerificationResult is what a PassVerifier returns
+ * after verifying.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ *
+ */
+public class VerificationResult{
+
+ /**
+ * Constant to indicate verification has not been tried yet.
+ * This happens if some earlier verification pass did not return VERIFIED_OK.
+ */
+ public static final int VERIFIED_NOTYET = 0;
+ /** Constant to indicate verification was passed. */
+ public static final int VERIFIED_OK = 1;
+ /** Constant to indicate verfication failed. */
+ public static final int VERIFIED_REJECTED = 2;
+
+ /**
+ * This string is the canonical message for verifications that have not been tried yet.
+ * This happens if some earlier verification pass did not return VERIFIED_OK.
+ */
+ private static final String VERIFIED_NOTYET_MSG = "Not yet verified.";
+ /** This string is the canonical message for passed verification passes. */
+ private static final String VERIFIED_OK_MSG = "Passed verification.";
+
+ /**
+ * Canonical VerificationResult for not-yet-tried verifications.
+ * This happens if some earlier verification pass did not return VERIFIED_OK.
+ */
+ public static final VerificationResult VR_NOTYET = new VerificationResult(VERIFIED_NOTYET, VERIFIED_NOTYET_MSG);
+ /** Canonical VerificationResult for passed verifications. */
+ public static final VerificationResult VR_OK = new VerificationResult(VERIFIED_OK, VERIFIED_OK_MSG);
+
+ /** The numeric status. */
+ private int numeric;
+
+ /** The detailed message. */
+ private String detailMessage;
+
+ /** This class is not no-args instantiable. */
+ private VerificationResult(){}
+
+ /** The usual constructor. */
+ public VerificationResult(int status, String message){
+ numeric = status;
+ detailMessage = message;
+ }
+
+ /** Returns one one the VERIFIED_OK, VERIFIED_NOTYET, VERIFIED_REJECTED constants. */
+ public int getStatus(){
+ return numeric;
+ }
+
+ /** Returns a detailed message. */
+ public String getMessage(){
+ return detailMessage;
+ }
+
+ /**
+ * Returns if two VerificationResult instances are equal.
+ */
+ public boolean equals(Object o){
+ if (! (o instanceof VerificationResult)) return false;
+ VerificationResult other = (VerificationResult) o;
+ return ((other.numeric == this.numeric) && (other.detailMessage.equals(this.detailMessage)));
+ }
+
+ /**
+ * Returns a String representation of the VerificationResult.
+ */
+ public String toString(){
+ String ret="";
+ if (numeric == VERIFIED_NOTYET) ret = "VERIFIED_NOTYET";
+ if (numeric == VERIFIED_OK) ret = "VERIFIED_OK";
+ if (numeric == VERIFIED_REJECTED) ret = "VERIFIED_REJECTED";
+ ret+="\n"+detailMessage+"\n";
+ return ret;
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/Verifier.java b/src/java/org/apache/bcel/verifier/Verifier.java
new file mode 100644
index 00000000..8e2dd2b8
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/Verifier.java
@@ -0,0 +1,283 @@
+package org.apache.bcel.verifier;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.*;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.generic.*;
+import org.apache.bcel.util.*;
+import org.apache.bcel.verifier.statics.*;
+import org.apache.bcel.verifier.structurals.*;
+import org.apache.bcel.verifier.exc.*;
+import org.apache.bcel.verifier.exc.Utility; // Ambigous if not declared explicitely.
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+
+/**
+ * A Verifier instance is there to verify a class file according to The Java Virtual
+ * Machine Specification, 2nd Edition.
+ *
+ * Pass-3b-verification includes pass-3a-verification;
+ * pass-3a-verification includes pass-2-verification;
+ * pass-2-verification includes pass-1-verification.
+ *
+ * A Verifier creates PassVerifier instances to perform the actual verification.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ * @see org.apache.bcel.verifier.PassVerifier
+ */
+public class Verifier{
+ /**
+ * The name of the class this verifier operates on.
+ */
+ private final String classname;
+
+ /** A Pass1Verifier for this Verifier instance. */
+ private Pass1Verifier p1v;
+ /** A Pass2Verifier for this Verifier instance. */
+ private Pass2Verifier p2v;
+ /** The Pass3aVerifiers for this Verifier instance. Key: Interned string specifying the method number. */
+ private HashMap p3avs = new HashMap();
+ /** The Pass3bVerifiers for this Verifier instance. Key: Interned string specifying the method number. */
+ private HashMap p3bvs = new HashMap();
+
+ /** Returns the VerificationResult for the given pass. */
+ public VerificationResult doPass1(){
+ if (p1v == null){
+ p1v = new Pass1Verifier(this);
+ }
+ return p1v.verify();
+ }
+
+ /** Returns the VerificationResult for the given pass. */
+ public VerificationResult doPass2(){
+ if (p2v == null){
+ p2v = new Pass2Verifier(this);
+ }
+ return p2v.verify();
+ }
+
+ /** Returns the VerificationResult for the given pass. */
+ public VerificationResult doPass3a(int method_no){
+ String key = Integer.toString(method_no);
+ Pass3aVerifier p3av;
+ p3av = (Pass3aVerifier) (p3avs.get(key));
+ if (p3avs.get(key) == null){
+ p3av = new Pass3aVerifier(this, method_no);
+ p3avs.put(key, p3av);
+ }
+ return p3av.verify();
+ }
+
+ /** Returns the VerificationResult for the given pass. */
+ public VerificationResult doPass3b(int method_no){
+ String key = Integer.toString(method_no);
+ Pass3bVerifier p3bv;
+ p3bv = (Pass3bVerifier) (p3bvs.get(key));
+ if (p3bvs.get(key) == null){
+ p3bv = new Pass3bVerifier(this, method_no);
+ p3bvs.put(key, p3bv);
+ }
+ return p3bv.verify();
+ }
+
+ /**
+ * This class may not be no-args instantiated.
+ */
+ private Verifier(){
+ classname = ""; // never executed anyway, make compiler happy.
+ }// not noargs-instantiable
+
+ /**
+ * Instantiation is done by the VerifierFactory.
+ *
+ * @see VerifierFactory
+ */
+ Verifier(String fully_qualified_classname){
+ classname = fully_qualified_classname;
+ flush();
+ }
+
+ /**
+ * Returns the name of the class this verifier operates on.
+ * This is particularly interesting when this verifier was created
+ * recursively by another Verifier and you got a reference to this
+ * Verifier by the getVerifiers() method of the VerifierFactory.
+ * @see VerifierFactory
+ */
+ public final String getClassName(){
+ return classname;
+ }
+
+ /**
+ * Forget everything known about the class file; that means, really
+ * start a new verification of a possibly different class file from
+ * BCEL's repository.
+ *
+ */
+ public void flush(){
+ p1v = null;
+ p2v = null;
+ p3avs.clear();
+ p3bvs.clear();
+ }
+
+ /**
+ * This returns all the (warning) messages collected during verification.
+ * A prefix shows from which verifying pass a message originates.
+ */
+ public String[] getMessages(){
+ ArrayList messages = new ArrayList();
+
+ if (p1v != null){
+ String[] p1m = p1v.getMessages();
+ for (int i=0; i<p1m.length; i++){
+ messages.add("Pass 1: "+p1m[i]);
+ }
+ }
+ if (p2v != null){
+ String[] p2m = p2v.getMessages();
+ for (int i=0; i<p2m.length; i++){
+ messages.add("Pass 2: "+p2m[i]);
+ }
+ }
+ Iterator p3as = p3avs.values().iterator();
+ while (p3as.hasNext()){
+ Pass3aVerifier pv = (Pass3aVerifier) p3as.next();
+ String[] p3am = pv.getMessages();
+ int meth = pv.getMethodNo();
+ for (int i=0; i<p3am.length; i++){
+ messages.add("Pass 3a, method "+meth+" ('"+Repository.lookupClass(classname).getMethods()[meth]+"'): "+p3am[i]);
+ }
+ }
+ Iterator p3bs = p3bvs.values().iterator();
+ while (p3bs.hasNext()){
+ Pass3bVerifier pv = (Pass3bVerifier) p3bs.next();
+ String[] p3bm = pv.getMessages();
+ int meth = pv.getMethodNo();
+ for (int i=0; i<p3bm.length; i++){
+ messages.add("Pass 3b, method "+meth+" ('"+Repository.lookupClass(classname).getMethods()[meth]+"'): "+p3bm[i]);
+ }
+ }
+
+ String[] ret = new String[messages.size()];
+ for (int i=0; i< messages.size(); i++){
+ ret[i] = (String) messages.get(i);
+ }
+
+ return ret;
+ }
+
+ /**
+ * Verifies class files.
+ * This is a simple demonstration of how the API of BCEL's
+ * class file verifier "JustIce" may be used.
+ * You should supply command-line arguments which are
+ * fully qualified namea of the classes to verify. These class files
+ * must be somewhere in your CLASSPATH (refer to Sun's
+ * documentation for questions about this) or you must have put the classes
+ * into the BCEL Repository yourself (via 'addClass(JavaClass)').
+ */
+ public static void main(String [] args){
+ System.out.println("JustIce by Enver Haase, (C) 2001. http://bcel.sourceforge.net\n");
+ for(int k=0; k < args.length; k++) {
+
+ if (args[k].endsWith(".class")){
+ int dotclasspos = args[k].lastIndexOf(".class");
+ if (dotclasspos != -1) args[k] = args[k].substring(0,dotclasspos);
+ }
+
+ args[k] = args[k].replace('/', '.');
+
+ System.out.println("Now verifiying: "+args[k]+"\n");
+
+ Verifier v = VerifierFactory.getVerifier(args[k]);
+ VerificationResult vr;
+
+ vr = v.doPass1();
+ System.out.println("Pass 1:\n"+vr);
+
+ vr = v.doPass2();
+ System.out.println("Pass 2:\n"+vr);
+
+ if (vr == VerificationResult.VR_OK){
+ JavaClass jc = Repository.lookupClass(args[k]);
+ for (int i=0; i<jc.getMethods().length; i++){
+ vr = v.doPass3a(i);
+ System.out.println("Pass 3a, method "+i+" ['"+jc.getMethods()[i]+"']:\n"+vr);
+
+ vr = v.doPass3b(i);
+ System.out.println("Pass 3b, method number "+i+" ['"+jc.getMethods()[i]+"']:\n"+vr);
+ }
+ }
+
+ System.out.println("Warnings:");
+ String[] warnings = v.getMessages();
+ if (warnings.length == 0) System.out.println("<none>");
+ for (int j=0; j<warnings.length; j++){
+ System.out.println(warnings[j]);
+ }
+
+ System.out.println("\n");
+
+ // avoid swapping.
+ v.flush();
+ Repository.clearCache();
+ System.gc();
+ }
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/VerifierAppFrame.java b/src/java/org/apache/bcel/verifier/VerifierAppFrame.java
new file mode 100644
index 00000000..4d5e9842
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/VerifierAppFrame.java
@@ -0,0 +1,390 @@
+package org.apache.bcel.verifier;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.event.*;
+import org.apache.bcel.*;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.verifier.*;
+
+/**
+ * This class implements a machine-generated frame for use with
+ * the GraphicalVerfifier.
+ *
+ * @version $Id$
+ * @author Enver Haase
+ * @see GraphicalVerifier
+ */
+public class VerifierAppFrame extends JFrame {
+ JPanel contentPane;
+ JSplitPane jSplitPane1 = new JSplitPane();
+ JPanel jPanel1 = new JPanel();
+ JPanel jPanel2 = new JPanel();
+ JSplitPane jSplitPane2 = new JSplitPane();
+ JPanel jPanel3 = new JPanel();
+ JList classNamesJList = new JList();
+ GridLayout gridLayout1 = new GridLayout();
+ JPanel messagesPanel = new JPanel();
+ GridLayout gridLayout2 = new GridLayout();
+ JMenuBar jMenuBar1 = new JMenuBar();
+ JMenu jMenu1 = new JMenu();
+ JScrollPane jScrollPane1 = new JScrollPane();
+ JScrollPane messagesScrollPane = new JScrollPane();
+ JScrollPane jScrollPane3 = new JScrollPane();
+ GridLayout gridLayout4 = new GridLayout();
+ JScrollPane jScrollPane4 = new JScrollPane();
+ CardLayout cardLayout1 = new CardLayout();
+
+ private String JUSTICE_VERSION = "JustIce by Enver Haase";
+ private String current_class;
+ GridLayout gridLayout3 = new GridLayout();
+ JTextPane pass1TextPane = new JTextPane();
+ JTextPane pass2TextPane = new JTextPane();
+ JTextPane messagesTextPane = new JTextPane();
+ JMenuItem newFileMenuItem = new JMenuItem();
+ JSplitPane jSplitPane3 = new JSplitPane();
+ JSplitPane jSplitPane4 = new JSplitPane();
+ JScrollPane jScrollPane2 = new JScrollPane();
+ JScrollPane jScrollPane5 = new JScrollPane();
+ JScrollPane jScrollPane6 = new JScrollPane();
+ JScrollPane jScrollPane7 = new JScrollPane();
+ JList pass3aJList = new JList();
+ JList pass3bJList = new JList();
+ JTextPane pass3aTextPane = new JTextPane();
+ JTextPane pass3bTextPane = new JTextPane();
+ JMenu jMenu2 = new JMenu();
+ JMenuItem whatisMenuItem = new JMenuItem();
+ JMenuItem aboutMenuItem = new JMenuItem();
+
+ /** Constructor. */
+ public VerifierAppFrame() {
+ enableEvents(AWTEvent.WINDOW_EVENT_MASK);
+ try {
+ jbInit();
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ /** Initizalization of the components. */
+ private void jbInit() throws Exception {
+ //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Ihr Symbol]")));
+ contentPane = (JPanel) this.getContentPane();
+ contentPane.setLayout(cardLayout1);
+ this.setJMenuBar(jMenuBar1);
+ this.setSize(new Dimension(708, 451));
+ this.setTitle("JustIce");
+ jPanel1.setMinimumSize(new Dimension(100, 100));
+ jPanel1.setPreferredSize(new Dimension(100, 100));
+ jPanel1.setLayout(gridLayout1);
+ jSplitPane2.setOrientation(JSplitPane.VERTICAL_SPLIT);
+ jPanel2.setLayout(gridLayout2);
+ jPanel3.setMinimumSize(new Dimension(200, 100));
+ jPanel3.setPreferredSize(new Dimension(400, 400));
+ jPanel3.setLayout(gridLayout4);
+ messagesPanel.setMinimumSize(new Dimension(100, 100));
+ messagesPanel.setLayout(gridLayout3);
+ jPanel2.setMinimumSize(new Dimension(200, 100));
+ jMenu1.setText("File");
+
+ jScrollPane1.getViewport().setBackground(Color.red);
+ messagesScrollPane.getViewport().setBackground(Color.red);
+ messagesScrollPane.setPreferredSize(new Dimension(10, 10));
+ classNamesJList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
+ public void valueChanged(ListSelectionEvent e) {
+ classNamesJList_valueChanged(e);
+ }
+ });
+ classNamesJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ jScrollPane3.setBorder(BorderFactory.createLineBorder(Color.black));
+ jScrollPane3.setPreferredSize(new Dimension(100, 100));
+ gridLayout4.setRows(4);
+ gridLayout4.setColumns(1);
+ gridLayout4.setHgap(1);
+ jScrollPane4.setBorder(BorderFactory.createLineBorder(Color.black));
+ jScrollPane4.setPreferredSize(new Dimension(100, 100));
+ pass1TextPane.setBorder(BorderFactory.createRaisedBevelBorder());
+ pass1TextPane.setToolTipText("");
+ pass1TextPane.setEditable(false);
+ pass2TextPane.setBorder(BorderFactory.createRaisedBevelBorder());
+ pass2TextPane.setEditable(false);
+ messagesTextPane.setBorder(BorderFactory.createRaisedBevelBorder());
+ messagesTextPane.setEditable(false);
+ newFileMenuItem.setText("New...");
+ newFileMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(78, java.awt.event.KeyEvent.CTRL_MASK, true));
+ newFileMenuItem.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ newFileMenuItem_actionPerformed(e);
+ }
+ });
+ pass3aTextPane.setEditable(false);
+ pass3bTextPane.setEditable(false);
+ pass3aJList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
+ public void valueChanged(ListSelectionEvent e) {
+ pass3aJList_valueChanged(e);
+ }
+ });
+ pass3bJList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
+ public void valueChanged(ListSelectionEvent e) {
+ pass3bJList_valueChanged(e);
+ }
+ });
+ jMenu2.setText("Help");
+ whatisMenuItem.setText("What is...");
+ whatisMenuItem.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ whatisMenuItem_actionPerformed(e);
+ }
+ });
+ aboutMenuItem.setText("About");
+ aboutMenuItem.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ aboutMenuItem_actionPerformed(e);
+ }
+ });
+ jSplitPane2.add(messagesPanel, JSplitPane.BOTTOM);
+ messagesPanel.add(messagesScrollPane, null);
+ messagesScrollPane.getViewport().add(messagesTextPane, null);
+ jSplitPane2.add(jPanel3, JSplitPane.TOP);
+ jPanel3.add(jScrollPane3, null);
+ jScrollPane3.getViewport().add(pass1TextPane, null);
+ jPanel3.add(jScrollPane4, null);
+ jPanel3.add(jSplitPane3, null);
+ jSplitPane3.add(jScrollPane2, JSplitPane.LEFT);
+ jScrollPane2.getViewport().add(pass3aJList, null);
+ jSplitPane3.add(jScrollPane5, JSplitPane.RIGHT);
+ jScrollPane5.getViewport().add(pass3aTextPane, null);
+ jPanel3.add(jSplitPane4, null);
+ jSplitPane4.add(jScrollPane6, JSplitPane.LEFT);
+ jScrollPane6.getViewport().add(pass3bJList, null);
+ jSplitPane4.add(jScrollPane7, JSplitPane.RIGHT);
+ jScrollPane7.getViewport().add(pass3bTextPane, null);
+ jScrollPane4.getViewport().add(pass2TextPane, null);
+ jSplitPane1.add(jPanel2, JSplitPane.TOP);
+ jPanel2.add(jScrollPane1, null);
+ jSplitPane1.add(jPanel1, JSplitPane.BOTTOM);
+ jPanel1.add(jSplitPane2, null);
+ jScrollPane1.getViewport().add(classNamesJList, null);
+ jMenuBar1.add(jMenu1);
+ jMenuBar1.add(jMenu2);
+ contentPane.add(jSplitPane1, "jSplitPane1");
+ jMenu1.add(newFileMenuItem);
+ jMenu2.add(whatisMenuItem);
+ jMenu2.add(aboutMenuItem);
+ jSplitPane2.setDividerLocation(300);
+ jSplitPane3.setDividerLocation(150);
+ jSplitPane4.setDividerLocation(150);
+ }
+
+ /** Overridden to stop the application on a closing window. */
+ protected void processWindowEvent(WindowEvent e) {
+ super.processWindowEvent(e);
+ if (e.getID() == WindowEvent.WINDOW_CLOSING) {
+ System.exit(0);
+ }
+ }
+
+ synchronized void classNamesJList_valueChanged(ListSelectionEvent e) {
+ if (e.getValueIsAdjusting()) return;
+ current_class = classNamesJList.getSelectedValue().toString();
+ verify();
+ classNamesJList.setSelectedValue(current_class, true);
+ }
+
+ private void verify(){
+ setTitle("PLEASE WAIT");
+
+ Verifier v = VerifierFactory.getVerifier(current_class);
+ v.flush(); // Don't cache the verification result for this class.
+
+ VerificationResult vr;
+
+ vr = v.doPass1();
+ if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED){
+ pass1TextPane.setText(vr.getMessage());
+ pass1TextPane.setBackground(Color.red);
+
+ pass2TextPane.setText("");
+ pass2TextPane.setBackground(Color.yellow);
+ pass3aTextPane.setText("");
+ pass3aJList.setListData(new Object[0]);
+ pass3aTextPane.setBackground(Color.yellow);
+
+ pass3bTextPane.setText("");
+ pass3bJList.setListData(new Object[0]);
+ pass3bTextPane.setBackground(Color.yellow);
+
+ }
+ else{ // Must be VERIFIED_OK, Pass 1 does not know VERIFIED_NOTYET
+ pass1TextPane.setBackground(Color.green);
+ pass1TextPane.setText(vr.getMessage());
+
+ vr = v.doPass2();
+ if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED){
+ pass2TextPane.setText(vr.getMessage());
+ pass2TextPane.setBackground(Color.red);
+
+ pass3aTextPane.setText("");
+ pass3aTextPane.setBackground(Color.yellow);
+ pass3aJList.setListData(new Object[0]);
+ pass3bTextPane.setText("");
+ pass3bTextPane.setBackground(Color.yellow);
+ pass3bJList.setListData(new Object[0]);
+ }
+ else{ // must be Verified_OK, because Pass1 was OK (cannot be Verified_NOTYET).
+ pass2TextPane.setText(vr.getMessage());
+ pass2TextPane.setBackground(Color.green);
+
+ JavaClass jc = Repository.lookupClass(current_class);
+ boolean all3aok = true;
+ boolean all3bok = true;
+ String all3amsg = "";
+ String all3bmsg = "";
+
+ String[] methodnames = new String[jc.getMethods().length];
+ for (int i=0; i<jc.getMethods().length; i++){
+ methodnames[i] = jc.getMethods()[i].toString().replace('\n',' ').replace('\t',' ');
+ }
+ pass3aJList.setListData(methodnames);
+ pass3aJList.setSelectionInterval(0,jc.getMethods().length-1);
+ pass3bJList.setListData(methodnames);
+ pass3bJList.setSelectionInterval(0,jc.getMethods().length-1);
+ }
+
+ }
+ String[] msgs = v.getMessages();
+ messagesTextPane.setBackground(msgs.length == 0? Color.green : Color.yellow);
+ String allmsgs = "";
+ for (int i=0; i<msgs.length; i++){
+ msgs[i] = msgs[i].replace('\n',' ');
+ allmsgs += msgs[i] + "\n\n";
+ }
+ messagesTextPane.setText(allmsgs);
+
+ setTitle(current_class + " - " + JUSTICE_VERSION);
+ }
+
+ void newFileMenuItem_actionPerformed(ActionEvent e) {
+ String classname = JOptionPane.showInputDialog("Please enter the fully qualified name of a class or interface to verify:");
+ if ((classname == null) || (classname.equals(""))) return;
+ VerifierFactory.getVerifier(classname); // let observers do the rest.
+ classNamesJList.setSelectedValue(classname, true);
+ }
+
+ synchronized void pass3aJList_valueChanged(ListSelectionEvent e) {
+
+ if (e.getValueIsAdjusting()) return;
+ Verifier v = VerifierFactory.getVerifier(current_class);
+
+ String all3amsg = "";
+ boolean all3aok = true;
+ boolean rejected = false;
+ for (int i=0; i<pass3aJList.getModel().getSize(); i++){
+
+ if (pass3aJList.isSelectedIndex(i)){
+ VerificationResult vr = v.doPass3a(i);
+
+ if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED){
+ all3aok = false;
+ rejected = true;
+ }
+ all3amsg += "Method '"+Repository.lookupClass(v.getClassName()).getMethods()[i]+"': "+vr.getMessage().replace('\n',' ')+"\n\n";
+ }
+ }
+ pass3aTextPane.setText(all3amsg);
+ pass3aTextPane.setBackground(all3aok? Color.green : (rejected? Color.red : Color.yellow));
+
+ }
+
+ synchronized void pass3bJList_valueChanged(ListSelectionEvent e) {
+ if (e.getValueIsAdjusting()) return;
+
+ Verifier v = VerifierFactory.getVerifier(current_class);
+
+ String all3bmsg = "";
+ boolean all3bok = true;
+ boolean rejected = false;
+ for (int i=0; i<pass3bJList.getModel().getSize(); i++){
+
+ if (pass3bJList.isSelectedIndex(i)){
+ VerificationResult vr = v.doPass3b(i);
+
+ if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED){
+ all3bok = false;
+ rejected = true;
+ }
+ all3bmsg += "Method '"+Repository.lookupClass(v.getClassName()).getMethods()[i]+"': "+vr.getMessage().replace('\n',' ')+"\n\n";
+ }
+ }
+ pass3bTextPane.setText(all3bmsg);
+ pass3bTextPane.setBackground(all3bok? Color.green : (rejected? Color.red : Color.yellow));
+
+ }
+
+ void aboutMenuItem_actionPerformed(ActionEvent e) {
+ JOptionPane.showMessageDialog(this,
+ "JustIce is a Java class file verifier.\nIt was implemented by Enver Haase in 2001.\nhttp://bcel.sourceforge.net",
+ JUSTICE_VERSION, JOptionPane.INFORMATION_MESSAGE);
+ }
+
+ void whatisMenuItem_actionPerformed(ActionEvent e) {
+ JOptionPane.showMessageDialog(this,
+ "The upper four boxes to the right reflect verification passes according to The Java Virtual Machine Specification.\nThese are (in that order): Pass one, Pass two, Pass three (before data flow analysis), Pass three (data flow analysis).\nThe bottom box to the right shows (warning) messages; warnings do not cause a class to be rejected.",
+ JUSTICE_VERSION, JOptionPane.INFORMATION_MESSAGE);
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/VerifierFactory.java b/src/java/org/apache/bcel/verifier/VerifierFactory.java
new file mode 100644
index 00000000..c6ff992b
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/VerifierFactory.java
@@ -0,0 +1,142 @@
+package org.apache.bcel.verifier;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Vector;
+
+/**
+ * This class produces instances of the Verifier class. Its purpose is to make
+ * sure that they are singleton instances with respect to the class name they
+ * operate on. That means, for every class (represented by a unique fully qualified
+ * class name) there is exactly one Verifier.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public class VerifierFactory{
+
+ /**
+ * The HashMap that holds the data about the already-constructed Verifier instances.
+ */
+ private static HashMap hashMap = new HashMap();
+
+ /**
+ * The VerifierFactoryObserver instances that observe the VerifierFactory.
+ */
+ private static Vector observers = new Vector();
+
+ /**
+ * The VerifierFactory is not instantiable.
+ */
+ private VerifierFactory(){}
+
+ /**
+ * Returns the (only) verifier responsible for the class with the given name.
+ * Possibly a new Verifier object is transparently created.
+ * @return the (only) verifier responsible for the class with the given name.
+ */
+ public static Verifier getVerifier(String fully_qualified_classname){
+ fully_qualified_classname = fully_qualified_classname;
+
+ Verifier v = (Verifier) (hashMap.get(fully_qualified_classname));
+ if (v==null){
+ v = new Verifier(fully_qualified_classname);
+ hashMap.put(fully_qualified_classname, v);
+ notify(fully_qualified_classname);
+ }
+
+ return v;
+ }
+
+ /**
+ * Notifies the observers of a newly generated Verifier.
+ */
+ private static void notify(String fully_qualified_classname){
+ // notify the observers
+ Iterator i = observers.iterator();
+ while (i.hasNext()){
+ VerifierFactoryObserver vfo = (VerifierFactoryObserver) i.next();
+ vfo.update(fully_qualified_classname);
+ }
+ }
+
+ /**
+ * Returns all Verifier instances created so far.
+ * This is useful when a Verifier recursively lets
+ * the VerifierFactory create other Verifier instances
+ * and if you want to verify the transitive hull of
+ * referenced class files.
+ */
+ public static Verifier[] getVerifiers(){
+ Verifier[] vs = new Verifier[hashMap.values().size()];
+ return (Verifier[]) (hashMap.values().toArray(vs)); // Because vs is big enough, vs is used to store the values into and returned!
+ }
+
+ /**
+ * Adds the VerifierFactoryObserver o to the list of observers.
+ */
+ public static void attach(VerifierFactoryObserver o){
+ observers.addElement(o);
+ }
+
+ /**
+ * Removes the VerifierFactoryObserver o from the list of observers.
+ */
+ public static void detach(VerifierFactoryObserver o){
+ observers.removeElement(o);
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/VerifierFactoryListModel.java b/src/java/org/apache/bcel/verifier/VerifierFactoryListModel.java
new file mode 100644
index 00000000..38d4cd05
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/VerifierFactoryListModel.java
@@ -0,0 +1,107 @@
+package org.apache.bcel.verifier;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+import org.apache.bcel.verifier.*;
+import javax.swing.event.*;
+/**
+ * This class implements an adapter; it implements both a Swing ListModel and
+ * a VerifierFactoryObserver.
+ *
+ * @version $Id$
+ * @author Enver Haase
+ */
+public class VerifierFactoryListModel implements org.apache.bcel.verifier.VerifierFactoryObserver, javax.swing.ListModel{
+
+ private java.util.ArrayList listeners = new java.util.ArrayList();
+
+ private java.util.TreeSet cache = new java.util.TreeSet();
+
+ public VerifierFactoryListModel() {
+ VerifierFactory.attach(this);
+ update(null); // fill cache.
+ }
+
+ public synchronized void update(String s){
+ int size = listeners.size();
+
+ Verifier[] verifiers = VerifierFactory.getVerifiers();
+ int num_of_verifiers = verifiers.length;
+ cache.clear();
+ for (int i=0; i<num_of_verifiers; i++) {
+ cache.add(verifiers[i].getClassName());
+ }
+
+ for (int i=0; i<size; i++){
+ ListDataEvent e = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, num_of_verifiers-1);
+ ((javax.swing.event.ListDataListener) (listeners.get(i))).contentsChanged(e);
+ }
+ }
+
+ public synchronized void addListDataListener(javax.swing.event.ListDataListener l){
+ listeners.add(l);
+ }
+
+ public synchronized void removeListDataListener(javax.swing.event.ListDataListener l){
+ listeners.remove(l);
+ }
+
+ public synchronized int getSize(){
+ return cache.size();
+ }
+
+ public synchronized Object getElementAt(int index){
+ return (cache.toArray())[index];
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/VerifierFactoryObserver.java b/src/java/org/apache/bcel/verifier/VerifierFactoryObserver.java
new file mode 100644
index 00000000..0d0480f6
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/VerifierFactoryObserver.java
@@ -0,0 +1,76 @@
+package org.apache.bcel.verifier;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * VerifierFactoryObserver instances are notified when new Verifier
+ * instances are created.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ *
+ * @see VerifierFactory#getVerifier(String)
+ * @see VerifierFactory#getVerifiers()
+ * @see VerifierFactory#attach(VerifierFactoryObserver)
+ * @see VerifierFactory#detach(VerifierFactoryObserver)
+ */
+public interface VerifierFactoryObserver{
+ /**
+ * VerifierFactoryObserver instances are notified invoking this method.
+ * The String argument is the fully qualified class name of a class a
+ * new Verifier instance created by the VerifierFactory operates on.
+ */
+ public void update(String s);
+}
diff --git a/src/java/org/apache/bcel/verifier/VerifyDialog.java b/src/java/org/apache/bcel/verifier/VerifyDialog.java
new file mode 100644
index 00000000..9fe642d0
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/VerifyDialog.java
@@ -0,0 +1,559 @@
+package org.apache.bcel.verifier;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.*;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.verifier.*;
+import java.awt.Color;
+
+/**
+ * A class for simple graphical class file verification.
+ * Use the main(String []) method with fully qualified
+ * class names as arguments to use it as a stand-alone
+ * application.
+ * Use the VerifyDialog(String) constructor to use this
+ * class in your application.
+ * [This class was created using VisualAge for Java,
+ * but it does not work under VAJ itself (Version 3.02 JDK 1.2)]
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ * @see #main(String[])
+ * @see #VerifyDialog(String)
+ */
+public class VerifyDialog extends javax.swing.JDialog {
+ /** Machine-generated. */
+ private javax.swing.JPanel ivjJDialogContentPane = null;
+ /** Machine-generated. */
+ private javax.swing.JPanel ivjPass1Panel = null;
+ /** Machine-generated. */
+ private javax.swing.JPanel ivjPass2Panel = null;
+ /** Machine-generated. */
+ private javax.swing.JPanel ivjPass3Panel = null;
+ /** Machine-generated. */
+ private javax.swing.JButton ivjPass1Button = null;
+ /** Machine-generated. */
+ private javax.swing.JButton ivjPass2Button = null;
+ /** Machine-generated. */
+ private javax.swing.JButton ivjPass3Button = null;
+ /** Machine-generated. */
+ IvjEventHandler ivjEventHandler = new IvjEventHandler();
+
+ /**
+ * The class to verify. Default set to 'java.lang.Object'
+ * in case this class is instantiated via one of the many
+ * machine-generated constructors.
+ */
+ private String class_name = "java.lang.Object";
+
+ /**
+ * This field is here to count the number of open VerifyDialog
+ * instances so the JVM can be exited afer every Dialog had been
+ * closed.
+ */
+ private static int classes_to_verify;
+
+/** Machine-generated. */
+class IvjEventHandler implements java.awt.event.ActionListener {
+ public void actionPerformed(java.awt.event.ActionEvent e) {
+ if (e.getSource() == VerifyDialog.this.getPass1Button())
+ connEtoC1(e);
+ if (e.getSource() == VerifyDialog.this.getPass2Button())
+ connEtoC2(e);
+ if (e.getSource() == VerifyDialog.this.getPass3Button())
+ connEtoC3(e);
+ if (e.getSource() == VerifyDialog.this.getFlushButton())
+ connEtoC4(e);
+ };
+ };
+ /** Machine-generated. */
+ private javax.swing.JButton ivjFlushButton = null;
+/** Machine-generated. */
+public VerifyDialog() {
+ super();
+ initialize();
+}
+
+/** Machine-generated. */
+public VerifyDialog(java.awt.Dialog owner) {
+ super(owner);
+}
+
+/** Machine-generated. */
+public VerifyDialog(java.awt.Dialog owner, String title) {
+ super(owner, title);
+}
+
+/** Machine-generated. */
+public VerifyDialog(java.awt.Dialog owner, String title, boolean modal) {
+ super(owner, title, modal);
+}
+
+/** Machine-generated. */
+public VerifyDialog(java.awt.Dialog owner, boolean modal) {
+ super(owner, modal);
+}
+
+/** Machine-generated. */
+public VerifyDialog(java.awt.Frame owner) {
+ super(owner);
+}
+
+/** Machine-generated. */
+public VerifyDialog(java.awt.Frame owner, String title) {
+ super(owner, title);
+}
+
+/** Machine-generated. */
+public VerifyDialog(java.awt.Frame owner, String title, boolean modal) {
+ super(owner, title, modal);
+}
+
+/** Machine-generated. */
+public VerifyDialog(java.awt.Frame owner, boolean modal) {
+ super(owner, modal);
+}
+
+/**
+ * Use this constructor if you want a possibility to verify other
+ * class files than java.lang.Object.
+ * @param fully_qualified_class_name java.lang.String
+ */
+public VerifyDialog(String fully_qualified_class_name) {
+ super();
+
+ int dotclasspos = fully_qualified_class_name.lastIndexOf(".class");
+ if (dotclasspos != -1) fully_qualified_class_name = fully_qualified_class_name.substring(0,dotclasspos);
+ fully_qualified_class_name = fully_qualified_class_name.replace('/', '.');
+
+ class_name = fully_qualified_class_name;
+ initialize();
+}
+
+
+/** Machine-generated. */
+private void connEtoC1(java.awt.event.ActionEvent arg1) {
+ try {
+ // user code begin {1}
+ // user code end
+ this.pass1Button_ActionPerformed(arg1);
+ // user code begin {2}
+ // user code end
+ } catch (java.lang.Throwable ivjExc) {
+ // user code begin {3}
+ // user code end
+ handleException(ivjExc);
+ }
+}
+
+/** Machine-generated. */
+private void connEtoC2(java.awt.event.ActionEvent arg1) {
+ try {
+ // user code begin {1}
+ // user code end
+ this.pass2Button_ActionPerformed(arg1);
+ // user code begin {2}
+ // user code end
+ } catch (java.lang.Throwable ivjExc) {
+ // user code begin {3}
+ // user code end
+ handleException(ivjExc);
+ }
+}
+
+/** Machine-generated. */
+private void connEtoC3(java.awt.event.ActionEvent arg1) {
+ try {
+ // user code begin {1}
+ // user code end
+ this.pass4Button_ActionPerformed(arg1);
+ // user code begin {2}
+ // user code end
+ } catch (java.lang.Throwable ivjExc) {
+ // user code begin {3}
+ // user code end
+ handleException(ivjExc);
+ }
+}
+
+/** Machine-generated. */
+private void connEtoC4(java.awt.event.ActionEvent arg1) {
+ try {
+ // user code begin {1}
+ // user code end
+ this.flushButton_ActionPerformed(arg1);
+ // user code begin {2}
+ // user code end
+ } catch (java.lang.Throwable ivjExc) {
+ // user code begin {3}
+ // user code end
+ handleException(ivjExc);
+ }
+}
+
+/** Machine-generated. */
+public void flushButton_ActionPerformed(java.awt.event.ActionEvent actionEvent) {
+ VerifierFactory.getVerifier(class_name).flush();
+ Repository.removeClass(class_name); // Make sure it will be reloaded.
+ getPass1Panel().setBackground(Color.gray);
+ getPass1Panel().repaint();
+ getPass2Panel().setBackground(Color.gray);
+ getPass2Panel().repaint();
+ getPass3Panel().setBackground(Color.gray);
+ getPass3Panel().repaint();
+}
+
+/** Machine-generated. */
+private javax.swing.JButton getFlushButton() {
+ if (ivjFlushButton == null) {
+ try {
+ ivjFlushButton = new javax.swing.JButton();
+ ivjFlushButton.setName("FlushButton");
+ ivjFlushButton.setText("Flush: Forget old verification results");
+ ivjFlushButton.setBackground(java.awt.SystemColor.controlHighlight);
+ ivjFlushButton.setBounds(60, 215, 300, 30);
+ ivjFlushButton.setForeground(java.awt.Color.red);
+ ivjFlushButton.setActionCommand("FlushButton");
+ // user code begin {1}
+ // user code end
+ } catch (java.lang.Throwable ivjExc) {
+ // user code begin {2}
+ // user code end
+ handleException(ivjExc);
+ }
+ }
+ return ivjFlushButton;
+}
+
+/** Machine-generated. */
+private javax.swing.JPanel getJDialogContentPane() {
+ if (ivjJDialogContentPane == null) {
+ try {
+ ivjJDialogContentPane = new javax.swing.JPanel();
+ ivjJDialogContentPane.setName("JDialogContentPane");
+ ivjJDialogContentPane.setLayout(null);
+ getJDialogContentPane().add(getPass1Panel(), getPass1Panel().getName());
+ getJDialogContentPane().add(getPass3Panel(), getPass3Panel().getName());
+ getJDialogContentPane().add(getPass2Panel(), getPass2Panel().getName());
+ getJDialogContentPane().add(getPass1Button(), getPass1Button().getName());
+ getJDialogContentPane().add(getPass2Button(), getPass2Button().getName());
+ getJDialogContentPane().add(getPass3Button(), getPass3Button().getName());
+ getJDialogContentPane().add(getFlushButton(), getFlushButton().getName());
+ // user code begin {1}
+ // user code end
+ } catch (java.lang.Throwable ivjExc) {
+ // user code begin {2}
+ // user code end
+ handleException(ivjExc);
+ }
+ }
+ return ivjJDialogContentPane;
+}
+
+/** Machine-generated. */
+private javax.swing.JButton getPass1Button() {
+ if (ivjPass1Button == null) {
+ try {
+ ivjPass1Button = new javax.swing.JButton();
+ ivjPass1Button.setName("Pass1Button");
+ ivjPass1Button.setText("Pass1: Verify binary layout of .class file");
+ ivjPass1Button.setBackground(java.awt.SystemColor.controlHighlight);
+ ivjPass1Button.setBounds(100, 40, 300, 30);
+ ivjPass1Button.setActionCommand("Button1");
+ // user code begin {1}
+ // user code end
+ } catch (java.lang.Throwable ivjExc) {
+ // user code begin {2}
+ // user code end
+ handleException(ivjExc);
+ }
+ }
+ return ivjPass1Button;
+}
+
+/** Machine-generated. */
+private javax.swing.JPanel getPass1Panel() {
+ if (ivjPass1Panel == null) {
+ try {
+ ivjPass1Panel = new javax.swing.JPanel();
+ ivjPass1Panel.setName("Pass1Panel");
+ ivjPass1Panel.setLayout(null);
+ ivjPass1Panel.setBackground(java.awt.SystemColor.controlShadow);
+ ivjPass1Panel.setBounds(30, 30, 50, 50);
+ // user code begin {1}
+ // user code end
+ } catch (java.lang.Throwable ivjExc) {
+ // user code begin {2}
+ // user code end
+ handleException(ivjExc);
+ }
+ }
+ return ivjPass1Panel;
+}
+
+/** Machine-generated. */
+private javax.swing.JButton getPass2Button() {
+ if (ivjPass2Button == null) {
+ try {
+ ivjPass2Button = new javax.swing.JButton();
+ ivjPass2Button.setName("Pass2Button");
+ ivjPass2Button.setText("Pass 2: Verify static .class file constraints");
+ ivjPass2Button.setBackground(java.awt.SystemColor.controlHighlight);
+ ivjPass2Button.setBounds(100, 100, 300, 30);
+ ivjPass2Button.setActionCommand("Button2");
+ // user code begin {1}
+ // user code end
+ } catch (java.lang.Throwable ivjExc) {
+ // user code begin {2}
+ // user code end
+ handleException(ivjExc);
+ }
+ }
+ return ivjPass2Button;
+}
+
+/** Machine-generated. */
+private javax.swing.JPanel getPass2Panel() {
+ if (ivjPass2Panel == null) {
+ try {
+ ivjPass2Panel = new javax.swing.JPanel();
+ ivjPass2Panel.setName("Pass2Panel");
+ ivjPass2Panel.setLayout(null);
+ ivjPass2Panel.setBackground(java.awt.SystemColor.controlShadow);
+ ivjPass2Panel.setBounds(30, 90, 50, 50);
+ // user code begin {1}
+ // user code end
+ } catch (java.lang.Throwable ivjExc) {
+ // user code begin {2}
+ // user code end
+ handleException(ivjExc);
+ }
+ }
+ return ivjPass2Panel;
+}
+
+/** Machine-generated. */
+private javax.swing.JButton getPass3Button() {
+ if (ivjPass3Button == null) {
+ try {
+ ivjPass3Button = new javax.swing.JButton();
+ ivjPass3Button.setName("Pass3Button");
+ ivjPass3Button.setText("Passes 3a+3b: Verify code arrays");
+ ivjPass3Button.setBackground(java.awt.SystemColor.controlHighlight);
+ ivjPass3Button.setBounds(100, 160, 300, 30);
+ ivjPass3Button.setActionCommand("Button2");
+ // user code begin {1}
+ // user code end
+ } catch (java.lang.Throwable ivjExc) {
+ // user code begin {2}
+ // user code end
+ handleException(ivjExc);
+ }
+ }
+ return ivjPass3Button;
+}
+
+/** Machine-generated. */
+private javax.swing.JPanel getPass3Panel() {
+ if (ivjPass3Panel == null) {
+ try {
+ ivjPass3Panel = new javax.swing.JPanel();
+ ivjPass3Panel.setName("Pass3Panel");
+ ivjPass3Panel.setLayout(null);
+ ivjPass3Panel.setBackground(java.awt.SystemColor.controlShadow);
+ ivjPass3Panel.setBounds(30, 150, 50, 50);
+ // user code begin {1}
+ // user code end
+ } catch (java.lang.Throwable ivjExc) {
+ // user code begin {2}
+ // user code end
+ handleException(ivjExc);
+ }
+ }
+ return ivjPass3Panel;
+}
+
+/** Machine-generated. */
+private void handleException(java.lang.Throwable exception) {
+
+ /* Uncomment the following lines to print uncaught exceptions to stdout */
+ System.out.println("--------- UNCAUGHT EXCEPTION ---------");
+ exception.printStackTrace(System.out);
+}
+
+
+/** Machine-generated. */
+private void initConnections() throws java.lang.Exception {
+ // user code begin {1}
+ // user code end
+ getPass1Button().addActionListener(ivjEventHandler);
+ getPass2Button().addActionListener(ivjEventHandler);
+ getPass3Button().addActionListener(ivjEventHandler);
+ getFlushButton().addActionListener(ivjEventHandler);
+}
+
+/** Machine-generated. */
+private void initialize() {
+ try {
+ // user code begin {1}
+ // user code end
+ setName("VerifyDialog");
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+ setSize(430, 280);
+ setVisible(true);
+ setModal(true);
+ setResizable(false);
+ setContentPane(getJDialogContentPane());
+ initConnections();
+ } catch (java.lang.Throwable ivjExc) {
+ handleException(ivjExc);
+ }
+ // user code begin {2}
+ setTitle("'"+class_name+"' verification - JustIce / BCEL");
+ // user code end
+}
+/**
+ * Verifies one or more class files.
+ * Verification results are presented graphically: Red means 'rejected',
+ * green means 'passed' while yellow means 'could not be verified yet'.
+ * @param args java.lang.String[] fully qualified names of classes to verify.
+ */
+public static void main(java.lang.String[] args) {
+ classes_to_verify = args.length;
+
+ for (int i=0; i<args.length; i++){
+
+ try {
+ VerifyDialog aVerifyDialog;
+ aVerifyDialog = new VerifyDialog(args[i]);
+ aVerifyDialog.setModal(true);
+ aVerifyDialog.addWindowListener(new java.awt.event.WindowAdapter() {
+ public void windowClosing(java.awt.event.WindowEvent e) {
+ classes_to_verify--;
+ if (classes_to_verify == 0) System.exit(0);
+ };
+ });
+ aVerifyDialog.setVisible(true);
+ } catch (Throwable exception) {
+ System.err.println("Exception occurred in main() of javax.swing.JDialog");
+ exception.printStackTrace(System.out);
+ }
+
+ }
+}
+
+/** Machine-generated. */
+public void pass1Button_ActionPerformed(java.awt.event.ActionEvent actionEvent) {
+ Verifier v = VerifierFactory.getVerifier(class_name);
+ VerificationResult vr = v.doPass1();
+ if (vr.getStatus() == VerificationResult.VERIFIED_OK){
+ getPass1Panel().setBackground(Color.green);
+ getPass1Panel().repaint();
+ }
+ if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED){
+ getPass1Panel().setBackground(Color.red);
+ getPass1Panel().repaint();
+ }
+}
+
+/** Machine-generated. */
+public void pass2Button_ActionPerformed(java.awt.event.ActionEvent actionEvent) {
+ pass1Button_ActionPerformed(actionEvent);
+
+ Verifier v = VerifierFactory.getVerifier(class_name);
+ VerificationResult vr = v.doPass2();
+ if (vr.getStatus() == VerificationResult.VERIFIED_OK){
+ getPass2Panel().setBackground(Color.green);
+ getPass2Panel().repaint();
+ }
+ if (vr.getStatus() == VerificationResult.VERIFIED_NOTYET){
+ getPass2Panel().setBackground(Color.yellow);
+ getPass2Panel().repaint();
+ }
+ if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED){
+ getPass2Panel().setBackground(Color.red);
+ getPass2Panel().repaint();
+ }
+}
+
+/** Machine-generated. */
+public void pass4Button_ActionPerformed(java.awt.event.ActionEvent actionEvent) {
+
+ pass2Button_ActionPerformed(actionEvent);
+
+
+ Color color = Color.green;
+
+ Verifier v = VerifierFactory.getVerifier(class_name);
+ VerificationResult vr = v.doPass2();
+ if (vr.getStatus() == VerificationResult.VERIFIED_OK){
+ JavaClass jc = Repository.lookupClass(class_name);
+ int nr = jc.getMethods().length;
+ for (int i=0; i<nr; i++) {
+ vr = v.doPass3b(i);
+ if (vr.getStatus() != VerificationResult.VERIFIED_OK){
+ color = Color.red;
+ break;
+ }
+ }
+ }
+ else{
+ color = Color.yellow;
+ }
+
+ getPass3Panel().setBackground(color);
+ getPass3Panel().repaint();
+}
+}
diff --git a/src/java/org/apache/bcel/verifier/exc/AssertionViolatedException.java b/src/java/org/apache/bcel/verifier/exc/AssertionViolatedException.java
new file mode 100644
index 00000000..91b8c6b7
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/exc/AssertionViolatedException.java
@@ -0,0 +1,115 @@
+package org.apache.bcel.verifier.exc;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Instances of this class should never be thrown. When such an instance is thrown,
+ * this is due to an INTERNAL ERROR of BCEL's class file verifier &quot;JustIce&quot;.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public final class AssertionViolatedException extends RuntimeException{
+ /** The error message. */
+ private String detailMessage;
+ /** Constructs a new AssertionViolatedException with null as its error message string. */
+ public AssertionViolatedException(){
+ super();
+ }
+ /**
+ * Constructs a new AssertionViolatedException with the specified error message preceded
+ * by &quot;INTERNAL ERROR: &quot;.
+ */
+ public AssertionViolatedException(String message){
+ super(message = "INTERNAL ERROR: "+message); // Thanks to Java, the constructor call here must be first.
+ detailMessage=message;
+ }
+ /** Extends the error message with a string before ("pre") and after ("post") the
+ 'old' error message. All of these three strings are allowed to be null, and null
+ is always replaced by the empty string (""). In particular, after invoking this
+ method, the error message of this object can no longer be null.
+ */
+ public void extendMessage(String pre, String post){
+ if (pre == null) pre="";
+ if (detailMessage == null) detailMessage="";
+ if (post == null) post="";
+ detailMessage = pre+detailMessage+post;
+ }
+ /**
+ * Returns the error message string of this AssertionViolatedException object.
+ * @return the error message string of this AssertionViolatedException.
+ */
+ public String getMessage(){
+ return detailMessage;
+ }
+
+ /**
+ * DO NOT USE. It's for experimental testing during development only.
+ */
+ public static void main(String[] args){
+ AssertionViolatedException ave = new AssertionViolatedException("Oops!");
+ ave.extendMessage("\nFOUND:\n\t","\nExiting!!\n");
+ throw ave;
+ }
+
+ /**
+ * Returns the backtrace of this AssertionViolatedException as a String.
+ * @return The backtrace of this AssertionViolatedException as a String.
+ */
+ public String getStackTrace(){
+ return Utility.getStackTrace(this);
+ }
+
+}
diff --git a/src/java/org/apache/bcel/verifier/exc/ClassConstraintException.java b/src/java/org/apache/bcel/verifier/exc/ClassConstraintException.java
new file mode 100644
index 00000000..11b67f24
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/exc/ClassConstraintException.java
@@ -0,0 +1,83 @@
+package org.apache.bcel.verifier.exc;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Instances of this class are thrown by BCEL's class file verifier "JustIce"
+ * when a class file to verify does not pass the verification pass 2 as described
+ * in the Java Virtual Machine specification, 2nd edition.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public class ClassConstraintException extends VerificationException{
+ /** The specified error message. */
+ private String detailMessage;
+
+ /**
+ * Constructs a new ClassConstraintException with null as its error message string.
+ */
+ public ClassConstraintException(){
+ super();
+ }
+
+ /**
+ * Constructs a new ClassConstraintException with the specified error message.
+ */
+ public ClassConstraintException(String message){
+ super (message);
+ detailMessage = message;
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/exc/CodeConstraintException.java b/src/java/org/apache/bcel/verifier/exc/CodeConstraintException.java
new file mode 100644
index 00000000..14dfd4f7
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/exc/CodeConstraintException.java
@@ -0,0 +1,77 @@
+package org.apache.bcel.verifier.exc;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+/**
+ * Instances of this class are thrown by BCEL's class file verifier "JustIce" when
+ * a class file does not pass the verification pass 3. Note that the pass 3 used by
+ * "JustIce" involves verification that is usually delayed to pass 4.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public abstract class CodeConstraintException extends VerificationException{
+ /**
+ * Constructs a new CodeConstraintException with null as its error message string.
+ */
+ CodeConstraintException(){
+ super();
+ }
+ /**
+ * Constructs a new CodeConstraintException with the specified error message.
+ */
+ CodeConstraintException(String message){
+ super(message);
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/exc/InvalidMethodException.java b/src/java/org/apache/bcel/verifier/exc/InvalidMethodException.java
new file mode 100644
index 00000000..5101b632
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/exc/InvalidMethodException.java
@@ -0,0 +1,71 @@
+package org.apache.bcel.verifier.exc;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+/**
+ * Instances of this class are thrown by BCEL's class file verifier "JustIce"
+ * when the verification of a method is requested that does not exist.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public class InvalidMethodException extends RuntimeException{
+ /** Must not be no-args requested so there's always some error message. */
+ private InvalidMethodException(){}
+
+ /** Constructs an InvalidMethodException with the specified detail message. */
+ public InvalidMethodException(String message){
+ super(message);
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/exc/LinkingConstraintException.java b/src/java/org/apache/bcel/verifier/exc/LinkingConstraintException.java
new file mode 100644
index 00000000..6ca913c4
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/exc/LinkingConstraintException.java
@@ -0,0 +1,74 @@
+package org.apache.bcel.verifier.exc;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+/**
+ * Instances of this class are thrown by BCEL's class file verifier "JustIce" when
+ * a class file to verify does not pass the verification pass 3 because of a violation
+ * of a constraint that is usually only verified at run-time (pass 4).
+ * The Java Virtual Machine Specification, 2nd edition, states that certain constraints
+ * are usually verified at run-time for performance reasons (the verification of those
+ * constraints requires loading in and recursively verifying referenced classes) that
+ * conceptually belong to pass 3; to be precise, that conceptually belong to the
+ * data flow analysis of pass 3 (called pass 3b in JustIce).
+ * These are the checks necessary for resolution: Compare pages 142-143 ("4.9.1 The
+ * Verification Process") and pages 50-51 ("2.17.3 Linking: Verification, Preparation,
+ * and Resolution") of the above mentioned book.
+ * <B>TODO: At this time, this class is not used in JustIce.</B>
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public class LinkingConstraintException extends StructuralCodeConstraintException{
+}
diff --git a/src/java/org/apache/bcel/verifier/exc/LoadingException.java b/src/java/org/apache/bcel/verifier/exc/LoadingException.java
new file mode 100644
index 00000000..4e17e6cd
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/exc/LoadingException.java
@@ -0,0 +1,82 @@
+package org.apache.bcel.verifier.exc;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * When loading a class file, BCEL will throw an instance of LoadingException if
+ * the class file is malformed; so it is not conforming to the "Pass 1" verification
+ * process as described in the Java Virtual Machine specification, 2nd. edition.
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public class LoadingException extends VerifierConstraintViolatedException{
+ /** The specified error message. */
+ private String detailMessage;
+
+ /**
+ * Constructs a new LoadingException with null as its error message string.
+ */
+ public LoadingException(){
+ super();
+ }
+
+ /**
+ * Constructs a new LoadingException with the specified error message.
+ */
+ public LoadingException(String message){
+ super (message);
+ detailMessage = message;
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/exc/LocalVariableInfoInconsistentException.java b/src/java/org/apache/bcel/verifier/exc/LocalVariableInfoInconsistentException.java
new file mode 100644
index 00000000..2a52743d
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/exc/LocalVariableInfoInconsistentException.java
@@ -0,0 +1,81 @@
+package org.apache.bcel.verifier.exc;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * A LocalVariableInfoInconsistentException instance is thrown by
+ * the LocalVariableInfo class when it detects that the information
+ * it holds is inconsistent; this is normally due to inconsistent
+ * LocalVariableTable entries in the Code attribute of a certain
+ * Method object.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public class LocalVariableInfoInconsistentException extends ClassConstraintException{
+ /**
+ * Constructs a new LocalVariableInfoInconsistentException with null as its error message string.
+ */
+ public LocalVariableInfoInconsistentException(){
+ super();
+ }
+
+ /**
+ * Constructs a new LocalVariableInfoInconsistentException with the specified error message.
+ */
+ public LocalVariableInfoInconsistentException(String message){
+ super (message);
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/exc/StaticCodeConstraintException.java b/src/java/org/apache/bcel/verifier/exc/StaticCodeConstraintException.java
new file mode 100644
index 00000000..86b0fd3b
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/exc/StaticCodeConstraintException.java
@@ -0,0 +1,71 @@
+package org.apache.bcel.verifier.exc;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Instances of this class are thrown by BCEL's class file verifier "JustIce" when
+ * a class file to verify does not pass the verification pass 3 because of a violation
+ * of a static constraint as described in the Java Virtual Machine Specification,
+ * 2nd edition, 4.8.1, pages 133-137. The static constraints checking part of pass 3
+ * is called pass 3a in JustIce.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public abstract class StaticCodeConstraintException extends CodeConstraintException{
+ public StaticCodeConstraintException(String message){
+ super(message);
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/exc/StaticCodeInstructionConstraintException.java b/src/java/org/apache/bcel/verifier/exc/StaticCodeInstructionConstraintException.java
new file mode 100644
index 00000000..43a8a3f7
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/exc/StaticCodeInstructionConstraintException.java
@@ -0,0 +1,74 @@
+package org.apache.bcel.verifier.exc;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Instances of this class are thrown by BCEL's class file verifier "JustIce" when
+ * a class file to verify does not pass the verification pass 3 because of a violation
+ * of a static constraint as described in the Java Virtual Machine Specification,
+ * Second edition, 4.8.1, pages 133-137. The static constraints checking part of pass 3
+ * is called pass 3a in JustIce.
+ * Static constraints on the instructions in the code array are checked early in
+ * pass 3a and are described on page 134 in the Java Virtual Machine Specification,
+ * Second Edition.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public class StaticCodeInstructionConstraintException extends StaticCodeConstraintException{
+ public StaticCodeInstructionConstraintException(String message){
+ super(message);
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/exc/StaticCodeInstructionOperandConstraintException.java b/src/java/org/apache/bcel/verifier/exc/StaticCodeInstructionOperandConstraintException.java
new file mode 100644
index 00000000..3825a741
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/exc/StaticCodeInstructionOperandConstraintException.java
@@ -0,0 +1,74 @@
+package org.apache.bcel.verifier.exc;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Instances of this class are thrown by BCEL's class file verifier "JustIce" when
+ * a class file to verify does not pass the verification pass 3 because of a violation
+ * of a static constraint as described in the Java Virtual Machine Specification,
+ * Second edition, 4.8.1, pages 133-137. The static constraints checking part of pass 3
+ * is called pass 3a in JustIce.
+ * Static constraints on the operands of instructions in the code array are checked late in
+ * pass 3a and are described on page 134-137 in the Java Virtual Machine Specification,
+ * Second Edition.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public class StaticCodeInstructionOperandConstraintException extends StaticCodeConstraintException{
+ public StaticCodeInstructionOperandConstraintException(String message){
+ super(message);
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/exc/StructuralCodeConstraintException.java b/src/java/org/apache/bcel/verifier/exc/StructuralCodeConstraintException.java
new file mode 100644
index 00000000..946f1044
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/exc/StructuralCodeConstraintException.java
@@ -0,0 +1,82 @@
+package org.apache.bcel.verifier.exc;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+/**
+ * Instances of this class are thrown by BCEL's class file verifier "JustIce" when
+ * a class file to verify does not pass the verification pass 3 because of a violation
+ * of a structural constraint as described in the Java Virtual Machine Specification,
+ * 2nd edition, 4.8.2, pages 137-139.
+ * Note that the notion of a "structural" constraint is somewhat misleading. Structural
+ * constraints are constraints on relationships between Java virtual machine instructions.
+ * These are the constraints where data-flow analysis is needed to verify if they hold.
+ * The data flow analysis of pass 3 is called pass 3b in JustIce.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public class StructuralCodeConstraintException extends CodeConstraintException{
+ /**
+ * Constructs a new StructuralCodeConstraintException with the specified error message.
+ */
+ public StructuralCodeConstraintException(String message){
+ super(message);
+ }
+ /**
+ * Constructs a new StructuralCodeConstraintException with null as its error message string.
+ */
+ public StructuralCodeConstraintException(){
+ super();
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/exc/Utility.java b/src/java/org/apache/bcel/verifier/exc/Utility.java
new file mode 100644
index 00000000..01b80cea
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/exc/Utility.java
@@ -0,0 +1,76 @@
+package org.apache.bcel.verifier.exc;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import java.io.*;
+
+/**
+ * A utility class providing convenience methods concerning Throwable instances.
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ * @see java.lang.Throwable
+ */
+public final class Utility{
+ /** This class is not instantiable. */
+ private Utility(){}
+
+ /** This method returns the stack trace of a Throwable instance as a String. */
+ public static String getStackTrace(Throwable t){
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ t.printStackTrace(pw);
+ return sw.toString();
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/exc/VerificationException.java b/src/java/org/apache/bcel/verifier/exc/VerificationException.java
new file mode 100644
index 00000000..d8d473fa
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/exc/VerificationException.java
@@ -0,0 +1,82 @@
+package org.apache.bcel.verifier.exc;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Instances of this class are thrown by BCEL's class file verifier "JustIce" when a
+ * class file to verify does not pass one of the verification passes 2 or 3.
+ * Note that the pass 3 used by "JustIce" involves verification that is usually
+ * delayed to pass 4.
+ * The name of this class is justified by the Java Virtual Machine Specification, 2nd
+ * edition, page 164, 5.4.1 where verification as a part of the linking process is
+ * defined to be the verification happening in passes 2 and 3.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public abstract class VerificationException extends VerifierConstraintViolatedException{
+ /**
+ * Constructs a new VerificationException with null as its error message string.
+ */
+ VerificationException(){
+ super();
+ }
+ /**
+ * Constructs a new VerificationException with the specified error message.
+ */
+ VerificationException(String message){
+ super(message);
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/exc/VerifierConstraintViolatedException.java b/src/java/org/apache/bcel/verifier/exc/VerifierConstraintViolatedException.java
new file mode 100644
index 00000000..65dd1e96
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/exc/VerifierConstraintViolatedException.java
@@ -0,0 +1,107 @@
+package org.apache.bcel.verifier.exc;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * Instances of this class are thrown by BCEL's class file verifier "JustIce"
+ * whenever
+ * verification proves that some constraint of a class file (as stated in the
+ * Java Virtual Machine Specification, Edition 2) is violated.
+ * This is roughly equivalent to the VerifyError the JVM-internal verifiers
+ * throw.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public abstract class VerifierConstraintViolatedException extends RuntimeException{
+ // /** The name of the offending class that did not pass the verifier. */
+ // String name_of_offending_class;
+
+ /** The specified error message. */
+ private String detailMessage;
+ /**
+ * Constructs a new VerifierConstraintViolatedException with null as its error message string.
+ */
+ VerifierConstraintViolatedException(){
+ super();
+ }
+ /**
+ * Constructs a new VerifierConstraintViolatedException with the specified error message.
+ */
+ VerifierConstraintViolatedException(String message){
+ super(message); // Not that important
+ detailMessage = message;
+ }
+
+
+ /** Extends the error message with a string before ("pre") and after ("post") the
+ 'old' error message. All of these three strings are allowed to be null, and null
+ is always replaced by the empty string (""). In particular, after invoking this
+ method, the error message of this object can no longer be null.
+ */
+ public void extendMessage(String pre, String post){
+ if (pre == null) pre="";
+ if (detailMessage == null) detailMessage="";
+ if (post == null) post="";
+ detailMessage = pre+detailMessage+post;
+ }
+ /**
+ * Returns the error message string of this VerifierConstraintViolatedException object.
+ * @return the error message string of this VerifierConstraintViolatedException.
+ */
+ public String getMessage(){
+ return detailMessage;
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/exc/package.html b/src/java/org/apache/bcel/verifier/exc/package.html
new file mode 100644
index 00000000..3d04b1b5
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/exc/package.html
@@ -0,0 +1,24 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+$Id$
+-->
+</head>
+<body bgcolor="white">
+
+Exception classes used by JustIce, mostly used internally. You don't need to bother with them.
+
+<h2>Package Specification</h2>
+
+Contained in this package are Exception classes for use with the JustIce verifier.
+
+<h2>Related Documentation</h2>
+
+For a simple demonstration of JustIce working, please see:
+<ul>
+ <li><a href="http://www.inf.fu-berlin.de/~ehaase/cgi-html/Verifier.html">A WWW front-end for JustIce.</a>
+</ul>
+
+</body>
+</html>
diff --git a/src/java/org/apache/bcel/verifier/package.html b/src/java/org/apache/bcel/verifier/package.html
new file mode 100644
index 00000000..5f73d77d
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/package.html
@@ -0,0 +1,25 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+$Id$
+-->
+</head>
+<body bgcolor="white">
+
+BCEL's verifier JustIce is there to help you dump correct Java class files created or modified with BCEL.
+
+<h2>Package Specification</h2>
+
+This is the top-level package of the JustIce verifier. To actually use it, have a look at the VerifierFactory and
+Verifier classes.
+
+<h2>Related Documentation</h2>
+
+For a simple demonstration of JustIce working, please see:
+<ul>
+ <li><a href="http://www.inf.fu-berlin.de/~ehaase/cgi-html/Verifier.html">A WWW front-end for JustIce.</a>
+</ul>
+
+</body>
+</html>
diff --git a/src/java/org/apache/bcel/verifier/statics/DOUBLE_Upper.java b/src/java/org/apache/bcel/verifier/statics/DOUBLE_Upper.java
new file mode 100644
index 00000000..108988c4
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/statics/DOUBLE_Upper.java
@@ -0,0 +1,79 @@
+package org.apache.bcel.verifier.statics;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import org.apache.bcel.generic.Type;
+
+/**
+ * This class represents the upper half of a DOUBLE variable.
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public final class DOUBLE_Upper extends Type{
+
+ /** The one and only instance of this class. */
+ private static DOUBLE_Upper singleInstance = new DOUBLE_Upper();
+
+ /** The constructor; this class must not be instantiated from the outside. */
+ private DOUBLE_Upper(){
+ super(Constants.T_UNKNOWN, "Long_Upper");
+ }
+
+ /** Use this method to get the single instance of this class. */
+ public static DOUBLE_Upper theInstance(){
+ return singleInstance;
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/statics/IntList.java b/src/java/org/apache/bcel/verifier/statics/IntList.java
new file mode 100644
index 00000000..bc45fda1
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/statics/IntList.java
@@ -0,0 +1,85 @@
+package org.apache.bcel.verifier.statics;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import java.util.ArrayList;
+
+/**
+ * A small utility class representing a set of basic int values.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public class IntList{
+ /** The int are stored as Integer objects here. */
+ private ArrayList theList;
+ /** This constructor creates an empty list. */
+ IntList(){
+ theList = new ArrayList();
+ }
+ /** Adds an element to the list. */
+ void add(int i){
+ theList.add(new Integer(i));
+ }
+ /** Checks if the specified int is already in the list. */
+ boolean contains(int i){
+ Integer[] ints = new Integer[theList.size()];
+ theList.toArray(ints);
+ for (int j=0; j<ints.length; j++){
+ if (i == ints[j].intValue()) return true;
+ }
+ return false;
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/statics/LONG_Upper.java b/src/java/org/apache/bcel/verifier/statics/LONG_Upper.java
new file mode 100644
index 00000000..b1d1defe
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/statics/LONG_Upper.java
@@ -0,0 +1,79 @@
+package org.apache.bcel.verifier.statics;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import org.apache.bcel.generic.Type;
+
+/**
+ * This class represents the upper half of a LONG variable.
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public final class LONG_Upper extends Type{
+
+ /** The one and only instance of this class. */
+ private static LONG_Upper singleInstance = new LONG_Upper();
+
+ /** The constructor; this class must not be instantiated from the outside. */
+ private LONG_Upper(){
+ super(Constants.T_UNKNOWN, "Long_Upper");
+ }
+
+ /** Use this method to get the single instance of this class. */
+ public static LONG_Upper theInstance(){
+ return singleInstance;
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/statics/LocalVariableInfo.java b/src/java/org/apache/bcel/verifier/statics/LocalVariableInfo.java
new file mode 100644
index 00000000..2c9a7dec
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/statics/LocalVariableInfo.java
@@ -0,0 +1,145 @@
+package org.apache.bcel.verifier.statics;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import org.apache.bcel.generic.Type;
+import org.apache.bcel.verifier.exc.*;
+import java.util.Hashtable;
+
+/**
+ * A utility class holding the information about
+ * the name and the type of a local variable in
+ * a given slot (== index). This information
+ * often changes in course of byte code offsets.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public class LocalVariableInfo{
+
+ /** The types database. KEY: String representing the offset integer. */
+ private Hashtable types = new Hashtable();
+ /** The names database. KEY: String representing the offset integer. */
+ private Hashtable names = new Hashtable();
+
+ /**
+ * Adds a name of a local variable and a certain slot to our 'names'
+ * (Hashtable) database.
+ */
+ private void setName(int offset, String name){
+ names.put( ((Integer.toString(offset))), name);
+ }
+ /**
+ * Adds a type of a local variable and a certain slot to our 'types'
+ * (Hashtable) database.
+ */
+ private void setType(int offset, Type t){
+ types.put( ((Integer.toString(offset))), t);
+ }
+
+ /**
+ * Returns the type of the local variable that uses this local
+ * variable slot at the given bytecode offset.
+ * Care for legal bytecode offsets yourself, otherwise the return value
+ * might be wrong.
+ * May return 'null' if nothing is known about the type of this local
+ * variable slot at the given bytecode offset.
+ */
+ public Type getType(int offset){
+ return (Type) types.get(Integer.toString(offset));
+ }
+ /**
+ * Returns the name of the local variable that uses this local
+ * variable slot at the given bytecode offset.
+ * Care for legal bytecode offsets yourself, otherwise the return value
+ * might be wrong.
+ * May return 'null' if nothing is known about the type of this local
+ * variable slot at the given bytecode offset.
+ */
+ public String getName(int offset){
+ return (String) (names.get(Integer.toString(offset)));
+ }
+ /**
+ * Adds some information about this local variable (slot).
+ * @throws LocalVariableInfoInconsistentException if the new information conflicts
+ * with already gathered information.
+ */
+ public void add(String name, int startpc, int length, Type t) throws LocalVariableInfoInconsistentException{
+ for (int i=startpc; i<=startpc+length; i++){ // incl/incl-notation!
+ add(i,name,t);
+ }
+ }
+
+ /**
+ * Adds information about name and type for a given offset.
+ * @throws LocalVariableInfoInconsistentException if the new information conflicts
+ * with already gathered information.
+ */
+ private void add(int offset, String name, Type t) throws LocalVariableInfoInconsistentException{
+ if (getName(offset) != null){
+ if (! getName(offset).equals(name)){
+ throw new LocalVariableInfoInconsistentException("At bytecode offset '"+offset+"' a local variable has two different names: '"+getName(offset)+"' and '"+name+"'.");
+ }
+ }
+ if (getType(offset) != null){
+ if (! getType(offset).equals(t)){
+ throw new LocalVariableInfoInconsistentException("At bytecode offset '"+offset+"' a local variable has two different types: '"+getType(offset)+"' and '"+t+"'.");
+ }
+ }
+ setName(offset, name);
+ setType(offset, t);
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/statics/LocalVariablesInfo.java b/src/java/org/apache/bcel/verifier/statics/LocalVariablesInfo.java
new file mode 100644
index 00000000..221e6ab9
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/statics/LocalVariablesInfo.java
@@ -0,0 +1,113 @@
+package org.apache.bcel.verifier.statics;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import org.apache.bcel.generic.Type;
+import org.apache.bcel.verifier.exc.*;
+
+/**
+ * A utility class holding the information about
+ * the names and the types of the local variables in
+ * a given method.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public class LocalVariablesInfo{
+
+ /** The information about the local variables is stored here. */
+ private LocalVariableInfo[] localVariableInfos;
+
+ /**
+ * The ints in the list represent code offsets where either instructions must start
+ * or the offset is the length of the code array. This will be verified in Pass 3a.
+ */
+ private IntList instruction_offsets = new IntList();
+
+ /** The constructor. */
+ LocalVariablesInfo(int max_locals){
+ localVariableInfos = new LocalVariableInfo[max_locals];
+ for (int i=0; i<max_locals; i++){
+ localVariableInfos[i] = new LocalVariableInfo();
+ }
+ }
+
+ /** Returns the LocalVariableInfo for the given slot. */
+ public LocalVariableInfo getLocalVariableInfo(int slot){
+ if (slot < 0 || slot >= localVariableInfos.length){
+ throw new AssertionViolatedException("Slot number for local variable information out of range.");
+ }
+ return localVariableInfos[slot];
+ }
+
+ /**
+ * Adds information about the local variable in slot 'slot'. Automatically
+ * adds information for slot+1 if 't' is Type.LONG or Type.DOUBLE.
+ * @throws LocalVariableInfoInconsistentException if the new information conflicts
+ * with already gathered information.
+ */
+ public void add(int slot, String name, int startpc, int length, Type t) throws LocalVariableInfoInconsistentException{
+ // The add operation on LocalVariableInfo may throw the '...Inconsistent...' exception, we don't throw it explicitely here.
+
+ if (slot < 0 || slot >= localVariableInfos.length){
+ throw new AssertionViolatedException("Slot number for local variable information out of range.");
+ }
+
+ localVariableInfos[slot].add(name, startpc, length, t);
+ if (t == Type.LONG) localVariableInfos[slot+1].add(name, startpc, length, LONG_Upper.theInstance());
+ if (t == Type.DOUBLE) localVariableInfos[slot+1].add(name, startpc, length, DOUBLE_Upper.theInstance());
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/statics/Pass1Verifier.java b/src/java/org/apache/bcel/verifier/statics/Pass1Verifier.java
new file mode 100644
index 00000000..4b1e8c00
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/statics/Pass1Verifier.java
@@ -0,0 +1,214 @@
+package org.apache.bcel.verifier.statics;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.Repository;
+import org.apache.bcel.verifier.*;
+import org.apache.bcel.verifier.exc.*;
+import org.apache.bcel.verifier.exc.Utility;
+import java.util.ArrayList;
+
+/**
+ * This PassVerifier verifies a class file according to pass 1 as
+ * described in The Java Virtual Machine Specification, 2nd edition.
+ * More detailed information is to be found at the do_verify() method's
+ * documentation.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ * @see #do_verify()
+ */
+public final class Pass1Verifier extends PassVerifier{
+ /**
+ * DON'T USE THIS EVEN PRIVATELY! USE getJavaClass() INSTEAD.
+ * @see #getJavaClass()
+ */
+ private JavaClass jc;
+
+ /**
+ * The Verifier that created this.
+ */
+ private Verifier myOwner;
+
+ /** Used to load in and return the myOwner-matching JavaClass object when needed. Avoids loading in a class file when it's not really needed! */
+ private JavaClass getJavaClass(){
+ if (jc == null){
+ jc = Repository.lookupClass(myOwner.getClassName());
+ }
+ return jc;
+ }
+
+ /**
+ * Should only be instantiated by a Verifier.
+ *
+ * @see org.apache.bcel.verifier.Verifier
+ */
+ public Pass1Verifier(Verifier owner){
+ myOwner = owner;
+ }
+
+ /**
+ * Pass-one verification basically means loading in a class file.
+ * The Java Virtual Machine Specification is not too precise about
+ * what makes the difference between passes one and two.
+ * The answer is that only pass one is performed on a class file as
+ * long as its resolution is not requested; whereas pass two and
+ * pass three are performed during the resolution process.
+ * Only four constraints to be checked are explicitely stated by
+ * The Java Virtual Machine Specification, 2nd edition:
+ * <UL>
+ * <LI>The first four bytes must contain the right magic number (0xCAFEBABE).
+ * <LI>All recognized attributes must be of the proper length.
+ * <LI>The class file must not be truncated or have extra bytes at the end.
+ * <LI>The constant pool must not contain any superficially unrecognizable information.
+ * </UL>
+ * A more in-depth documentation of what pass one should do was written by
+ * <A HREF=mailto:pwfong@cs.sfu.ca>Philip W. L. Fong</A>:
+ * <UL>
+ * <LI> the file should not be truncated.
+ * <LI> the file should not have extra bytes at the end.
+ * <LI> all variable-length structures should be well-formatted:
+ * <UL>
+ * <LI> there should only be constant_pool_count-1 many entries in the constant pool.
+ * <LI> all constant pool entries should have size the same as indicated by their type tag.
+ * <LI> there are exactly interfaces_count many entries in the interfaces array of the class file.
+ * <LI> there are exactly fields_count many entries in the fields array of the class file.
+ * <LI> there are exactly methods_count many entries in the methods array of the class file.
+ * <LI> there are exactly attributes_count many entries in the attributes array of the class file, fields, methods, and code attribute.
+ * <LI> there should be exactly attribute_length many bytes in each attribute. Inconsistency between attribute_length and the actually size of the attribute content should be uncovered. For example, in an Exceptions attribute, the actual number of exceptions as required by the number_of_exceptions field might yeild an attribute size that doesn't match the attribute_length. Such an anomaly should be detected.
+ * <LI> all attributes should have proper length. In particular, under certain context (e.g. while parsing method_info), recognizable attributes (e.g. "Code" attribute) should have correct format (e.g. attribute_length is 2).
+ * </UL>
+ * <LI> Also, certain constant values are checked for validity:
+ * <UL>
+ * <LI> The magic number should be 0xCAFEBABE.
+ * <LI> The major and minor version numbers are valid.
+ * <LI> All the constant pool type tags are recognizable.
+ * <LI> All undocumented access flags are masked off before use. Strictly speaking, this is not really a check.
+ * <LI> The field this_class should point to a string that represents a legal non-array class name, and this name should be the same as the class file being loaded.
+ * <LI> the field super_class should point to a string that represents a legal non-array class name.
+ * <LI> Because some of the above checks require cross referencing the constant pool entries, guards are set up to make sure that the referenced entries are of the right type and the indices are within the legal range (0 < index < constant_pool_count).
+ * </UL>
+ * <LI> Extra checks done in pass 1:
+ * <UL>
+ * <LI> the constant values of static fields should have the same type as the fields.
+ * <LI> the number of words in a parameter list does not exceed 255 and locals_max.
+ * <LI> the name and signature of fields and methods are verified to be of legal format.
+ * </UL>
+ * </UL>
+ * (From the Paper <A HREF=http://www.cs.sfu.ca/people/GradStudents/pwfong/personal/JVM/pass1/>The Mysterious Pass One, first draft, September 2, 1997</A>.)
+ * </BR>
+ * However, most of this is done by parsing a class file or generating a class file into BCEL's internal data structure.
+ * <B>Therefore, all that is really done here is look up the class file from BCEL's repository.</B>
+ * This is also motivated by the fact that some omitted things
+ * (like the check for extra bytes at the end of the class file) are handy when actually using BCEL to repair a class file (otherwise you would not be
+ * able to load it into BCEL).
+ *
+ * @see org.apache.bcel.Repository
+ */
+ public VerificationResult do_verify(){
+ JavaClass jc;
+ try{
+ jc = getJavaClass(); //loads in the class file if not already done.
+
+ if (jc != null){
+ /* If we find more constraints to check, we should do this in an own method. */
+ if (! myOwner.getClassName().equals(jc.getClassName())){
+ // This should maybe caught by BCEL: In case of renamed .class files we get wrong
+ // JavaClass objects here.
+ throw new LoadingException("Wrong name: the internal name of the .class file '"+jc.getClassName()+"' does not match the file's name '"+myOwner.getClassName()+"'.");
+ }
+ }
+
+ }
+ catch(LoadingException e){
+ return new VerificationResult(VerificationResult.VERIFIED_REJECTED, e.getMessage());
+ }
+ catch(ClassFormatError e){
+ // BCEL sometimes is a little harsh describing exceptual situations.
+ return new VerificationResult(VerificationResult.VERIFIED_REJECTED, e.getMessage());
+ }
+ catch(RuntimeException e){
+ // BCEL does not catch every possible RuntimeException; e.g. if
+ // a constant pool index is referenced that does not exist.
+ return new VerificationResult(VerificationResult.VERIFIED_REJECTED, "Parsing via BCEL did not succeed. "+e.getClass().getName()+" occured:\n"+Utility.getStackTrace(e));
+ }
+
+ if (jc != null){
+ return VerificationResult.VR_OK;
+ }
+ else{
+ //TODO: Maybe change Repository's behaviour to throw a LoadingException instead of just returning "null"
+ // if a class file cannot be found or in another way be looked up.
+ return new VerificationResult(VerificationResult.VERIFIED_REJECTED, "Repository.lookup() failed. FILE NOT FOUND?");
+ }
+ }
+
+ /**
+ * Currently this returns an empty array of String.
+ * One could parse the error messages of BCEL
+ * (written to java.lang.System.err) when loading
+ * a class file such as detecting unknown attributes
+ * or trailing garbage at the end of a class file.
+ * However, Markus Dahm does not like the idea so this
+ * method is currently useless and therefore marked as
+ * <B>TODO</B>.
+ */
+ public String[] getMessages(){
+ // This method is only here to override the javadoc-comment.
+ return super.getMessages();
+ }
+
+}
diff --git a/src/java/org/apache/bcel/verifier/statics/Pass2Verifier.java b/src/java/org/apache/bcel/verifier/statics/Pass2Verifier.java
new file mode 100644
index 00000000..7c41d1fb
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/statics/Pass2Verifier.java
@@ -0,0 +1,1334 @@
+package org.apache.bcel.verifier.statics;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import org.apache.bcel.Repository;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.classfile.DescendingVisitor; // Use _this_ one!
+import org.apache.bcel.classfile.EmptyVisitor; // Use _this_ one!
+import org.apache.bcel.classfile.Visitor; // Use _this_ one!
+import org.apache.bcel.generic.*;
+import org.apache.bcel.verifier.*;
+import org.apache.bcel.verifier.exc.*;
+import java.util.HashMap;
+import java.util.HashSet;
+
+/**
+ * This PassVerifier verifies a class file according to
+ * pass 2 as described in The Java Virtual Machine
+ * Specification, 2nd edition.
+ * More detailed information is to be found at the do_verify()
+ * method's documentation.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ * @see #do_verify()
+ */
+public final class Pass2Verifier extends PassVerifier implements Constants{
+
+ /**
+ * The LocalVariableInfo instances used by Pass3bVerifier.
+ * localVariablesInfos[i] denotes the information for the
+ * local variables of method number i in the
+ * JavaClass this verifier operates on.
+ */
+ private LocalVariablesInfo[] localVariablesInfos;
+
+ /** The Verifier that created this. */
+ private Verifier myOwner;
+
+ /**
+ * Should only be instantiated by a Verifier.
+ *
+ * @see Verifier
+ */
+ public Pass2Verifier(Verifier owner){
+ myOwner = owner;
+ }
+
+ /**
+ * Returns a LocalVariablesInfo object containing information
+ * about the usage of the local variables in the Code attribute
+ * of the said method or <B>null</B> if the class file this
+ * Pass2Verifier operates on could not be pass-2-verified correctly.
+ * The method number method_nr is the method you get using
+ * <B>Repository.lookupClass(myOwner.getClassname()).getMethods()[method_nr];</B>.
+ * You should not add own information. Leave that to JustIce.
+ */
+ public LocalVariablesInfo getLocalVariablesInfo(int method_nr){
+ if (this.verify() != VerificationResult.VR_OK) return null; // It's cached, don't worry.
+ if (method_nr < 0 || method_nr >= localVariablesInfos.length){
+ throw new AssertionViolatedException("Method number out of range.");
+ }
+ return localVariablesInfos[method_nr];
+ }
+
+ /**
+ * Pass 2 is the pass where static properties of the
+ * class file are checked without looking into "Code"
+ * arrays of methods.
+ * This verification pass is usually invoked when
+ * a class is resolved; and it may be possible that
+ * this verification pass has to load in other classes
+ * such as superclasses or implemented interfaces.
+ * Therefore, Pass 1 is run on them.<BR>
+ * Note that most referenced classes are <B>not</B> loaded
+ * in for verification or for an existance check by this
+ * pass; only the syntactical correctness of their names
+ * and descriptors (a.k.a. signatures) is checked.<BR>
+ * Very few checks that conceptually belong here
+ * are delayed until pass 3a in JustIce. JustIce does
+ * not only check for syntactical correctness but also
+ * for semantical sanity - therefore it needs access to
+ * the "Code" array of methods in a few cases. Please
+ * see the pass 3a documentation, too.
+ *
+ * @see org.apache.bcel.verifier.statics.Pass3aVerifier
+ */
+ public VerificationResult do_verify(){
+ VerificationResult vr1 = myOwner.doPass1();
+ if (vr1.equals(VerificationResult.VR_OK)){
+
+ // For every method, we could have information about the local variables out of LocalVariableTable attributes of
+ // the Code attributes.
+ localVariablesInfos = new LocalVariablesInfo[Repository.lookupClass(myOwner.getClassName()).getMethods().length];
+
+ VerificationResult vr = VerificationResult.VR_OK; // default.
+ try{
+ constant_pool_entries_satisfy_static_constraints();
+ field_and_method_refs_are_valid();
+ every_class_has_an_accessible_superclass();
+ final_methods_are_not_overridden();
+ }
+ catch (ClassConstraintException cce){
+ vr = new VerificationResult(VerificationResult.VERIFIED_REJECTED, cce.getMessage());
+ }
+ return vr;
+ }
+ else
+ return VerificationResult.VR_NOTYET;
+ }
+
+ /**
+ * Ensures that every class has a super class and that
+ * <B>final</B> classes are not subclassed.
+ * This means, the class this Pass2Verifier operates
+ * on has proper super classes (transitively) up to
+ * java.lang.Object.
+ * The reason for really loading (and Pass1-verifying)
+ * all of those classes here is that we need them in
+ * Pass2 anyway to verify no final methods are overridden
+ * (that could be declared anywhere in the ancestor hierarchy).
+ *
+ * @throws ClassConstraintException otherwise.
+ */
+ private void every_class_has_an_accessible_superclass(){
+ HashSet hs = new HashSet(); // save class names to detect circular inheritance
+ JavaClass jc = Repository.lookupClass(myOwner.getClassName());
+ int supidx = -1;
+
+ while (supidx != 0){
+ supidx = jc.getSuperclassNameIndex();
+
+ if (supidx == 0){
+ if (jc != Repository.lookupClass(Type.OBJECT.getClassName())){
+ throw new ClassConstraintException("Superclass of '"+jc.getClassName()+"' missing but not "+Type.OBJECT.getClassName()+" itself!");
+ }
+ }
+ else{
+ String supername = jc.getSuperclassName();
+ if (! hs.add(supername)){ // If supername already is in the list
+ throw new ClassConstraintException("Circular superclass hierarchy detected.");
+ }
+ Verifier v = VerifierFactory.getVerifier(supername);
+ VerificationResult vr = v.doPass1();
+
+ if (vr != VerificationResult.VR_OK){
+ throw new ClassConstraintException("Could not load in ancestor class '"+supername+"'.");
+ }
+ jc = Repository.lookupClass(supername);
+
+ if (jc.isFinal()){
+ throw new ClassConstraintException("Ancestor class '"+supername+"' has the FINAL access modifier and must therefore not be subclassed.");
+ }
+ }
+ }
+ }
+
+ /**
+ * Ensures that <B>final</B> methods are not overridden.
+ * <B>Precondition to run this method:
+ * constant_pool_entries_satisfy_static_constraints() and
+ * every_class_has_an_accessible_superclass() have to be invoked before
+ * (in that order).</B>
+ *
+ * @throws ClassConstraintException otherwise.
+ * @see #constant_pool_entries_satisfy_static_constraints()
+ * @see #every_class_has_an_accessible_superclass()
+ */
+ private void final_methods_are_not_overridden(){
+ HashMap hashmap = new HashMap();
+ JavaClass jc = Repository.lookupClass(myOwner.getClassName());
+
+ int supidx = -1;
+ while (supidx != 0){
+ supidx = jc.getSuperclassNameIndex();
+
+ ConstantPoolGen cpg = new ConstantPoolGen(jc.getConstantPool());
+ Method[] methods = jc.getMethods();
+ for (int i=0; i<methods.length; i++){
+ String name_and_sig = (methods[i].getName()+methods[i].getSignature());
+
+ if (hashmap.containsKey(name_and_sig)){
+ if (methods[i].isFinal()){
+ throw new ClassConstraintException("Method '"+name_and_sig+"' in class '"+hashmap.get(name_and_sig)+"' overrides the final (not-overridable) definition in class '"+jc.getClassName()+"'.");
+ }
+ else{
+ if (!methods[i].isStatic()){ // static methods don't inherit
+ hashmap.put(name_and_sig, jc.getClassName());
+ }
+ }
+ }
+ else{
+ if (!methods[i].isStatic()){ // static methods don't inherit
+ hashmap.put(name_and_sig, jc.getClassName());
+ }
+ }
+ }
+
+ jc = Repository.lookupClass(jc.getSuperclassName()); // Well, for OBJECT this returns OBJECT so it works (could return anything but must not throw an Exception).
+ }
+
+ }
+
+ /**
+ * Ensures that the constant pool entries satisfy the static constraints
+ * as described in The Java Virtual Machine Specification, 2nd Edition.
+ *
+ * @throws ClassConstraintException otherwise.
+ */
+ private void constant_pool_entries_satisfy_static_constraints(){
+ // Most of the consistency is handled internally by BCEL; here
+ // we only have to verify if the indices of the constants point
+ // to constants of the appropriate type and such.
+ JavaClass jc = Repository.lookupClass(myOwner.getClassName());
+ new CPESSC_Visitor(jc); // constructor implicitely traverses jc
+ }
+
+ /**
+ * A Visitor class that ensures the constant pool satisfies the static
+ * constraints.
+ * The visitXXX() methods throw ClassConstraintException instances otherwise.
+ *
+ * @see #constant_pool_entries_satisfy_static_constraints()
+ */
+ private class CPESSC_Visitor extends org.apache.bcel.classfile.EmptyVisitor implements Visitor{
+ private Class CONST_Class;
+ private Class CONST_Fieldref;
+ private Class CONST_Methodref;
+ private Class CONST_InterfaceMethodref;
+ private Class CONST_String;
+ private Class CONST_Integer;
+ private Class CONST_Float;
+ private Class CONST_Long;
+ private Class CONST_Double;
+ private Class CONST_NameAndType;
+ private Class CONST_Utf8;
+
+ private final JavaClass jc;
+ private final ConstantPool cp; // ==jc.getConstantPool() -- only here to save typing work and computing power.
+ private final int cplen; // == cp.getLength() -- to save computing power.
+ private DescendingVisitor carrier;
+
+ private HashSet field_names = new HashSet();
+ private HashSet field_names_and_desc = new HashSet();
+ private HashSet method_names_and_desc = new HashSet();
+
+ private CPESSC_Visitor(JavaClass _jc){
+ jc = _jc;
+ cp = _jc.getConstantPool();
+ cplen = cp.getLength();
+
+ CONST_Class = org.apache.bcel.classfile.ConstantClass.class;
+ CONST_Fieldref = org.apache.bcel.classfile.ConstantFieldref.class;
+ CONST_Methodref = org.apache.bcel.classfile.ConstantMethodref.class;
+ CONST_InterfaceMethodref = org.apache.bcel.classfile.ConstantInterfaceMethodref.class;
+ CONST_String = org.apache.bcel.classfile.ConstantString.class;
+ CONST_Integer = org.apache.bcel.classfile.ConstantInteger.class;
+ CONST_Float = org.apache.bcel.classfile.ConstantFloat.class;
+ CONST_Long = org.apache.bcel.classfile.ConstantLong.class;
+ CONST_Double = org.apache.bcel.classfile.ConstantDouble.class;
+ CONST_NameAndType = org.apache.bcel.classfile.ConstantNameAndType.class;
+ CONST_Utf8 = org.apache.bcel.classfile.ConstantUtf8.class;
+
+ carrier = new DescendingVisitor(_jc, this);
+ carrier.visit();
+ }
+
+ private void checkIndex(Node referrer, int index, Class shouldbe){
+ if ((index < 0) || (index >= cplen)){
+ throw new ClassConstraintException("Invalid index '"+index+"' used by '"+tostring(referrer)+"'.");
+ }
+ Constant c = cp.getConstant(index);
+ if (! shouldbe.isInstance(c)){
+ String isnot = shouldbe.toString().substring(shouldbe.toString().lastIndexOf(".")+1); //Cut all before last "."
+ throw new ClassCastException("Illegal constant '"+tostring(c)+"' at index '"+index+"'. '"+tostring(referrer)+"' expects a '"+shouldbe+"'.");
+ }
+ }
+ ///////////////////////////////////////
+ // ClassFile structure (vmspec2 4.1) //
+ ///////////////////////////////////////
+ public void visitJavaClass(JavaClass obj){
+ Attribute[] atts = obj.getAttributes();
+ boolean foundSourceFile = false;
+ boolean foundInnerClasses = false;
+
+ // Is there an InnerClass referenced?
+ // This is a costly check; existing verifiers don't do it!
+ boolean hasInnerClass = new InnerClassDetector(jc).innerClassReferenced();
+
+ for (int i=0; i<atts.length; i++){
+ if ((! (atts[i] instanceof SourceFile)) &&
+ (! (atts[i] instanceof Deprecated)) &&
+ (! (atts[i] instanceof InnerClasses)) &&
+ (! (atts[i] instanceof Synthetic))){
+ addMessage("Attribute '"+tostring(atts[i])+"' as an attribute of the ClassFile structure '"+tostring(obj)+"' is unknown and will therefore be ignored.");
+ }
+
+ if (atts[i] instanceof SourceFile){
+ if (foundSourceFile == false) foundSourceFile = true;
+ else throw new ClassConstraintException("A ClassFile structure (like '"+tostring(obj)+"') may have no more than one SourceFile attribute."); //vmspec2 4.7.7
+ }
+
+ if (atts[i] instanceof InnerClasses){
+ if (foundInnerClasses == false) foundInnerClasses = true;
+ else{
+ if (hasInnerClass){
+ throw new ClassConstraintException("A Classfile structure (like '"+tostring(obj)+"') must have exactly one InnerClasses attribute if at least one Inner Class is referenced (which is the case). More than one InnerClasses attribute was found.");
+ }
+ }
+ if (!hasInnerClass){
+ addMessage("No referenced Inner Class found, but InnerClasses attribute '"+tostring(atts[i])+"' found. Strongly suggest removal of that attribute.");
+ }
+ }
+
+ }
+ if (hasInnerClass && !foundInnerClasses){
+ //throw new ClassConstraintException("A Classfile structure (like '"+tostring(obj)+"') must have exactly one InnerClasses attribute if at least one Inner Class is referenced (which is the case). No InnerClasses attribute was found.");
+ //vmspec2, page 125 says it would be a constraint: but existing verifiers
+ //don't check it and javac doesn't satisfy it when it comes to anonymous
+ //inner classes
+ addMessage("A Classfile structure (like '"+tostring(obj)+"') must have exactly one InnerClasses attribute if at least one Inner Class is referenced (which is the case). No InnerClasses attribute was found.");
+ }
+ }
+ /////////////////////////////
+ // CONSTANTS (vmspec2 4.4) //
+ /////////////////////////////
+ public void visitConstantClass(ConstantClass obj){
+ if (obj.getTag() != Constants.CONSTANT_Class){
+ throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'.");
+ }
+ checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
+
+ }
+ public void visitConstantFieldref(ConstantFieldref obj){
+ if (obj.getTag() != Constants.CONSTANT_Fieldref){
+ throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'.");
+ }
+ checkIndex(obj, obj.getClassIndex(), CONST_Class);
+ checkIndex(obj, obj.getNameAndTypeIndex(), CONST_NameAndType);
+ }
+ public void visitConstantMethodref(ConstantMethodref obj){
+ if (obj.getTag() != Constants.CONSTANT_Methodref){
+ throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'.");
+ }
+ checkIndex(obj, obj.getClassIndex(), CONST_Class);
+ checkIndex(obj, obj.getNameAndTypeIndex(), CONST_NameAndType);
+ }
+ public void visitConstantInterfaceMethodref(ConstantInterfaceMethodref obj){
+ if (obj.getTag() != Constants.CONSTANT_InterfaceMethodref){
+ throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'.");
+ }
+ checkIndex(obj, obj.getClassIndex(), CONST_Class);
+ checkIndex(obj, obj.getNameAndTypeIndex(), CONST_NameAndType);
+ }
+ public void visitConstantString(ConstantString obj){
+ if (obj.getTag() != Constants.CONSTANT_String){
+ throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'.");
+ }
+ checkIndex(obj, obj.getStringIndex(), CONST_Utf8);
+ }
+ public void visitConstantInteger(ConstantInteger obj){
+ if (obj.getTag() != Constants.CONSTANT_Integer){
+ throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'.");
+ }
+ // no indices to check
+ }
+ public void visitConstantFloat(ConstantFloat obj){
+ if (obj.getTag() != Constants.CONSTANT_Float){
+ throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'.");
+ }
+ //no indices to check
+ }
+ public void visitConstantLong(ConstantLong obj){
+ if (obj.getTag() != Constants.CONSTANT_Long){
+ throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'.");
+ }
+ //no indices to check
+ }
+ public void visitConstantDouble(ConstantDouble obj){
+ if (obj.getTag() != Constants.CONSTANT_Double){
+ throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'.");
+ }
+ //no indices to check
+ }
+ public void visitConstantNameAndType(ConstantNameAndType obj){
+ if (obj.getTag() != Constants.CONSTANT_NameAndType){
+ throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'.");
+ }
+ checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
+ //checkIndex(obj, obj.getDescriptorIndex(), CONST_Utf8); //inconsistently named in BCEL, see below.
+ checkIndex(obj, obj.getSignatureIndex(), CONST_Utf8);
+ }
+ public void visitConstantUtf8(ConstantUtf8 obj){
+ if (obj.getTag() != Constants.CONSTANT_Utf8){
+ throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'.");
+ }
+ //no indices to check
+ }
+ //////////////////////////
+ // FIELDS (vmspec2 4.5) //
+ //////////////////////////
+ public void visitField(Field obj){
+
+ if (jc.isClass()){
+ int maxone=0;
+ if (obj.isPrivate()) maxone++;
+ if (obj.isProtected()) maxone++;
+ if (obj.isPublic()) maxone++;
+ if (maxone > 1){
+ throw new ClassConstraintException("Field '"+tostring(obj)+"' must only have at most one of its ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC modifiers set.");
+ }
+
+ if (obj.isFinal() && obj.isVolatile()){
+ throw new ClassConstraintException("Field '"+tostring(obj)+"' must only have at most one of its ACC_FINAL, ACC_VOLATILE modifiers set.");
+ }
+ }
+ else{ // isInterface!
+ if (!obj.isPublic()){
+ throw new ClassConstraintException("Interface field '"+tostring(obj)+"' must have the ACC_PUBLIC modifier set but hasn't!");
+ }
+ if (!obj.isStatic()){
+ throw new ClassConstraintException("Interface field '"+tostring(obj)+"' must have the ACC_STATIC modifier set but hasn't!");
+ }
+ if (!obj.isFinal()){
+ throw new ClassConstraintException("Interface field '"+tostring(obj)+"' must have the ACC_FINAL modifier set but hasn't!");
+ }
+ }
+
+ if ((obj.getAccessFlags() & ~(ACC_PUBLIC|ACC_PRIVATE|ACC_PROTECTED|ACC_STATIC|ACC_FINAL|ACC_VOLATILE|ACC_TRANSIENT)) > 0){
+ addMessage("Field '"+tostring(obj)+"' has access flag(s) other than ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_VOLATILE, ACC_TRANSIENT set (ignored).");
+ }
+
+ checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
+
+ String name = obj.getName();
+ if (! validFieldName(name)){
+ throw new ClassConstraintException("Field '"+tostring(obj)+"' has illegal name '"+obj.getName()+"'.");
+ }
+
+ // A descriptor is often named signature in BCEL
+ checkIndex(obj, obj.getSignatureIndex(), CONST_Utf8);
+
+ String sig = ((ConstantUtf8) (cp.getConstant(obj.getSignatureIndex()))).getBytes(); // Field or Method signature(=descriptor)
+
+ try{
+ Type t = Type.getType(sig);
+ }
+ catch (ClassFormatError cfe){ // sometimes BCEL is a little harsh describing exceptional situations.
+ throw new ClassConstraintException("Illegal descriptor (==signature) '"+sig+"' used by '"+tostring(obj)+"'.");
+ }
+
+ String nameanddesc = (name+sig);
+ if (field_names_and_desc.contains(nameanddesc)){
+ throw new ClassConstraintException("No two fields (like '"+tostring(obj)+"') are allowed have same names and descriptors!");
+ }
+ if (field_names.contains(name)){
+ addMessage("More than one field of name '"+name+"' detected (but with different type descriptors). This is very unusual.");
+ }
+ field_names_and_desc.add(nameanddesc);
+ field_names.add(name);
+
+ Attribute[] atts = obj.getAttributes();
+ for (int i=0; i<atts.length; i++){
+ if ((! (atts[i] instanceof ConstantValue)) &&
+ (! (atts[i] instanceof Synthetic)) &&
+ (! (atts[i] instanceof Deprecated))){
+ addMessage("Attribute '"+tostring(atts[i])+"' as an attribute of Field '"+tostring(obj)+"' is unknown and will therefore be ignored.");
+ }
+ if (! (atts[i] instanceof ConstantValue)){
+ addMessage("Attribute '"+tostring(atts[i])+"' as an attribute of Field '"+tostring(obj)+"' is not a ConstantValue and is therefore only of use for debuggers and such.");
+ }
+ }
+ }
+ ///////////////////////////
+ // METHODS (vmspec2 4.6) //
+ ///////////////////////////
+ public void visitMethod(Method obj){
+
+ checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
+
+ String name = obj.getName();
+ if (! validMethodName(name, true)){
+ throw new ClassConstraintException("Method '"+tostring(obj)+"' has illegal name '"+name+"'.");
+ }
+
+ // A descriptor is often named signature in BCEL
+ checkIndex(obj, obj.getSignatureIndex(), CONST_Utf8);
+
+ String sig = ((ConstantUtf8) (cp.getConstant(obj.getSignatureIndex()))).getBytes(); // Method's signature(=descriptor)
+
+ Type t;
+ Type[] ts; // needed below the try block.
+ try{
+ t = Type.getReturnType(sig);
+ ts = Type.getArgumentTypes(sig);
+ }
+ catch (ClassFormatError cfe){
+ // Well, BCEL sometimes is a little harsh describing exceptional situations.
+ throw new ClassConstraintException("Illegal descriptor (==signature) '"+sig+"' used by Method '"+tostring(obj)+"'.");
+ }
+
+ // Check if referenced objects exist.
+ Type act = t;
+ if (act instanceof ArrayType) act = ((ArrayType) act).getBasicType();
+ if (act instanceof ObjectType){
+ Verifier v = VerifierFactory.getVerifier( ((ObjectType) act).getClassName() );
+ VerificationResult vr = v.doPass1();
+ if (vr != VerificationResult.VR_OK) {
+ throw new ClassConstraintException("Method '"+tostring(obj)+"' has a return type that does not pass verification pass 1: '"+vr+"'.");
+ }
+ }
+
+ for (int i=0; i<ts.length; i++){
+ act = ts[i];
+ if (act instanceof ArrayType) act = ((ArrayType) act).getBasicType();
+ if (act instanceof ObjectType){
+ Verifier v = VerifierFactory.getVerifier( ((ObjectType) act).getClassName() );
+ VerificationResult vr = v.doPass1();
+ if (vr != VerificationResult.VR_OK) {
+ throw new ClassConstraintException("Method '"+tostring(obj)+"' has an argument type that does not pass verification pass 1: '"+vr+"'.");
+ }
+ }
+ }
+
+ // Nearly forgot this! Funny return values are allowed, but a non-empty arguments list makes a different method out of it!
+ if (name.equals(STATIC_INITIALIZER_NAME) && (ts.length != 0)){
+ throw new ClassConstraintException("Method '"+tostring(obj)+"' has illegal name '"+name+"'. It's name resembles the class or interface initialization method which it isn't because of its arguments (==descriptor).");
+ }
+
+ if (jc.isClass()){
+ int maxone=0;
+ if (obj.isPrivate()) maxone++;
+ if (obj.isProtected()) maxone++;
+ if (obj.isPublic()) maxone++;
+ if (maxone > 1){
+ throw new ClassConstraintException("Method '"+tostring(obj)+"' must only have at most one of its ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC modifiers set.");
+ }
+
+ if (obj.isAbstract()){
+ if (obj.isFinal()) throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_FINAL modifier set.");
+ if (obj.isNative()) throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_NATIVE modifier set.");
+ if (obj.isPrivate()) throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_PRIVATE modifier set.");
+ if (obj.isStatic()) throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_STATIC modifier set.");
+ if (obj.isStrictfp()) throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_STRICT modifier set.");
+ if (obj.isSynchronized()) throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_SYNCHRONIZED modifier set.");
+ }
+ }
+ else{ // isInterface!
+ if (!name.equals(STATIC_INITIALIZER_NAME)){//vmspec2, p.116, 2nd paragraph
+ if (!obj.isPublic()){
+ throw new ClassConstraintException("Interface method '"+tostring(obj)+"' must have the ACC_PUBLIC modifier set but hasn't!");
+ }
+ if (!obj.isAbstract()){
+ throw new ClassConstraintException("Interface method '"+tostring(obj)+"' must have the ACC_STATIC modifier set but hasn't!");
+ }
+ if ( obj.isPrivate() ||
+ obj.isProtected() ||
+ obj.isStatic() ||
+ obj.isFinal() ||
+ obj.isSynchronized() ||
+ obj.isNative() ||
+ obj.isStrictfp() ){
+ throw new ClassConstraintException("Interface method '"+tostring(obj)+"' must not have any of the ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT, ACC_STRICT modifiers set.");
+ }
+ }
+ }
+
+ // A specific instance initialization method... (vmspec2,Page 116).
+ if (name.equals(CONSTRUCTOR_NAME)){
+ //..may have at most one of ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC set: is checked above.
+ //..may also have ACC_STRICT set, but none of the other flags in table 4.5 (vmspec2, page 115)
+ if ( obj.isStatic() ||
+ obj.isFinal() ||
+ obj.isSynchronized() ||
+ obj.isNative() ||
+ obj.isAbstract() ){
+ throw new ClassConstraintException("Instance initialization method '"+tostring(obj)+"' must not have any of the ACC_STATIC, ACC_FINAL, ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT modifiers set.");
+ }
+ }
+
+ // Class and interface initialization methods...
+ if (name.equals(STATIC_INITIALIZER_NAME)){
+ if ((obj.getAccessFlags() & (~ACC_STRICT)) > 0){
+ addMessage("Class or interface initialization method '"+tostring(obj)+"' has superfluous access modifier(s) set: everything but ACC_STRICT is ignored.");
+ }
+ if (obj.isAbstract()){
+ throw new ClassConstraintException("Class or interface initialization method '"+tostring(obj)+"' must not be abstract. This contradicts the Java Language Specification, Second Edition (which omits this constraint) but is common practice of existing verifiers.");
+ }
+ }
+
+ if ((obj.getAccessFlags() & ~(ACC_PUBLIC|ACC_PRIVATE|ACC_PROTECTED|ACC_STATIC|ACC_FINAL|ACC_SYNCHRONIZED|ACC_NATIVE|ACC_ABSTRACT|ACC_STRICT)) > 0){
+ addMessage("Method '"+tostring(obj)+"' has access flag(s) other than ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT, ACC_STRICT set (ignored).");
+ }
+
+ String nameanddesc = (name+sig);
+ if (method_names_and_desc.contains(nameanddesc)){
+ throw new ClassConstraintException("No two methods (like '"+tostring(obj)+"') are allowed have same names and desciptors!");
+ }
+ method_names_and_desc.add(nameanddesc);
+
+ Attribute[] atts = obj.getAttributes();
+ int num_code_atts = 0;
+ for (int i=0; i<atts.length; i++){
+ if ((! (atts[i] instanceof Code)) &&
+ (! (atts[i] instanceof ExceptionTable)) &&
+ (! (atts[i] instanceof Synthetic)) &&
+ (! (atts[i] instanceof Deprecated))){
+ addMessage("Attribute '"+tostring(atts[i])+"' as an attribute of Method '"+tostring(obj)+"' is unknown and will therefore be ignored.");
+ }
+ if ((! (atts[i] instanceof Code)) &&
+ (! (atts[i] instanceof ExceptionTable))){
+ addMessage("Attribute '"+tostring(atts[i])+"' as an attribute of Method '"+tostring(obj)+"' is neither Code nor Exceptions and is therefore only of use for debuggers and such.");
+ }
+ if ((atts[i] instanceof Code) && (obj.isNative() || obj.isAbstract())){
+ throw new ClassConstraintException("Native or abstract methods like '"+tostring(obj)+"' must not have a Code attribute like '"+tostring(atts[i])+"'."); //vmspec2 page120, 4.7.3
+ }
+ if (atts[i] instanceof Code) num_code_atts++;
+ }
+ if ( !obj.isNative() && !obj.isAbstract() && num_code_atts != 1){
+ throw new ClassConstraintException("Non-native, non-abstract methods like '"+tostring(obj)+"' must have exactly one Code attribute (found: "+num_code_atts+").");
+ }
+ }
+ ///////////////////////////////////////////////////////
+ // ClassFile-structure-ATTRIBUTES (vmspec2 4.1, 4.7) //
+ ///////////////////////////////////////////////////////
+ public void visitSourceFile(SourceFile obj){//vmspec2 4.7.7
+
+ // zero or one SourceFile attr per ClassFile: see visitJavaClass()
+
+ checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
+
+ String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getBytes();
+ if (! name.equals("SourceFile")){
+ throw new ClassConstraintException("The SourceFile attribute '"+tostring(obj)+"' is not correctly named 'SourceFile' but '"+name+"'.");
+ }
+
+ checkIndex(obj, obj.getSourceFileIndex(), CONST_Utf8);
+
+ String sourcefilename = ((ConstantUtf8) cp.getConstant(obj.getSourceFileIndex())).getBytes(); //==obj.getSourceFileName() ?
+ String sourcefilenamelc = sourcefilename.toLowerCase();
+
+ if ( (sourcefilename.indexOf('/') != -1) ||
+ (sourcefilename.indexOf('\\') != -1) ||
+ (sourcefilename.indexOf(':') != -1) ||
+ (sourcefilenamelc.lastIndexOf(".java") == -1) ){
+ addMessage("SourceFile attribute '"+tostring(obj)+"' has a funny name: remember not to confuse certain parsers working on javap's output. Also, this name ('"+sourcefilename+"') is considered an unqualified (simple) file name only.");
+ }
+ }
+ public void visitDeprecated(Deprecated obj){//vmspec2 4.7.10
+ checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
+
+ String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getBytes();
+ if (! name.equals("Deprecated")){
+ throw new ClassConstraintException("The Deprecated attribute '"+tostring(obj)+"' is not correctly named 'Deprecated' but '"+name+"'.");
+ }
+ }
+ public void visitSynthetic(Synthetic obj){//vmspec2 4.7.6
+ checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
+ String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getBytes();
+ if (! name.equals("Synthetic")){
+ throw new ClassConstraintException("The Synthetic attribute '"+tostring(obj)+"' is not correctly named 'Synthetic' but '"+name+"'.");
+ }
+ }
+ public void visitInnerClasses(InnerClasses obj){//vmspec2 4.7.5
+
+ // exactly one InnerClasses attr per ClassFile if some inner class is refernced: see visitJavaClass()
+
+ checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
+
+ String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getBytes();
+ if (! name.equals("InnerClasses")){
+ throw new ClassConstraintException("The InnerClasses attribute '"+tostring(obj)+"' is not correctly named 'InnerClasses' but '"+name+"'.");
+ }
+
+ InnerClass[] ics = obj.getInnerClasses();
+
+ for (int i=0; i<ics.length; i++){
+ checkIndex(obj, ics[i].getInnerClassIndex(), CONST_Class);
+ int outer_idx = ics[i].getOuterClassIndex();
+ if (outer_idx != 0){
+ checkIndex(obj, outer_idx, CONST_Class);
+ }
+ int innername_idx = ics[i].getInnerNameIndex();
+ if (innername_idx != 0){
+ checkIndex(obj, innername_idx, CONST_Utf8);
+ }
+ int acc = ics[i].getInnerAccessFlags();
+ acc = acc & (~ (ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED | ACC_STATIC | ACC_FINAL | ACC_INTERFACE | ACC_ABSTRACT));
+ if (acc != 0){
+ addMessage("Unknown access flag for inner class '"+tostring(ics[i])+"' set (InnerClasses attribute '"+tostring(obj)+"').");
+ }
+ }
+ // Semantical consistency is not yet checked by Sun, see vmspec2 4.7.5.
+ // [marked TODO in JustIce]
+ }
+ ////////////////////////////////////////////////////////
+ // field_info-structure-ATTRIBUTES (vmspec2 4.5, 4.7) //
+ ////////////////////////////////////////////////////////
+ public void visitConstantValue(ConstantValue obj){//vmspec2 4.7.2
+ // Despite its name, this really is an Attribute,
+ // not a constant!
+ checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
+
+ String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getBytes();
+ if (! name.equals("ConstantValue")){
+ throw new ClassConstraintException("The ConstantValue attribute '"+tostring(obj)+"' is not correctly named 'ConstantValue' but '"+name+"'.");
+ }
+
+ Object pred = carrier.predecessor();
+ if (pred instanceof Field){ //ConstantValue attributes are quite senseless if the predecessor is not a field.
+ Field f = (Field) pred;
+ // Field constraints have been checked before -- so we are safe using their type information.
+ Type field_type = Type.getType(((ConstantUtf8) (cp.getConstant(f.getSignatureIndex()))).getBytes());
+
+ int index = obj.getConstantValueIndex();
+ if ((index < 0) || (index >= cplen)){
+ throw new ClassConstraintException("Invalid index '"+index+"' used by '"+tostring(obj)+"'.");
+ }
+ Constant c = cp.getConstant(index);
+
+ if (CONST_Long.isInstance(c) && field_type.equals(Type.LONG)){
+ return;
+ }
+ if (CONST_Float.isInstance(c) && field_type.equals(Type.FLOAT)){
+ return;
+ }
+ if (CONST_Double.isInstance(c) && field_type.equals(Type.DOUBLE)){
+ return;
+ }
+ if (CONST_Integer.isInstance(c) && (field_type.equals(Type.INT) || field_type.equals(Type.SHORT) || field_type.equals(Type.CHAR) || field_type.equals(Type.BYTE) || field_type.equals(Type.BOOLEAN))){
+ return;
+ }
+ if (CONST_String.isInstance(c) && field_type.equals(Type.STRING)){
+ return;
+ }
+
+ throw new ClassConstraintException("Illegal type of ConstantValue '"+obj+"' embedding Constant '"+c+"'. It is referenced by field '"+tostring(f)+"' expecting a different type: '"+field_type+"'.");
+ }
+ }
+ // SYNTHETIC: see above
+ // DEPRECATED: see above
+ /////////////////////////////////////////////////////////
+ // method_info-structure-ATTRIBUTES (vmspec2 4.6, 4.7) //
+ /////////////////////////////////////////////////////////
+ public void visitCode(Code obj){//vmspec2 4.7.3
+ // No code attribute allowed for native or abstract methods: see visitMethod(Method).
+ // Code array constraints are checked in Pass3 (3a and 3b).
+
+ checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
+
+ String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getBytes();
+ if (! name.equals("Code")){
+ throw new ClassConstraintException("The Code attribute '"+tostring(obj)+"' is not correctly named 'Code' but '"+name+"'.");
+ }
+
+ Method m = null; // satisfy compiler
+ if (!(carrier.predecessor() instanceof Method)){
+ addMessage("Code attribute '"+tostring(obj)+"' is not declared in a method_info structure but in '"+carrier.predecessor()+"'. Ignored.");
+ return;
+ }
+ else{
+ m = (Method) carrier.predecessor(); // we can assume this method was visited before;
+ // i.e. the data consistency was verified.
+ }
+
+ if (obj.getCode().length == 0){
+ throw new ClassConstraintException("Code array of Code attribute '"+tostring(obj)+"' (method '"+m+"') must not be empty.");
+ }
+
+ //In JustIce, the check for correct offsets into the code array is delayed to Pass 3a.
+ CodeException[] exc_table = obj.getExceptionTable();
+ for (int i=0; i<exc_table.length; i++){
+ int exc_index = exc_table[i].getCatchType();
+ if (exc_index != 0){ // if 0, it catches all Throwables
+ checkIndex(obj, exc_index, CONST_Class);
+ ConstantClass cc = (ConstantClass) (cp.getConstant(exc_index));
+ checkIndex(cc, cc.getNameIndex(), CONST_Utf8); // cannot be sure this ConstantClass has already been visited (checked)!
+ String cname = ((ConstantUtf8) cp.getConstant(cc.getNameIndex())).getBytes().replace('/','.');
+
+ Verifier v = VerifierFactory.getVerifier(cname);
+ VerificationResult vr = v.doPass1();
+
+ if (vr != VerificationResult.VR_OK){
+ throw new ClassConstraintException("Code attribute '"+tostring(obj)+"' (method '"+m+"') has an exception_table entry '"+tostring(exc_table[i])+"' that references '"+cname+"' as an Exception but it does not pass verification pass 1: "+vr);
+ }
+ else{
+ // We cannot safely trust any other "instanceof" mechanism. We need to transitively verify
+ // the ancestor hierarchy.
+ JavaClass e = Repository.lookupClass(cname);
+ JavaClass t = Repository.lookupClass(Type.THROWABLE.getClassName());
+ JavaClass o = Repository.lookupClass(Type.OBJECT.getClassName());
+ while (e != o){
+ if (e == t) break; // It's a subclass of Throwable, OKAY, leave.
+
+ v = VerifierFactory.getVerifier(e.getSuperclassName());
+ vr = v.doPass1();
+ if (vr != VerificationResult.VR_OK){
+ throw new ClassConstraintException("Code attribute '"+tostring(obj)+"' (method '"+m+"') has an exception_table entry '"+tostring(exc_table[i])+"' that references '"+cname+"' as an Exception but '"+e.getSuperclassName()+"' in the ancestor hierachy does not pass verification pass 1: "+vr);
+ }
+ else{
+ e = Repository.lookupClass(e.getSuperclassName());
+ }
+ }
+ if (e != t) throw new ClassConstraintException("Code attribute '"+tostring(obj)+"' (method '"+m+"') has an exception_table entry '"+tostring(exc_table[i])+"' that references '"+cname+"' as an Exception but it is not a subclass of '"+t.getClassName()+"'.");
+ }
+ }
+ }
+
+ // Create object for local variables information
+ // This is highly unelegant due to usage of the Visitor pattern.
+ // TODO: rework it.
+ int method_number = -1;
+ Method[] ms = Repository.lookupClass(myOwner.getClassName()).getMethods();
+ for (int mn=0; mn<ms.length; mn++){
+ if (m == ms[mn]){
+ method_number = mn;
+ break;
+ }
+ }
+ if (method_number < 0){ // Mmmmh. Can we be sure BCEL does not sometimes instantiate new objects?
+ throw new AssertionViolatedException("Could not find a known BCEL Method object in the corresponding BCEL JavaClass object.");
+ }
+ localVariablesInfos[method_number] = new LocalVariablesInfo(obj.getMaxLocals());
+
+ int num_of_lvt_attribs = 0;
+ // Now iterate through the attributes the Code attribute has.
+ Attribute[] atts = obj.getAttributes();
+ for (int a=0; a<atts.length; a++){
+ if ((! (atts[a] instanceof LineNumberTable)) &&
+ (! (atts[a] instanceof LocalVariableTable))){
+ addMessage("Attribute '"+tostring(atts[a])+"' as an attribute of Code attribute '"+tostring(obj)+"' (method '"+m+"') is unknown and will therefore be ignored.");
+ }
+ else{// LineNumberTable or LocalVariableTable
+ addMessage("Attribute '"+tostring(atts[a])+"' as an attribute of Code attribute '"+tostring(obj)+"' (method '"+m+"') will effectively be ignored and is only useful for debuggers and such.");
+ }
+
+ //LocalVariableTable check (partially delayed to Pass3a).
+ //Here because its easier to collect the information of the
+ //(possibly more than one) LocalVariableTables belonging to
+ //one certain Code attribute.
+ if (atts[a] instanceof LocalVariableTable){ // checks conforming to vmspec2 4.7.9
+
+ LocalVariableTable lvt = (LocalVariableTable) atts[a];
+
+ checkIndex(lvt, lvt.getNameIndex(), CONST_Utf8);
+
+ String lvtname = ((ConstantUtf8) cp.getConstant(lvt.getNameIndex())).getBytes();
+ if (! lvtname.equals("LocalVariableTable")){
+ throw new ClassConstraintException("The LocalVariableTable attribute '"+tostring(lvt)+"' is not correctly named 'LocalVariableTable' but '"+lvtname+"'.");
+ }
+
+ Code code = obj;
+ int max_locals = code.getMaxLocals();
+
+ //In JustIce, the check for correct offsets into the code array is delayed to Pass 3a.
+ LocalVariable[] localvariables = lvt.getLocalVariableTable();
+
+ for (int i=0; i<localvariables.length; i++){
+ checkIndex(lvt, localvariables[i].getNameIndex(), CONST_Utf8);
+ String localname = ((ConstantUtf8) cp.getConstant(localvariables[i].getNameIndex())).getBytes();
+ if (!validJavaIdentifier(localname)){
+ throw new ClassConstraintException("LocalVariableTable '"+tostring(lvt)+"' references a local variable by the name '"+localname+"' which is not a legal Java simple name.");
+ }
+
+ checkIndex(lvt, localvariables[i].getSignatureIndex(), CONST_Utf8);
+ String localsig = ((ConstantUtf8) (cp.getConstant(localvariables[i].getSignatureIndex()))).getBytes(); // Local signature(=descriptor)
+ Type t;
+ try{
+ t = Type.getType(localsig);
+ }
+ catch (ClassFormatError cfe){ // sometimes BCEL is a little harsh describing exceptional situations.
+ throw new ClassConstraintException("Illegal descriptor (==signature) '"+localsig+"' used by LocalVariable '"+tostring(localvariables[i])+"' referenced by '"+tostring(lvt)+"'.");
+ }
+ int localindex = localvariables[i].getIndex();
+ if ( ( (t==Type.LONG || t==Type.DOUBLE)? localindex+1:localindex) >= code.getMaxLocals()){
+ throw new ClassConstraintException("LocalVariableTable attribute '"+tostring(lvt)+"' references a LocalVariable '"+tostring(localvariables[i])+"' with an index that exceeds the surrounding Code attribute's max_locals value of '"+code.getMaxLocals()+"'.");
+ }
+
+ try{
+ localVariablesInfos[method_number].add(localindex, localname, localvariables[i].getStartPC(), localvariables[i].getLength(), t);
+ }
+ catch(LocalVariableInfoInconsistentException lviie){
+ throw new ClassConstraintException("Conflicting information in LocalVariableTable '"+tostring(lvt)+"' found in Code attribute '"+tostring(obj)+"' (method '"+tostring(m)+"'). "+lviie.getMessage());
+ }
+ }// for all local variables localvariables[i] in the LocalVariableTable attribute atts[a] END
+
+ num_of_lvt_attribs++;
+ if (num_of_lvt_attribs > obj.getMaxLocals()){
+ throw new ClassConstraintException("Number of LocalVariableTable attributes of Code attribute '"+tostring(obj)+"' (method '"+tostring(m)+"') exceeds number of local variable slots '"+obj.getMaxLocals()+"' ('There may be no more than one LocalVariableTable attribute per local variable in the Code attribute.').");
+ }
+ }// if atts[a] instanceof LocalVariableTable END
+ }// for all attributes atts[a] END
+ }// visitCode(Code) END
+
+ public void visitExceptionTable(ExceptionTable obj){//vmspec2 4.7.4
+ // incorrectly named, it's the Exceptions attribute (vmspec2 4.7.4)
+ checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
+
+ String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getBytes();
+ if (! name.equals("Exceptions")){
+ throw new ClassConstraintException("The Exceptions attribute '"+tostring(obj)+"' is not correctly named 'Exceptions' but '"+name+"'.");
+ }
+
+ int[] exc_indices = obj.getExceptionIndexTable();
+
+ for (int i=0; i<exc_indices.length; i++){
+ checkIndex(obj, exc_indices[i], CONST_Class);
+
+ ConstantClass cc = (ConstantClass) (cp.getConstant(exc_indices[i]));
+ checkIndex(cc, cc.getNameIndex(), CONST_Utf8); // cannot be sure this ConstantClass has already been visited (checked)!
+ String cname = ((ConstantUtf8) cp.getConstant(cc.getNameIndex())).getBytes().replace('/','.'); //convert internal notation on-the-fly to external notation
+
+ Verifier v = VerifierFactory.getVerifier(cname);
+ VerificationResult vr = v.doPass1();
+
+ if (vr != VerificationResult.VR_OK){
+ throw new ClassConstraintException("Exceptions attribute '"+tostring(obj)+"' references '"+cname+"' as an Exception but it does not pass verification pass 1: "+vr);
+ }
+ else{
+ // We cannot safely trust any other "instanceof" mechanism. We need to transitively verify
+ // the ancestor hierarchy.
+ JavaClass e = Repository.lookupClass(cname);
+ JavaClass t = Repository.lookupClass(Type.THROWABLE.getClassName());
+ JavaClass o = Repository.lookupClass(Type.OBJECT.getClassName());
+ while (e != o){
+ if (e == t) break; // It's a subclass of Throwable, OKAY, leave.
+
+ v = VerifierFactory.getVerifier(e.getSuperclassName());
+ vr = v.doPass1();
+ if (vr != VerificationResult.VR_OK){
+ throw new ClassConstraintException("Exceptions attribute '"+tostring(obj)+"' references '"+cname+"' as an Exception but '"+e.getSuperclassName()+"' in the ancestor hierachy does not pass verification pass 1: "+vr);
+ }
+ else{
+ e = Repository.lookupClass(e.getSuperclassName());
+ }
+ }
+ if (e != t) throw new ClassConstraintException("Exceptions attribute '"+tostring(obj)+"' references '"+cname+"' as an Exception but it is not a subclass of '"+t.getClassName()+"'.");
+ }
+ }
+ }
+ // SYNTHETIC: see above
+ // DEPRECATED: see above
+ //////////////////////////////////////////////////////////////
+ // code_attribute-structure-ATTRIBUTES (vmspec2 4.7.3, 4.7) //
+ //////////////////////////////////////////////////////////////
+ public void visitLineNumberTable(LineNumberTable obj){//vmspec2 4.7.8
+ checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
+
+ String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getBytes();
+ if (! name.equals("LineNumberTable")){
+ throw new ClassConstraintException("The LineNumberTable attribute '"+tostring(obj)+"' is not correctly named 'LineNumberTable' but '"+name+"'.");
+ }
+
+ //In JustIce,this check is delayed to Pass 3a.
+ //LineNumber[] linenumbers = obj.getLineNumberTable();
+ // ...validity check...
+
+ }
+ public void visitLocalVariableTable(LocalVariableTable obj){//vmspec2 4.7.9
+ //In JustIce,this check is partially delayed to Pass 3a.
+ //The other part can be found in the visitCode(Code) method.
+ }
+ ////////////////////////////////////////////////////
+ // MISC-structure-ATTRIBUTES (vmspec2 4.7.1, 4.7) //
+ ////////////////////////////////////////////////////
+ public void visitUnknown(Unknown obj){//vmspec2 4.7.1
+ // Represents an unknown attribute.
+ checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
+
+ // Maybe only misnamed? Give a (warning) message.
+ addMessage("Unknown attribute '"+tostring(obj)+"'. This attribute is not known in any context!");
+ }
+ //////////
+ // BCEL //
+ //////////
+ public void visitLocalVariable(LocalVariable obj){
+ // This does not represent an Attribute but is only
+ // related to internal BCEL data representation.
+
+ // see visitLocalVariableTable(LocalVariableTable)
+ }
+ public void visitCodeException(CodeException obj){
+ // Code constraints are checked in Pass3 (3a and 3b).
+ // This does not represent an Attribute but is only
+ // related to internal BCEL data representation.
+
+ // see visitCode(Code)
+ }
+ public void visitConstantPool(ConstantPool obj){
+ // No need to. We're piggybacked by the DescendingVisitor.
+ // This does not represent an Attribute but is only
+ // related to internal BCEL data representation.
+ }
+ public void visitInnerClass(InnerClass obj){
+ // This does not represent an Attribute but is only
+ // related to internal BCEL data representation.
+ }
+ public void visitLineNumber(LineNumber obj){
+ // This does not represent an Attribute but is only
+ // related to internal BCEL data representation.
+
+ // see visitLineNumberTable(LineNumberTable)
+ }
+ }
+
+ /**
+ * Ensures that the ConstantCP-subclassed entries of the constant
+ * pool are valid. According to "Yellin: Low Level Security in Java",
+ * this method does not verify the existence of referenced entities
+ * (such as classes) but only the formal correctness (such as well-formed
+ * signatures).
+ * The visitXXX() methods throw ClassConstraintException instances otherwise.
+ * <B>Precondition: index-style cross referencing in the constant
+ * pool must be valid. Simply invoke constant_pool_entries_satisfy_static_constraints()
+ * before.</B>
+ *
+ * @throws ClassConstraintException otherwise.
+ * @see #constant_pool_entries_satisfy_static_constraints()
+ */
+ private void field_and_method_refs_are_valid(){
+ JavaClass jc = Repository.lookupClass(myOwner.getClassName());
+ DescendingVisitor v = new DescendingVisitor(jc, new FAMRAV_Visitor(jc));
+ v.visit();
+ }
+
+ /**
+ * A Visitor class that ensures the ConstantCP-subclassed entries
+ * of the constant pool are valid.
+ * <B>Precondition: index-style cross referencing in the constant
+ * pool must be valid.</B>
+ *
+ * @see #constant_pool_entries_satisfy_static_constraints()
+ * @see org.apache.bcel.classfile.ConstantCP
+ */
+ private class FAMRAV_Visitor extends EmptyVisitor implements Visitor{
+ private final JavaClass jc;
+ private final ConstantPool cp; // ==jc.getConstantPool() -- only here to save typing work.
+ private FAMRAV_Visitor(JavaClass _jc){
+ jc = _jc;
+ cp = _jc.getConstantPool();
+ }
+
+ public void visitConstantFieldref(ConstantFieldref obj){
+ if (obj.getTag() != Constants.CONSTANT_Fieldref){
+ throw new ClassConstraintException("ConstantFieldref '"+tostring(obj)+"' has wrong tag!");
+ }
+ int name_and_type_index = obj.getNameAndTypeIndex();
+ ConstantNameAndType cnat = (ConstantNameAndType) (cp.getConstant(name_and_type_index));
+ String name = ((ConstantUtf8) (cp.getConstant(cnat.getNameIndex()))).getBytes(); // Field or Method name
+ if (!validFieldName(name)){
+ throw new ClassConstraintException("Invalid field name '"+name+"' referenced by '"+tostring(obj)+"'.");
+ }
+
+ int class_index = obj.getClassIndex();
+ ConstantClass cc = (ConstantClass) (cp.getConstant(class_index));
+ String className = ((ConstantUtf8) (cp.getConstant(cc.getNameIndex()))).getBytes(); // Class Name in internal form
+ if (! validClassName(className)){
+ throw new ClassConstraintException("Illegal class name '"+className+"' used by '"+tostring(obj)+"'.");
+ }
+
+ String sig = ((ConstantUtf8) (cp.getConstant(cnat.getSignatureIndex()))).getBytes(); // Field or Method signature(=descriptor)
+
+ try{
+ Type t = Type.getType(sig);
+ }
+ catch (ClassFormatError cfe){
+ // Well, BCEL sometimes is a little harsh describing exceptional situations.
+ throw new ClassConstraintException("Illegal descriptor (==signature) '"+sig+"' used by '"+tostring(obj)+"'.");
+ }
+ }
+
+ public void visitConstantMethodref(ConstantMethodref obj){
+ if (obj.getTag() != Constants.CONSTANT_Methodref){
+ throw new ClassConstraintException("ConstantMethodref '"+tostring(obj)+"' has wrong tag!");
+ }
+ int name_and_type_index = obj.getNameAndTypeIndex();
+ ConstantNameAndType cnat = (ConstantNameAndType) (cp.getConstant(name_and_type_index));
+ String name = ((ConstantUtf8) (cp.getConstant(cnat.getNameIndex()))).getBytes(); // Field or Method name
+ if (!validClassMethodName(name)){
+ throw new ClassConstraintException("Invalid (non-interface) method name '"+name+"' referenced by '"+tostring(obj)+"'.");
+ }
+
+ int class_index = obj.getClassIndex();
+ ConstantClass cc = (ConstantClass) (cp.getConstant(class_index));
+ String className = ((ConstantUtf8) (cp.getConstant(cc.getNameIndex()))).getBytes(); // Class Name in internal form
+ if (! validClassName(className)){
+ throw new ClassConstraintException("Illegal class name '"+className+"' used by '"+tostring(obj)+"'.");
+ }
+
+ String sig = ((ConstantUtf8) (cp.getConstant(cnat.getSignatureIndex()))).getBytes(); // Field or Method signature(=descriptor)
+
+ try{
+ Type t = Type.getReturnType(sig);
+ Type[] ts = Type.getArgumentTypes(sig);
+ if ( name.equals(CONSTRUCTOR_NAME) && (t != Type.VOID) ){
+ throw new ClassConstraintException("Instance initialization method must have VOID return type.");
+ }
+ }
+ catch (ClassFormatError cfe){
+ // Well, BCEL sometimes is a little harsh describing exceptional situations.
+ throw new ClassConstraintException("Illegal descriptor (==signature) '"+sig+"' used by '"+tostring(obj)+"'.");
+ }
+ }
+
+ public void visitConstantInterfaceMethodref(ConstantInterfaceMethodref obj){
+ if (obj.getTag() != Constants.CONSTANT_InterfaceMethodref){
+ throw new ClassConstraintException("ConstantInterfaceMethodref '"+tostring(obj)+"' has wrong tag!");
+ }
+ int name_and_type_index = obj.getNameAndTypeIndex();
+ ConstantNameAndType cnat = (ConstantNameAndType) (cp.getConstant(name_and_type_index));
+ String name = ((ConstantUtf8) (cp.getConstant(cnat.getNameIndex()))).getBytes(); // Field or Method name
+ if (!validInterfaceMethodName(name)){
+ throw new ClassConstraintException("Invalid (interface) method name '"+name+"' referenced by '"+tostring(obj)+"'.");
+ }
+
+ int class_index = obj.getClassIndex();
+ ConstantClass cc = (ConstantClass) (cp.getConstant(class_index));
+ String className = ((ConstantUtf8) (cp.getConstant(cc.getNameIndex()))).getBytes(); // Class Name in internal form
+ if (! validClassName(className)){
+ throw new ClassConstraintException("Illegal class name '"+className+"' used by '"+tostring(obj)+"'.");
+ }
+
+ String sig = ((ConstantUtf8) (cp.getConstant(cnat.getSignatureIndex()))).getBytes(); // Field or Method signature(=descriptor)
+
+ try{
+ Type t = Type.getReturnType(sig);
+ Type[] ts = Type.getArgumentTypes(sig);
+ if ( name.equals(STATIC_INITIALIZER_NAME) && (t != Type.VOID) ){
+ addMessage("Class or interface initialization method '"+STATIC_INITIALIZER_NAME+"' usually has VOID return type instead of '"+t+"'. Note this is really not a requirement of The Java Virtual Machine Specification, Second Edition.");
+ }
+ }
+ catch (ClassFormatError cfe){
+ // Well, BCEL sometimes is a little harsh describing exceptional situations.
+ throw new ClassConstraintException("Illegal descriptor (==signature) '"+sig+"' used by '"+tostring(obj)+"'.");
+ }
+
+ }
+
+ }
+
+ /**
+ * This method returns true if and only if the supplied String
+ * represents a valid Java class name.
+ */
+ private static final boolean validClassName(String name){
+ // Are there restrictions?
+ return true;
+ }
+ /**
+ * This method returns true if and only if the supplied String
+ * represents a valid method name.
+ * This is basically the same as a valid identifier name in the
+ * Java programming language, but the special name for
+ * the instance initialization method is allowed and the special name
+ * for the class/interface initialization method may be allowed.
+ */
+ private static boolean validMethodName(String name, boolean allowStaticInit){
+ if (validJavaLangMethodName(name)) return true;
+
+ if (allowStaticInit){
+ return (name.equals(CONSTRUCTOR_NAME) || name.equals(STATIC_INITIALIZER_NAME));
+ }
+ else{
+ return name.equals(CONSTRUCTOR_NAME);
+ }
+ }
+
+ /**
+ * This method returns true if and only if the supplied String
+ * represents a valid method name that may be referenced by
+ * ConstantMethodref objects.
+ */
+ private static boolean validClassMethodName(String name){
+ return validMethodName(name, false);
+ }
+
+ /**
+ * This method returns true if and only if the supplied String
+ * represents a valid Java programming language method name stored as a simple
+ * (non-qualified) name.
+ * Conforming to: The Java Virtual Machine Specification, Second Edition, §2.7, §2.7.1, §2.2.
+ */
+ private static boolean validJavaLangMethodName(String name){
+ if (!Character.isJavaIdentifierStart(name.charAt(0))) return false;
+
+ for (int i=1; i<name.length(); i++){
+ if (!Character.isJavaIdentifierPart(name.charAt(i))) return false;
+ }
+ return true;
+ }
+
+ /**
+ * This method returns true if and only if the supplied String
+ * represents a valid Java interface method name that may be
+ * referenced by ConstantInterfaceMethodref objects.
+ */
+ private static boolean validInterfaceMethodName(String name){
+ // I guess we should assume special names forbidden here.
+ if (name.startsWith("<")) return false;
+ return validJavaLangMethodName(name);
+ }
+
+ /**
+ * This method returns true if and only if the supplied String
+ * represents a valid Java identifier (so-called simple name).
+ */
+ private static boolean validJavaIdentifier(String name){
+ // vmspec2 2.7, vmspec2 2.2
+ if (!Character.isJavaIdentifierStart(name.charAt(0))) return false;
+
+ for (int i=1; i<name.length(); i++){
+ if (!Character.isJavaIdentifierPart(name.charAt(i))) return false;
+ }
+ return true;
+ }
+
+ /**
+ * This method returns true if and only if the supplied String
+ * represents a valid Java field name.
+ */
+ private static boolean validFieldName(String name){
+ // vmspec2 2.7, vmspec2 2.2
+ return validJavaIdentifier(name);
+ }
+
+ /**
+ * This class serves for finding out if a given JavaClass' ConstantPool
+ * references an Inner Class.
+ * The Java Virtual Machine Specification, Second Edition is not very precise
+ * about when an "InnerClasses" attribute has to appear. However, it states that
+ * there has to be exactly one InnerClasses attribute in the ClassFile structure
+ * if the constant pool of a class or interface refers to any class or interface
+ * "that is not a member of a package". Sun does not mean "member of the default
+ * package". In "Inner Classes Specification" they point out how a "bytecode name"
+ * is derived so one has to deduce what a class name of a class "that is not a
+ * member of a package" looks like: there is at least one character in the byte-
+ * code name that cannot be part of a legal Java Language Class name (and not equal
+ * to '/'). This assumption is wrong as the delimiter is '$' for which
+ * Character.isJavaIdentifierPart() == true.
+ * Hence, you really run into trouble if you have a toplevel class called
+ * "A$XXX" and another toplevel class called "A" with in inner class called "XXX".
+ * JustIce cannot repair this; please note that existing verifiers at this
+ * time even fail to detect missing InnerClasses attributes in pass 2.
+ */
+ private class InnerClassDetector extends EmptyVisitor{
+ private boolean hasInnerClass = false;
+ private JavaClass jc;
+ private ConstantPool cp;
+ private InnerClassDetector(){} // Don't use.
+ /** Constructs an InnerClassDetector working on the JavaClass _jc. */
+ public InnerClassDetector(JavaClass _jc){
+ jc = _jc;
+ cp = jc.getConstantPool();
+ (new DescendingVisitor(jc, this)).visit();
+ }
+ /**
+ * Returns if the JavaClass this InnerClassDetector is working on
+ * has an Inner Class reference in its constant pool.
+ */
+ public boolean innerClassReferenced(){
+ return hasInnerClass;
+ }
+ /** This method casually visits ConstantClass references. */
+ public void visitConstantClass(ConstantClass obj){
+ Constant c = cp.getConstant(obj.getNameIndex());
+ if (c instanceof ConstantUtf8){ //Ignore the case where it's not a ConstantUtf8 here, we'll find out later.
+ String classname = ((ConstantUtf8) c).getBytes();
+ if (classname.startsWith(jc.getClassName().replace('.','/')+"$")){
+ hasInnerClass = true;
+ }
+ }
+ }
+ }
+
+ /**
+ * This method is here to save typing work and improve code readability.
+ */
+ private static String tostring(Node n){
+ return new StringRepresentation(n).toString();
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java b/src/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java
new file mode 100644
index 00000000..109006d6
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java
@@ -0,0 +1,1070 @@
+package org.apache.bcel.verifier.statics;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.*;
+import org.apache.bcel.generic.*;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.verifier.*;
+import org.apache.bcel.verifier.exc.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+/**
+ * This PassVerifier verifies a class file according to
+ * pass 3, static part as described in The Java Virtual
+ * Machine Specification, 2nd edition.
+ * More detailed information is to be found at the do_verify()
+ * method's documentation.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ * @see #do_verify()
+ */
+public final class Pass3aVerifier extends PassVerifier{
+
+ /** The Verifier that created this. */
+ private Verifier myOwner;
+
+ /**
+ * The method number to verify.
+ * This is the index in the array returned
+ * by JavaClass.getMethods().
+ */
+ private int method_no;
+
+ /** The one and only InstructionList object used by an instance of this class. It's here for performance reasons by do_verify() and its callees. */
+ InstructionList instructionList;
+ /** The one and only Code object used by an instance of this class. It's here for performance reasons by do_verify() and its callees. */
+ Code code;
+
+ /** Should only be instantiated by a Verifier. */
+ public Pass3aVerifier(Verifier owner, int method_no){
+ myOwner = owner;
+ this.method_no = method_no;
+ }
+
+ /**
+ * Pass 3a is the verification of static constraints of
+ * JVM code (such as legal targets of branch instructions).
+ * This is the part of pass 3 where you do not need data
+ * flow analysis.
+ * JustIce also delays the checks for a correct exception
+ * table of a Code attribute and correct line number entries
+ * in a LineNumberTable attribute of a Code attribute (which
+ * conceptually belong to pass 2) to this pass. Also, most
+ * of the check for valid local variable entries in a
+ * LocalVariableTable attribute of a Code attribute is
+ * delayed until this pass.
+ * All these checks need access to the code array of the
+ * Code attribute.
+ *
+ * @throws InvalidMethodException if the method to verify does not exist.
+ */
+ public VerificationResult do_verify(){
+ if (myOwner.doPass2().equals(VerificationResult.VR_OK)){
+ // Okay, class file was loaded correctly by Pass 1
+ // and satisfies static constraints of Pass 2.
+ JavaClass jc = Repository.lookupClass(myOwner.getClassName());
+ Method[] methods = jc.getMethods();
+ if (method_no >= methods.length){
+ throw new InvalidMethodException("METHOD DOES NOT EXIST!");
+ }
+ Method method = methods[method_no];
+ code = method.getCode();
+
+ // No Code? Nothing to verify!
+ if ( method.isAbstract() || method.isNative() ){ // IF mg HAS NO CODE (static constraint of Pass 2)
+ return VerificationResult.VR_OK;
+ }
+
+ // TODO:
+ // We want a very sophisticated code examination here with good explanations
+ // on where to look for an illegal instruction or such.
+ // Only after that we should try to build an InstructionList and throw an
+ // AssertionViolatedException if after our examination InstructionList building
+ // still fails.
+ // That examination should be implemented in a byte-oriented way, i.e. look for
+ // an instruction, make sure its validity, count its length, find the next
+ // instruction and so on.
+ try{
+ instructionList = new InstructionList(method.getCode().getCode());
+ }
+ catch(RuntimeException re){
+ return new VerificationResult(VerificationResult.VERIFIED_REJECTED, "Bad bytecode in the code array of the Code attribute of method '"+method+"'.");
+ }
+
+ instructionList.setPositions(true);
+
+ // Start verification.
+ VerificationResult vr = VerificationResult.VR_OK; //default
+ try{
+ delayedPass2Checks();
+ }
+ catch(ClassConstraintException cce){
+ vr = new VerificationResult(VerificationResult.VERIFIED_REJECTED, cce.getMessage());
+ return vr;
+ }
+ try{
+ pass3StaticInstructionChecks();
+ pass3StaticInstructionOperandsChecks();
+ }
+ catch(StaticCodeConstraintException scce){
+ vr = new VerificationResult(VerificationResult.VERIFIED_REJECTED, scce.getMessage());
+ }
+ return vr;
+ }
+ else{ //did not pass Pass 2.
+ return VerificationResult.VR_NOTYET;
+ }
+ }
+
+ /**
+ * These are the checks that could be done in pass 2 but are delayed to pass 3
+ * for performance reasons. Also, these checks need access to the code array
+ * of the Code attribute of a Method so it's okay to perform them here.
+ * Also see the description of the do_verify() method.
+ *
+ * @throws ClassConstraintException if the verification fails.
+ * @see #do_verify()
+ */
+ private void delayedPass2Checks(){
+
+ int[] instructionPositions = instructionList.getInstructionPositions();
+ int codeLength = code.getCode().length;
+
+ /////////////////////
+ // LineNumberTable //
+ /////////////////////
+ LineNumberTable lnt = code.getLineNumberTable();
+ if (lnt != null){
+ LineNumber[] lineNumbers = lnt.getLineNumberTable();
+ IntList offsets = new IntList();
+ lineNumber_loop: for (int i=0; i < lineNumbers.length; i++){ // may appear in any order.
+ for (int j=0; j < instructionPositions.length; j++){
+ // TODO: Make this a binary search! The instructionPositions array is naturally ordered!
+ int offset = lineNumbers[i].getStartPC();
+ if (instructionPositions[j] == offset){
+ if (offsets.contains(offset)){
+ addMessage("LineNumberTable attribute '"+code.getLineNumberTable()+"' refers to the same code offset ('"+offset+"') more than once which is violating the semantics [but is sometimes produced by IBM's 'jikes' compiler].");
+ }
+ else{
+ offsets.add(offset);
+ }
+ continue lineNumber_loop;
+ }
+ }
+ throw new ClassConstraintException("Code attribute '"+code+"' has a LineNumberTable attribute '"+code.getLineNumberTable()+"' referring to a code offset ('"+lineNumbers[i].getStartPC()+"') that does not exist.");
+ }
+ }
+
+ ///////////////////////////
+ // LocalVariableTable(s) //
+ ///////////////////////////
+ /* We cannot use code.getLocalVariableTable() because there could be more
+ than only one. This is a bug in BCEL. */
+ Attribute[] atts = code.getAttributes();
+ for (int a=0; a<atts.length; a++){
+ if (atts[a] instanceof LocalVariableTable){
+ LocalVariableTable lvt = (LocalVariableTable) atts[a];
+ if (lvt != null){
+ LocalVariable[] localVariables = lvt.getLocalVariableTable();
+ for (int i=0; i<localVariables.length; i++){
+ int startpc = localVariables[i].getStartPC();
+ int length = localVariables[i].getLength();
+
+ if (!contains(instructionPositions, startpc)){
+ throw new ClassConstraintException("Code attribute '"+code+"' has a LocalVariableTable attribute '"+code.getLocalVariableTable()+"' referring to a code offset ('"+startpc+"') that does not exist.");
+ }
+ if ( (!contains(instructionPositions, startpc+length)) && (startpc+length != codeLength) ){
+ throw new ClassConstraintException("Code attribute '"+code+"' has a LocalVariableTable attribute '"+code.getLocalVariableTable()+"' referring to a code offset start_pc+length ('"+(startpc+length)+"') that does not exist.");
+ }
+ }
+ }
+ }
+ }
+
+ ////////////////////
+ // ExceptionTable //
+ ////////////////////
+ // In BCEL's "classfile" API, the startPC/endPC-notation is
+ // inclusive/exclusive as in the Java Virtual Machine Specification.
+ // WARNING: This is not true for BCEL's "generic" API.
+ CodeException[] exceptionTable = code.getExceptionTable();
+ for (int i=0; i<exceptionTable.length; i++){
+ int startpc = exceptionTable[i].getStartPC();
+ int endpc = exceptionTable[i].getEndPC();
+ int handlerpc = exceptionTable[i].getHandlerPC();
+ if (startpc >= endpc){
+ throw new ClassConstraintException("Code attribute '"+code+"' has an exception_table entry '"+exceptionTable[i]+"' that has its start_pc ('"+startpc+"') not smaller than its end_pc ('"+endpc+"').");
+ }
+ if (!contains(instructionPositions, startpc)){
+ throw new ClassConstraintException("Code attribute '"+code+"' has an exception_table entry '"+exceptionTable[i]+"' that has a non-existant bytecode offset as its start_pc ('"+startpc+"').");
+ }
+ if ( (!contains(instructionPositions, endpc)) && (endpc != codeLength)){
+ throw new ClassConstraintException("Code attribute '"+code+"' has an exception_table entry '"+exceptionTable[i]+"' that has a non-existant bytecode offset as its end_pc ('"+startpc+"') [that is also not equal to code_length ('"+codeLength+"')].");
+ }
+ if (!contains(instructionPositions, handlerpc)){
+ throw new ClassConstraintException("Code attribute '"+code+"' has an exception_table entry '"+exceptionTable[i]+"' that has a non-existant bytecode offset as its handler_pc ('"+handlerpc+"').");
+ }
+ }
+ }
+
+ /**
+ * These are the checks if constraints are satisfied which are described in the
+ * Java Virtual Machine Specification, Second Edition as Static Constraints on
+ * the instructions of Java Virtual Machine Code (chapter 4.8.1).
+ *
+ * @throws StaticCodeConstraintException if the verification fails.
+ */
+ private void pass3StaticInstructionChecks(){
+
+ // Code array must not be empty:
+ // Enforced in pass 2 (also stated in the static constraints of the Code
+ // array in vmspec2), together with pass 1 (reading code_length bytes and
+ // interpreting them as code[]). So this must not be checked again here.
+
+ if (! (code.getCode().length < 65536)){// contradicts vmspec2 page 152 ("Limitations"), but is on page 134.
+ throw new StaticCodeInstructionConstraintException("Code array in code attribute '"+code+"' too big: must be smaller than 65536 bytes.");
+ }
+
+ // First opcode at offset 0: okay, that's clear. Nothing to do.
+
+ // Only instances of the instructions documented in Section 6.4 may appear in
+ // the code array.
+
+ // For BCEL's sake, we cannot handle WIDE stuff, but hopefully BCEL does its job right :)
+
+ // The last byte of the last instruction in the code array must be the byte at index
+ // code_length-1 : See the do_verify() comments. We actually don't iterate through the
+ // byte array, but use an InstructionList so we cannot check for this. But BCEL does
+ // things right, so it's implicitely okay.
+
+ // TODO: Check how BCEL handles (and will handle) instructions like IMPDEP1, IMPDEP2,
+ // BREAKPOINT... that BCEL knows about but which are illegal anyway.
+ // We currently go the safe way here.
+ InstructionHandle ih = instructionList.getStart();
+ while (ih != null){
+ Instruction i = ih.getInstruction();
+ if (i instanceof IMPDEP1){
+ throw new StaticCodeInstructionConstraintException("IMPDEP1 must not be in the code, it is an illegal instruction for _internal_ JVM use!");
+ }
+ if (i instanceof IMPDEP2){
+ throw new StaticCodeInstructionConstraintException("IMPDEP2 must not be in the code, it is an illegal instruction for _internal_ JVM use!");
+ }
+ if (i instanceof BREAKPOINT){
+ throw new StaticCodeInstructionConstraintException("BREAKPOINT must not be in the code, it is an illegal instruction for _internal_ JVM use!");
+ }
+ ih = ih.getNext();
+ }
+
+ // The original verifier seems to do this check here, too.
+ // An unreachable last instruction may also not fall through the
+ // end of the code, which is stupid -- but with the original
+ // verifier's subroutine semantics one cannot predict reachability.
+ Instruction last = instructionList.getEnd().getInstruction();
+ if (! ((last instanceof ReturnInstruction) ||
+ (last instanceof RET) ||
+ (last instanceof GotoInstruction) ||
+ (last instanceof ATHROW) )) // JSR / JSR_W would possibly RETurn and then fall off the code!
+ throw new StaticCodeInstructionConstraintException("Execution must not fall off the bottom of the code array. This constraint is enforced statically as some existing verifiers do - so it may be a false alarm if the last instruction is not reachable.");
+ }
+
+ /**
+ * These are the checks for the satisfaction of constraints which are described in the
+ * Java Virtual Machine Specification, Second Edition as Static Constraints on
+ * the operands of instructions of Java Virtual Machine Code (chapter 4.8.1).
+ * BCEL parses the code array to create an InstructionList and therefore has to check
+ * some of these constraints. Additional checks are also implemented here.
+ *
+ * @throws StaticCodeConstraintException if the verification fails.
+ */
+ private void pass3StaticInstructionOperandsChecks(){
+ // When building up the InstructionList, BCEL has already done all those checks
+ // mentioned in The Java Virtual Machine Specification, Second Edition, as
+ // "static constraints on the operands of instructions in the code array".
+ // TODO: see the do_verify() comments. Maybe we should really work on the
+ // byte array first to give more comprehensive messages.
+ // TODO: Review Exception API, possibly build in some "offending instruction" thing
+ // when we're ready to insulate the offending instruction by doing the
+ // above thing.
+
+ // TODO: Implement as much as possible here. BCEL does _not_ check everything.
+
+ ConstantPoolGen cpg = new ConstantPoolGen(Repository.lookupClass(myOwner.getClassName()).getConstantPool());
+ InstOperandConstraintVisitor v = new InstOperandConstraintVisitor(cpg);
+
+ // Checks for the things BCEL does _not_ handle itself.
+ InstructionHandle ih = instructionList.getStart();
+ while (ih != null){
+ Instruction i = ih.getInstruction();
+
+ // An "own" constraint, due to JustIce's new definition of what "subroutine" means.
+ if (i instanceof JsrInstruction){
+ InstructionHandle target = ((JsrInstruction) i).getTarget();
+ if (target == instructionList.getStart()){
+ throw new StaticCodeInstructionOperandConstraintException("Due to JustIce's clear definition of subroutines, no JSR or JSR_W may have a top-level instruction (such as the very first instruction, which is targeted by instruction '"+ih+"' as its target.");
+ }
+ if (!(target.getInstruction() instanceof ASTORE)){
+ throw new StaticCodeInstructionOperandConstraintException("Due to JustIce's clear definition of subroutines, no JSR or JSR_W may target anything else than an ASTORE instruction. Instruction '"+ih+"' targets '"+target+"'.");
+ }
+ }
+
+ // vmspec2, page 134-137
+ ih.accept(v);
+
+ ih = ih.getNext();
+ }
+
+ }
+
+ /** A small utility method returning if a given int i is in the given int[] ints. */
+ private static boolean contains(int[] ints, int i){
+ for (int j=0; j<ints.length; j++){
+ if (ints[j]==i) return true;
+ }
+ return false;
+ }
+
+ /** Returns the method number as supplied when instantiating. */
+ public int getMethodNo(){
+ return method_no;
+ }
+
+ /**
+ * This visitor class does the actual checking for the instruction
+ * operand's constraints.
+ */
+ private class InstOperandConstraintVisitor extends org.apache.bcel.generic.EmptyVisitor{
+ /** The ConstantPoolGen instance this Visitor operates on. */
+ private ConstantPoolGen cpg;
+
+ /** The only Constructor. */
+ InstOperandConstraintVisitor(ConstantPoolGen cpg){
+ this.cpg = cpg;
+ }
+
+ /**
+ * Utility method to return the max_locals value of the method verified
+ * by the surrounding Pass3aVerifier instance.
+ */
+ private int max_locals(){
+ return Repository.lookupClass(myOwner.getClassName()).getMethods()[method_no].getCode().getMaxLocals();
+ }
+
+ /**
+ * A utility method to always raise an exeption.
+ */
+ private void constraintViolated(Instruction i, String message) {
+ throw new StaticCodeInstructionOperandConstraintException("Instruction "+i+" constraint violated: "+message);
+ }
+
+ /**
+ * A utility method to raise an exception if the index is not
+ * a valid constant pool index.
+ */
+ private void indexValid(Instruction i, int idx){
+ if (idx < 0 || idx >= cpg.getSize()){
+ constraintViolated(i, "Illegal constant pool index '"+idx+"'.");
+ }
+ }
+
+ ///////////////////////////////////////////////////////////
+ // The Java Virtual Machine Specification, pages 134-137 //
+ ///////////////////////////////////////////////////////////
+ /**
+ * Assures the generic preconditions of a LoadClass instance.
+ * The referenced class is loaded and pass2-verified.
+ */
+ public void visitLoadClass(LoadClass o){
+ ObjectType t = o.getLoadClassType(cpg);
+ if (t != null){// null means "no class is loaded"
+ Verifier v = VerifierFactory.getVerifier(t.getClassName());
+ VerificationResult vr = v.doPass1();
+ if (vr.getStatus() != VerificationResult.VERIFIED_OK){
+ constraintViolated((Instruction) o, "Class '"+o.getLoadClassType(cpg).getClassName()+"' is referenced, but cannot be loaded: '"+vr+"'.");
+ }
+ }
+ }
+
+ // The target of each jump and branch instruction [...] must be the opcode [...]
+ // BCEL _DOES_ handle this.
+
+ // tableswitch: BCEL will do it, supposedly.
+
+ // lookupswitch: BCEL will do it, supposedly.
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ // LDC and LDC_W (LDC_W is a subclass of LDC in BCEL's model)
+ public void visitLDC(LDC o){
+ indexValid(o, o.getIndex());
+ Constant c = cpg.getConstant(o.getIndex());
+ if (! ( (c instanceof ConstantInteger) ||
+ (c instanceof ConstantFloat) ||
+ (c instanceof ConstantString) ) ){
+ constraintViolated(o, "Operand of LDC or LDC_W must be one of CONSTANT_Integer, CONSTANT_Float or CONSTANT_String, but is '"+c+"'.");
+ }
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ // LDC2_W
+ public void visitLDC2_W(LDC2_W o){
+ indexValid(o, o.getIndex());
+ Constant c = cpg.getConstant(o.getIndex());
+ if (! ( (c instanceof ConstantLong) ||
+ (c instanceof ConstantDouble) ) ){
+ constraintViolated(o, "Operand of LDC2_W must be CONSTANT_Long or CONSTANT_Double, but is '"+c+"'.");
+ }
+ try{
+ indexValid(o, o.getIndex()+1);
+ }
+ catch(StaticCodeInstructionOperandConstraintException e){
+ throw new AssertionViolatedException("OOPS: Does not BCEL handle that? LDC2_W operand has a problem.");
+ }
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ //getfield, putfield, getstatic, putstatic
+ public void visitFieldInstruction(FieldInstruction o){
+ indexValid(o, o.getIndex());
+ Constant c = cpg.getConstant(o.getIndex());
+ if (! (c instanceof ConstantFieldref)){
+ constraintViolated(o, "Indexing a constant that's not a CONSTANT_Fieldref but a '"+c+"'.");
+ }
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitInvokeInstruction(InvokeInstruction o){
+ indexValid(o, o.getIndex());
+ if ( (o instanceof INVOKEVIRTUAL) ||
+ (o instanceof INVOKESPECIAL) ||
+ (o instanceof INVOKESTATIC) ){
+ Constant c = cpg.getConstant(o.getIndex());
+ if (! (c instanceof ConstantMethodref)){
+ constraintViolated(o, "Indexing a constant that's not a CONSTANT_Methodref but a '"+c+"'.");
+ }
+ else{
+ // Constants are okay due to pass2.
+ ConstantNameAndType cnat = (ConstantNameAndType) (cpg.getConstant(((ConstantMethodref) c).getNameAndTypeIndex()));
+ ConstantUtf8 cutf8 = (ConstantUtf8) (cpg.getConstant(cnat.getNameIndex()));
+ if (cutf8.getBytes().equals(Constants.CONSTRUCTOR_NAME) && (!(o instanceof INVOKESPECIAL)) ){
+ constraintViolated(o, "Only INVOKESPECIAL is allowed to invoke instance initialization methods.");
+ }
+ if ( (! (cutf8.getBytes().equals(Constants.CONSTRUCTOR_NAME)) ) && (cutf8.getBytes().startsWith("<")) ){
+ constraintViolated(o, "No method with a name beginning with '<' other than the instance initialization methods may be called by the method invocation instructions.");
+ }
+ }
+ }
+ else{ //if (o instanceof INVOKEINTERFACE){
+ Constant c = cpg.getConstant(o.getIndex());
+ if (! (c instanceof ConstantInterfaceMethodref)){
+ constraintViolated(o, "Indexing a constant that's not a CONSTANT_InterfaceMethodref but a '"+c+"'.");
+ }
+ // TODO: From time to time check if BCEL allows to detect if the
+ // 'count' operand is consistent with the information in the
+ // CONSTANT_InterfaceMethodref and if the last operand is zero.
+ // By now, BCEL hides those two operands because they're superfluous.
+
+ // Invoked method must not be <init> or <clinit>
+ ConstantNameAndType cnat = (ConstantNameAndType) (cpg.getConstant(((ConstantInterfaceMethodref)c).getNameAndTypeIndex()));
+ String name = ((ConstantUtf8) (cpg.getConstant(cnat.getNameIndex()))).getBytes();
+ if (name.equals(Constants.CONSTRUCTOR_NAME)){
+ constraintViolated(o, "Method to invoke must not be '"+Constants.CONSTRUCTOR_NAME+"'.");
+ }
+ if (name.equals(Constants.STATIC_INITIALIZER_NAME)){
+ constraintViolated(o, "Method to invoke must not be '"+Constants.STATIC_INITIALIZER_NAME+"'.");
+ }
+ }
+
+ // The LoadClassType is the method-declaring class, so we have to check the other types.
+
+ Type t = o.getReturnType(cpg);
+ if (t instanceof ArrayType){
+ t = ((ArrayType) t).getBasicType();
+ }
+ if (t instanceof ObjectType){
+ Verifier v = VerifierFactory.getVerifier(((ObjectType) t).getClassName());
+ VerificationResult vr = v.doPass2();
+ if (vr.getStatus() != VerificationResult.VERIFIED_OK){
+ constraintViolated(o, "Return type class/interface could not be verified successfully: '"+vr.getMessage()+"'.");
+ }
+ }
+
+ Type[] ts = o.getArgumentTypes(cpg);
+ for (int i=0; i<ts.length; i++){
+ t = ts[i];
+ if (t instanceof ArrayType){
+ t = ((ArrayType) t).getBasicType();
+ }
+ if (t instanceof ObjectType){
+ Verifier v = VerifierFactory.getVerifier(((ObjectType) t).getClassName());
+ VerificationResult vr = v.doPass2();
+ if (vr.getStatus() != VerificationResult.VERIFIED_OK){
+ constraintViolated(o, "Argument type class/interface could not be verified successfully: '"+vr.getMessage()+"'.");
+ }
+ }
+ }
+
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitINSTANCEOF(INSTANCEOF o){
+ indexValid(o, o.getIndex());
+ Constant c = cpg.getConstant(o.getIndex());
+ if (! (c instanceof ConstantClass)){
+ constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '"+c+"'.");
+ }
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitCHECKCAST(CHECKCAST o){
+ indexValid(o, o.getIndex());
+ Constant c = cpg.getConstant(o.getIndex());
+ if (! (c instanceof ConstantClass)){
+ constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '"+c+"'.");
+ }
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitNEW(NEW o){
+ indexValid(o, o.getIndex());
+ Constant c = cpg.getConstant(o.getIndex());
+ if (! (c instanceof ConstantClass)){
+ constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '"+c+"'.");
+ }
+ else{
+ ConstantUtf8 cutf8 = (ConstantUtf8) (cpg.getConstant( ((ConstantClass) c).getNameIndex() ));
+ Type t = Type.getType("L"+cutf8.getBytes()+";");
+ if (t instanceof ArrayType){
+ constraintViolated(o, "NEW must not be used to create an array.");
+ }
+ }
+
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitMULTIANEWARRAY(MULTIANEWARRAY o){
+ indexValid(o, o.getIndex());
+ Constant c = cpg.getConstant(o.getIndex());
+ if (! (c instanceof ConstantClass)){
+ constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '"+c+"'.");
+ }
+ int dimensions2create = o.getDimensions();
+ if (dimensions2create < 1){
+ constraintViolated(o, "Number of dimensions to create must be greater than zero.");
+ }
+ Type t = o.getType(cpg);
+ if (t instanceof ArrayType){
+ int dimensions = ((ArrayType) t).getDimensions();
+ if (dimensions < dimensions2create){
+ constraintViolated(o, "Not allowed to create array with more dimensions ('+dimensions2create+') than the one referenced by the CONSTANT_Class '"+t+"'.");
+ }
+ }
+ else{
+ constraintViolated(o, "Expecting a CONSTANT_Class referencing an array type. [Constraint not found in The Java Virtual Machine Specification, Second Edition, 4.8.1]");
+ }
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitANEWARRAY(ANEWARRAY o){
+ indexValid(o, o.getIndex());
+ Constant c = cpg.getConstant(o.getIndex());
+ if (! (c instanceof ConstantClass)){
+ constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '"+c+"'.");
+ }
+ Type t = o.getType(cpg);
+ if (t instanceof ArrayType){
+ int dimensions = ((ArrayType) t).getDimensions();
+ if (dimensions >= 255){
+ constraintViolated(o, "Not allowed to create an array with more than 255 dimensions.");
+ }
+ }
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitNEWARRAY(NEWARRAY o){
+ byte t = o.getTypecode();
+ if (! ( (t == Constants.T_BOOLEAN) ||
+ (t == Constants.T_CHAR) ||
+ (t == Constants.T_FLOAT) ||
+ (t == Constants.T_DOUBLE) ||
+ (t == Constants.T_BYTE) ||
+ (t == Constants.T_SHORT) ||
+ (t == Constants.T_INT) ||
+ (t == Constants.T_LONG) ) ){
+ constraintViolated(o, "Illegal type code '+t+' for 'atype' operand.");
+ }
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitILOAD(ILOAD o){
+ int idx = o.getIndex();
+ if (idx < 0){
+ constraintViolated(o, "Index '"+idx+"' must be non-negative.");
+ }
+ else{
+ int maxminus1 = max_locals()-1;
+ if (idx > maxminus1){
+ constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-1 '"+maxminus1+"'.");
+ }
+ }
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitFLOAD(FLOAD o){
+ int idx = o.getIndex();
+ if (idx < 0){
+ constraintViolated(o, "Index '"+idx+"' must be non-negative.");
+ }
+ else{
+ int maxminus1 = max_locals()-1;
+ if (idx > maxminus1){
+ constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-1 '"+maxminus1+"'.");
+ }
+ }
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitALOAD(ALOAD o){
+ int idx = o.getIndex();
+ if (idx < 0){
+ constraintViolated(o, "Index '"+idx+"' must be non-negative.");
+ }
+ else{
+ int maxminus1 = max_locals()-1;
+ if (idx > maxminus1){
+ constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-1 '"+maxminus1+"'.");
+ }
+ }
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitISTORE(ISTORE o){
+ int idx = o.getIndex();
+ if (idx < 0){
+ constraintViolated(o, "Index '"+idx+"' must be non-negative.");
+ }
+ else{
+ int maxminus1 = max_locals()-1;
+ if (idx > maxminus1){
+ constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-1 '"+maxminus1+"'.");
+ }
+ }
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitFSTORE(FSTORE o){
+ int idx = o.getIndex();
+ if (idx < 0){
+ constraintViolated(o, "Index '"+idx+"' must be non-negative.");
+ }
+ else{
+ int maxminus1 = max_locals()-1;
+ if (idx > maxminus1){
+ constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-1 '"+maxminus1+"'.");
+ }
+ }
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitASTORE(ASTORE o){
+ int idx = o.getIndex();
+ if (idx < 0){
+ constraintViolated(o, "Index '"+idx+"' must be non-negative.");
+ }
+ else{
+ int maxminus1 = max_locals()-1;
+ if (idx > maxminus1){
+ constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-1 '"+maxminus1+"'.");
+ }
+ }
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitIINC(IINC o){
+ int idx = o.getIndex();
+ if (idx < 0){
+ constraintViolated(o, "Index '"+idx+"' must be non-negative.");
+ }
+ else{
+ int maxminus1 = max_locals()-1;
+ if (idx > maxminus1){
+ constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-1 '"+maxminus1+"'.");
+ }
+ }
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitRET(RET o){
+ int idx = o.getIndex();
+ if (idx < 0){
+ constraintViolated(o, "Index '"+idx+"' must be non-negative.");
+ }
+ else{
+ int maxminus1 = max_locals()-1;
+ if (idx > maxminus1){
+ constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-1 '"+maxminus1+"'.");
+ }
+ }
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitLLOAD(LLOAD o){
+ int idx = o.getIndex();
+ if (idx < 0){
+ constraintViolated(o, "Index '"+idx+"' must be non-negative. [Constraint by JustIce as an analogon to the single-slot xLOAD/xSTORE instructions; may not happen anyway.]");
+ }
+ else{
+ int maxminus2 = max_locals()-2;
+ if (idx > maxminus2){
+ constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-2 '"+maxminus2+"'.");
+ }
+ }
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitDLOAD(DLOAD o){
+ int idx = o.getIndex();
+ if (idx < 0){
+ constraintViolated(o, "Index '"+idx+"' must be non-negative. [Constraint by JustIce as an analogon to the single-slot xLOAD/xSTORE instructions; may not happen anyway.]");
+ }
+ else{
+ int maxminus2 = max_locals()-2;
+ if (idx > maxminus2){
+ constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-2 '"+maxminus2+"'.");
+ }
+ }
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitLSTORE(LSTORE o){
+ int idx = o.getIndex();
+ if (idx < 0){
+ constraintViolated(o, "Index '"+idx+"' must be non-negative. [Constraint by JustIce as an analogon to the single-slot xLOAD/xSTORE instructions; may not happen anyway.]");
+ }
+ else{
+ int maxminus2 = max_locals()-2;
+ if (idx > maxminus2){
+ constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-2 '"+maxminus2+"'.");
+ }
+ }
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitDSTORE(DSTORE o){
+ int idx = o.getIndex();
+ if (idx < 0){
+ constraintViolated(o, "Index '"+idx+"' must be non-negative. [Constraint by JustIce as an analogon to the single-slot xLOAD/xSTORE instructions; may not happen anyway.]");
+ }
+ else{
+ int maxminus2 = max_locals()-2;
+ if (idx > maxminus2){
+ constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-2 '"+maxminus2+"'.");
+ }
+ }
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitLOOKUPSWITCH(LOOKUPSWITCH o){
+ int[] matchs = o.getMatchs();
+ int max = Integer.MIN_VALUE;
+ for (int i=0; i<matchs.length; i++){
+ if (matchs[i] == max && i != 0){
+ constraintViolated(o, "Match '"+matchs[i]+"' occurs more than once.");
+ }
+ if (matchs[i] < max){
+ constraintViolated(o, "Lookup table must be sorted but isn't.");
+ }
+ else{
+ max = matchs[i];
+ }
+ }
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitTABLESWITCH(TABLESWITCH o){
+ // "high" must be >= "low". We cannot check this, as BCEL hides
+ // it from us.
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitPUTSTATIC(PUTSTATIC o){
+ String field_name = o.getFieldName(cpg);
+ JavaClass jc = Repository.lookupClass(o.getClassType(cpg).getClassName());
+ Field[] fields = jc.getFields();
+ Field f = null;
+ for (int i=0; i<fields.length; i++){
+ if (fields[i].getName().equals(field_name)){
+ f = fields[i];
+ break;
+ }
+ }
+ if (f == null){
+ throw new AssertionViolatedException("Field not found?!?");
+ }
+
+ if (f.isFinal()){
+ if (!(myOwner.getClassName().equals(o.getClassType(cpg).getClassName()))){
+ constraintViolated(o, "Referenced field '"+f+"' is final and must therefore be declared in the current class '"+myOwner.getClassName()+"' which is not the case: it is declared in '"+o.getClassType(cpg).getClassName()+"'.");
+ }
+ }
+
+ if (! (f.isStatic())){
+ constraintViolated(o, "Referenced field '"+f+"' is not static which it should be.");
+ }
+
+ String meth_name = Repository.lookupClass(myOwner.getClassName()).getMethods()[method_no].getName();
+
+ // If it's an interface, it can be set only in <clinit>.
+ if ((!(jc.isClass())) && (!(meth_name.equals(Constants.STATIC_INITIALIZER_NAME)))){
+ constraintViolated(o, "Interface field '"+f+"' must be set in a '"+Constants.STATIC_INITIALIZER_NAME+"' method.");
+ }
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitGETSTATIC(GETSTATIC o){
+ String field_name = o.getFieldName(cpg);
+ JavaClass jc = Repository.lookupClass(o.getClassType(cpg).getClassName());
+ Field[] fields = jc.getFields();
+ Field f = null;
+ for (int i=0; i<fields.length; i++){
+ if (fields[i].getName().equals(field_name)){
+ f = fields[i];
+ break;
+ }
+ }
+ if (f == null){
+ throw new AssertionViolatedException("Field not found?!?");
+ }
+
+ if (! (f.isStatic())){
+ constraintViolated(o, "Referenced field '"+f+"' is not static which it should be.");
+ }
+ }
+
+ /* Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ //public void visitPUTFIELD(PUTFIELD o){
+ // for performance reasons done in Pass 3b
+ //}
+
+ /* Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ //public void visitGETFIELD(GETFIELD o){
+ // for performance reasons done in Pass 3b
+ //}
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitINVOKEINTERFACE(INVOKEINTERFACE o){
+ // INVOKEINTERFACE is a LoadClass; the Class where the referenced method is declared in,
+ // is therefore resolved/verified.
+ // INVOKEINTERFACE is an InvokeInstruction, the argument and return types are resolved/verified,
+ // too. So are the allowed method names.
+ String classname = o.getClassName(cpg);
+ JavaClass jc = Repository.lookupClass(classname);
+ Method[] ms = jc.getMethods();
+ Method m = null;
+ for (int i=0; i<ms.length; i++){
+ if ( (ms[i].getName().equals(o.getMethodName(cpg))) &&
+ (Type.getReturnType(ms[i].getSignature()).equals(o.getReturnType(cpg))) &&
+ (objarrayequals(Type.getArgumentTypes(ms[i].getSignature()), o.getArgumentTypes(cpg))) ){
+ m = ms[i];
+ break;
+ }
+ }
+ if (m == null){
+ constraintViolated(o, "Referenced method '"+o.getMethodName(cpg)+"' with expected signature not found in class '"+jc.getClassName()+"'. The native verfier does allow the method to be declared in some superinterface, which the Java Virtual Machine Specification, Second Edition does not.");
+ }
+ if (jc.isClass()){
+ constraintViolated(o, "Referenced class '"+jc.getClassName()+"' is a class, but not an interface as expected.");
+ }
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitINVOKESPECIAL(INVOKESPECIAL o){
+ // INVOKESPECIAL is a LoadClass; the Class where the referenced method is declared in,
+ // is therefore resolved/verified.
+ // INVOKESPECIAL is an InvokeInstruction, the argument and return types are resolved/verified,
+ // too. So are the allowed method names.
+ String classname = o.getClassName(cpg);
+ JavaClass jc = Repository.lookupClass(classname);
+ Method[] ms = jc.getMethods();
+ Method m = null;
+ for (int i=0; i<ms.length; i++){
+ if ( (ms[i].getName().equals(o.getMethodName(cpg))) &&
+ (Type.getReturnType(ms[i].getSignature()).equals(o.getReturnType(cpg))) &&
+ (objarrayequals(Type.getArgumentTypes(ms[i].getSignature()), o.getArgumentTypes(cpg))) ){
+ m = ms[i];
+ break;
+ }
+ }
+ if (m == null){
+ constraintViolated(o, "Referenced method '"+o.getMethodName(cpg)+"' with expected signature not found in class '"+jc.getClassName()+"'. The native verfier does allow the method to be declared in some superclass or implemented interface, which the Java Virtual Machine Specification, Second Edition does not.");
+ }
+
+ JavaClass current = Repository.lookupClass(myOwner.getClassName());
+ if (current.isSuper()){
+
+ if ((Repository.instanceOf( current, jc )) && (!current.equals(jc))){
+
+ if (! (o.getMethodName(cpg).equals(Constants.CONSTRUCTOR_NAME) )){
+ // Special lookup procedure for ACC_SUPER classes.
+
+ int supidx = -1;
+
+ Method meth = null;
+ while (supidx != 0){
+ supidx = current.getSuperclassNameIndex();
+ current = Repository.lookupClass(current.getSuperclassName());
+
+ Method[] meths = current.getMethods();
+ for (int i=0; i<meths.length; i++){
+ if ( (meths[i].getName().equals(o.getMethodName(cpg))) &&
+ (Type.getReturnType(meths[i].getSignature()).equals(o.getReturnType(cpg))) &&
+ (objarrayequals(Type.getArgumentTypes(meths[i].getSignature()), o.getArgumentTypes(cpg))) ){
+ meth = meths[i];
+ break;
+ }
+ }
+ if (meth != null) break;
+ }
+ if (meth == null){
+ constraintViolated(o, "ACC_SUPER special lookup procedure not successful: method '"+o.getMethodName(cpg)+"' with proper signature not declared in superclass hierarchy.");
+ }
+ }
+ }
+ }
+
+
+ }
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitINVOKESTATIC(INVOKESTATIC o){
+ // INVOKESTATIC is a LoadClass; the Class where the referenced method is declared in,
+ // is therefore resolved/verified.
+ // INVOKESTATIC is an InvokeInstruction, the argument and return types are resolved/verified,
+ // too. So are the allowed method names.
+ String classname = o.getClassName(cpg);
+ JavaClass jc = Repository.lookupClass(classname);
+ Method[] ms = jc.getMethods();
+ Method m = null;
+ for (int i=0; i<ms.length; i++){
+ if ( (ms[i].getName().equals(o.getMethodName(cpg))) &&
+ (Type.getReturnType(ms[i].getSignature()).equals(o.getReturnType(cpg))) &&
+ (objarrayequals(Type.getArgumentTypes(ms[i].getSignature()), o.getArgumentTypes(cpg))) ){
+ m = ms[i];
+ break;
+ }
+ }
+ if (m == null){
+ constraintViolated(o, "Referenced method '"+o.getMethodName(cpg)+"' with expected signature not found in class '"+jc.getClassName()+"'. The native verifier possibly allows the method to be declared in some superclass or implemented interface, which the Java Virtual Machine Specification, Second Edition does not.");
+ }
+
+ if (! (m.isStatic())){ // implies it's not abstract, verified in pass 2.
+ constraintViolated(o, "Referenced method '"+o.getMethodName(cpg)+"' has ACC_STATIC unset.");
+ }
+
+ }
+
+
+ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+ public void visitINVOKEVIRTUAL(INVOKEVIRTUAL o){
+ // INVOKEVIRTUAL is a LoadClass; the Class where the referenced method is declared in,
+ // is therefore resolved/verified.
+ // INVOKEVIRTUAL is an InvokeInstruction, the argument and return types are resolved/verified,
+ // too. So are the allowed method names.
+ String classname = o.getClassName(cpg);
+ JavaClass jc = Repository.lookupClass(classname);
+ Method[] ms = jc.getMethods();
+ Method m = null;
+ for (int i=0; i<ms.length; i++){
+ if ( (ms[i].getName().equals(o.getMethodName(cpg))) &&
+ (Type.getReturnType(ms[i].getSignature()).equals(o.getReturnType(cpg))) &&
+ (objarrayequals(Type.getArgumentTypes(ms[i].getSignature()), o.getArgumentTypes(cpg))) ){
+ m = ms[i];
+ break;
+ }
+ }
+ if (m == null){
+ constraintViolated(o, "Referenced method '"+o.getMethodName(cpg)+"' with expected signature not found in class '"+jc.getClassName()+"'. The native verfier does allow the method to be declared in some superclass or implemented interface, which the Java Virtual Machine Specification, Second Edition does not.");
+ }
+ if (! (jc.isClass())){
+ constraintViolated(o, "Referenced class '"+jc.getClassName()+"' is an interface, but not a class as expected.");
+ }
+
+ }
+
+
+ // WIDE stuff is BCEL-internal and cannot be checked here.
+
+ /**
+ * A utility method like equals(Object) for arrays.
+ * The equality of the elements is based on their equals(Object)
+ * method instead of their object identity.
+ */
+ private boolean objarrayequals(Object[] o, Object[] p){
+ if (o.length != p.length){
+ return false;
+ }
+
+ for (int i=0; i<o.length; i++){
+ if (! (o[i].equals(p[i])) ){
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/statics/StringRepresentation.java b/src/java/org/apache/bcel/verifier/statics/StringRepresentation.java
new file mode 100644
index 00000000..93f36373
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/statics/StringRepresentation.java
@@ -0,0 +1,202 @@
+package org.apache.bcel.verifier.statics;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.classfile.*;
+
+/**
+ * BCEL's Node classes (those from the classfile API that <B>accept()</B> Visitor
+ * instances) have <B>toString()</B> methods that were not designed to be robust,
+ * this gap is closed by this class.
+ * When performing class file verification, it may be useful to output which
+ * entity (e.g. a <B>Code</B> instance) is not satisfying the verifier's
+ * constraints, but in this case it could be possible for the <B>toString()</B>
+ * method to throw a RuntimeException.
+ * A (new StringRepresentation(Node n)).toString() never throws any exception.
+ * Note that this class also serves as a placeholder for more sophisticated message
+ * handling in future versions of JustIce.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public class StringRepresentation extends org.apache.bcel.classfile.EmptyVisitor implements Visitor{
+ /** The string representation, created by a visitXXX() method, output by toString(). */
+ private String tostring;
+ /**
+ * Creates a new StringRepresentation object which is the representation of n.
+ *
+ * @see #toString()
+ */
+ public StringRepresentation(Node n){
+ n.accept(this);
+ }
+ /**
+ * Returns the String representation.
+ */
+ public String toString(){
+ return tostring;
+ }
+ /**
+ * Returns the String representation of the Node object obj;
+ * this is obj.toString() if it does not throw any RuntimeException,
+ * or else it is a string derived only from obj's class name.
+ */
+ private String toString(Node obj){
+ String ret;
+ try{
+ ret = obj.toString();
+ }
+ catch(RuntimeException e){
+ String s = obj.getClass().getName();
+ s = s.substring(s.lastIndexOf(".")+1);
+ ret = "<<"+s+">>";
+ }
+ return ret;
+ }
+ ////////////////////////////////
+ // Visitor methods start here //
+ ////////////////////////////////
+ // We don't of course need to call some default implementation:
+ // e.g. we could also simply output "Code" instead of a possibly
+ // lengthy Code attribute's toString().
+ public void visitCode(Code obj){
+ //tostring = toString(obj);
+ tostring = "<CODE>"; // We don't need real code outputs.
+ }
+ public void visitCodeException(CodeException obj){
+ tostring = toString(obj);
+ }
+ public void visitConstantClass(ConstantClass obj){
+ tostring = toString(obj);
+ }
+ public void visitConstantDouble(ConstantDouble obj){
+ tostring = toString(obj);
+ }
+ public void visitConstantFieldref(ConstantFieldref obj){
+ tostring = toString(obj);
+ }
+ public void visitConstantFloat(ConstantFloat obj){
+ tostring = toString(obj);
+ }
+ public void visitConstantInteger(ConstantInteger obj){
+ tostring = toString(obj);
+ }
+ public void visitConstantInterfaceMethodref(ConstantInterfaceMethodref obj){
+ tostring = toString(obj);
+ }
+ public void visitConstantLong(ConstantLong obj){
+ tostring = toString(obj);
+ }
+ public void visitConstantMethodref(ConstantMethodref obj){
+ tostring = toString(obj);
+ }
+ public void visitConstantNameAndType(ConstantNameAndType obj){
+ tostring = toString(obj);
+ }
+ public void visitConstantPool(ConstantPool obj){
+ tostring = toString(obj);
+ }
+ public void visitConstantString(ConstantString obj){
+ tostring = toString(obj);
+ }
+ public void visitConstantUtf8(ConstantUtf8 obj){
+ tostring = toString(obj);
+ }
+ public void visitConstantValue(ConstantValue obj){
+ tostring = toString(obj);
+ }
+ public void visitDeprecated(Deprecated obj){
+ tostring = toString(obj);
+ }
+ public void visitExceptionTable(ExceptionTable obj){
+ tostring = toString(obj);
+ }
+ public void visitField(Field obj){
+ tostring = toString(obj);
+ }
+ public void visitInnerClass(InnerClass obj){
+ tostring = toString(obj);
+ }
+ public void visitInnerClasses(InnerClasses obj){
+ tostring = toString(obj);
+ }
+ public void visitJavaClass(JavaClass obj){
+ tostring = toString(obj);
+ }
+ public void visitLineNumber(LineNumber obj){
+ tostring = toString(obj);
+ }
+ public void visitLineNumberTable(LineNumberTable obj){
+ tostring = "<LineNumberTable: "+toString(obj)+">";
+ }
+ public void visitLocalVariable(LocalVariable obj){
+ tostring = toString(obj);
+ }
+ public void visitLocalVariableTable(LocalVariableTable obj){
+ tostring = "<LocalVariableTable: "+toString(obj)+">";
+ }
+ public void visitMethod(Method obj){
+ tostring = toString(obj);
+ }
+ public void visitSourceFile(SourceFile obj){
+ tostring = toString(obj);
+ }
+ public void visitSynthetic(Synthetic obj){
+ tostring = toString(obj);
+ }
+ public void visitUnknown(Unknown obj){
+ tostring = toString(obj);
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/statics/package.html b/src/java/org/apache/bcel/verifier/statics/package.html
new file mode 100644
index 00000000..b86c53b9
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/statics/package.html
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+$Id$
+-->
+</head>
+<body bgcolor="white">
+
+Provides PassVerifier classes used internally by JustIce. You don't need to bother with them.
+
+<h2>Package Specification</h2>
+
+Contained in this package are PassVerifier classes for use with the JustIce verifier.
+Only the passes performing what Sun calls 'static constraints' have PassVerifier classes
+here.
+
+<h2>Related Documentation</h2>
+
+For a simple demonstration of JustIce working, please see:
+<ul>
+ <li><a href="http://www.inf.fu-berlin.de/~ehaase/cgi-html/Verifier.html">A WWW front-end for JustIce.</a>
+</ul>
+
+</body>
+</html>
diff --git a/src/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java b/src/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java
new file mode 100644
index 00000000..e59ceb90
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java
@@ -0,0 +1,466 @@
+package org.apache.bcel.verifier.structurals;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.generic.*;
+import org.apache.bcel.verifier.VerifierFactory;
+import org.apache.bcel.verifier.exc.*;
+import java.util.*;
+
+/**
+ * This class represents a control flow graph of a method.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public class ControlFlowGraph{
+
+ /**
+ * Objects of this class represent a node in a ControlFlowGraph.
+ * These nodes are instructions, not basic blocks.
+ */
+ private class InstructionContextImpl implements InstructionContext{
+
+ /**
+ * The TAG field is here for external temporary flagging, such
+ * as graph colouring.
+ *
+ * @see #getTag()
+ * @see #setTag(int)
+ */
+ private int TAG;
+
+ /**
+ * The InstructionHandle this InstructionContext is wrapped around.
+ */
+ private InstructionHandle instruction;
+
+ /**
+ * The 'incoming' execution Frames.
+ */
+ private HashMap inFrames; // key: the last-executed JSR
+
+ /**
+ * The 'outgoing' execution Frames.
+ */
+ private HashMap outFrames; // key: the last-executed JSR
+
+ /**
+ * The 'execution predecessors' - a list of type InstructionContext
+ * of those instances that have been execute()d before in that order.
+ */
+ private ArrayList executionPredecessors = null; // Type: InstructionContext
+
+ /**
+ * Creates an InstructionHandleImpl object from an InstructionHandle.
+ * Creation of one per InstructionHandle suffices. Don't create more.
+ */
+ public InstructionContextImpl(InstructionHandle inst){
+ if (inst == null) throw new AssertionViolatedException("Cannot instantiate InstructionContextImpl from NULL.");
+
+ instruction = inst;
+ inFrames = new java.util.HashMap();
+ outFrames = new java.util.HashMap();
+ }
+
+ /* Satisfies InstructionContext.getTag(). */
+ public int getTag(){
+ return TAG;
+ }
+
+ /* Satisfies InstructionContext.setTag(int). */
+ public void setTag(int tag){
+ TAG = tag;
+ }
+
+ /**
+ * Returns the exception handlers of this instruction.
+ */
+ public ExceptionHandler[] getExceptionHandlers(){
+ return exceptionhandlers.getExceptionHandlers(getInstruction());
+ }
+
+ /**
+ * Returns a clone of the "outgoing" frame situation with respect to the given ExecutionChain.
+ */
+ public Frame getOutFrame(ArrayList execChain){
+ executionPredecessors = execChain;
+
+ Frame org;
+
+ InstructionContext jsr = lastExecutionJSR();
+
+ org = (Frame) outFrames.get(jsr);
+
+ if (org == null){
+ throw new AssertionViolatedException("outFrame not set! This:\n"+this+"\nExecutionChain: "+getExecutionChain()+"\nOutFrames: '"+outFrames+"'.");
+ }
+ return org.getClone();
+ }
+
+ /**
+ * "Merges in" (vmspec2, page 146) the "incoming" frame situation;
+ * executes the instructions symbolically
+ * and therefore calculates the "outgoing" frame situation.
+ * Returns: True iff the "incoming" frame situation changed after
+ * merging with "inFrame".
+ * The execPreds ArrayList must contain the InstructionContext
+ * objects executed so far in the correct order. This is just
+ * one execution path [out of many]. This is needed to correctly
+ * "merge" in the special case of a RET's successor.
+ * <B>The InstConstraintVisitor and ExecutionVisitor instances
+ * must be set up correctly.</B>
+ * @return true - if and only if the "outgoing" frame situation
+ * changed from the one before execute()ing.
+ */
+ public boolean execute(Frame inFrame, ArrayList execPreds, InstConstraintVisitor icv, ExecutionVisitor ev){
+
+ executionPredecessors = (ArrayList) execPreds.clone();
+
+ //sanity check
+ if ( (lastExecutionJSR() == null) && (subroutines.subroutineOf(getInstruction()) != subroutines.getTopLevel() ) ){
+ throw new AssertionViolatedException("Huh?! Am I '"+this+"' part of a subroutine or not?");
+ }
+ if ( (lastExecutionJSR() != null) && (subroutines.subroutineOf(getInstruction()) == subroutines.getTopLevel() ) ){
+ throw new AssertionViolatedException("Huh?! Am I '"+this+"' part of a subroutine or not?");
+ }
+
+ Frame inF = (Frame) inFrames.get(lastExecutionJSR());
+ if (inF == null){// no incoming frame was set, so set it.
+ inFrames.put(lastExecutionJSR(), inFrame);
+ inF = inFrame;
+ }
+ else{// if there was an "old" inFrame
+ if (inF.equals(inFrame)){ //shortcut: no need to merge equal frames.
+ return false;
+ }
+ if (! mergeInFrames(inFrame)){
+ return false;
+ }
+ }
+
+ // Now we're sure the inFrame has changed!
+
+ // new inFrame is already merged in, see above.
+ Frame workingFrame = inF.getClone();
+
+ try{
+ // This verifies the InstructionConstraint for the current
+ // instruction, but does not modify the workingFrame object.
+//InstConstraintVisitor icv = InstConstraintVisitor.getInstance(VerifierFactory.getVerifier(method_gen.getClassName()));
+ icv.setFrame(workingFrame);
+ getInstruction().accept(icv);
+ }
+ catch(StructuralCodeConstraintException ce){
+ ce.extendMessage("","\nInstructionHandle: "+getInstruction()+"\n");
+ ce.extendMessage("","\nExecution Frame:\n"+workingFrame);
+ extendMessageWithFlow(ce);
+ throw ce;
+ }
+
+ // This executes the Instruction.
+ // Therefore the workingFrame object is modified.
+//ExecutionVisitor ev = ExecutionVisitor.getInstance(VerifierFactory.getVerifier(method_gen.getClassName()));
+ ev.setFrame(workingFrame);
+ getInstruction().accept(ev);
+ //getInstruction().accept(ExecutionVisitor.withFrame(workingFrame));
+ outFrames.put(lastExecutionJSR(), workingFrame);
+
+ return true; // new inFrame was different from old inFrame so merging them
+ // yielded a different this.inFrame.
+ }
+
+ /**
+ * Returns a simple String representation of this InstructionContext.
+ */
+ public String toString(){
+ //TODO: Put information in the brackets, e.g.
+ // Is this an ExceptionHandler? Is this a RET? Is this the start of
+ // a subroutine?
+ String ret = getInstruction().toString(false)+"\t[InstructionContext]";
+ return ret;
+ }
+
+ /**
+ * Does the actual merging (vmspec2, page 146).
+ * Returns true IFF this.inFrame was changed in course of merging with inFrame.
+ */
+ private boolean mergeInFrames(Frame inFrame){
+ // TODO: Can be performance-improved.
+ Frame inF = (Frame) inFrames.get(lastExecutionJSR());
+ OperandStack oldstack = inF.getStack().getClone();
+ LocalVariables oldlocals = inF.getLocals().getClone();
+ try{
+ inF.getStack().merge(inFrame.getStack());
+ inF.getLocals().merge(inFrame.getLocals());
+ }
+ catch (StructuralCodeConstraintException sce){
+ extendMessageWithFlow(sce);
+ throw sce;
+ }
+ if ( oldstack.equals(inF.getStack()) &&
+ oldlocals.equals(inF.getLocals()) ){
+ return false;
+ }
+ else{
+ return true;
+ }
+ }
+
+ /**
+ * Returns the control flow execution chain. This is built
+ * while execute(Frame, ArrayList)-ing the code represented
+ * by the surrounding ControlFlowGraph.
+ */
+ private String getExecutionChain(){
+ String s = this.toString();
+ for (int i=executionPredecessors.size()-1; i>=0; i--){
+ s = executionPredecessors.get(i)+"\n" + s;
+ }
+ return s;
+ }
+
+
+ /**
+ * Extends the StructuralCodeConstraintException ("e") object with an at-the-end-extended message.
+ * This extended message will then reflect the execution flow needed to get to the constraint
+ * violation that triggered the throwing of the "e" object.
+ */
+ private void extendMessageWithFlow(StructuralCodeConstraintException e){
+ String s = "Execution flow:\n";
+ e.extendMessage("", s+getExecutionChain());
+ }
+
+ /*
+ * Fulfils the contract of InstructionContext.getInstruction().
+ */
+ public InstructionHandle getInstruction(){
+ return instruction;
+ }
+
+ /**
+ * Returns the InstructionContextImpl with an JSR/JSR_W
+ * that was last in the ExecutionChain, without
+ * a corresponding RET, i.e.
+ * we were called by this one.
+ * Returns null if we were called from the top level.
+ */
+ private InstructionContextImpl lastExecutionJSR(){
+
+ int size = executionPredecessors.size();
+ int retcount = 0;
+
+ for (int i=size-1; i>=0; i--){
+ InstructionContextImpl current = (InstructionContextImpl) (executionPredecessors.get(i));
+ Instruction currentlast = current.getInstruction().getInstruction();
+ if (currentlast instanceof RET) retcount++;
+ if (currentlast instanceof JsrInstruction){
+ retcount--;
+ if (retcount == -1) return current;
+ }
+ }
+ return null;
+ }
+
+ /* Satisfies InstructionContext.getSuccessors(). */
+ public InstructionContext[] getSuccessors(){
+ return contextsOf(_getSuccessors());
+ }
+
+ /**
+ * A utility method that calculates the successors of a given InstructionHandle
+ * That means, a RET does have successors as defined here.
+ * A JsrInstruction has its target as its successor
+ * (opposed to its physical successor) as defined here.
+ */
+// TODO: implement caching!
+ private InstructionHandle[] _getSuccessors(){
+ final InstructionHandle[] empty = new InstructionHandle[0];
+ final InstructionHandle[] single = new InstructionHandle[1];
+ final InstructionHandle[] pair = new InstructionHandle[2];
+
+ Instruction inst = getInstruction().getInstruction();
+
+ if (inst instanceof RET){
+ Subroutine s = subroutines.subroutineOf(getInstruction());
+ if (s==null){ //return empty; // RET in dead code. "empty" would be the correct answer, but we know something about the surrounding project...
+ throw new AssertionViolatedException("Asking for successors of a RET in dead code?!");
+ }
+//TODO: remove
+throw new AssertionViolatedException("DID YOU REALLY WANT TO ASK FOR RET'S SUCCS?");
+/*
+ InstructionHandle[] jsrs = s.getEnteringJsrInstructions();
+ InstructionHandle[] ret = new InstructionHandle[jsrs.length];
+ for (int i=0; i<jsrs.length; i++){
+ ret[i] = jsrs[i].getNext();
+ }
+ return ret;
+*/
+ }
+
+ // Terminates method normally.
+ if (inst instanceof ReturnInstruction){
+ return empty;
+ }
+
+ // Terminates method abnormally, because JustIce mandates
+ // subroutines not to be protected by exception handlers.
+ if (inst instanceof ATHROW){
+ return empty;
+ }
+
+ // See method comment.
+ if (inst instanceof JsrInstruction){
+ single[0] = ((JsrInstruction) inst).getTarget();
+ return single;
+ }
+
+ if (inst instanceof GotoInstruction){
+ single[0] = ((GotoInstruction) inst).getTarget();
+ return single;
+ }
+
+ if (inst instanceof BranchInstruction){
+ if (inst instanceof Select){
+ // BCEL's getTargets() returns only the non-default targets,
+ // thanks to Eli Tilevich for reporting.
+ InstructionHandle[] matchTargets = ((Select) inst).getTargets();
+ InstructionHandle[] ret = new InstructionHandle[matchTargets.length+1];
+ ret[0] = ((Select) inst).getTarget();
+ System.arraycopy(matchTargets, 0, ret, 1, matchTargets.length);
+ return ret;
+ }
+ else{
+ pair[0] = getInstruction().getNext();
+ pair[1] = ((BranchInstruction) inst).getTarget();
+ return pair;
+ }
+ }
+
+ // default case: Fall through.
+ single[0] = getInstruction().getNext();
+ return single;
+ }
+
+ } // End Inner InstructionContextImpl Class.
+
+ /** The MethofGen object we're working on. */
+ private final MethodGen method_gen;
+
+ /** The Subroutines object for the method whose control flow is represented by this ControlFlowGraph. */
+ private final Subroutines subroutines;
+
+ /** The ExceptionHandlers object for the method whose control flow is represented by this ControlFlowGraph. */
+ private final ExceptionHandlers exceptionhandlers;
+
+ /** All InstructionContext instances of this ControlFlowGraph. */
+ private Hashtable instructionContexts = new Hashtable(); //keys: InstructionHandle, values: InstructionContextImpl
+
+ /**
+ * A Control Flow Graph.
+ */
+ public ControlFlowGraph(MethodGen method_gen){
+ subroutines = new Subroutines(method_gen);
+ exceptionhandlers = new ExceptionHandlers(method_gen);
+
+ InstructionHandle[] instructionhandles = method_gen.getInstructionList().getInstructionHandles();
+ for (int i=0; i<instructionhandles.length; i++){
+ instructionContexts.put(instructionhandles[i], new InstructionContextImpl(instructionhandles[i]));
+ }
+
+ this.method_gen = method_gen;
+ }
+
+ /**
+ * Returns the InstructionContext of a given instruction.
+ */
+ public InstructionContext contextOf(InstructionHandle inst){
+ InstructionContext ic = (InstructionContext) instructionContexts.get(inst);
+ if (ic == null){
+ throw new AssertionViolatedException("InstructionContext requested for an InstructionHandle that's not known!");
+ }
+ return ic;
+ }
+
+ /**
+ * Returns the InstructionContext[] of a given InstructionHandle[],
+ * in a naturally ordered manner.
+ */
+ public InstructionContext[] contextsOf(InstructionHandle[] insts){
+ InstructionContext[] ret = new InstructionContext[insts.length];
+ for (int i=0; i<insts.length; i++){
+ ret[i] = contextOf(insts[i]);
+ }
+ return ret;
+ }
+
+ /**
+ * Returns an InstructionContext[] with all the InstructionContext instances
+ * for the method whose control flow is represented by this ControlFlowGraph
+ * <B>(NOT ORDERED!)</B>.
+ */
+ public InstructionContext[] getInstructionContexts(){
+ InstructionContext[] ret = new InstructionContext[instructionContexts.values().size()];
+ return (InstructionContext[]) instructionContexts.values().toArray(ret);
+ }
+
+ /**
+ * Returns true, if and only if the said instruction is not reachable; that means,
+ * if it not part of this ControlFlowGraph.
+ */
+ public boolean isDead(InstructionHandle i){
+ return instructionContexts.containsKey(i);
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/structurals/ExceptionHandler.java b/src/java/org/apache/bcel/verifier/structurals/ExceptionHandler.java
new file mode 100644
index 00000000..b05040b3
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/structurals/ExceptionHandler.java
@@ -0,0 +1,93 @@
+package org.apache.bcel.verifier.structurals;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.generic.*;
+
+/**
+ * This class represents an exception handler; that is, an ObjectType
+ * representing a subclass of java.lang.Throwable and the instruction
+ * the handler starts off (represented by an InstructionContext).
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public class ExceptionHandler{
+ /** The type of the exception to catch. NULL means ANY. */
+ private ObjectType catchtype;
+
+ /** The InstructionHandle where the handling begins. */
+ private InstructionHandle handlerpc;
+
+ /** Leave instance creation to JustIce. */
+ ExceptionHandler(ObjectType catch_type, InstructionHandle handler_pc){
+ catchtype = catch_type;
+ handlerpc = handler_pc;
+ }
+
+ /**
+ * Returns the type of the exception that's handled. <B>'null' means 'ANY'.</B>
+ */
+ public ObjectType getExceptionType(){
+ return catchtype;
+ }
+
+ /**
+ * Returns the InstructionHandle where the handler starts off.
+ */
+ public InstructionHandle getHandlerStart(){
+ return handlerpc;
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/structurals/ExceptionHandlers.java b/src/java/org/apache/bcel/verifier/structurals/ExceptionHandlers.java
new file mode 100644
index 00000000..ebf95e69
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/structurals/ExceptionHandlers.java
@@ -0,0 +1,107 @@
+package org.apache.bcel.verifier.structurals;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.generic.*;
+import java.util.HashSet;
+import java.util.Hashtable;
+
+/**
+ * This class allows easy access to ExceptionHandler objects.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public class ExceptionHandlers{
+ /**
+ * The ExceptionHandler instances.
+ * Key: InstructionHandle objects, Values: HashSet<ExceptionHandler> instances.
+ */
+ private Hashtable exceptionhandlers;
+
+ /**
+ * Constructor. Creates a new ExceptionHandlers instance.
+ */
+ public ExceptionHandlers(MethodGen mg){
+ exceptionhandlers = new Hashtable();
+ CodeExceptionGen[] cegs = mg.getExceptionHandlers();
+ for (int i=0; i<cegs.length; i++){
+ ExceptionHandler eh = new ExceptionHandler(cegs[i].getCatchType(), cegs[i].getHandlerPC());
+ for (InstructionHandle ih=cegs[i].getStartPC(); ih != cegs[i].getEndPC().getNext(); ih=ih.getNext()){
+ HashSet hs;
+ hs = (HashSet) exceptionhandlers.get(ih);
+ if (hs == null){
+ hs = new HashSet();
+ exceptionhandlers.put(ih, hs);
+ }
+ hs.add(eh);
+ }
+ }
+ }
+
+ /**
+ * Returns all the ExceptionHandler instances representing exception
+ * handlers that protect the instruction ih.
+ */
+ public ExceptionHandler[] getExceptionHandlers(InstructionHandle ih){
+ HashSet hs = (HashSet) exceptionhandlers.get(ih);
+ if (hs == null) return new ExceptionHandler[0];
+ else{
+ ExceptionHandler[] ret = new ExceptionHandler[hs.size()];
+ return (ExceptionHandler[]) (hs.toArray(ret));
+ }
+ }
+
+}
diff --git a/src/java/org/apache/bcel/verifier/structurals/ExecutionVisitor.java b/src/java/org/apache/bcel/verifier/structurals/ExecutionVisitor.java
new file mode 100644
index 00000000..330f3a2f
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/structurals/ExecutionVisitor.java
@@ -0,0 +1,1126 @@
+package org.apache.bcel.verifier.structurals;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import org.apache.bcel.Repository;
+import org.apache.bcel.generic.*;
+import org.apache.bcel.classfile.JavaClass;
+import org.apache.bcel.classfile.Constant;
+import org.apache.bcel.classfile.ConstantDouble;
+import org.apache.bcel.classfile.ConstantFloat;
+import org.apache.bcel.classfile.ConstantInteger;
+import org.apache.bcel.classfile.ConstantLong;
+import org.apache.bcel.classfile.ConstantString;
+import org.apache.bcel.verifier.Verifier;
+import org.apache.bcel.verifier.exc.*;
+import java.util.ArrayList;
+import java.util.Hashtable;
+
+/**
+ * This Visitor class may be used for a type-based Java Virtual Machine
+ * simulation.
+ * It does not check for correct types on the OperandStack or in the
+ * LocalVariables; nor does it check their sizes are sufficiently big.
+ * Thus, to use this Visitor for bytecode verifying, you have to make sure
+ * externally that the type constraints of the Java Virtual Machine instructions
+ * are satisfied. An InstConstraintVisitor may be used for this.
+ * Anyway, this Visitor does not mandate it. For example, when you
+ * visitIADD(IADD o), then there are two stack slots popped and one
+ * stack slot containing a Type.INT is pushed (where you could also
+ * pop only one slot if you know there are two Type.INT on top of the
+ * stack). Monitor-specific behaviour is not simulated.
+ *
+ * </P><B>Conventions:</B>
+ *
+ * Type.VOID will never be pushed onto the stack. Type.DOUBLE and Type.LONG
+ * that would normally take up two stack slots (like Double_HIGH and
+ * Double_LOW) are represented by a simple single Type.DOUBLE or Type.LONG
+ * object on the stack here.
+ * If a two-slot type is stored into a local variable, the next variable
+ * is given the type Type.UNKNOWN.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ * @see #visitDSTORE(DSTORE o)
+ * @see InstConstraintVisitor
+ */
+public class ExecutionVisitor extends EmptyVisitor implements Visitor{
+
+ /**
+ * The executionframe we're operating on.
+ */
+ private Frame frame = null;
+
+ /**
+ * The ConstantPoolGen we're working with.
+ * @see #setConstantPoolGen(ConstantPoolGen)
+ */
+ private ConstantPoolGen cpg = null;
+
+ /**
+ * Constructor. Constructs a new instance of this class.
+ */
+ public ExecutionVisitor(){}
+
+ /**
+ * The OperandStack from the current Frame we're operating on.
+ * @see #setFrame(Frame)
+ */
+ private OperandStack stack(){
+ return frame.getStack();
+ }
+
+ /**
+ * The LocalVariables from the current Frame we're operating on.
+ * @see #setFrame(Frame)
+ */
+ private LocalVariables locals(){
+ return frame.getLocals();
+ }
+
+ /**
+ * Sets the ConstantPoolGen needed for symbolic execution.
+ */
+ public void setConstantPoolGen(ConstantPoolGen cpg){
+ this.cpg = cpg;
+ }
+
+ /**
+ * The only method granting access to the single instance of
+ * the ExecutionVisitor class. Before actively using this
+ * instance, <B>SET THE ConstantPoolGen FIRST</B>.
+ * @see #setConstantPoolGen(ConstantPoolGen)
+ */
+ public void setFrame(Frame f){
+ this.frame = f;
+ }
+
+ ///** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ //public void visitWIDE(WIDE o){
+ // The WIDE instruction is modelled as a flag
+ // of the embedded instructions in BCEL.
+ // Therefore BCEL checks for possible errors
+ // when parsing in the .class file: We don't
+ // have even the possibilty to care for WIDE
+ // here.
+ //}
+
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitAALOAD(AALOAD o){
+ stack().pop(); // pop the index int
+//System.out.print(stack().peek());
+ Type t = stack().pop(); // Pop Array type
+ if (t == Type.NULL){
+ stack().push(Type.NULL);
+ } // Do nothing stackwise --- a NullPointerException is thrown at Run-Time
+ else{
+ ArrayType at = (ArrayType) t;
+ stack().push(at.getElementType());
+ }
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitAASTORE(AASTORE o){
+ stack().pop();
+ stack().pop();
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitACONST_NULL(ACONST_NULL o){
+ stack().push(Type.NULL);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitALOAD(ALOAD o){
+ stack().push(locals().get(o.getIndex()));
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitANEWARRAY(ANEWARRAY o){
+ stack().pop(); //count
+ stack().push( new ArrayType(o.getType(cpg), 1) );
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitARETURN(ARETURN o){
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitARRAYLENGTH(ARRAYLENGTH o){
+ stack().pop();
+ stack().push(Type.INT);
+ }
+
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitASTORE(ASTORE o){
+ locals().set(o.getIndex(), stack().pop());
+ //System.err.println("TODO-DEBUG: set LV '"+o.getIndex()+"' to '"+locals().get(o.getIndex())+"'.");
+ }
+
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitATHROW(ATHROW o){
+ Type t = stack().pop();
+ stack().clear();
+ if (t.equals(Type.NULL))
+ stack().push(Type.getType("Ljava/lang/NullPointerException;"));
+ else
+ stack().push(t);
+ }
+
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitBALOAD(BALOAD o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.INT);
+ }
+
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitBASTORE(BASTORE o){
+ stack().pop();
+ stack().pop();
+ stack().pop();
+ }
+
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitBIPUSH(BIPUSH o){
+ stack().push(Type.INT);
+ }
+
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitCALOAD(CALOAD o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitCASTORE(CASTORE o){
+ stack().pop();
+ stack().pop();
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitCHECKCAST(CHECKCAST o){
+ // It's possibly wrong to do so, but SUN's
+ // ByteCode verifier seems to do (only) this, too.
+ // TODO: One could use a sophisticated analysis here to check
+ // if a type cannot possibly be cated to another and by
+ // so doing predict the ClassCastException at run-time.
+ stack().pop();
+ stack().push(o.getType(cpg));
+ }
+
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitD2F(D2F o){
+ stack().pop();
+ stack().push(Type.FLOAT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitD2I(D2I o){
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitD2L(D2L o){
+ stack().pop();
+ stack().push(Type.LONG);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitDADD(DADD o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.DOUBLE);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitDALOAD(DALOAD o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.DOUBLE);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitDASTORE(DASTORE o){
+ stack().pop();
+ stack().pop();
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitDCMPG(DCMPG o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitDCMPL(DCMPL o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitDCONST(DCONST o){
+ stack().push(Type.DOUBLE);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitDDIV(DDIV o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.DOUBLE);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitDLOAD(DLOAD o){
+ stack().push(Type.DOUBLE);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitDMUL(DMUL o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.DOUBLE);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitDNEG(DNEG o){
+ stack().pop();
+ stack().push(Type.DOUBLE);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitDREM(DREM o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.DOUBLE);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitDRETURN(DRETURN o){
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitDSTORE(DSTORE o){
+ locals().set(o.getIndex(), stack().pop());
+ locals().set(o.getIndex()+1, Type.UNKNOWN);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitDSUB(DSUB o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.DOUBLE);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitDUP(DUP o){
+ Type t = stack().pop();
+ stack().push(t);
+ stack().push(t);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitDUP_X1(DUP_X1 o){
+ Type w1 = stack().pop();
+ Type w2 = stack().pop();
+ stack().push(w1);
+ stack().push(w2);
+ stack().push(w1);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitDUP_X2(DUP_X2 o){
+ Type w1 = stack().pop();
+ Type w2 = stack().pop();
+ if (w2.getSize() == 2){
+ stack().push(w1);
+ stack().push(w2);
+ stack().push(w1);
+ }
+ else{
+ Type w3 = stack().pop();
+ stack().push(w1);
+ stack().push(w3);
+ stack().push(w2);
+ stack().push(w1);
+ }
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitDUP2(DUP2 o){
+ Type t = stack().pop();
+ if (t.getSize() == 2){
+ stack().push(t);
+ stack().push(t);
+ }
+ else{ // t.getSize() is 1
+ Type u = stack().pop();
+ stack().push(u);
+ stack().push(t);
+ stack().push(u);
+ stack().push(t);
+ }
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitDUP2_X1(DUP2_X1 o){
+ Type t = stack().pop();
+ if (t.getSize() == 2){
+ Type u = stack().pop();
+ stack().push(t);
+ stack().push(u);
+ stack().push(t);
+ }
+ else{ //t.getSize() is1
+ Type u = stack().pop();
+ Type v = stack().pop();
+ stack().push(u);
+ stack().push(t);
+ stack().push(v);
+ stack().push(u);
+ stack().push(t);
+ }
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitDUP2_X2(DUP2_X2 o){
+ Type t = stack().pop();
+ if (t.getSize() == 2){
+ Type u = stack().pop();
+ if (u.getSize() == 2){
+ stack().push(t);
+ stack().push(u);
+ stack().push(t);
+ }else{
+ Type v = stack().pop();
+ stack().push(t);
+ stack().push(v);
+ stack().push(u);
+ stack().push(t);
+ }
+ }
+ else{ //t.getSize() is 1
+ Type u = stack().pop();
+ Type v = stack().pop();
+ if (v.getSize() == 2){
+ stack().push(u);
+ stack().push(t);
+ stack().push(v);
+ stack().push(u);
+ stack().push(t);
+ }else{
+ Type w = stack().pop();
+ stack().push(u);
+ stack().push(t);
+ stack().push(w);
+ stack().push(v);
+ stack().push(u);
+ stack().push(t);
+ }
+ }
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitF2D(F2D o){
+ stack().pop();
+ stack().push(Type.DOUBLE);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitF2I(F2I o){
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitF2L(F2L o){
+ stack().pop();
+ stack().push(Type.LONG);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitFADD(FADD o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.FLOAT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitFALOAD(FALOAD o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.FLOAT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitFASTORE(FASTORE o){
+ stack().pop();
+ stack().pop();
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitFCMPG(FCMPG o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitFCMPL(FCMPL o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitFCONST(FCONST o){
+ stack().push(Type.FLOAT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitFDIV(FDIV o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.FLOAT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitFLOAD(FLOAD o){
+ stack().push(Type.FLOAT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitFMUL(FMUL o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.FLOAT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitFNEG(FNEG o){
+ stack().pop();
+ stack().push(Type.FLOAT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitFREM(FREM o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.FLOAT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitFRETURN(FRETURN o){
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitFSTORE(FSTORE o){
+ locals().set(o.getIndex(), stack().pop());
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitFSUB(FSUB o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.FLOAT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitGETFIELD(GETFIELD o){
+ stack().pop();
+ Type t = o.getFieldType(cpg);
+ if ( t.equals(Type.BOOLEAN) ||
+ t.equals(Type.CHAR) ||
+ t.equals(Type.BYTE) ||
+ t.equals(Type.SHORT) )
+ t = Type.INT;
+ stack().push(t);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitGETSTATIC(GETSTATIC o){
+ Type t = o.getFieldType(cpg);
+ if ( t.equals(Type.BOOLEAN) ||
+ t.equals(Type.CHAR) ||
+ t.equals(Type.BYTE) ||
+ t.equals(Type.SHORT) )
+ t = Type.INT;
+ stack().push(t);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitGOTO(GOTO o){
+ // no stack changes.
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitGOTO_W(GOTO_W o){
+ // no stack changes.
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitI2B(I2B o){
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitI2C(I2C o){
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitI2D(I2D o){
+ stack().pop();
+ stack().push(Type.DOUBLE);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitI2F(I2F o){
+ stack().pop();
+ stack().push(Type.FLOAT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitI2L(I2L o){
+ stack().pop();
+ stack().push(Type.LONG);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitI2S(I2S o){
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIADD(IADD o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIALOAD(IALOAD o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIAND(IAND o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIASTORE(IASTORE o){
+ stack().pop();
+ stack().pop();
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitICONST(ICONST o){
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIDIV(IDIV o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIF_ACMPEQ(IF_ACMPEQ o){
+ stack().pop();
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIF_ACMPNE(IF_ACMPNE o){
+ stack().pop();
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIF_ICMPEQ(IF_ICMPEQ o){
+ stack().pop();
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIF_ICMPGE(IF_ICMPGE o){
+ stack().pop();
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIF_ICMPGT(IF_ICMPGT o){
+ stack().pop();
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIF_ICMPLE(IF_ICMPLE o){
+ stack().pop();
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIF_ICMPLT(IF_ICMPLT o){
+ stack().pop();
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIF_ICMPNE(IF_ICMPNE o){
+ stack().pop();
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIFEQ(IFEQ o){
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIFGE(IFGE o){
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIFGT(IFGT o){
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIFLE(IFLE o){
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIFLT(IFLT o){
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIFNE(IFNE o){
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIFNONNULL(IFNONNULL o){
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIFNULL(IFNULL o){
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIINC(IINC o){
+ // stack is not changed.
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitILOAD(ILOAD o){
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIMUL(IMUL o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitINEG(INEG o){
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitINSTANCEOF(INSTANCEOF o){
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitINVOKEINTERFACE(INVOKEINTERFACE o){
+ stack().pop(); //objectref
+ for (int i=0; i<o.getArgumentTypes(cpg).length; i++){
+ stack().pop();
+ }
+ // We are sure the invoked method will xRETURN eventually
+ // We simulate xRETURNs functionality here because we
+ // don't really "jump into" and simulate the invoked
+ // method.
+ if (o.getReturnType(cpg) != Type.VOID){
+ Type t = o.getReturnType(cpg);
+ if ( t.equals(Type.BOOLEAN) ||
+ t.equals(Type.CHAR) ||
+ t.equals(Type.BYTE) ||
+ t.equals(Type.SHORT) )
+ t = Type.INT;
+ stack().push(t);
+ }
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitINVOKESPECIAL(INVOKESPECIAL o){
+ if (o.getMethodName(cpg).equals(Constants.CONSTRUCTOR_NAME)){
+ UninitializedObjectType t = (UninitializedObjectType) stack().peek(o.getArgumentTypes(cpg).length);
+ if (t == frame._this){
+ frame._this = null;
+ }
+ stack().initializeObject(t);
+ locals().initializeObject(t);
+ }
+ stack().pop(); //objectref
+ for (int i=0; i<o.getArgumentTypes(cpg).length; i++){
+ stack().pop();
+ }
+ // We are sure the invoked method will xRETURN eventually
+ // We simulate xRETURNs functionality here because we
+ // don't really "jump into" and simulate the invoked
+ // method.
+ if (o.getReturnType(cpg) != Type.VOID){
+ Type t = o.getReturnType(cpg);
+ if ( t.equals(Type.BOOLEAN) ||
+ t.equals(Type.CHAR) ||
+ t.equals(Type.BYTE) ||
+ t.equals(Type.SHORT) )
+ t = Type.INT;
+ stack().push(t);
+ }
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitINVOKESTATIC(INVOKESTATIC o){
+ for (int i=0; i<o.getArgumentTypes(cpg).length; i++){
+ stack().pop();
+ }
+ // We are sure the invoked method will xRETURN eventually
+ // We simulate xRETURNs functionality here because we
+ // don't really "jump into" and simulate the invoked
+ // method.
+ if (o.getReturnType(cpg) != Type.VOID){
+ Type t = o.getReturnType(cpg);
+ if ( t.equals(Type.BOOLEAN) ||
+ t.equals(Type.CHAR) ||
+ t.equals(Type.BYTE) ||
+ t.equals(Type.SHORT) )
+ t = Type.INT;
+ stack().push(t);
+ }
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitINVOKEVIRTUAL(INVOKEVIRTUAL o){
+ stack().pop(); //objectref
+ for (int i=0; i<o.getArgumentTypes(cpg).length; i++){
+ stack().pop();
+ }
+ // We are sure the invoked method will xRETURN eventually
+ // We simulate xRETURNs functionality here because we
+ // don't really "jump into" and simulate the invoked
+ // method.
+ if (o.getReturnType(cpg) != Type.VOID){
+ Type t = o.getReturnType(cpg);
+ if ( t.equals(Type.BOOLEAN) ||
+ t.equals(Type.CHAR) ||
+ t.equals(Type.BYTE) ||
+ t.equals(Type.SHORT) )
+ t = Type.INT;
+ stack().push(t);
+ }
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIOR(IOR o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIREM(IREM o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIRETURN(IRETURN o){
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitISHL(ISHL o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitISHR(ISHR o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitISTORE(ISTORE o){
+ locals().set(o.getIndex(), stack().pop());
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitISUB(ISUB o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIUSHR(IUSHR o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitIXOR(IXOR o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.INT);
+ }
+
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitJSR(JSR o){
+ stack().push(new ReturnaddressType(o.physicalSuccessor()));
+//System.err.println("TODO-----------:"+o.physicalSuccessor());
+ }
+
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitJSR_W(JSR_W o){
+ stack().push(new ReturnaddressType(o.physicalSuccessor()));
+ }
+
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitL2D(L2D o){
+ stack().pop();
+ stack().push(Type.DOUBLE);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitL2F(L2F o){
+ stack().pop();
+ stack().push(Type.FLOAT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitL2I(L2I o){
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitLADD(LADD o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.LONG);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitLALOAD(LALOAD o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.LONG);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitLAND(LAND o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.LONG);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitLASTORE(LASTORE o){
+ stack().pop();
+ stack().pop();
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitLCMP(LCMP o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitLCONST(LCONST o){
+ stack().push(Type.LONG);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitLDC(LDC o){
+ Constant c = cpg.getConstant(o.getIndex());
+ if (c instanceof ConstantInteger){
+ stack().push(Type.INT);
+ }
+ if (c instanceof ConstantFloat){
+ stack().push(Type.FLOAT);
+ }
+ if (c instanceof ConstantString){
+ stack().push(Type.STRING);
+ }
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitLDC_W(LDC_W o){
+ Constant c = cpg.getConstant(o.getIndex());
+ if (c instanceof ConstantInteger){
+ stack().push(Type.INT);
+ }
+ if (c instanceof ConstantFloat){
+ stack().push(Type.FLOAT);
+ }
+ if (c instanceof ConstantString){
+ stack().push(Type.STRING);
+ }
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitLDC2_W(LDC2_W o){
+ Constant c = cpg.getConstant(o.getIndex());
+ if (c instanceof ConstantLong){
+ stack().push(Type.LONG);
+ }
+ if (c instanceof ConstantDouble){
+ stack().push(Type.DOUBLE);
+ }
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitLDIV(LDIV o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.LONG);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitLLOAD(LLOAD o){
+ stack().push(locals().get(o.getIndex()));
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitLMUL(LMUL o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.LONG);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitLNEG(LNEG o){
+ stack().pop();
+ stack().push(Type.LONG);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitLOOKUPSWITCH(LOOKUPSWITCH o){
+ stack().pop(); //key
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitLOR(LOR o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.LONG);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitLREM(LREM o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.LONG);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitLRETURN(LRETURN o){
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitLSHL(LSHL o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.LONG);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitLSHR(LSHR o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.LONG);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitLSTORE(LSTORE o){
+ locals().set(o.getIndex(), stack().pop());
+ locals().set(o.getIndex()+1, Type.UNKNOWN);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitLSUB(LSUB o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.LONG);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitLUSHR(LUSHR o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.LONG);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitLXOR(LXOR o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.LONG);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitMONITORENTER(MONITORENTER o){
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitMONITOREXIT(MONITOREXIT o){
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitMULTIANEWARRAY(MULTIANEWARRAY o){
+ for (int i=0; i<o.getDimensions(); i++){
+ stack().pop();
+ }
+ stack().push(o.getType(cpg));
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitNEW(NEW o){
+ stack().push(new UninitializedObjectType((ObjectType) (o.getType(cpg))));
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitNEWARRAY(NEWARRAY o){
+ stack().pop();
+ stack().push(o.getType());
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitNOP(NOP o){
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitPOP(POP o){
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitPOP2(POP2 o){
+ Type t = stack().pop();
+ if (t.getSize() == 1){
+ stack().pop();
+ }
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitPUTFIELD(PUTFIELD o){
+ stack().pop();
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitPUTSTATIC(PUTSTATIC o){
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitRET(RET o){
+ // do nothing, return address
+ // is in in the local variables.
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitRETURN(RETURN o){
+ // do nothing.
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitSALOAD(SALOAD o){
+ stack().pop();
+ stack().pop();
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitSASTORE(SASTORE o){
+ stack().pop();
+ stack().pop();
+ stack().pop();
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitSIPUSH(SIPUSH o){
+ stack().push(Type.INT);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitSWAP(SWAP o){
+ Type t = stack().pop();
+ Type u = stack().pop();
+ stack().push(t);
+ stack().push(u);
+ }
+ /** Symbolically executes the corresponding Java Virtual Machine instruction. */
+ public void visitTABLESWITCH(TABLESWITCH o){
+ stack().pop();
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/structurals/Frame.java b/src/java/org/apache/bcel/verifier/structurals/Frame.java
new file mode 100644
index 00000000..cfff00f5
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/structurals/Frame.java
@@ -0,0 +1,153 @@
+package org.apache.bcel.verifier.structurals;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.generic.*;
+import org.apache.bcel.verifier.exc.*;
+import java.util.ArrayList;
+
+/**
+ * This class represents a JVM execution frame; that means,
+ * a local variable array and an operand stack.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+
+public class Frame{
+
+ /**
+ * For instance initialization methods, it is important to remember
+ * which instance it is that is not initialized yet. It will be
+ * initialized invoking another constructor later.
+ * NULL means the instance already *is* initialized.
+ */
+ protected static UninitializedObjectType _this;
+
+ /**
+ *
+ */
+ private LocalVariables locals;
+
+ /**
+ *
+ */
+ private OperandStack stack;
+
+ /**
+ *
+ */
+ public Frame(int maxLocals, int maxStack){
+ locals = new LocalVariables(maxLocals);
+ stack = new OperandStack(maxStack);
+ }
+
+ /**
+ *
+ */
+ public Frame(LocalVariables locals, OperandStack stack){
+ this.locals = locals;
+ this.stack = stack;
+ }
+
+ /**
+ *
+ */
+ protected Object clone(){
+ Frame f = new Frame(locals.getClone(), stack.getClone());
+ return f;
+ }
+
+ /**
+ *
+ */
+ public Frame getClone(){
+ return (Frame) clone();
+ }
+
+ /**
+ *
+ */
+ public LocalVariables getLocals(){
+ return locals;
+ }
+
+ /**
+ *
+ */
+ public OperandStack getStack(){
+ return stack;
+ }
+
+ /**
+ *
+ */
+ public boolean equals(Object o){
+ if (!(o instanceof Frame)) return false; // implies "null" is non-equal.
+ Frame f = (Frame) o;
+ return this.stack.equals(f.stack) && this.locals.equals(f.locals);
+ }
+
+ /**
+ * Returns a String representation of the Frame instance.
+ */
+ public String toString(){
+ String s="Local Variables:\n";
+ s += locals;
+ s += "OperandStack:\n";
+ s += stack;
+ return s;
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/structurals/GenericArray.java b/src/java/org/apache/bcel/verifier/structurals/GenericArray.java
new file mode 100644
index 00000000..30cdafe6
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/structurals/GenericArray.java
@@ -0,0 +1,66 @@
+package org.apache.bcel.verifier.structurals;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+ * A placeholder class that can be used to create an ObjectType of which
+ * has some of the properties arrays have. They implement java.lang.Cloneable
+ * and java.io.Serializable and they extend java.lang.Object.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public class GenericArray extends java.lang.Object implements java.lang.Cloneable, java.io.Serializable{
+}
diff --git a/src/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java b/src/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java
new file mode 100644
index 00000000..05c999ad
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java
@@ -0,0 +1,2652 @@
+package org.apache.bcel.verifier.structurals;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.Constants;
+import org.apache.bcel.Repository;
+import org.apache.bcel.classfile.Constant;
+import org.apache.bcel.classfile.ConstantClass;
+import org.apache.bcel.classfile.ConstantDouble;
+import org.apache.bcel.classfile.ConstantInteger;
+import org.apache.bcel.classfile.ConstantFieldref;
+import org.apache.bcel.classfile.ConstantFloat;
+import org.apache.bcel.classfile.ConstantInterfaceMethodref;
+import org.apache.bcel.classfile.ConstantLong;
+import org.apache.bcel.classfile.ConstantNameAndType;
+import org.apache.bcel.classfile.ConstantString;
+import org.apache.bcel.classfile.ConstantUtf8;
+import org.apache.bcel.classfile.Field;
+import org.apache.bcel.classfile.JavaClass;
+import org.apache.bcel.generic.*;
+import org.apache.bcel.verifier.*;
+import org.apache.bcel.verifier.exc.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Hashtable;
+
+/**
+ * A Visitor class testing for valid preconditions of JVM instructions.
+ * The instance of this class will throw a StructuralCodeConstraintException
+ * instance if an instruction is visitXXX()ed which has preconditions that are
+ * not satisfied.
+ * TODO: Currently, the JVM's behaviour concerning monitors (MONITORENTER,
+ * MONITOREXIT) is not modeled in JustIce.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ * @see org.apache.bcel.verifier.exc.StructuralCodeConstraintException
+ * @see org.apache.bcel.verifier.exc.LinkingConstraintException
+ */
+public class InstConstraintVisitor extends EmptyVisitor implements org.apache.bcel.generic.Visitor{
+
+ private static ObjectType GENERIC_ARRAY = new ObjectType("org.apache.bcel.verifier.structurals.GenericArray");
+
+ /**
+ * The constructor. Constructs a new instance of this class.
+ */
+ public InstConstraintVisitor(){}
+
+ /**
+ * The Execution Frame we're working on.
+ *
+ * @see #setFrame(Frame f)
+ * @see #locals()
+ * @see #stack()
+ */
+ private Frame frame = null;
+
+ /**
+ * The ConstantPoolGen we're working on.
+ *
+ * @see #setConstantPoolGen(ConstantPoolGen cpg)
+ */
+ private ConstantPoolGen cpg = null;
+
+ /**
+ * The MethodGen we're working on.
+ *
+ * @see #setMethodGen(MethodGen mg)
+ */
+ private MethodGen mg = null;
+
+ /**
+ * The OperandStack we're working on.
+ *
+ * @see #setFrame(Frame f)
+ */
+ private OperandStack stack(){
+ return frame.getStack();
+ }
+
+ /**
+ * The LocalVariables we're working on.
+ *
+ * @see #setFrame(Frame f)
+ */
+ private LocalVariables locals(){
+ return frame.getLocals();
+ }
+
+ /**
+ * This method is called by the visitXXX() to notify the acceptor of this InstConstraintVisitor
+ * that a constraint violation has occured. This is done by throwing an instance of a
+ * StructuralCodeConstraintException.
+ * @throws org.apache.bcel.verifier.exc.StructuralCodeConstraintException always.
+ */
+ private void constraintViolated(Instruction violator, String description){
+ String fq_classname = violator.getClass().getName();
+ throw new StructuralCodeConstraintException("Instruction "+ fq_classname.substring(fq_classname.lastIndexOf('.')+1) +" constraint violated: " + description);
+ }
+
+ /**
+ * This returns the single instance of the InstConstraintVisitor class.
+ * To operate correctly, other values must have been set before actually
+ * using the instance.
+ * Use this method for performance reasons.
+ *
+ * @see #setConstantPoolGen(ConstantPoolGen cpg)
+ * @see #setMethodGen(MethodGen mg)
+ */
+ public void setFrame(Frame f){
+ this.frame = f;
+ //if (singleInstance.mg == null || singleInstance.cpg == null) throw new AssertionViolatedException("Forgot to set important values first.");
+ }
+
+ /**
+ * Sets the ConstantPoolGen instance needed for constraint
+ * checking prior to execution.
+ */
+ public void setConstantPoolGen(ConstantPoolGen cpg){
+ this.cpg = cpg;
+ }
+
+ /**
+ * Sets the MethodGen instance needed for constraint
+ * checking prior to execution.
+ */
+ public void setMethodGen(MethodGen mg){
+ this.mg = mg;
+ }
+
+ /**
+ * Assures index is of type INT.
+ * @throws org.apache.bcel.verifier.exc.StructuralCodeConstraintException if the above constraint is not satisfied.
+ */
+ private void indexOfInt(Instruction o, Type index){
+ if (! index.equals(Type.INT))
+ constraintViolated(o, "The 'index' is not of type int but of type "+index+".");
+ }
+
+ /**
+ * Assures the ReferenceType r is initialized (or Type.NULL).
+ * Formally, this means (!(r instanceof UninitializedObjectType)), because
+ * there are no uninitialized array types.
+ * @throws org.apache.bcel.verifier.exc.StructuralCodeConstraintException if the above constraint is not satisfied.
+ */
+ private void referenceTypeIsInitialized(Instruction o, ReferenceType r){
+ if (r instanceof UninitializedObjectType){
+ constraintViolated(o, "Working on an uninitialized object '"+r+"'.");
+ }
+ }
+
+ /** Assures value is of type INT. */
+ private void valueOfInt(Instruction o, Type value){
+ if (! value.equals(Type.INT))
+ constraintViolated(o, "The 'value' is not of type int but of type "+value+".");
+ }
+
+ /**
+ * Assures arrayref is of ArrayType or NULL;
+ * returns true if and only if arrayref is non-NULL.
+ * @throws org.apache.bcel.verifier.exc.StructuralCodeConstraintException if the above constraint is violated.
+ */
+ private boolean arrayrefOfArrayType(Instruction o, Type arrayref){
+ if (! ((arrayref instanceof ArrayType) || arrayref.equals(Type.NULL)) )
+ constraintViolated(o, "The 'arrayref' does not refer to an array but is of type "+arrayref+".");
+ return (arrayref instanceof ArrayType);
+ }
+
+ /***************************************************************/
+ /* MISC */
+ /***************************************************************/
+ /**
+ * Ensures the general preconditions of an instruction that accesses the stack.
+ * This method is here because BCEL has no such superinterface for the stack
+ * accessing instructions; and there are funny unexpected exceptions in the
+ * semantices of the superinterfaces and superclasses provided.
+ * E.g. SWAP is a StackConsumer, but DUP_X1 is not a StackProducer.
+ * Therefore, this method is called by all StackProducer, StackConsumer,
+ * and StackInstruction instances via their visitXXX() method.
+ * Unfortunately, as the superclasses and superinterfaces overlap, some instructions
+ * cause this method to be called two or three times. [TODO: Fix this.]
+ *
+ * @see #visitStackConsumer(StackConsumer o)
+ * @see #visitStackProducer(StackProducer o)
+ * @see #visitStackInstruction(StackInstruction o)
+ */
+ private void _visitStackAccessor(Instruction o){
+ int consume = o.consumeStack(cpg); // Stack values are always consumed first; then produced.
+ if (consume > stack().slotsUsed()){
+ constraintViolated((Instruction) o, "Cannot consume "+consume+" stack slots: only "+stack().slotsUsed()+" slot(s) left on stack!\nStack:\n"+stack());
+ }
+
+ int produce = o.produceStack(cpg) - ((Instruction) o).consumeStack(cpg); // Stack values are always consumed first; then produced.
+ if ( produce + stack().slotsUsed() > stack().maxStack() ){
+ constraintViolated((Instruction) o, "Cannot produce "+produce+" stack slots: only "+(stack().maxStack()-stack().slotsUsed())+" free stack slot(s) left.\nStack:\n"+stack());
+ }
+ }
+
+ /***************************************************************/
+ /* "generic"visitXXXX methods where XXXX is an interface */
+ /* therefore, we don't know the order of visiting; but we know */
+ /* these methods are called before the visitYYYY methods below */
+ /***************************************************************/
+
+ /**
+ * Assures the generic preconditions of a LoadClass instance.
+ * The referenced class is loaded and pass2-verified.
+ */
+ public void visitLoadClass(LoadClass o){
+ ObjectType t = o.getLoadClassType(cpg);
+ if (t != null){// null means "no class is loaded"
+ Verifier v = VerifierFactory.getVerifier(t.getClassName());
+ VerificationResult vr = v.doPass2();
+ if (vr.getStatus() != VerificationResult.VERIFIED_OK){
+ constraintViolated((Instruction) o, "Class '"+o.getLoadClassType(cpg).getClassName()+"' is referenced, but cannot be loaded and resolved: '"+vr+"'.");
+ }
+ }
+ }
+
+ /**
+ * Ensures the general preconditions of a StackConsumer instance.
+ */
+ public void visitStackConsumer(StackConsumer o){
+ _visitStackAccessor((Instruction) o);
+ }
+
+ /**
+ * Ensures the general preconditions of a StackProducer instance.
+ */
+ public void visitStackProducer(StackProducer o){
+ _visitStackAccessor((Instruction) o);
+ }
+
+
+ /***************************************************************/
+ /* "generic" visitYYYY methods where YYYY is a superclass. */
+ /* therefore, we know the order of visiting; we know */
+ /* these methods are called after the visitXXXX methods above. */
+ /***************************************************************/
+ /**
+ * Ensures the general preconditions of a CPInstruction instance.
+ */
+ public void visitCPInstruction(CPInstruction o){
+ int idx = o.getIndex();
+ if ((idx < 0) || (idx >= cpg.getSize())){
+ throw new AssertionViolatedException("Huh?! Constant pool index of instruction '"+o+"' illegal? Pass 3a should have checked this!");
+ }
+ }
+
+ /**
+ * Ensures the general preconditions of a FieldInstruction instance.
+ */
+ public void visitFieldInstruction(FieldInstruction o){
+ // visitLoadClass(o) has been called before: Every FieldOrMethod
+ // implements LoadClass.
+ // visitCPInstruction(o) has been called before.
+ // A FieldInstruction may be: GETFIELD, GETSTATIC, PUTFIELD, PUTSTATIC
+ Constant c = cpg.getConstant(o.getIndex());
+ if (!(c instanceof ConstantFieldref)){
+ constraintViolated(o, "Index '"+o.getIndex()+"' should refer to a CONSTANT_Fieldref_info structure, but refers to '"+c+"'.");
+ }
+ // the o.getClassType(cpg) type has passed pass 2; see visitLoadClass(o).
+ Type t = o.getType(cpg);
+ if (t instanceof ObjectType){
+ String name = ((ObjectType)t).getClassName();
+ Verifier v = VerifierFactory.getVerifier( name );
+ VerificationResult vr = v.doPass2();
+ if (vr.getStatus() != VerificationResult.VERIFIED_OK){
+ constraintViolated((Instruction) o, "Class '"+name+"' is referenced, but cannot be loaded and resolved: '"+vr+"'.");
+ }
+ }
+ }
+
+ /**
+ * Ensures the general preconditions of an InvokeInstruction instance.
+ */
+ public void visitInvokeInstruction(InvokeInstruction o){
+ // visitLoadClass(o) has been called before: Every FieldOrMethod
+ // implements LoadClass.
+ // visitCPInstruction(o) has been called before.
+//TODO
+ }
+
+ /**
+ * Ensures the general preconditions of a StackInstruction instance.
+ */
+ public void visitStackInstruction(StackInstruction o){
+ _visitStackAccessor(o);
+ }
+
+ /**
+ * Assures the generic preconditions of a LocalVariableInstruction instance.
+ * That is, the index of the local variable must be valid.
+ */
+ public void visitLocalVariableInstruction(LocalVariableInstruction o){
+ if (locals().maxLocals() <= (o.getType(cpg).getSize()==1? o.getIndex() : o.getIndex()+1) ){
+ constraintViolated(o, "The 'index' is not a valid index into the local variable array.");
+ }
+ }
+
+ /**
+ * Assures the generic preconditions of a LoadInstruction instance.
+ */
+ public void visitLoadInstruction(LoadInstruction o){
+ //visitLocalVariableInstruction(o) is called before, because it is more generic.
+
+ // LOAD instructions must not read Type.UNKNOWN
+ if (locals().get(o.getIndex()) == Type.UNKNOWN){
+ constraintViolated(o, "Read-Access on local variable "+o.getIndex()+" with unknown content.");
+ }
+
+ // LOAD instructions, two-slot-values at index N must have Type.UNKNOWN
+ // as a symbol for the higher halve at index N+1
+ // [suppose some instruction put an int at N+1--- our double at N is defective]
+ if (o.getType(cpg).getSize() == 2){
+ if (locals().get(o.getIndex()+1) != Type.UNKNOWN){
+ constraintViolated(o, "Reading a two-locals value from local variables "+o.getIndex()+" and "+(o.getIndex()+1)+" where the latter one is destroyed.");
+ }
+ }
+
+ // LOAD instructions must read the correct type.
+ if (!(o instanceof ALOAD)){
+ if (locals().get(o.getIndex()) != o.getType(cpg) ){
+ constraintViolated(o, "Local Variable type and LOADing Instruction type mismatch: Local Variable: '"+locals().get(o.getIndex())+"'; Instruction type: '"+o.getType(cpg)+"'.");
+ }
+ }
+ else{ // we deal with an ALOAD
+ if (!(locals().get(o.getIndex()) instanceof ReferenceType)){
+ constraintViolated(o, "Local Variable type and LOADing Instruction type mismatch: Local Variable: '"+locals().get(o.getIndex())+"'; Instruction expects a ReferenceType.");
+ }
+ // ALOAD __IS ALLOWED__ to put uninitialized objects onto the stack!
+ //referenceTypeIsInitialized(o, (ReferenceType) (locals().get(o.getIndex())));
+ }
+
+ // LOAD instructions must have enough free stack slots.
+ if ((stack().maxStack() - stack().slotsUsed()) < o.getType(cpg).getSize()){
+ constraintViolated(o, "Not enough free stack slots to load a '"+o.getType(cpg)+"' onto the OperandStack.");
+ }
+ }
+
+ /**
+ * Assures the generic preconditions of a StoreInstruction instance.
+ */
+ public void visitStoreInstruction(StoreInstruction o){
+ //visitLocalVariableInstruction(o) is called before, because it is more generic.
+
+ if (stack().isEmpty()){ // Don't bother about 1 or 2 stack slots used. This check is implicitely done below while type checking.
+ constraintViolated(o, "Cannot STORE: Stack to read from is empty.");
+ }
+
+ if ( (!(o instanceof ASTORE)) ){
+ if (! (stack().peek() == o.getType(cpg)) ){// the other xSTORE types are singletons in BCEL.
+ constraintViolated(o, "Stack top type and STOREing Instruction type mismatch: Stack top: '"+stack().peek()+"'; Instruction type: '"+o.getType(cpg)+"'.");
+ }
+ }
+ else{ // we deal with ASTORE
+ Type stacktop = stack().peek();
+ if ( (!(stacktop instanceof ReferenceType)) && (!(stacktop instanceof ReturnaddressType)) ){
+ constraintViolated(o, "Stack top type and STOREing Instruction type mismatch: Stack top: '"+stack().peek()+"'; Instruction expects a ReferenceType or a ReturnadressType.");
+ }
+ if (stacktop instanceof ReferenceType){
+ referenceTypeIsInitialized(o, (ReferenceType) stacktop);
+ }
+ }
+ }
+
+ /**
+ * Assures the generic preconditions of a ReturnInstruction instance.
+ */
+ public void visitReturnInstruction(ReturnInstruction o){
+ if (o instanceof RETURN){
+ return;
+ }
+ if (o instanceof ARETURN){
+ if (stack().peek() == Type.NULL){
+ return;
+ }
+ else{
+ if (! (stack().peek() instanceof ReferenceType)){
+ constraintViolated(o, "Reference type expected on top of stack, but is: '"+stack().peek()+"'.");
+ }
+ referenceTypeIsInitialized(o, (ReferenceType) (stack().peek()));
+ ReferenceType objectref = (ReferenceType) (stack().peek());
+ // TODO: This can only be checked if using Staerk-et-al's "set of object types" instead of a
+ // "wider cast object type" created during verification.
+ //if (! (objectref.isAssignmentCompatibleWith(mg.getType())) ){
+ // constraintViolated(o, "Type on stack top which should be returned is a '"+stack().peek()+"' which is not assignment compatible with the return type of this method, '"+mg.getType()+"'.");
+ //}
+ }
+ }
+ else{
+ Type method_type = mg.getType();
+ if (method_type == Type.BOOLEAN ||
+ method_type == Type.BYTE ||
+ method_type == Type.SHORT ||
+ method_type == Type.CHAR){
+ method_type = Type.INT;
+ }
+ if (! ( method_type.equals( stack().peek() ))){
+ constraintViolated(o, "Current method has return type of '"+mg.getType()+"' expecting a '"+method_type+"' on top of the stack. But stack top is a '"+stack().peek()+"'.");
+ }
+ }
+ }
+
+ /***************************************************************/
+ /* "special"visitXXXX methods for one type of instruction each */
+ /***************************************************************/
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitAALOAD(AALOAD o){
+ Type arrayref = stack().peek(1);
+ Type index = stack().peek(0);
+
+ indexOfInt(o, index);
+ if (arrayrefOfArrayType(o, arrayref)){
+ if (! (((ArrayType) arrayref).getElementType() instanceof ReferenceType)){
+ constraintViolated(o, "The 'arrayref' does not refer to an array with elements of a ReferenceType but to an array of "+((ArrayType) arrayref).getElementType()+".");
+ }
+ referenceTypeIsInitialized(o, (ReferenceType) (((ArrayType) arrayref).getElementType()));
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitAASTORE(AASTORE o){
+ Type arrayref = stack().peek(2);
+ Type index = stack().peek(1);
+ Type value = stack().peek(0);
+
+ indexOfInt(o, index);
+ if (!(value instanceof ReferenceType)){
+ constraintViolated(o, "The 'value' is not of a ReferenceType but of type "+value+".");
+ }else{
+ referenceTypeIsInitialized(o, (ReferenceType) value);
+ }
+ // Don't bother further with "referenceTypeIsInitialized()", there are no arrays
+ // of an uninitialized object type.
+ if (arrayrefOfArrayType(o, arrayref)){
+ if (! (((ArrayType) arrayref).getElementType() instanceof ReferenceType)){
+ constraintViolated(o, "The 'arrayref' does not refer to an array with elements of a ReferenceType but to an array of "+((ArrayType) arrayref).getElementType()+".");
+ }
+ if (! ((ReferenceType)value).isAssignmentCompatibleWith((ReferenceType) ((ArrayType) arrayref).getElementType())){
+ constraintViolated(o, "The type of 'value' ('"+value+"') is not assignment compatible to the components of the array 'arrayref' refers to. ('"+((ArrayType) arrayref).getElementType()+"')");
+ }
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitACONST_NULL(ACONST_NULL o){
+ // Nothing needs to be done here.
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitALOAD(ALOAD o){
+ //visitLoadInstruction(LoadInstruction) is called before.
+
+ // Nothing else needs to be done here.
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitANEWARRAY(ANEWARRAY o){
+ if (!stack().peek().equals(Type.INT))
+ constraintViolated(o, "The 'count' at the stack top is not of type '"+Type.INT+"' but of type '"+stack().peek()+"'.");
+ // The runtime constant pool item at that index must be a symbolic reference to a class,
+ // array, or interface type. See Pass 3a.
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitARETURN(ARETURN o){
+ if (! (stack().peek() instanceof ReferenceType) ){
+ constraintViolated(o, "The 'objectref' at the stack top is not of a ReferenceType but of type '"+stack().peek()+"'.");
+ }
+ ReferenceType objectref = (ReferenceType) (stack().peek());
+ referenceTypeIsInitialized(o, objectref);
+
+ // The check below should already done via visitReturnInstruction(ReturnInstruction), see there.
+ // It cannot be done using Staerk-et-al's "set of object types" instead of a
+ // "wider cast object type", anyway.
+ //if (! objectref.isAssignmentCompatibleWith(mg.getReturnType() )){
+ // constraintViolated(o, "The 'objectref' type "+objectref+" at the stack top is not assignment compatible with the return type '"+mg.getReturnType()+"' of the method.");
+ //}
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitARRAYLENGTH(ARRAYLENGTH o){
+ Type arrayref = stack().peek(0);
+ arrayrefOfArrayType(o, arrayref);
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitASTORE(ASTORE o){
+ if (! ( (stack().peek() instanceof ReferenceType) || (stack().peek() instanceof ReturnaddressType) ) ){
+ constraintViolated(o, "The 'objectref' is not of a ReferenceType or of ReturnaddressType but of "+stack().peek()+".");
+ }
+ if (stack().peek() instanceof ReferenceType){
+ referenceTypeIsInitialized(o, (ReferenceType) (stack().peek()) );
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitATHROW(ATHROW o){
+ // It's stated that 'objectref' must be of a ReferenceType --- but since Throwable is
+ // not derived from an ArrayType, it follows that 'objectref' must be of an ObjectType or Type.NULL.
+ if (! ((stack().peek() instanceof ObjectType) || (stack().peek().equals(Type.NULL))) ){
+ constraintViolated(o, "The 'objectref' is not of an (initialized) ObjectType but of type "+stack().peek()+".");
+ }
+
+ // NULL is a subclass of every class, so to speak.
+ if (stack().peek().equals(Type.NULL)) return;
+
+ ObjectType exc = (ObjectType) (stack().peek());
+ ObjectType throwable = (ObjectType) (Type.getType("Ljava/lang/Throwable;"));
+ if ( (! (exc.subclassOf(throwable)) ) && (! (exc.equals(throwable))) ){
+ constraintViolated(o, "The 'objectref' is not of class Throwable or of a subclass of Throwable, but of '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitBALOAD(BALOAD o){
+ Type arrayref = stack().peek(1);
+ Type index = stack().peek(0);
+ indexOfInt(o, index);
+ if (arrayrefOfArrayType(o, arrayref)){
+ if (! ( (((ArrayType) arrayref).getElementType().equals(Type.BOOLEAN)) ||
+ (((ArrayType) arrayref).getElementType().equals(Type.BYTE)) ) ){
+ constraintViolated(o, "The 'arrayref' does not refer to an array with elements of a Type.BYTE or Type.BOOLEAN but to an array of '"+((ArrayType) arrayref).getElementType()+"'.");
+ }
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitBASTORE(BASTORE o){
+ Type arrayref = stack().peek(2);
+ Type index = stack().peek(1);
+ Type value = stack().peek(0);
+
+ indexOfInt(o, index);
+ valueOfInt(o, index);
+ if (arrayrefOfArrayType(o, arrayref)){
+ if (! ( (((ArrayType) arrayref).getElementType().equals(Type.BOOLEAN)) ||
+ (((ArrayType) arrayref).getElementType().equals(Type.BYTE)) ) )
+ constraintViolated(o, "The 'arrayref' does not refer to an array with elements of a Type.BYTE or Type.BOOLEAN but to an array of '"+((ArrayType) arrayref).getElementType()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitBIPUSH(BIPUSH o){
+ // Nothing to do...
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitBREAKPOINT(BREAKPOINT o){
+ throw new AssertionViolatedException("In this JustIce verification pass there should not occur an illegal instruction such as BREAKPOINT.");
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitCALOAD(CALOAD o){
+ Type arrayref = stack().peek(1);
+ Type index = stack().peek(0);
+
+ indexOfInt(o, index);
+ arrayrefOfArrayType(o, arrayref);
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitCASTORE(CASTORE o){
+ Type arrayref = stack().peek(2);
+ Type index = stack().peek(1);
+ Type value = stack().peek(0);
+
+ indexOfInt(o, index);
+ valueOfInt(o, index);
+ if (arrayrefOfArrayType(o, arrayref)){
+ if (! ((ArrayType) arrayref).getElementType().equals(Type.CHAR) ){
+ constraintViolated(o, "The 'arrayref' does not refer to an array with elements of type char but to an array of type "+((ArrayType) arrayref).getElementType()+".");
+ }
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitCHECKCAST(CHECKCAST o){
+ // The objectref must be of type reference.
+ Type objectref = stack().peek(0);
+ if (!(objectref instanceof ReferenceType)){
+ constraintViolated(o, "The 'objectref' is not of a ReferenceType but of type "+objectref+".");
+ }
+ else{
+ referenceTypeIsInitialized(o, (ReferenceType) objectref);
+ }
+ // The unsigned indexbyte1 and indexbyte2 are used to construct an index into the runtime constant pool of the
+ // current class (§3.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The runtime constant
+ // pool item at the index must be a symbolic reference to a class, array, or interface type.
+ Constant c = cpg.getConstant(o.getIndex());
+ if (! (c instanceof ConstantClass)){
+ constraintViolated(o, "The Constant at 'index' is not a ConstantClass, but '"+c+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitD2F(D2F o){
+ if (stack().peek() != Type.DOUBLE){
+ constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitD2I(D2I o){
+ if (stack().peek() != Type.DOUBLE){
+ constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitD2L(D2L o){
+ if (stack().peek() != Type.DOUBLE){
+ constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitDADD(DADD o){
+ if (stack().peek() != Type.DOUBLE){
+ constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.DOUBLE){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitDALOAD(DALOAD o){
+ indexOfInt(o, stack().peek());
+ if (stack().peek(1) == Type.NULL){
+ return;
+ }
+ if (! (stack().peek(1) instanceof ArrayType)){
+ constraintViolated(o, "Stack next-to-top must be of type double[] but is '"+stack().peek(1)+"'.");
+ }
+ Type t = ((ArrayType) (stack().peek(1))).getBasicType();
+ if (t != Type.DOUBLE){
+ constraintViolated(o, "Stack next-to-top must be of type double[] but is '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitDASTORE(DASTORE o){
+ if (stack().peek() != Type.DOUBLE){
+ constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'.");
+ }
+ indexOfInt(o, stack().peek(1));
+ if (stack().peek(2) == Type.NULL){
+ return;
+ }
+ if (! (stack().peek(2) instanceof ArrayType)){
+ constraintViolated(o, "Stack next-to-next-to-top must be of type double[] but is '"+stack().peek(2)+"'.");
+ }
+ Type t = ((ArrayType) (stack().peek(2))).getBasicType();
+ if (t != Type.DOUBLE){
+ constraintViolated(o, "Stack next-to-next-to-top must be of type double[] but is '"+stack().peek(2)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitDCMPG(DCMPG o){
+ if (stack().peek() != Type.DOUBLE){
+ constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.DOUBLE){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitDCMPL(DCMPL o){
+ if (stack().peek() != Type.DOUBLE){
+ constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.DOUBLE){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitDCONST(DCONST o){
+ // There's nothing to be done here.
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitDDIV(DDIV o){
+ if (stack().peek() != Type.DOUBLE){
+ constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.DOUBLE){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitDLOAD(DLOAD o){
+ //visitLoadInstruction(LoadInstruction) is called before.
+
+ // Nothing else needs to be done here.
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitDMUL(DMUL o){
+ if (stack().peek() != Type.DOUBLE){
+ constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.DOUBLE){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitDNEG(DNEG o){
+ if (stack().peek() != Type.DOUBLE){
+ constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitDREM(DREM o){
+ if (stack().peek() != Type.DOUBLE){
+ constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.DOUBLE){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitDRETURN(DRETURN o){
+ if (stack().peek() != Type.DOUBLE){
+ constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitDSTORE(DSTORE o){
+ //visitStoreInstruction(StoreInstruction) is called before.
+
+ // Nothing else needs to be done here.
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitDSUB(DSUB o){
+ if (stack().peek() != Type.DOUBLE){
+ constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.DOUBLE){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitDUP(DUP o){
+ if (stack().peek().getSize() != 1){
+ constraintViolated(o, "Won't DUP type on stack top '"+stack().peek()+"' because it must occupy exactly one slot, not '"+stack().peek().getSize()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitDUP_X1(DUP_X1 o){
+ if (stack().peek().getSize() != 1){
+ constraintViolated(o, "Type on stack top '"+stack().peek()+"' should occupy exactly one slot, not '"+stack().peek().getSize()+"'.");
+ }
+ if (stack().peek(1).getSize() != 1){
+ constraintViolated(o, "Type on stack next-to-top '"+stack().peek(1)+"' should occupy exactly one slot, not '"+stack().peek(1).getSize()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitDUP_X2(DUP_X2 o){
+ if (stack().peek().getSize() != 1){
+ constraintViolated(o, "Stack top type must be of size 1, but is '"+stack().peek()+"' of size '"+stack().peek().getSize()+"'.");
+ }
+ if (stack().peek(1).getSize() == 2){
+ return; // Form 2, okay.
+ }
+ else{ //stack().peek(1).getSize == 1.
+ if (stack().peek(2).getSize() != 1){
+ constraintViolated(o, "If stack top's size is 1 and stack next-to-top's size is 1, stack next-to-next-to-top's size must also be 1, but is: '"+stack().peek(2)+"' of size '"+stack().peek(2).getSize()+"'.");
+ }
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitDUP2(DUP2 o){
+ if (stack().peek().getSize() == 2){
+ return; // Form 2, okay.
+ }
+ else{ //stack().peek().getSize() == 1.
+ if (stack().peek(1).getSize() != 1){
+ constraintViolated(o, "If stack top's size is 1, then stack next-to-top's size must also be 1. But it is '"+stack().peek(1)+"' of size '"+stack().peek(1).getSize()+"'.");
+ }
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitDUP2_X1(DUP2_X1 o){
+ if (stack().peek().getSize() == 2){
+ if (stack().peek(1).getSize() != 1){
+ constraintViolated(o, "If stack top's size is 2, then stack next-to-top's size must be 1. But it is '"+stack().peek(1)+"' of size '"+stack().peek(1).getSize()+"'.");
+ }
+ else{
+ return; // Form 2
+ }
+ }
+ else{ // stack top is of size 1
+ if ( stack().peek(1).getSize() != 1 ){
+ constraintViolated(o, "If stack top's size is 1, then stack next-to-top's size must also be 1. But it is '"+stack().peek(1)+"' of size '"+stack().peek(1).getSize()+"'.");
+ }
+ if ( stack().peek(2).getSize() != 1 ){
+ constraintViolated(o, "If stack top's size is 1, then stack next-to-next-to-top's size must also be 1. But it is '"+stack().peek(2)+"' of size '"+stack().peek(2).getSize()+"'.");
+ }
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitDUP2_X2(DUP2_X2 o){
+
+ if (stack().peek(0).getSize() == 2){
+ if (stack().peek(1).getSize() == 2){
+ return; // Form 4
+ }
+ else{// stack top size is 2, next-to-top's size is 1
+ if ( stack().peek(2).getSize() != 1 ){
+ constraintViolated(o, "If stack top's size is 2 and stack-next-to-top's size is 1, then stack next-to-next-to-top's size must also be 1. But it is '"+stack().peek(2)+"' of size '"+stack().peek(2).getSize()+"'.");
+ }
+ else{
+ return; // Form 2
+ }
+ }
+ }
+ else{// stack top is of size 1
+ if (stack().peek(1).getSize() == 1){
+ if ( stack().peek(2).getSize() == 2 ){
+ return; // Form 3
+ }
+ else{
+ if ( stack().peek(3).getSize() == 1){
+ return; // Form 1
+ }
+ }
+ }
+ }
+ constraintViolated(o, "The operand sizes on the stack do not match any of the four forms of usage of this instruction.");
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitF2D(F2D o){
+ if (stack().peek() != Type.FLOAT){
+ constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitF2I(F2I o){
+ if (stack().peek() != Type.FLOAT){
+ constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitF2L(F2L o){
+ if (stack().peek() != Type.FLOAT){
+ constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitFADD(FADD o){
+ if (stack().peek() != Type.FLOAT){
+ constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.FLOAT){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'float', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitFALOAD(FALOAD o){
+ indexOfInt(o, stack().peek());
+ if (stack().peek(1) == Type.NULL){
+ return;
+ }
+ if (! (stack().peek(1) instanceof ArrayType)){
+ constraintViolated(o, "Stack next-to-top must be of type float[] but is '"+stack().peek(1)+"'.");
+ }
+ Type t = ((ArrayType) (stack().peek(1))).getBasicType();
+ if (t != Type.FLOAT){
+ constraintViolated(o, "Stack next-to-top must be of type float[] but is '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitFASTORE(FASTORE o){
+ if (stack().peek() != Type.FLOAT){
+ constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'.");
+ }
+ indexOfInt(o, stack().peek(1));
+ if (stack().peek(2) == Type.NULL){
+ return;
+ }
+ if (! (stack().peek(2) instanceof ArrayType)){
+ constraintViolated(o, "Stack next-to-next-to-top must be of type float[] but is '"+stack().peek(2)+"'.");
+ }
+ Type t = ((ArrayType) (stack().peek(2))).getBasicType();
+ if (t != Type.FLOAT){
+ constraintViolated(o, "Stack next-to-next-to-top must be of type float[] but is '"+stack().peek(2)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitFCMPG(FCMPG o){
+ if (stack().peek() != Type.FLOAT){
+ constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.FLOAT){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'float', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitFCMPL(FCMPL o){
+ if (stack().peek() != Type.FLOAT){
+ constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.FLOAT){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'float', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitFCONST(FCONST o){
+ // nothing to do here.
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitFDIV(FDIV o){
+ if (stack().peek() != Type.FLOAT){
+ constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.FLOAT){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'float', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitFLOAD(FLOAD o){
+ //visitLoadInstruction(LoadInstruction) is called before.
+
+ // Nothing else needs to be done here.
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitFMUL(FMUL o){
+ if (stack().peek() != Type.FLOAT){
+ constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.FLOAT){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'float', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitFNEG(FNEG o){
+ if (stack().peek() != Type.FLOAT){
+ constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitFREM(FREM o){
+ if (stack().peek() != Type.FLOAT){
+ constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.FLOAT){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'float', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitFRETURN(FRETURN o){
+ if (stack().peek() != Type.FLOAT){
+ constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitFSTORE(FSTORE o){
+ //visitStoreInstruction(StoreInstruction) is called before.
+
+ // Nothing else needs to be done here.
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitFSUB(FSUB o){
+ if (stack().peek() != Type.FLOAT){
+ constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.FLOAT){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'float', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitGETFIELD(GETFIELD o){
+ Type objectref = stack().peek();
+ if (! ( (objectref instanceof ObjectType) || (objectref == Type.NULL) ) ){
+ constraintViolated(o, "Stack top should be an object reference that's not an array reference, but is '"+objectref+"'.");
+ }
+
+ String field_name = o.getFieldName(cpg);
+
+ JavaClass jc = Repository.lookupClass(o.getClassType(cpg).getClassName());
+ Field[] fields = jc.getFields();
+ Field f = null;
+ for (int i=0; i<fields.length; i++){
+ if (fields[i].getName().equals(field_name)){
+ f = fields[i];
+ break;
+ }
+ }
+ if (f == null){
+ throw new AssertionViolatedException("Field not found?!?");
+ }
+
+ if (f.isProtected()){
+ ObjectType classtype = o.getClassType(cpg);
+ ObjectType curr = new ObjectType(mg.getClassName());
+
+ if ( classtype.equals(curr) ||
+ curr.subclassOf(classtype) ){
+ Type t = stack().peek();
+ if (t == Type.NULL){
+ return;
+ }
+ if (! (t instanceof ObjectType) ){
+ constraintViolated(o, "The 'objectref' must refer to an object that's not an array. Found instead: '"+t+"'.");
+ }
+ ObjectType objreftype = (ObjectType) t;
+ if (! ( objreftype.equals(curr) ||
+ objreftype.subclassOf(curr) ) ){
+ //TODO: One day move to Staerk-et-al's "Set of object types" instead of "wider" object types
+ // created during the verification.
+ // "Wider" object types don't allow us to check for things like that below.
+ //constraintViolated(o, "The referenced field has the ACC_PROTECTED modifier, and it's a member of the current class or a superclass of the current class. However, the referenced object type '"+stack().peek()+"' is not the current class or a subclass of the current class.");
+ }
+ }
+ }
+
+ // TODO: Could go into Pass 3a.
+ if (f.isStatic()){
+ constraintViolated(o, "Referenced field '"+f+"' is static which it shouldn't be.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitGETSTATIC(GETSTATIC o){
+ // Field must be static: see Pass 3a.
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitGOTO(GOTO o){
+ // nothing to do here.
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitGOTO_W(GOTO_W o){
+ // nothing to do here.
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitI2B(I2B o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitI2C(I2C o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitI2D(I2D o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitI2F(I2F o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitI2L(I2L o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitI2S(I2S o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIADD(IADD o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.INT){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIALOAD(IALOAD o){
+ indexOfInt(o, stack().peek());
+ if (stack().peek(1) == Type.NULL){
+ return;
+ }
+ if (! (stack().peek(1) instanceof ArrayType)){
+ constraintViolated(o, "Stack next-to-top must be of type int[] but is '"+stack().peek(1)+"'.");
+ }
+ Type t = ((ArrayType) (stack().peek(1))).getBasicType();
+ if (t != Type.INT){
+ constraintViolated(o, "Stack next-to-top must be of type int[] but is '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIAND(IAND o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.INT){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIASTORE(IASTORE o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ indexOfInt(o, stack().peek(1));
+ if (stack().peek(2) == Type.NULL){
+ return;
+ }
+ if (! (stack().peek(2) instanceof ArrayType)){
+ constraintViolated(o, "Stack next-to-next-to-top must be of type int[] but is '"+stack().peek(2)+"'.");
+ }
+ Type t = ((ArrayType) (stack().peek(2))).getBasicType();
+ if (t != Type.INT){
+ constraintViolated(o, "Stack next-to-next-to-top must be of type int[] but is '"+stack().peek(2)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitICONST(ICONST o){
+ //nothing to do here.
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIDIV(IDIV o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.INT){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIF_ACMPEQ(IF_ACMPEQ o){
+ if (!(stack().peek() instanceof ReferenceType)){
+ constraintViolated(o, "The value at the stack top is not of a ReferenceType, but of type '"+stack().peek()+"'.");
+ }
+ referenceTypeIsInitialized(o, (ReferenceType) (stack().peek()) );
+
+ if (!(stack().peek(1) instanceof ReferenceType)){
+ constraintViolated(o, "The value at the stack next-to-top is not of a ReferenceType, but of type '"+stack().peek(1)+"'.");
+ }
+ referenceTypeIsInitialized(o, (ReferenceType) (stack().peek(1)) );
+
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIF_ACMPNE(IF_ACMPNE o){
+ if (!(stack().peek() instanceof ReferenceType)){
+ constraintViolated(o, "The value at the stack top is not of a ReferenceType, but of type '"+stack().peek()+"'.");
+ referenceTypeIsInitialized(o, (ReferenceType) (stack().peek()) );
+ }
+ if (!(stack().peek(1) instanceof ReferenceType)){
+ constraintViolated(o, "The value at the stack next-to-top is not of a ReferenceType, but of type '"+stack().peek(1)+"'.");
+ referenceTypeIsInitialized(o, (ReferenceType) (stack().peek(1)) );
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIF_ICMPEQ(IF_ICMPEQ o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.INT){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIF_ICMPGE(IF_ICMPGE o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.INT){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIF_ICMPGT(IF_ICMPGT o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.INT){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIF_ICMPLE(IF_ICMPLE o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.INT){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIF_ICMPLT(IF_ICMPLT o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.INT){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIF_ICMPNE(IF_ICMPNE o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.INT){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIFEQ(IFEQ o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIFGE(IFGE o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIFGT(IFGT o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIFLE(IFLE o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIFLT(IFLT o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIFNE(IFNE o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIFNONNULL(IFNONNULL o){
+ if (!(stack().peek() instanceof ReferenceType)){
+ constraintViolated(o, "The value at the stack top is not of a ReferenceType, but of type '"+stack().peek()+"'.");
+ }
+ referenceTypeIsInitialized(o, (ReferenceType) (stack().peek()) );
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIFNULL(IFNULL o){
+ if (!(stack().peek() instanceof ReferenceType)){
+ constraintViolated(o, "The value at the stack top is not of a ReferenceType, but of type '"+stack().peek()+"'.");
+ }
+ referenceTypeIsInitialized(o, (ReferenceType) (stack().peek()) );
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIINC(IINC o){
+ // Mhhh. In BCEL, at this time "IINC" is not a LocalVariableInstruction.
+ if (locals().maxLocals() <= (o.getType(cpg).getSize()==1? o.getIndex() : o.getIndex()+1) ){
+ constraintViolated(o, "The 'index' is not a valid index into the local variable array.");
+ }
+
+ indexOfInt(o, locals().get(o.getIndex()));
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitILOAD(ILOAD o){
+ // All done by visitLocalVariableInstruction(), visitLoadInstruction()
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIMPDEP1(IMPDEP1 o){
+ throw new AssertionViolatedException("In this JustIce verification pass there should not occur an illegal instruction such as IMPDEP1.");
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIMPDEP2(IMPDEP2 o){
+ throw new AssertionViolatedException("In this JustIce verification pass there should not occur an illegal instruction such as IMPDEP2.");
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIMUL(IMUL o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.INT){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitINEG(INEG o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitINSTANCEOF(INSTANCEOF o){
+ // The objectref must be of type reference.
+ Type objectref = stack().peek(0);
+ if (!(objectref instanceof ReferenceType)){
+ constraintViolated(o, "The 'objectref' is not of a ReferenceType but of type "+objectref+".");
+ }
+ else{
+ referenceTypeIsInitialized(o, (ReferenceType) objectref);
+ }
+ // The unsigned indexbyte1 and indexbyte2 are used to construct an index into the runtime constant pool of the
+ // current class (§3.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The runtime constant
+ // pool item at the index must be a symbolic reference to a class, array, or interface type.
+ Constant c = cpg.getConstant(o.getIndex());
+ if (! (c instanceof ConstantClass)){
+ constraintViolated(o, "The Constant at 'index' is not a ConstantClass, but '"+c+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitINVOKEINTERFACE(INVOKEINTERFACE o){
+ // Method is not native, otherwise pass 3 would not happen.
+
+ int count = o.getCount();
+ if (count == 0){
+ constraintViolated(o, "The 'count' argument must not be 0.");
+ }
+ // It is a ConstantInterfaceMethodref, Pass 3a made it sure.
+ ConstantInterfaceMethodref cimr = (ConstantInterfaceMethodref) (cpg.getConstant(o.getIndex()));
+
+ // the o.getClassType(cpg) type has passed pass 2; see visitLoadClass(o).
+
+ Type t = o.getType(cpg);
+ if (t instanceof ObjectType){
+ String name = ((ObjectType)t).getClassName();
+ Verifier v = VerifierFactory.getVerifier( name );
+ VerificationResult vr = v.doPass2();
+ if (vr.getStatus() != VerificationResult.VERIFIED_OK){
+ constraintViolated((Instruction) o, "Class '"+name+"' is referenced, but cannot be loaded and resolved: '"+vr+"'.");
+ }
+ }
+
+
+ Type[] argtypes = o.getArgumentTypes(cpg);
+ int nargs = argtypes.length;
+
+ for (int i=nargs-1; i>=0; i--){
+ Type fromStack = stack().peek( (nargs-1) - i ); // 0 to nargs-1
+ Type fromDesc = argtypes[i];
+ if (fromDesc == Type.BOOLEAN ||
+ fromDesc == Type.BYTE ||
+ fromDesc == Type.CHAR ||
+ fromDesc == Type.SHORT){
+ fromDesc = Type.INT;
+ }
+ if (! fromStack.equals(fromDesc)){
+ if (fromStack instanceof ReferenceType && fromDesc instanceof ReferenceType){
+ ReferenceType rFromStack = (ReferenceType) fromStack;
+ ReferenceType rFromDesc = (ReferenceType) fromDesc;
+ // TODO: This can only be checked when using Staerk-et-al's "set of object types"
+ // instead of a "wider cast object type" created during verification.
+ //if ( ! rFromStack.isAssignmentCompatibleWith(rFromDesc) ){
+ // constraintViolated(o, "Expecting a '"+fromDesc+"' but found a '"+fromStack+"' on the stack (which is not assignment compatible).");
+ //}
+ }
+ else{
+ constraintViolated(o, "Expecting a '"+fromDesc+"' but found a '"+fromStack+"' on the stack.");
+ }
+ }
+ }
+
+ Type objref = stack().peek(nargs);
+ if (objref == Type.NULL){
+ return;
+ }
+ if (! (objref instanceof ReferenceType) ){
+ constraintViolated(o, "Expecting a reference type as 'objectref' on the stack, not a '"+objref+"'.");
+ }
+ referenceTypeIsInitialized(o, (ReferenceType) objref);
+ if (!(objref instanceof ObjectType)){
+ if (!(objref instanceof ArrayType)){
+ constraintViolated(o, "Expecting an ObjectType as 'objectref' on the stack, not a '"+objref+"'."); // could be a ReturnaddressType
+ }
+ else{
+ objref = GENERIC_ARRAY;
+ }
+ }
+
+ String objref_classname = ((ObjectType) objref).getClassName();
+
+ String theInterface = o.getClassName(cpg);
+
+ // TODO: This can only be checked if we're using Staerk-et-al's "set of object types"
+ // instead of "wider cast object types" generated during verification.
+ //if ( ! Repository.implementationOf(objref_classname, theInterface) ){
+ // constraintViolated(o, "The 'objref' item '"+objref+"' does not implement '"+theInterface+"' as expected.");
+ //}
+
+ int counted_count = 1; // 1 for the objectref
+ for (int i=0; i<nargs; i++){
+ counted_count += argtypes[i].getSize();
+ }
+ if (count != counted_count){
+ constraintViolated(o, "The 'count' argument should probably read '"+counted_count+"' but is '"+count+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitINVOKESPECIAL(INVOKESPECIAL o){
+ // Don't init an object twice.
+ if ( (o.getMethodName(cpg).equals(Constants.CONSTRUCTOR_NAME)) && (!(stack().peek(o.getArgumentTypes(cpg).length) instanceof UninitializedObjectType)) ){
+ constraintViolated(o, "Possibly initializing object twice. A valid instruction sequence must not have an uninitialized object on the operand stack or in a local variable during a backwards branch, or in a local variable in code protected by an exception handler. Please see The Java Virtual Machine Specification, Second Edition, 4.9.4 (pages 147 and 148) for details.");
+ }
+
+ // the o.getClassType(cpg) type has passed pass 2; see visitLoadClass(o).
+
+ Type t = o.getType(cpg);
+ if (t instanceof ObjectType){
+ String name = ((ObjectType)t).getClassName();
+ Verifier v = VerifierFactory.getVerifier( name );
+ VerificationResult vr = v.doPass2();
+ if (vr.getStatus() != VerificationResult.VERIFIED_OK){
+ constraintViolated((Instruction) o, "Class '"+name+"' is referenced, but cannot be loaded and resolved: '"+vr+"'.");
+ }
+ }
+
+
+ Type[] argtypes = o.getArgumentTypes(cpg);
+ int nargs = argtypes.length;
+
+ for (int i=nargs-1; i>=0; i--){
+ Type fromStack = stack().peek( (nargs-1) - i ); // 0 to nargs-1
+ Type fromDesc = argtypes[i];
+ if (fromDesc == Type.BOOLEAN ||
+ fromDesc == Type.BYTE ||
+ fromDesc == Type.CHAR ||
+ fromDesc == Type.SHORT){
+ fromDesc = Type.INT;
+ }
+ if (! fromStack.equals(fromDesc)){
+ if (fromStack instanceof ReferenceType && fromDesc instanceof ReferenceType){
+ ReferenceType rFromStack = (ReferenceType) fromStack;
+ ReferenceType rFromDesc = (ReferenceType) fromDesc;
+ // TODO: This can only be checked using Staerk-et-al's "set of object types", not
+ // using a "wider cast object type".
+ //if ( ! rFromStack.isAssignmentCompatibleWith(rFromDesc) ){
+ // constraintViolated(o, "Expecting a '"+fromDesc+"' but found a '"+fromStack+"' on the stack (which is not assignment compatible).");
+ //}
+ }
+ else{
+ constraintViolated(o, "Expecting a '"+fromDesc+"' but found a '"+fromStack+"' on the stack.");
+ }
+ }
+ }
+
+ Type objref = stack().peek(nargs);
+ if (objref == Type.NULL){
+ return;
+ }
+ if (! (objref instanceof ReferenceType) ){
+ constraintViolated(o, "Expecting a reference type as 'objectref' on the stack, not a '"+objref+"'.");
+ }
+ String objref_classname = null;
+ if ( !(o.getMethodName(cpg).equals(Constants.CONSTRUCTOR_NAME))){
+ referenceTypeIsInitialized(o, (ReferenceType) objref);
+ if (!(objref instanceof ObjectType)){
+ if (!(objref instanceof ArrayType)){
+ constraintViolated(o, "Expecting an ObjectType as 'objectref' on the stack, not a '"+objref+"'."); // could be a ReturnaddressType
+ }
+ else{
+ objref = GENERIC_ARRAY;
+ }
+ }
+
+ objref_classname = ((ObjectType) objref).getClassName();
+ }
+ else{
+ if (!(objref instanceof UninitializedObjectType)){
+ constraintViolated(o, "Expecting an UninitializedObjectType as 'objectref' on the stack, not a '"+objref+"'. Otherwise, you couldn't invoke a method since an array has no methods (not to speak of a return address).");
+ }
+ objref_classname = ((UninitializedObjectType) objref).getInitialized().getClassName();
+ }
+
+
+ String theClass = o.getClassName(cpg);
+ if ( ! Repository.instanceOf(objref_classname, theClass) ){
+ constraintViolated(o, "The 'objref' item '"+objref+"' does not implement '"+theClass+"' as expected.");
+ }
+
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitINVOKESTATIC(INVOKESTATIC o){
+ // Method is not native, otherwise pass 3 would not happen.
+
+ Type t = o.getType(cpg);
+ if (t instanceof ObjectType){
+ String name = ((ObjectType)t).getClassName();
+ Verifier v = VerifierFactory.getVerifier( name );
+ VerificationResult vr = v.doPass2();
+ if (vr.getStatus() != VerificationResult.VERIFIED_OK){
+ constraintViolated((Instruction) o, "Class '"+name+"' is referenced, but cannot be loaded and resolved: '"+vr+"'.");
+ }
+ }
+
+ Type[] argtypes = o.getArgumentTypes(cpg);
+ int nargs = argtypes.length;
+
+ for (int i=nargs-1; i>=0; i--){
+ Type fromStack = stack().peek( (nargs-1) - i ); // 0 to nargs-1
+ Type fromDesc = argtypes[i];
+ if (fromDesc == Type.BOOLEAN ||
+ fromDesc == Type.BYTE ||
+ fromDesc == Type.CHAR ||
+ fromDesc == Type.SHORT){
+ fromDesc = Type.INT;
+ }
+ if (! fromStack.equals(fromDesc)){
+ if (fromStack instanceof ReferenceType && fromDesc instanceof ReferenceType){
+ ReferenceType rFromStack = (ReferenceType) fromStack;
+ ReferenceType rFromDesc = (ReferenceType) fromDesc;
+ // TODO: This check can only be done using Staerk-et-al's "set of object types"
+ // instead of a "wider cast object type" created during verification.
+ //if ( ! rFromStack.isAssignmentCompatibleWith(rFromDesc) ){
+ // constraintViolated(o, "Expecting a '"+fromDesc+"' but found a '"+fromStack+"' on the stack (which is not assignment compatible).");
+ //}
+ }
+ else{
+ constraintViolated(o, "Expecting a '"+fromDesc+"' but found a '"+fromStack+"' on the stack.");
+ }
+ }
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitINVOKEVIRTUAL(INVOKEVIRTUAL o){
+ // the o.getClassType(cpg) type has passed pass 2; see visitLoadClass(o).
+
+ Type t = o.getType(cpg);
+ if (t instanceof ObjectType){
+ String name = ((ObjectType)t).getClassName();
+ Verifier v = VerifierFactory.getVerifier( name );
+ VerificationResult vr = v.doPass2();
+ if (vr.getStatus() != VerificationResult.VERIFIED_OK){
+ constraintViolated((Instruction) o, "Class '"+name+"' is referenced, but cannot be loaded and resolved: '"+vr+"'.");
+ }
+ }
+
+
+ Type[] argtypes = o.getArgumentTypes(cpg);
+ int nargs = argtypes.length;
+
+ for (int i=nargs-1; i>=0; i--){
+ Type fromStack = stack().peek( (nargs-1) - i ); // 0 to nargs-1
+ Type fromDesc = argtypes[i];
+ if (fromDesc == Type.BOOLEAN ||
+ fromDesc == Type.BYTE ||
+ fromDesc == Type.CHAR ||
+ fromDesc == Type.SHORT){
+ fromDesc = Type.INT;
+ }
+ if (! fromStack.equals(fromDesc)){
+ if (fromStack instanceof ReferenceType && fromDesc instanceof ReferenceType){
+ ReferenceType rFromStack = (ReferenceType) fromStack;
+ ReferenceType rFromDesc = (ReferenceType) fromDesc;
+ // TODO: This can only be checked when using Staerk-et-al's "set of object types" instead
+ // of a single "wider cast object type" created during verification.
+ //if ( ! rFromStack.isAssignmentCompatibleWith(rFromDesc) ){
+ // constraintViolated(o, "Expecting a '"+fromDesc+"' but found a '"+fromStack+"' on the stack (which is not assignment compatible).");
+ //}
+ }
+ else{
+ constraintViolated(o, "Expecting a '"+fromDesc+"' but found a '"+fromStack+"' on the stack.");
+ }
+ }
+ }
+
+ Type objref = stack().peek(nargs);
+ if (objref == Type.NULL){
+ return;
+ }
+ if (! (objref instanceof ReferenceType) ){
+ constraintViolated(o, "Expecting a reference type as 'objectref' on the stack, not a '"+objref+"'.");
+ }
+ referenceTypeIsInitialized(o, (ReferenceType) objref);
+ if (!(objref instanceof ObjectType)){
+ if (!(objref instanceof ArrayType)){
+ constraintViolated(o, "Expecting an ObjectType as 'objectref' on the stack, not a '"+objref+"'."); // could be a ReturnaddressType
+ }
+ else{
+ objref = GENERIC_ARRAY;
+ }
+ }
+
+ String objref_classname = ((ObjectType) objref).getClassName();
+
+ String theClass = o.getClassName(cpg);
+
+ if ( ! Repository.instanceOf(objref_classname, theClass) ){
+ constraintViolated(o, "The 'objref' item '"+objref+"' does not implement '"+theClass+"' as expected.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIOR(IOR o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.INT){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIREM(IREM o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.INT){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIRETURN(IRETURN o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitISHL(ISHL o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.INT){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitISHR(ISHR o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.INT){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitISTORE(ISTORE o){
+ //visitStoreInstruction(StoreInstruction) is called before.
+
+ // Nothing else needs to be done here.
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitISUB(ISUB o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.INT){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIUSHR(IUSHR o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.INT){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitIXOR(IXOR o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.INT){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitJSR(JSR o){
+ // nothing to do here.
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitJSR_W(JSR_W o){
+ // nothing to do here.
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitL2D(L2D o){
+ if (stack().peek() != Type.LONG){
+ constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitL2F(L2F o){
+ if (stack().peek() != Type.LONG){
+ constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitL2I(L2I o){
+ if (stack().peek() != Type.LONG){
+ constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitLADD(LADD o){
+ if (stack().peek() != Type.LONG){
+ constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.LONG){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'long', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitLALOAD(LALOAD o){
+ indexOfInt(o, stack().peek());
+ if (stack().peek(1) == Type.NULL){
+ return;
+ }
+ if (! (stack().peek(1) instanceof ArrayType)){
+ constraintViolated(o, "Stack next-to-top must be of type long[] but is '"+stack().peek(1)+"'.");
+ }
+ Type t = ((ArrayType) (stack().peek(1))).getBasicType();
+ if (t != Type.LONG){
+ constraintViolated(o, "Stack next-to-top must be of type long[] but is '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitLAND(LAND o){
+ if (stack().peek() != Type.LONG){
+ constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.LONG){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'long', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitLASTORE(LASTORE o){
+ if (stack().peek() != Type.LONG){
+ constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'.");
+ }
+ indexOfInt(o, stack().peek(1));
+ if (stack().peek(2) == Type.NULL){
+ return;
+ }
+ if (! (stack().peek(2) instanceof ArrayType)){
+ constraintViolated(o, "Stack next-to-next-to-top must be of type long[] but is '"+stack().peek(2)+"'.");
+ }
+ Type t = ((ArrayType) (stack().peek(2))).getBasicType();
+ if (t != Type.LONG){
+ constraintViolated(o, "Stack next-to-next-to-top must be of type long[] but is '"+stack().peek(2)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitLCMP(LCMP o){
+ if (stack().peek() != Type.LONG){
+ constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.LONG){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'long', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitLCONST(LCONST o){
+ // Nothing to do here.
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitLDC(LDC o){
+ // visitCPInstruction is called first.
+
+ Constant c = cpg.getConstant(o.getIndex());
+ if (! ( ( c instanceof ConstantInteger) ||
+ ( c instanceof ConstantFloat ) ||
+ ( c instanceof ConstantString ) ) ){
+ constraintViolated(o, "Referenced constant should be a CONSTANT_Integer, a CONSTANT_Float or a CONSTANT_String, but is '"+c+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitLDC_W(LDC_W o){
+ // visitCPInstruction is called first.
+
+ Constant c = cpg.getConstant(o.getIndex());
+ if (! ( ( c instanceof ConstantInteger) ||
+ ( c instanceof ConstantFloat ) ||
+ ( c instanceof ConstantString ) ) ){
+ constraintViolated(o, "Referenced constant should be a CONSTANT_Integer, a CONSTANT_Float or a CONSTANT_String, but is '"+c+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitLDC2_W(LDC2_W o){
+ // visitCPInstruction is called first.
+
+ Constant c = cpg.getConstant(o.getIndex());
+ if (! ( ( c instanceof ConstantLong) ||
+ ( c instanceof ConstantDouble ) ) ){
+ constraintViolated(o, "Referenced constant should be a CONSTANT_Integer, a CONSTANT_Float or a CONSTANT_String, but is '"+c+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitLDIV(LDIV o){
+ if (stack().peek() != Type.LONG){
+ constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.LONG){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'long', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitLLOAD(LLOAD o){
+ //visitLoadInstruction(LoadInstruction) is called before.
+
+ // Nothing else needs to be done here.
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitLMUL(LMUL o){
+ if (stack().peek() != Type.LONG){
+ constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.LONG){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'long', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitLNEG(LNEG o){
+ if (stack().peek() != Type.LONG){
+ constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitLOOKUPSWITCH(LOOKUPSWITCH o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ // See also pass 3a.
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitLOR(LOR o){
+ if (stack().peek() != Type.LONG){
+ constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.LONG){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'long', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitLREM(LREM o){
+ if (stack().peek() != Type.LONG){
+ constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.LONG){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'long', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitLRETURN(LRETURN o){
+ if (stack().peek() != Type.LONG){
+ constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitLSHL(LSHL o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.LONG){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'long', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitLSHR(LSHR o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.LONG){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'long', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitLSTORE(LSTORE o){
+ //visitStoreInstruction(StoreInstruction) is called before.
+
+ // Nothing else needs to be done here.
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitLSUB(LSUB o){
+ if (stack().peek() != Type.LONG){
+ constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.LONG){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'long', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitLUSHR(LUSHR o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.LONG){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'long', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitLXOR(LXOR o){
+ if (stack().peek() != Type.LONG){
+ constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'.");
+ }
+ if (stack().peek(1) != Type.LONG){
+ constraintViolated(o, "The value at the stack next-to-top is not of type 'long', but of type '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitMONITORENTER(MONITORENTER o){
+ if (! ((stack().peek()) instanceof ReferenceType)){
+ constraintViolated(o, "The stack top should be of a ReferenceType, but is '"+stack().peek()+"'.");
+ }
+ referenceTypeIsInitialized(o, (ReferenceType) (stack().peek()) );
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitMONITOREXIT(MONITOREXIT o){
+ if (! ((stack().peek()) instanceof ReferenceType)){
+ constraintViolated(o, "The stack top should be of a ReferenceType, but is '"+stack().peek()+"'.");
+ }
+ referenceTypeIsInitialized(o, (ReferenceType) (stack().peek()) );
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitMULTIANEWARRAY(MULTIANEWARRAY o){
+ int dimensions = o.getDimensions();
+ // Dimensions argument is okay: see Pass 3a.
+ for (int i=0; i<dimensions; i++){
+ if (stack().peek(i) != Type.INT){
+ constraintViolated(o, "The '"+dimensions+"' upper stack types should be 'int' but aren't.");
+ }
+ }
+ // The runtime constant pool item at that index must be a symbolic reference to a class,
+ // array, or interface type. See Pass 3a.
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitNEW(NEW o){
+ //visitCPInstruction(CPInstruction) has been called before.
+ //visitLoadClass(LoadClass) has been called before.
+
+ Type t = o.getType(cpg);
+ if (! (t instanceof ReferenceType)){
+ throw new AssertionViolatedException("NEW.getType() returning a non-reference type?!");
+ }
+ if (! (t instanceof ObjectType)){
+ constraintViolated(o, "Expecting a class type (ObjectType) to work on. Found: '"+t+"'.");
+ }
+ ObjectType obj = (ObjectType) t;
+
+ //e.g.: Don't instantiate interfaces
+ if (! obj.referencesClass()){
+ constraintViolated(o, "Expecting a class type (ObjectType) to work on. Found: '"+obj+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitNEWARRAY(NEWARRAY o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitNOP(NOP o){
+ // nothing is to be done here.
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitPOP(POP o){
+ if (stack().peek().getSize() != 1){
+ constraintViolated(o, "Stack top size should be 1 but stack top is '"+stack().peek()+"' of size '"+stack().peek().getSize()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitPOP2(POP2 o){
+ if (stack().peek().getSize() != 2){
+ constraintViolated(o, "Stack top size should be 2 but stack top is '"+stack().peek()+"' of size '"+stack().peek().getSize()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitPUTFIELD(PUTFIELD o){
+
+ Type objectref = stack().peek(1);
+ if (! ( (objectref instanceof ObjectType) || (objectref == Type.NULL) ) ){
+ constraintViolated(o, "Stack next-to-top should be an object reference that's not an array reference, but is '"+objectref+"'.");
+ }
+
+ String field_name = o.getFieldName(cpg);
+
+ JavaClass jc = Repository.lookupClass(o.getClassType(cpg).getClassName());
+ Field[] fields = jc.getFields();
+ Field f = null;
+ for (int i=0; i<fields.length; i++){
+ if (fields[i].getName().equals(field_name)){
+ f = fields[i];
+ break;
+ }
+ }
+ if (f == null){
+ throw new AssertionViolatedException("Field not found?!?");
+ }
+
+ Type value = stack().peek();
+ Type t = Type.getType(f.getSignature());
+ Type shouldbe = t;
+ if (shouldbe == Type.BOOLEAN ||
+ shouldbe == Type.BYTE ||
+ shouldbe == Type.CHAR ||
+ shouldbe == Type.SHORT){
+ shouldbe = Type.INT;
+ }
+ if (t instanceof ReferenceType){
+ ReferenceType rvalue = null;
+ if (value instanceof ReferenceType){
+ rvalue = (ReferenceType) value;
+ referenceTypeIsInitialized(o, rvalue);
+ }
+ else{
+ constraintViolated(o, "The stack top type '"+value+"' is not of a reference type as expected.");
+ }
+ // TODO: This can only be checked using Staerk-et-al's "set-of-object types", not
+ // using "wider cast object types" created during verification.
+ //if (!(rvalue.isAssignmentCompatibleWith(shouldbe))){
+ // constraintViolated(o, "The stack top type '"+value+"' is not assignment compatible with '"+shouldbe+"'.");
+ //}
+ }
+ else{
+ if (shouldbe != value){
+ constraintViolated(o, "The stack top type '"+value+"' is not of type '"+shouldbe+"' as expected.");
+ }
+ }
+
+ if (f.isProtected()){
+ ObjectType classtype = o.getClassType(cpg);
+ ObjectType curr = new ObjectType(mg.getClassName());
+
+ if ( classtype.equals(curr) ||
+ curr.subclassOf(classtype) ){
+ Type tp = stack().peek(1);
+ if (tp == Type.NULL){
+ return;
+ }
+ if (! (tp instanceof ObjectType) ){
+ constraintViolated(o, "The 'objectref' must refer to an object that's not an array. Found instead: '"+tp+"'.");
+ }
+ ObjectType objreftype = (ObjectType) tp;
+ if (! ( objreftype.equals(curr) ||
+ objreftype.subclassOf(curr) ) ){
+ constraintViolated(o, "The referenced field has the ACC_PROTECTED modifier, and it's a member of the current class or a superclass of the current class. However, the referenced object type '"+stack().peek()+"' is not the current class or a subclass of the current class.");
+ }
+ }
+ }
+
+ // TODO: Could go into Pass 3a.
+ if (f.isStatic()){
+ constraintViolated(o, "Referenced field '"+f+"' is static which it shouldn't be.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitPUTSTATIC(PUTSTATIC o){
+ String field_name = o.getFieldName(cpg);
+ JavaClass jc = Repository.lookupClass(o.getClassType(cpg).getClassName());
+ Field[] fields = jc.getFields();
+ Field f = null;
+ for (int i=0; i<fields.length; i++){
+ if (fields[i].getName().equals(field_name)){
+ f = fields[i];
+ break;
+ }
+ }
+ if (f == null){
+ throw new AssertionViolatedException("Field not found?!?");
+ }
+ Type value = stack().peek();
+ Type t = Type.getType(f.getSignature());
+ Type shouldbe = t;
+ if (shouldbe == Type.BOOLEAN ||
+ shouldbe == Type.BYTE ||
+ shouldbe == Type.CHAR ||
+ shouldbe == Type.SHORT){
+ shouldbe = Type.INT;
+ }
+ if (t instanceof ReferenceType){
+ ReferenceType rvalue = null;
+ if (value instanceof ReferenceType){
+ rvalue = (ReferenceType) value;
+ referenceTypeIsInitialized(o, rvalue);
+ }
+ else{
+ constraintViolated(o, "The stack top type '"+value+"' is not of a reference type as expected.");
+ }
+ if (!(rvalue.isAssignmentCompatibleWith(shouldbe))){
+ constraintViolated(o, "The stack top type '"+value+"' is not assignment compatible with '"+shouldbe+"'.");
+ }
+ }
+ else{
+ if (shouldbe != value){
+ constraintViolated(o, "The stack top type '"+value+"' is not of type '"+shouldbe+"' as expected.");
+ }
+ }
+ // TODO: Interface fields may be assigned to only once. (Hard to implement in
+ // JustIce's execution model). This may only happen in <clinit>, see Pass 3a.
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitRET(RET o){
+ if (! (locals().get(o.getIndex()) instanceof ReturnaddressType)){
+ constraintViolated(o, "Expecting a ReturnaddressType in local variable "+o.getIndex()+".");
+ }
+ if (locals().get(o.getIndex()) == ReturnaddressType.NO_TARGET){
+ throw new AssertionViolatedException("Oops: RET expecting a target!");
+ }
+ // Other constraints such as non-allowed overlapping subroutines are enforced
+ // while building the Subroutines data structure.
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitRETURN(RETURN o){
+ if (mg.getName().equals(Constants.CONSTRUCTOR_NAME)){// If we leave an <init> method
+ if ((frame._this != null) && (!(mg.getClassName().equals(Type.OBJECT.getClassName()))) ) {
+ constraintViolated(o, "Leaving a constructor that itself did not call a constructor.");
+ }
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitSALOAD(SALOAD o){
+ indexOfInt(o, stack().peek());
+ if (stack().peek(1) == Type.NULL){
+ return;
+ }
+ if (! (stack().peek(1) instanceof ArrayType)){
+ constraintViolated(o, "Stack next-to-top must be of type short[] but is '"+stack().peek(1)+"'.");
+ }
+ Type t = ((ArrayType) (stack().peek(1))).getBasicType();
+ if (t != Type.SHORT){
+ constraintViolated(o, "Stack next-to-top must be of type short[] but is '"+stack().peek(1)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitSASTORE(SASTORE o){
+ if (stack().peek() != Type.INT){
+ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'.");
+ }
+ indexOfInt(o, stack().peek(1));
+ if (stack().peek(2) == Type.NULL){
+ return;
+ }
+ if (! (stack().peek(2) instanceof ArrayType)){
+ constraintViolated(o, "Stack next-to-next-to-top must be of type short[] but is '"+stack().peek(2)+"'.");
+ }
+ Type t = ((ArrayType) (stack().peek(2))).getBasicType();
+ if (t != Type.SHORT){
+ constraintViolated(o, "Stack next-to-next-to-top must be of type short[] but is '"+stack().peek(2)+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitSIPUSH(SIPUSH o){
+ // nothing to do here. Generic visitXXX() methods did the trick before.
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitSWAP(SWAP o){
+ if (stack().peek().getSize() != 1){
+ constraintViolated(o, "The value at the stack top is not of size '1', but of size '"+stack().peek().getSize()+"'.");
+ }
+ if (stack().peek(1).getSize() != 1){
+ constraintViolated(o, "The value at the stack next-to-top is not of size '1', but of size '"+stack().peek(1).getSize()+"'.");
+ }
+ }
+
+ /**
+ * Ensures the specific preconditions of the said instruction.
+ */
+ public void visitTABLESWITCH(TABLESWITCH o){
+ indexOfInt(o, stack().peek());
+ // See Pass 3a.
+ }
+
+}
+
diff --git a/src/java/org/apache/bcel/verifier/structurals/InstructionContext.java b/src/java/org/apache/bcel/verifier/structurals/InstructionContext.java
new file mode 100644
index 00000000..f737bd12
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/structurals/InstructionContext.java
@@ -0,0 +1,141 @@
+package org.apache.bcel.verifier.structurals;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.generic.InstructionHandle;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * An InstructionContext offers convenient access
+ * to information like control flow successors and
+ * such.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public interface InstructionContext{
+
+ /**
+ * The getTag and setTag methods may be used for
+ * temporary flagging, such as graph colouring.
+ * Nothing in the InstructionContext object depends
+ * on the value of the tag. JustIce does not use it.
+ *
+ * @see #setTag(int tag)
+ */
+ public int getTag();
+
+ /**
+ * The getTag and setTag methods may be used for
+ * temporary flagging, such as graph colouring.
+ * Nothing in the InstructionContext object depends
+ * on the value of the tag. JustIce does not use it.
+ *
+ * @see #getTag()
+ */
+ public void setTag(int tag);
+
+ /**
+ * This method symbolically executes the Instruction
+ * held in the InstructionContext.
+ * It "merges in" the incoming execution frame situation
+ * (see The Java Virtual Machine Specification, 2nd
+ * edition, page 146).
+ * By so doing, the outgoing execution frame situation
+ * is calculated.
+ *
+ * This method is JustIce-specific and is usually of
+ * no sense for users of the ControlFlowGraph class.
+ * They should use getInstruction().accept(Visitor),
+ * possibly in conjunction with the ExecutionVisitor.
+ *
+ *
+ * @see ControlFlowGraph
+ * @see ExecutionVisitor
+ * @see #getOutFrame(ArrayList)
+ * @return true - if and only if the "outgoing" frame situation
+ * changed from the one before execute()ing.
+ */
+ boolean execute(Frame inFrame, ArrayList executionPredecessors, InstConstraintVisitor icv, ExecutionVisitor ev);
+
+ /**
+ * This method returns the outgoing execution frame situation;
+ * therefore <B>it has to be calculated by execute(Frame, ArrayList)
+ * first.</B>
+ *
+ * @see #execute(Frame, ArrayList, InstConstraintVisitor, ExecutionVisitor)
+ */
+ Frame getOutFrame(ArrayList executionPredecessors);
+
+ /**
+ * Returns the InstructionHandle this InstructionContext is wrapped around.
+ *
+ * @return The InstructionHandle this InstructionContext is wrapped around.
+ */
+ InstructionHandle getInstruction();
+
+ /**
+ * Returns the usual control flow successors.
+ * @see #getExceptionHandlers()
+ */
+ InstructionContext[] getSuccessors();
+
+ /**
+ * Returns the exception handlers that protect this instruction.
+ * They are special control flow successors.
+ */
+ ExceptionHandler[] getExceptionHandlers();
+}
diff --git a/src/java/org/apache/bcel/verifier/structurals/LocalVariables.java b/src/java/org/apache/bcel/verifier/structurals/LocalVariables.java
new file mode 100644
index 00000000..6dad821b
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/structurals/LocalVariables.java
@@ -0,0 +1,229 @@
+package org.apache.bcel.verifier.structurals;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.generic.Type;
+import org.apache.bcel.generic.ReferenceType;
+import org.apache.bcel.verifier.exc.*;
+
+/**
+ * This class implements an array of local variables used for symbolic JVM
+ * simulation.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public class LocalVariables{
+ /** The Type[] containing the local variable slots. */
+ private Type[] locals;
+
+ /**
+ * Creates a new LocalVariables object.
+ */
+ public LocalVariables(int maxLocals){
+ locals = new Type[maxLocals];
+ for (int i=0; i<maxLocals; i++){
+ locals[i] = Type.UNKNOWN;
+ }
+ }
+
+ /**
+ * Returns a deep copy of this object; i.e. the clone
+ * operates on a new local variable array.
+ * However, the Type objects in the array are shared.
+ */
+ protected Object clone(){
+ LocalVariables lvs = new LocalVariables(locals.length);
+ for (int i=0; i<locals.length; i++){
+ lvs.locals[i] = this.locals[i];
+ }
+ return lvs;
+ }
+
+ /**
+ * Returns the type of the local variable slot i.
+ */
+ public Type get(int i){
+ return locals[i];
+ }
+
+ /**
+ * Returns a (correctly typed) clone of this object.
+ * This is equivalent to ((LocalVariables) this.clone()).
+ */
+ public LocalVariables getClone(){
+ return (LocalVariables) this.clone();
+ }
+
+ /**
+ * Returns the number of local variable slots this
+ * LocalVariables instance has.
+ */
+ public int maxLocals(){
+ return locals.length;
+ }
+
+ /**
+ * Sets a new Type for the given local variable slot.
+ */
+ public void set(int i, Type type){
+ if (type == Type.BYTE || type == Type.SHORT || type == Type.BOOLEAN || type == Type.CHAR){
+ throw new AssertionViolatedException("LocalVariables do not know about '"+type+"'. Use Type.INT instead.");
+ }
+ locals[i] = type;
+ }
+
+ /*
+ * Fulfills the general contract of Object.equals().
+ */
+ public boolean equals(Object o){
+ if (!(o instanceof LocalVariables)) return false;
+ LocalVariables lv = (LocalVariables) o;
+ if (this.locals.length != lv.locals.length) return false;
+ for (int i=0; i<this.locals.length; i++){
+ if (!this.locals[i].equals(lv.locals[i])){
+ //System.out.println(this.locals[i]+" is not "+lv.locals[i]);
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Merges two local variables sets as described in the Java Virtual Machine Specification,
+ * Second Edition, section 4.9.2, page 146.
+ */
+ public void merge(LocalVariables lv){
+
+ if (this.locals.length != lv.locals.length){
+ throw new AssertionViolatedException("Merging LocalVariables of different size?!? From different methods or what?!?");
+ }
+
+ for (int i=0; i<locals.length; i++){
+ merge(lv, i);
+ }
+ }
+
+ /**
+ * Merges a single local variable.
+ *
+ * @see #merge(LocalVariables)
+ */
+ private void merge(LocalVariables lv, int i){
+
+ // We won't accept an unitialized object if we know it was initialized;
+ // compare vmspec2, 4.9.4, last paragraph.
+ if ( (!(locals[i] instanceof UninitializedObjectType)) && (lv.locals[i] instanceof UninitializedObjectType) ){
+ throw new StructuralCodeConstraintException("Backwards branch with an uninitialized object in the local variables detected.");
+ }
+ // Even harder, what about _different_ uninitialized object types?!
+ if ( (!(locals[i].equals(lv.locals[i]))) && (locals[i] instanceof UninitializedObjectType) && (lv.locals[i] instanceof UninitializedObjectType) ){
+ throw new StructuralCodeConstraintException("Backwards branch with an uninitialized object in the local variables detected.");
+ }
+ // If we just didn't know that it was initialized, we have now learned.
+ if (locals[i] instanceof UninitializedObjectType){
+ if (! (lv.locals[i] instanceof UninitializedObjectType)){
+ locals[i] = ((UninitializedObjectType) locals[i]).getInitialized();
+ }
+ }
+ if ((locals[i] instanceof ReferenceType) && (lv.locals[i] instanceof ReferenceType)){
+ if (! locals[i].equals(lv.locals[i])){ // needed in case of two UninitializedObjectType instances
+ Type sup = ((ReferenceType) locals[i]).firstCommonSuperclass((ReferenceType) (lv.locals[i]));
+
+ if (sup != null){
+ locals[i] = sup;
+ }
+ else{
+ // We should have checked this in Pass2!
+ throw new AssertionViolatedException("Could not load all the super classes of '"+locals[i]+"' and '"+lv.locals[i]+"'.");
+ }
+ }
+ }
+ else{
+ if (! (locals[i].equals(lv.locals[i])) ){
+/*TODO
+ if ((locals[i] instanceof org.apache.bcel.generic.ReturnaddressType) && (lv.locals[i] instanceof org.apache.bcel.generic.ReturnaddressType)){
+ //System.err.println("merging "+locals[i]+" and "+lv.locals[i]);
+ throw new AssertionViolatedException("Merging different ReturnAddresses: '"+locals[i]+"' and '"+lv.locals[i]+"'.");
+ }
+*/
+ locals[i] = Type.UNKNOWN;
+ }
+ }
+ }
+
+ /**
+ * Returns a String representation of this object.
+ */
+ public String toString(){
+ String s = new String();
+ for (int i=0; i<locals.length; i++){
+ s += Integer.toString(i)+": "+locals[i]+"\n";
+ }
+ return s;
+ }
+
+ /**
+ * Replaces all occurences of u in this local variables set
+ * with an "initialized" ObjectType.
+ */
+ public void initializeObject(UninitializedObjectType u){
+ for (int i=0; i<locals.length; i++){
+ if (locals[i] == u){
+ locals[i] = u.getInitialized();
+ }
+ }
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/structurals/OperandStack.java b/src/java/org/apache/bcel/verifier/structurals/OperandStack.java
new file mode 100644
index 00000000..d7f50895
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/structurals/OperandStack.java
@@ -0,0 +1,275 @@
+package org.apache.bcel.verifier.structurals;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.generic.*;
+import org.apache.bcel.verifier.exc.*;
+import java.util.*;
+
+/**
+ * This class implements a stack used for symbolic JVM stack simulation.
+ * [It's used an an operand stack substitute.]
+ * Elements of this stack are org.apache.bcel.generic.Type objects.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public class OperandStack{
+
+ /** We hold the stack information here. */
+ private ArrayList stack = new ArrayList();
+
+ /** The maximum number of stack slots this OperandStack instance may hold. */
+ private int maxStack;
+
+ /**
+ * Creates an empty stack with a maximum of maxStack slots.
+ */
+ public OperandStack(int maxStack){
+ this.maxStack = maxStack;
+ }
+
+ /**
+ * Creates an otherwise empty stack with a maximum of maxStack slots and
+ * the ObjectType 'obj' at the top.
+ */
+ public OperandStack(int maxStack, ObjectType obj){
+ this.maxStack = maxStack;
+ this.push(obj);
+ }
+ /**
+ * Returns a deep copy of this object; that means, the clone operates
+ * on a new stack. However, the Type objects on the stack are
+ * shared.
+ */
+ protected Object clone(){
+ OperandStack newstack = new OperandStack(this.maxStack);
+ newstack.stack = (ArrayList) this.stack.clone();
+ return newstack;
+ }
+
+ /**
+ * Clears the stack.
+ */
+ public void clear(){
+ stack = new ArrayList();
+ }
+
+ /**
+ * Returns true if and only if this OperandStack
+ * equals another, meaning equal lengths and equal
+ * objects on the stacks.
+ */
+ public boolean equals(Object o){
+ if (!(o instanceof OperandStack)) return false;
+ OperandStack s = (OperandStack) o;
+ return this.stack.equals(s.stack);
+ }
+
+ /**
+ * Returns a (typed!) clone of this.
+ *
+ * @see #clone()
+ */
+ public OperandStack getClone(){
+ return (OperandStack) this.clone();
+ }
+
+ /**
+ * Returns true IFF this OperandStack is empty.
+ */
+ public boolean isEmpty(){
+ return stack.isEmpty();
+ }
+
+ /**
+ * Returns the number of stack slots this stack can hold.
+ */
+ public int maxStack(){
+ return this.maxStack;
+ }
+
+ /**
+ * Returns the element on top of the stack. The element is not popped off the stack!
+ */
+ public Type peek(){
+ return peek(0);
+ }
+
+ /**
+ * Returns the element that's i elements below the top element; that means,
+ * iff i==0 the top element is returned. The element is not popped off the stack!
+ */
+ public Type peek(int i){
+ return (Type) stack.get(size()-i-1);
+ }
+
+ /**
+ * Returns the element on top of the stack. The element is popped off the stack.
+ */
+ public Type pop(){
+ Type e = (Type) stack.remove(size()-1);
+ return e;
+ }
+
+ /**
+ * Pops i elements off the stack. ALWAYS RETURNS "null"!!!
+ */
+ public Type pop(int i){
+ for (int j=0; j<i; j++){
+ pop();
+ }
+ return null;
+ }
+
+ /**
+ * Pushes a Type object onto the stack.
+ */
+ public void push(Type type){
+ if (type == null) throw new AssertionViolatedException("Cannot push NULL onto OperandStack.");
+ if (type == Type.BOOLEAN || type == Type.CHAR || type == Type.BYTE || type == Type.SHORT){
+ throw new AssertionViolatedException("The OperandStack does not know about '"+type+"'; use Type.INT instead.");
+ }
+ if (slotsUsed() >= maxStack){
+ throw new AssertionViolatedException("OperandStack too small, should have thrown proper Exception elsewhere. Stack: "+this);
+ }
+ stack.add(type);
+ }
+
+ /**
+ * Returns the size of this OperandStack; that means, how many Type objects there are.
+ */
+ int size(){
+ return stack.size();
+ }
+
+ /**
+ * Returns the number of stack slots used.
+ * @see #maxStack()
+ */
+ public int slotsUsed(){
+ /* XXX change this to a better implementation using a variable
+ that keeps track of the actual slotsUsed()-value monitoring
+ all push()es and pop()s.
+ */
+ int slots = 0;
+ for (int i=0; i<stack.size(); i++){
+ slots += peek(i).getSize();
+ }
+ return slots;
+ }
+
+ /**
+ * Returns a String representation of this OperandStack instance.
+ */
+ public String toString(){
+ String s = "Slots used: "+slotsUsed()+" MaxStack: "+maxStack+".\n";
+ for (int i=0; i<size(); i++){
+ s+=peek(i)+" (Size: "+peek(i).getSize()+")\n";
+ }
+ return s;
+ }
+
+ /**
+ * Merges another stack state into this instance's stack state.
+ * See the Java Virtual Machine Specification, Second Edition, page 146: 4.9.2
+ * for details.
+ */
+ public void merge(OperandStack s){
+ if ( (slotsUsed() != s.slotsUsed()) || (size() != s.size()) )
+ throw new StructuralCodeConstraintException("Cannot merge stacks of different size:\nOperandStack A:\n"+this+"\nOperandStack B:\n"+s);
+
+ for (int i=0; i<size(); i++){
+ // If the object _was_ initialized and we're supposed to merge
+ // in some uninitialized object, we reject the code (see vmspec2, 4.9.4, last paragraph).
+ if ( (! (stack.get(i) instanceof UninitializedObjectType)) && (s.stack.get(i) instanceof UninitializedObjectType) ){
+ throw new StructuralCodeConstraintException("Backwards branch with an uninitialized object on the stack detected.");
+ }
+ // Even harder, we're not initialized but are supposed to broaden
+ // the known object type
+ if ( (!(stack.get(i).equals(s.stack.get(i)))) && (stack.get(i) instanceof UninitializedObjectType) && (!(s.stack.get(i) instanceof UninitializedObjectType))){
+ throw new StructuralCodeConstraintException("Backwards branch with an uninitialized object on the stack detected.");
+ }
+ // on the other hand...
+ if (stack.get(i) instanceof UninitializedObjectType){ //if we have an uninitialized object here
+ if (! (s.stack.get(i) instanceof UninitializedObjectType)){ //that has been initialized by now
+ stack.set(i, ((UninitializedObjectType) (stack.get(i))).getInitialized() ); //note that.
+ }
+ }
+ if (! stack.get(i).equals(s.stack.get(i))){
+ if ( (stack.get(i) instanceof ReferenceType) &&
+ (s.stack.get(i) instanceof ReferenceType) ){
+ stack.set(i, ((ReferenceType) stack.get(i)).firstCommonSuperclass((ReferenceType) (s.stack.get(i))));
+ }
+ else{
+ throw new StructuralCodeConstraintException("Cannot merge stacks of different types:\nStack A:\n"+this+"\nStack B:\n"+s);
+ }
+ }
+ }
+ }
+
+ /**
+ * Replaces all occurences of u in this OperandStack instance
+ * with an "initialized" ObjectType.
+ */
+ public void initializeObject(UninitializedObjectType u){
+ for (int i=0; i<stack.size(); i++){
+ if (stack.get(i) == u){
+ stack.set(i, u.getInitialized());
+ }
+ }
+ }
+
+}
diff --git a/src/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java b/src/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java
new file mode 100644
index 00000000..62373b74
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java
@@ -0,0 +1,366 @@
+package org.apache.bcel.verifier.structurals;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Random;
+import java.util.Vector;
+import org.apache.bcel.Constants;
+import org.apache.bcel.Repository;
+import org.apache.bcel.classfile.*;
+import org.apache.bcel.generic.*;
+import org.apache.bcel.verifier.*;
+import org.apache.bcel.verifier.statics.*;
+import org.apache.bcel.verifier.exc.*;
+
+/**
+ * This PassVerifier verifies a method of class file according to pass 3,
+ * so-called structural verification as described in The Java Virtual Machine
+ * Specification, 2nd edition.
+ * More detailed information is to be found at the do_verify() method's
+ * documentation.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ * @see #do_verify()
+ */
+
+public final class Pass3bVerifier extends PassVerifier{
+ /* TODO: Throughout pass 3b, upper halves of LONG and DOUBLE
+ are represented by Type.UNKNOWN. This should be changed
+ in favour of LONG_Upper and DOUBLE_Upper as in pass 2. */
+
+ /**
+ * An InstructionContextQueue is a utility class that holds
+ * (InstructionContext, ArrayList) pairs in a Queue data structure.
+ * This is used to hold information about InstructionContext objects
+ * externally --- i.e. that information is not saved inside the
+ * InstructionContext object itself. This is useful to save the
+ * execution path of the symbolic execution of the
+ * Pass3bVerifier - this is not information
+ * that belongs into the InstructionContext object itself.
+ * Only at "execute()"ing
+ * time, an InstructionContext object will get the current information
+ * we have about its symbolic execution predecessors.
+ */
+ private static final class InstructionContextQueue{
+ private Vector ics = new Vector(); // Type: InstructionContext
+ private Vector ecs = new Vector(); // Type: ArrayList (of InstructionContext)
+ public void add(InstructionContext ic, ArrayList executionChain){
+ ics.add(ic);
+ ecs.add(executionChain);
+ }
+ public boolean isEmpty(){
+ return ics.isEmpty();
+ }
+ public void remove(){
+ this.remove(0);
+ }
+ public void remove(int i){
+ ics.remove(i);
+ ecs.remove(i);
+ }
+ public InstructionContext getIC(int i){
+ return (InstructionContext) ics.get(i);
+ }
+ public ArrayList getEC(int i){
+ return (ArrayList) ecs.get(i);
+ }
+ public int size(){
+ return ics.size();
+ }
+ } // end Inner Class InstructionContextQueue
+
+ /** In DEBUG mode, the verification algorithm is not randomized. */
+ private static final boolean DEBUG = true;
+
+ /** The Verifier that created this. */
+ private Verifier myOwner;
+
+ /** The method number to verify. */
+ private int method_no;
+
+ /**
+ * This class should only be instantiated by a Verifier.
+ *
+ * @see org.apache.bcel.verifier.Verifier
+ */
+ public Pass3bVerifier(Verifier owner, int method_no){
+ myOwner = owner;
+ this.method_no = method_no;
+ }
+
+ /**
+ * Whenever the outgoing frame
+ * situation of an InstructionContext changes, all its successors are
+ * put [back] into the queue [as if they were unvisited].
+ * The proof of termination is about the existence of a
+ * fix point of frame merging.
+ */
+ private void circulationPump(ControlFlowGraph cfg, InstructionContext start, Frame vanillaFrame, InstConstraintVisitor icv, ExecutionVisitor ev){
+ final Random random = new Random();
+ InstructionContextQueue icq = new InstructionContextQueue();
+
+ start.execute(vanillaFrame, new ArrayList(), icv, ev); // new ArrayList() <=> no Instruction was executed before
+ // => Top-Level routine (no jsr call before)
+ icq.add(start, new ArrayList());
+
+ // LOOP!
+ while (!icq.isEmpty()){
+ InstructionContext u;
+ ArrayList ec;
+ if (!DEBUG){
+ int r = random.nextInt(icq.size());
+ u = icq.getIC(r);
+ ec = icq.getEC(r);
+ icq.remove(r);
+ }
+ else{
+ u = icq.getIC(0);
+ ec = icq.getEC(0);
+ icq.remove(0);
+ }
+
+ ArrayList oldchain = (ArrayList) (ec.clone());
+ ArrayList newchain = (ArrayList) (ec.clone());
+ newchain.add(u);
+
+ if ((u.getInstruction().getInstruction()) instanceof RET){
+//System.err.println(u);
+ // We can only follow _one_ successor, the one after the
+ // JSR that was recently executed.
+ RET ret = (RET) (u.getInstruction().getInstruction());
+ ReturnaddressType t = (ReturnaddressType) u.getOutFrame(oldchain).getLocals().get(ret.getIndex());
+ InstructionContext theSuccessor = cfg.contextOf(t.getTarget());
+
+ // Sanity check
+ InstructionContext lastJSR = null;
+ int skip_jsr = 0;
+ for (int ss=oldchain.size()-1; ss >= 0; ss--){
+ if (skip_jsr < 0){
+ throw new AssertionViolatedException("More RET than JSR in execution chain?!");
+ }
+//System.err.println("+"+oldchain.get(ss));
+ if (((InstructionContext) oldchain.get(ss)).getInstruction().getInstruction() instanceof JsrInstruction){
+ if (skip_jsr == 0){
+ lastJSR = (InstructionContext) oldchain.get(ss);
+ break;
+ }
+ else{
+ skip_jsr--;
+ }
+ }
+ if (((InstructionContext) oldchain.get(ss)).getInstruction().getInstruction() instanceof RET){
+ skip_jsr++;
+ }
+ }
+ if (lastJSR == null){
+ throw new AssertionViolatedException("RET without a JSR before in ExecutionChain?! EC: '"+oldchain+"'.");
+ }
+ JsrInstruction jsr = (JsrInstruction) (lastJSR.getInstruction().getInstruction());
+ if ( theSuccessor != (cfg.contextOf(jsr.physicalSuccessor())) ){
+ throw new AssertionViolatedException("RET '"+u.getInstruction()+"' info inconsistent: jump back to '"+theSuccessor+"' or '"+cfg.contextOf(jsr.physicalSuccessor())+"'?");
+ }
+
+ if (theSuccessor.execute(u.getOutFrame(oldchain), newchain, icv, ev)){
+ icq.add(theSuccessor, (ArrayList) newchain.clone());
+ }
+ }
+ else{// "not a ret"
+
+ // Normal successors. Add them to the queue of successors.
+ InstructionContext[] succs = u.getSuccessors();
+ for (int s=0; s<succs.length; s++){
+ InstructionContext v = succs[s];
+ if (v.execute(u.getOutFrame(oldchain), newchain, icv, ev)){
+ icq.add(v, (ArrayList) newchain.clone());
+ }
+ }
+ }// end "not a ret"
+
+ // Exception Handlers. Add them to the queue of successors.
+ // [subroutines are never protected; mandated by JustIce]
+ ExceptionHandler[] exc_hds = u.getExceptionHandlers();
+ for (int s=0; s<exc_hds.length; s++){
+ InstructionContext v = cfg.contextOf(exc_hds[s].getHandlerStart());
+ // TODO: the "oldchain" and "newchain" is used to determine the subroutine
+ // we're in (by searching for the last JSR) by the InstructionContext
+ // implementation. Therefore, we should not use this chain mechanism
+ // when dealing with exception handlers.
+ // Example: a JSR with an exception handler as its successor does not
+ // mean we're in a subroutine if we go to the exception handler.
+ // We should address this problem later; by now we simply "cut" the chain
+ // by using an empty chain for the exception handlers.
+ //if (v.execute(new Frame(u.getOutFrame(oldchain).getLocals(), new OperandStack (u.getOutFrame().getStack().maxStack(), (exc_hds[s].getExceptionType()==null? Type.THROWABLE : exc_hds[s].getExceptionType())) ), newchain), icv, ev){
+ //icq.add(v, (ArrayList) newchain.clone());
+ if (v.execute(new Frame(u.getOutFrame(oldchain).getLocals(), new OperandStack (u.getOutFrame(oldchain).getStack().maxStack(), (exc_hds[s].getExceptionType()==null? Type.THROWABLE : exc_hds[s].getExceptionType())) ), new ArrayList(), icv, ev)){
+ icq.add(v, new ArrayList());
+ }
+ }
+
+ }// while (!icq.isEmpty()) END
+
+ InstructionHandle ih = start.getInstruction();
+ do{
+ if ((ih.getInstruction() instanceof ReturnInstruction) && (!(cfg.isDead(ih)))) {
+ InstructionContext ic = cfg.contextOf(ih);
+ Frame f = ic.getOutFrame(new ArrayList()); // TODO: This is buggy, we check only the top-level return instructions this way.
+ LocalVariables lvs = f.getLocals();
+ for (int i=0; i<lvs.maxLocals(); i++){
+ if (lvs.get(i) instanceof UninitializedObjectType){
+ this.addMessage("Warning: ReturnInstruction '"+ic+"' may leave method with an uninitialized object in the local variables array '"+lvs+"'.");
+ }
+ }
+ OperandStack os = f.getStack();
+ for (int i=0; i<os.size(); i++){
+ if (os.peek(i) instanceof UninitializedObjectType){
+ this.addMessage("Warning: ReturnInstruction '"+ic+"' may leave method with an uninitialized object on the operand stack '"+os+"'.");
+ }
+ }
+ }
+ }while ((ih = ih.getNext()) != null);
+
+ }
+
+ /**
+ * Pass 3b implements the data flow analysis as described in the Java Virtual
+ * Machine Specification, Second Edition.
+ * Later versions will use LocalVariablesInfo objects to verify if the
+ * verifier-inferred types and the class file's debug information (LocalVariables
+ * attributes) match [TODO].
+ *
+ * @see org.apache.bcel.verifier.statics.LocalVariablesInfo
+ * @see org.apache.bcel.verifier.statics.Pass2Verifier#getLocalVariablesInfo(int)
+ */
+ public VerificationResult do_verify(){
+ if (! myOwner.doPass3a(method_no).equals(VerificationResult.VR_OK)){
+ return VerificationResult.VR_NOTYET;
+ }
+
+ // Pass 3a ran before, so it's safe to assume the JavaClass object is
+ // in the BCEL repository.
+ JavaClass jc = Repository.lookupClass(myOwner.getClassName());
+
+ ConstantPoolGen constantPoolGen = new ConstantPoolGen(jc.getConstantPool());
+ // Init Visitors
+ InstConstraintVisitor icv = new InstConstraintVisitor();
+ icv.setConstantPoolGen(constantPoolGen);
+
+ ExecutionVisitor ev = new ExecutionVisitor();
+ ev.setConstantPoolGen(constantPoolGen);
+
+ Method[] methods = jc.getMethods(); // Method no "method_no" exists, we ran Pass3a before on it!
+
+ try{
+
+ MethodGen mg = new MethodGen(methods[method_no], myOwner.getClassName(), constantPoolGen);
+
+ icv.setMethodGen(mg);
+
+ ////////////// DFA BEGINS HERE ////////////////
+ if (! (mg.isAbstract() || mg.isNative()) ){ // IF mg HAS CODE (See pass 2)
+
+ ControlFlowGraph cfg = new ControlFlowGraph(mg);
+
+ // Build the initial frame situation for this method.
+ Frame f = new Frame(mg.getMaxLocals(),mg.getMaxStack());
+ if ( !mg.isStatic() ){
+ if (mg.getName().equals(Constants.CONSTRUCTOR_NAME)){
+ f._this = new UninitializedObjectType(new ObjectType(jc.getClassName()));
+ f.getLocals().set(0, f._this);
+ }
+ else{
+ f._this = null;
+ f.getLocals().set(0, new ObjectType(jc.getClassName()));
+ }
+ }
+ Type[] argtypes = mg.getArgumentTypes();
+ int twoslotoffset = 0;
+ for (int j=0; j<argtypes.length; j++){
+ if (argtypes[j] == Type.SHORT || argtypes[j] == Type.BYTE || argtypes[j] == Type.CHAR || argtypes[j] == Type.BOOLEAN){
+ argtypes[j] = Type.INT;
+ }
+ f.getLocals().set(twoslotoffset + j + (mg.isStatic()?0:1), argtypes[j]);
+ if (argtypes[j].getSize() == 2){
+ twoslotoffset++;
+ f.getLocals().set(twoslotoffset + j + (mg.isStatic()?0:1), Type.UNKNOWN);
+ }
+ }
+ circulationPump(cfg, cfg.contextOf(mg.getInstructionList().getStart()), f, icv, ev);
+ }
+ }
+ catch (VerifierConstraintViolatedException ce){
+ ce.extendMessage("Constraint violated in method '"+methods[method_no]+"':\n","");
+ return new VerificationResult(VerificationResult.VERIFIED_REJECTED, ce.getMessage());
+ }
+ catch (RuntimeException re){
+ // These are internal errors
+
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ re.printStackTrace(pw);
+
+ throw new AssertionViolatedException("Some RuntimeException occured while verify()ing class '"+jc.getClassName()+"', method '"+methods[method_no]+"'. Original RuntimeException's stack trace:\n---\n"+sw+"---\n");
+ }
+ return VerificationResult.VR_OK;
+ }
+
+ /** Returns the method number as supplied when instantiating. */
+ public int getMethodNo(){
+ return method_no;
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/structurals/Subroutine.java b/src/java/org/apache/bcel/verifier/structurals/Subroutine.java
new file mode 100644
index 00000000..9f4b8b73
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/structurals/Subroutine.java
@@ -0,0 +1,126 @@
+package org.apache.bcel.verifier.structurals;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.generic.*;
+
+/**
+ * This interface defines properties of JVM bytecode subroutines.
+ * Note that it is 'abused' to maintain the top-level code in a
+ * consistent fashion, too.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public interface Subroutine{
+ /**
+ * Returns all the JsrInstructions that have the
+ * first instruction of this subroutine as their target.
+ * <B>Must not be invoked on the 'top-level subroutine'.</B>
+ */
+ public InstructionHandle[] getEnteringJsrInstructions();
+
+ /**
+ * Returns the one and only RET that leaves the subroutine.
+ * Note that JustIce has a pretty rigid notion of a subroutine.
+ * <B>Must not be invoked on the 'top-level subroutine'.</B>
+ *
+ * @see org.apache.bcel.verifier.structurals.Subroutines
+ */
+ public InstructionHandle getLeavingRET();
+
+ /**
+ * Returns all instructions that together form this subroutine.
+ * Note that an instruction is part of exactly one subroutine
+ * (the top-level code is considered to be a special subroutine) -
+ * else it is not reachable at all (dead code).
+ */
+ public InstructionHandle[] getInstructions();
+
+ /**
+ * Returns if the given InstructionHandle refers to an instruction
+ * that is part of this subroutine. This is a convenience method
+ * that saves iteration over the InstructionHandle objects returned
+ * by getInstructions().
+ *
+ * @see #getInstructions()
+ */
+ public boolean contains(InstructionHandle inst);
+
+ /**
+ * Returns an int[] containing the indices of the local variable slots
+ * accessed by this Subroutine (read-accessed, write-accessed or both);
+ * local variables referenced by subroutines of this subroutine are
+ * not included.
+ *
+ * @see #getRecursivelyAccessedLocalsIndices()
+ */
+ public int[] getAccessedLocalsIndices();
+
+ /**
+ * Returns an int[] containing the indices of the local variable slots
+ * accessed by this Subroutine (read-accessed, write-accessed or both);
+ * local variables referenced by subroutines of this subroutine are
+ * included.
+ *
+ * @see #getAccessedLocalsIndices()
+ */
+ public int[] getRecursivelyAccessedLocalsIndices();
+
+ /**
+ * Returns the subroutines that are directly called from this subroutine.
+ */
+ public Subroutine[] subSubs();
+}
diff --git a/src/java/org/apache/bcel/verifier/structurals/Subroutines.java b/src/java/org/apache/bcel/verifier/structurals/Subroutines.java
new file mode 100644
index 00000000..47b5444e
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/structurals/Subroutines.java
@@ -0,0 +1,668 @@
+package org.apache.bcel.verifier.structurals;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.generic.*;
+import org.apache.bcel.verifier.exc.*;
+import java.awt.Color;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+
+ /**
+ * Instances of this class contain information about the subroutines
+ * found in a code array of a method.
+ * This implementation considers the top-level (the instructions
+ * reachable without a JSR or JSR_W starting off from the first
+ * instruction in a code array of a method) being a special subroutine;
+ * see getTopLevel() for that.
+ * Please note that the definition of subroutines in the Java Virtual
+ * Machine Specification, Second Edition is somewhat incomplete.
+ * Therefore, JustIce uses an own, more rigid notion.
+ * Basically, a subroutine is a piece of code that starts at the target
+ * of a JSR of JSR_W instruction and ends at a corresponding RET
+ * instruction. Note also that the control flow of a subroutine
+ * may be complex and non-linear; and that subroutines may be nested.
+ * JustIce also mandates subroutines not to be protected by exception
+ * handling code (for the sake of control flow predictability).
+ * To understand JustIce's notion of subroutines, please read
+ *
+ * TODO: refer to the paper.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ * @see #getTopLevel()
+ */
+public class Subroutines{
+ /**
+ * This inner class implements the Subroutine interface.
+ */
+ private class SubroutineImpl implements Subroutine{
+ /**
+ * UNSET, a symbol for an uninitialized localVariable
+ * field. This is used for the "top-level" Subroutine;
+ * i.e. no subroutine.
+ */
+ private final int UNSET = -1;
+
+ /**
+ * The Local Variable slot where the first
+ * instruction of this subroutine (an ASTORE) stores
+ * the JsrInstruction's ReturnAddress in and
+ * the RET of this subroutine operates on.
+ */
+ private int localVariable = UNSET;
+
+ /** The instructions that belong to this subroutine. */
+ private HashSet instructions = new HashSet(); // Elements: InstructionHandle
+
+ /*
+ * Refer to the Subroutine interface for documentation.
+ */
+ public boolean contains(InstructionHandle inst){
+ return instructions.contains(inst);
+ }
+
+ /**
+ * The JSR or JSR_W instructions that define this
+ * subroutine by targeting it.
+ */
+ private HashSet theJSRs = new HashSet();
+
+ /**
+ * The RET instruction that leaves this subroutine.
+ */
+ private InstructionHandle theRET;
+
+ /**
+ * Returns a String representation of this object, merely
+ * for debugging purposes.
+ * (Internal) Warning: Verbosity on a problematic subroutine may cause
+ * stack overflow errors due to recursive subSubs() calls.
+ * Don't use this, then.
+ */
+ public String toString(){
+ String ret = "Subroutine: Local variable is '"+localVariable+"', JSRs are '"+theJSRs+"', RET is '"+theRET+"', Instructions: '"+instructions.toString()+"'.";
+
+ ret += " Accessed local variable slots: '";
+ int[] alv = getAccessedLocalsIndices();
+ for (int i=0; i<alv.length; i++){
+ ret += alv[i]+" ";
+ }
+ ret+="'.";
+
+ ret += " Recursively (via subsub...routines) accessed local variable slots: '";
+ alv = getRecursivelyAccessedLocalsIndices();
+ for (int i=0; i<alv.length; i++){
+ ret += alv[i]+" ";
+ }
+ ret+="'.";
+
+ return ret;
+ }
+
+ /**
+ * Sets the leaving RET instruction. Must be invoked after all instructions are added.
+ * Must not be invoked for top-level 'subroutine'.
+ */
+ void setLeavingRET(){
+ if (localVariable == UNSET){
+ throw new AssertionViolatedException("setLeavingRET() called for top-level 'subroutine' or forgot to set local variable first.");
+ }
+ Iterator iter = instructions.iterator();
+ InstructionHandle ret = null;
+ while(iter.hasNext()){
+ InstructionHandle actual = (InstructionHandle) iter.next();
+ if (actual.getInstruction() instanceof RET){
+ if (ret != null){
+ throw new StructuralCodeConstraintException("Subroutine with more then one RET detected: '"+ret+"' and '"+actual+"'.");
+ }
+ else{
+ ret = actual;
+ }
+ }
+ }
+ if (ret == null){
+ throw new StructuralCodeConstraintException("Subroutine without a RET detected.");
+ }
+ if (((RET) ret.getInstruction()).getIndex() != localVariable){
+ throw new StructuralCodeConstraintException("Subroutine uses '"+ret+"' which does not match the correct local variable '"+localVariable+"'.");
+ }
+ theRET = ret;
+ }
+
+ /*
+ * Refer to the Subroutine interface for documentation.
+ */
+ public InstructionHandle[] getEnteringJsrInstructions(){
+ if (this == TOPLEVEL) {
+ throw new AssertionViolatedException("getLeavingRET() called on top level pseudo-subroutine.");
+ }
+ InstructionHandle[] jsrs = new InstructionHandle[theJSRs.size()];
+ return (InstructionHandle[]) (theJSRs.toArray(jsrs));
+ }
+
+ /**
+ * Adds a new JSR or JSR_W that has this subroutine as its target.
+ */
+ public void addEnteringJsrInstruction(InstructionHandle jsrInst){
+ if ( (jsrInst == null) || (! (jsrInst.getInstruction() instanceof JsrInstruction))){
+ throw new AssertionViolatedException("Expecting JsrInstruction InstructionHandle.");
+ }
+ if (localVariable == UNSET){
+ throw new AssertionViolatedException("Set the localVariable first!");
+ }
+ else{
+ // Something is wrong when an ASTORE is targeted that does not operate on the same local variable than the rest of the
+ // JsrInstruction-targets and the RET.
+ // (We don't know out leader here so we cannot check if we're really targeted!)
+ if (localVariable != ((ASTORE) (((JsrInstruction) jsrInst.getInstruction()).getTarget().getInstruction())).getIndex()){
+ throw new AssertionViolatedException("Setting a wrong JsrInstruction.");
+ }
+ }
+ theJSRs.add(jsrInst);
+ }
+
+ /*
+ * Refer to the Subroutine interface for documentation.
+ */
+ public InstructionHandle getLeavingRET(){
+ if (this == TOPLEVEL) {
+ throw new AssertionViolatedException("getLeavingRET() called on top level pseudo-subroutine.");
+ }
+ return theRET;
+ }
+
+ /*
+ * Refer to the Subroutine interface for documentation.
+ */
+ public InstructionHandle[] getInstructions(){
+ InstructionHandle[] ret = new InstructionHandle[instructions.size()];
+ return (InstructionHandle[]) instructions.toArray(ret);
+ }
+
+ /*
+ * Adds an instruction to this subroutine.
+ * All instructions must have been added before invoking setLeavingRET().
+ * @see #setLeavingRET
+ */
+ void addInstruction(InstructionHandle ih){
+ if (theRET != null){
+ throw new AssertionViolatedException("All instructions must have been added before invoking setLeavingRET().");
+ }
+ instructions.add(ih);
+ }
+
+ /* Satisfies Subroutine.getRecursivelyAccessedLocalsIndices(). */
+ public int[] getRecursivelyAccessedLocalsIndices(){
+ HashSet s = new HashSet();
+ int[] lvs = getAccessedLocalsIndices();
+ for (int j=0; j<lvs.length; j++){
+ s.add(new Integer(lvs[j]));
+ }
+ _getRecursivelyAccessedLocalsIndicesHelper(s, this.subSubs());
+ int[] ret = new int[s.size()];
+ Iterator i = s.iterator();
+ int j=-1;
+ while (i.hasNext()){
+ j++;
+ ret[j] = ((Integer) i.next()).intValue();
+ }
+ return ret;
+ }
+
+ /**
+ * A recursive helper method for getRecursivelyAccessedLocalsIndices().
+ * @see #getRecursivelyAccessedLocalsIndices()
+ */
+ private void _getRecursivelyAccessedLocalsIndicesHelper(HashSet s, Subroutine[] subs){
+ for (int i=0; i<subs.length; i++){
+ int[] lvs = subs[i].getAccessedLocalsIndices();
+ for (int j=0; j<lvs.length; j++){
+ s.add(new Integer(lvs[j]));
+ }
+ if(subs[i].subSubs().length != 0){
+ _getRecursivelyAccessedLocalsIndicesHelper(s, subs[i].subSubs());
+ }
+ }
+ }
+
+ /*
+ * Satisfies Subroutine.getAccessedLocalIndices().
+ */
+ public int[] getAccessedLocalsIndices(){
+ //TODO: Implement caching.
+ HashSet acc = new HashSet();
+ if (theRET == null && this != TOPLEVEL){
+ throw new AssertionViolatedException("This subroutine object must be built up completely before calculating accessed locals.");
+ }
+ Iterator i = instructions.iterator();
+ while (i.hasNext()){
+ InstructionHandle ih = (InstructionHandle) i.next();
+ // RET is not a LocalVariableInstruction in the current version of BCEL.
+ if (ih.getInstruction() instanceof LocalVariableInstruction || ih.getInstruction() instanceof RET){
+ int idx = ((IndexedInstruction) (ih.getInstruction())).getIndex();
+ acc.add(new Integer(idx));
+ // LONG? DOUBLE?.
+ try{
+ // LocalVariableInstruction instances are typed without the need to look into
+ // the constant pool.
+ if (ih.getInstruction() instanceof LocalVariableInstruction){
+ int s = ((LocalVariableInstruction) ih.getInstruction()).getType(null).getSize();
+ if (s==2) acc.add(new Integer(idx+1));
+ }
+ }
+ catch(RuntimeException re){
+ throw new AssertionViolatedException("Oops. BCEL did not like NULL as a ConstantPoolGen object.");
+ }
+ }
+ }
+
+ int[] ret = new int[acc.size()];
+ i = acc.iterator();
+ int j=-1;
+ while (i.hasNext()){
+ j++;
+ ret[j] = ((Integer) i.next()).intValue();
+ }
+ return ret;
+ }
+
+ /*
+ * Satisfies Subroutine.subSubs().
+ */
+ public Subroutine[] subSubs(){
+ HashSet h = new HashSet();
+
+ Iterator i = instructions.iterator();
+ while (i.hasNext()){
+ Instruction inst = ((InstructionHandle) i.next()).getInstruction();
+ if (inst instanceof JsrInstruction){
+ InstructionHandle targ = ((JsrInstruction) inst).getTarget();
+ h.add(getSubroutine(targ));
+ }
+ }
+ Subroutine[] ret = new Subroutine[h.size()];
+ return (Subroutine[]) h.toArray(ret);
+ }
+
+ /*
+ * Sets the local variable slot the ASTORE that is targeted
+ * by the JsrInstructions of this subroutine operates on.
+ * This subroutine's RET operates on that same local variable
+ * slot, of course.
+ */
+ void setLocalVariable(int i){
+ if (localVariable != UNSET){
+ throw new AssertionViolatedException("localVariable set twice.");
+ }
+ else{
+ localVariable = i;
+ }
+ }
+
+ /**
+ * The default constructor.
+ */
+ public SubroutineImpl(){
+ }
+
+ }// end Inner Class SubrouteImpl
+
+ /**
+ * The Hashtable containing the subroutines found.
+ * Key: InstructionHandle of the leader of the subroutine.
+ * Elements: SubroutineImpl objects.
+ */
+ private Hashtable subroutines = new Hashtable();
+
+ /**
+ * This is referring to a special subroutine, namely the
+ * top level. This is not really a subroutine but we use
+ * it to distinguish between top level instructions and
+ * unreachable instructions.
+ */
+ public final Subroutine TOPLEVEL;
+
+ /**
+ * Constructor.
+ * @param il A MethodGen object representing method to
+ * create the Subroutine objects of.
+ */
+ public Subroutines(MethodGen mg){
+
+ InstructionHandle[] all = mg.getInstructionList().getInstructionHandles();
+ CodeExceptionGen[] handlers = mg.getExceptionHandlers();
+
+ // Define our "Toplevel" fake subroutine.
+ TOPLEVEL = new SubroutineImpl();
+
+ // Calculate "real" subroutines.
+ HashSet sub_leaders = new HashSet(); // Elements: InstructionHandle
+ InstructionHandle ih = all[0];
+ for (int i=0; i<all.length; i++){
+ Instruction inst = all[i].getInstruction();
+ if (inst instanceof JsrInstruction){
+ sub_leaders.add(((JsrInstruction) inst).getTarget());
+ }
+ }
+
+ // Build up the database.
+ Iterator iter = sub_leaders.iterator();
+ while (iter.hasNext()){
+ SubroutineImpl sr = new SubroutineImpl();
+ InstructionHandle astore = (InstructionHandle) (iter.next());
+ sr.setLocalVariable( ((ASTORE) (astore.getInstruction())).getIndex() );
+ subroutines.put(astore, sr);
+ }
+
+ // Fake it a bit. We want a virtual "TopLevel" subroutine.
+ subroutines.put(all[0], TOPLEVEL);
+ sub_leaders.add(all[0]);
+
+ // Tell the subroutines about their JsrInstructions.
+ // Note that there cannot be a JSR targeting the top-level
+ // since "Jsr 0" is disallowed in Pass 3a.
+ // Instructions shared by a subroutine and the toplevel are
+ // disallowed and checked below, after the BFS.
+ for (int i=0; i<all.length; i++){
+ Instruction inst = all[i].getInstruction();
+ if (inst instanceof JsrInstruction){
+ InstructionHandle leader = ((JsrInstruction) inst).getTarget();
+ ((SubroutineImpl) getSubroutine(leader)).addEnteringJsrInstruction(all[i]);
+ }
+ }
+
+ // Now do a BFS from every subroutine leader to find all the
+ // instructions that belong to a subroutine.
+ HashSet instructions_assigned = new HashSet(); // we don't want to assign an instruction to two or more Subroutine objects.
+
+ Hashtable colors = new Hashtable(); //Graph colouring. Key: InstructionHandle, Value: java.awt.Color .
+
+ iter = sub_leaders.iterator();
+ while (iter.hasNext()){
+ // Do some BFS with "actual" as the root of the graph.
+ InstructionHandle actual = (InstructionHandle) (iter.next());
+ // Init colors
+ for (int i=0; i<all.length; i++){
+ colors.put(all[i], Color.white);
+ }
+ colors.put(actual, Color.gray);
+ // Init Queue
+ ArrayList Q = new ArrayList();
+ Q.add(actual); // add(Obj) adds to the end, remove(0) removes from the start.
+
+ /* BFS ALGORITHM MODIFICATION: Start out with multiple "root" nodes, as exception handlers are starting points of top-level code, too. [why top-level? TODO: Refer to the special JustIce notion of subroutines.]*/
+ if (actual == all[0]){
+ for (int j=0; j<handlers.length; j++){
+ colors.put(handlers[j].getHandlerPC(), Color.gray);
+ Q.add(handlers[j].getHandlerPC());
+ }
+ }
+ /* CONTINUE NORMAL BFS ALGORITHM */
+
+ // Loop until Queue is empty
+ while (Q.size() != 0){
+ InstructionHandle u = (InstructionHandle) Q.remove(0);
+ InstructionHandle[] successors = getSuccessors(u);
+ for (int i=0; i<successors.length; i++){
+ if (((Color) colors.get(successors[i])) == Color.white){
+ colors.put(successors[i], Color.gray);
+ Q.add(successors[i]);
+ }
+ }
+ colors.put(u, Color.black);
+ }
+ // BFS ended above.
+ for (int i=0; i<all.length; i++){
+ if (colors.get(all[i]) == Color.black){
+ ((SubroutineImpl) (actual==all[0]?getTopLevel():getSubroutine(actual))).addInstruction(all[i]);
+ if (instructions_assigned.contains(all[i])){
+ throw new StructuralCodeConstraintException("Instruction '"+all[i]+"' is part of more than one subroutine (or of the top level and a subroutine).");
+ }
+ else{
+ instructions_assigned.add(all[i]);
+ }
+ }
+ }
+ if (actual != all[0]){// If we don't deal with the top-level 'subroutine'
+ ((SubroutineImpl) getSubroutine(actual)).setLeavingRET();
+ }
+ }
+
+ // Now make sure no instruction of a Subroutine is protected by exception handling code
+ // as is mandated by JustIces notion of subroutines.
+ for (int i=0; i<handlers.length; i++){
+ InstructionHandle _protected = handlers[i].getStartPC();
+ while (_protected != handlers[i].getEndPC().getNext()){// Note the inclusive/inclusive notation of "generic API" exception handlers!
+ Enumeration subs = subroutines.elements();
+ while (subs.hasMoreElements()){
+ Subroutine sub = (Subroutine) subs.nextElement();
+ if (sub != subroutines.get(all[0])){ // We don't want to forbid top-level exception handlers.
+ if (sub.contains(_protected)){
+ throw new StructuralCodeConstraintException("Subroutine instruction '"+_protected+"' is protected by an exception handler, '"+handlers[i]+"'. This is forbidden by the JustIce verifier due to its clear definition of subroutines.");
+ }
+ }
+ }
+ _protected = _protected.getNext();
+ }
+ }
+
+ // Now make sure no subroutine is calling a subroutine
+ // that uses the same local variable for the RET as themselves
+ // (recursively).
+ // This includes that subroutines may not call themselves
+ // recursively, even not through intermediate calls to other
+ // subroutines.
+ noRecursiveCalls(getTopLevel(), new HashSet());
+
+ }
+
+ /**
+ * This (recursive) utility method makes sure that
+ * no subroutine is calling a subroutine
+ * that uses the same local variable for the RET as themselves
+ * (recursively).
+ * This includes that subroutines may not call themselves
+ * recursively, even not through intermediate calls to other
+ * subroutines.
+ *
+ * @throws StructuralCodeConstraintException if the above constraint is not satisfied.
+ */
+ private void noRecursiveCalls(Subroutine sub, HashSet set){
+ Subroutine[] subs = sub.subSubs();
+
+ for (int i=0; i<subs.length; i++){
+ int index = ((RET) (subs[i].getLeavingRET().getInstruction())).getIndex();
+
+ if (!set.add(new Integer(index))){
+ // Don't use toString() here because of possibly infinite recursive subSubs() calls then.
+ SubroutineImpl si = (SubroutineImpl) subs[i];
+ throw new StructuralCodeConstraintException("Subroutine with local variable '"+si.localVariable+"', JSRs '"+si.theJSRs+"', RET '"+si.theRET+"' is called by a subroutine which uses the same local variable index as itself; maybe even a recursive call? JustIce's clean definition of a subroutine forbids both.");
+ }
+
+ noRecursiveCalls(subs[i], set);
+
+ set.remove(new Integer(index));
+ }
+ }
+
+ /**
+ * Returns the Subroutine object associated with the given
+ * leader (that is, the first instruction of the subroutine).
+ * You must not use this to get the top-level instructions
+ * modeled as a Subroutine object.
+ *
+ * @see #getTopLevel()
+ */
+ public Subroutine getSubroutine(InstructionHandle leader){
+ Subroutine ret = (Subroutine) subroutines.get(leader);
+
+ if (ret == null){
+ throw new AssertionViolatedException("Subroutine requested for an InstructionHandle that is not a leader of a subroutine.");
+ }
+
+ if (ret == TOPLEVEL){
+ throw new AssertionViolatedException("TOPLEVEL special subroutine requested; use getTopLevel().");
+ }
+
+ return ret;
+ }
+
+ /**
+ * Returns the subroutine object associated with the
+ * given instruction. This is a costly operation, you
+ * should consider using getSubroutine(InstructionHandle).
+ * Returns 'null' if the given InstructionHandle lies
+ * in so-called 'dead code', i.e. code that can never
+ * be executed.
+ *
+ * @see #getSubroutine(InstructionHandle)
+ * @see #getTopLevel()
+ */
+ public Subroutine subroutineOf(InstructionHandle any){
+ Iterator i = subroutines.values().iterator();
+ while (i.hasNext()){
+ Subroutine s = (Subroutine) i.next();
+ if (s.contains(any)) return s;
+ }
+System.err.println("DEBUG: Please verify '"+any+"' lies in dead code.");
+ return null;
+ //throw new AssertionViolatedException("No subroutine for InstructionHandle found (DEAD CODE?).");
+ }
+
+ /**
+ * For easy handling, the piece of code that is <B>not</B> a
+ * subroutine, the top-level, is also modeled as a Subroutine
+ * object.
+ * It is a special Subroutine object where <B>you must not invoke
+ * getEnteringJsrInstructions() or getLeavingRET()</B>.
+ *
+ * @see Subroutine#getEnteringJsrInstructions()
+ * @see Subroutine#getLeavingRET()
+ */
+ public Subroutine getTopLevel(){
+ return TOPLEVEL;
+ }
+ /**
+ * A utility method that calculates the successors of a given InstructionHandle
+ * <B>in the same subroutine</B>. That means, a RET does not have any successors
+ * as defined here. A JsrInstruction has its physical successor as its successor
+ * (opposed to its target) as defined here.
+ */
+ private static InstructionHandle[] getSuccessors(InstructionHandle instruction){
+ final InstructionHandle[] empty = new InstructionHandle[0];
+ final InstructionHandle[] single = new InstructionHandle[1];
+ final InstructionHandle[] pair = new InstructionHandle[2];
+
+ Instruction inst = instruction.getInstruction();
+
+ if (inst instanceof RET){
+ return empty;
+ }
+
+ // Terminates method normally.
+ if (inst instanceof ReturnInstruction){
+ return empty;
+ }
+
+ // Terminates method abnormally, because JustIce mandates
+ // subroutines not to be protected by exception handlers.
+ if (inst instanceof ATHROW){
+ return empty;
+ }
+
+ // See method comment.
+ if (inst instanceof JsrInstruction){
+ single[0] = instruction.getNext();
+ return single;
+ }
+
+ if (inst instanceof GotoInstruction){
+ single[0] = ((GotoInstruction) inst).getTarget();
+ return single;
+ }
+
+ if (inst instanceof BranchInstruction){
+ if (inst instanceof Select){
+ // BCEL's getTargets() returns only the non-default targets,
+ // thanks to Eli Tilevich for reporting.
+ InstructionHandle[] matchTargets = ((Select) inst).getTargets();
+ InstructionHandle[] ret = new InstructionHandle[matchTargets.length+1];
+ ret[0] = ((Select) inst).getTarget();
+ System.arraycopy(matchTargets, 0, ret, 1, matchTargets.length);
+ return ret;
+ }
+ else{
+ pair[0] = instruction.getNext();
+ pair[1] = ((BranchInstruction) inst).getTarget();
+ return pair;
+ }
+ }
+
+ // default case: Fall through.
+ single[0] = instruction.getNext();
+ return single;
+ }
+
+ /**
+ * Returns a String representation of this object; merely for debugging puposes.
+ */
+ public String toString(){
+ return "---\n"+subroutines.toString()+"\n---\n";
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/structurals/UninitializedObjectType.java b/src/java/org/apache/bcel/verifier/structurals/UninitializedObjectType.java
new file mode 100644
index 00000000..ac9bbddb
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/structurals/UninitializedObjectType.java
@@ -0,0 +1,97 @@
+package org.apache.bcel.verifier.structurals;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache BCEL" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache BCEL", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.bcel.*;
+import org.apache.bcel.generic.*;
+
+/**
+ * This class represents an uninitialized object type; see The Java
+ * Virtual Machine Specification, Second Edition, page 147: 4.9.4 for
+ * more details.
+ *
+ * @version $Id$
+ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
+ */
+public class UninitializedObjectType extends ReferenceType implements Constants{
+
+ /** The "initialized" version. */
+ private ObjectType initialized;
+
+ /** Creates a new instance. */
+ public UninitializedObjectType(ObjectType t){
+ super(T_UNKNOWN, "<UNINITIALIZED OBJECT OF TYPE '"+t.getClassName()+"'>");
+ initialized = t;
+ }
+
+ /**
+ * Returns the ObjectType of the same class as the one of the uninitialized object
+ * represented by this UninitializedObjectType instance.
+ */
+ public ObjectType getInitialized(){
+ return initialized;
+ }
+
+ /**
+ * Returns true on equality of this and o.
+ * Equality means the ObjectType instances of "initialized"
+ * equal one another in this and the o instance.
+ *
+ */
+ public boolean equals(Object o){
+ if (! (o instanceof UninitializedObjectType)) return false;
+ return initialized.equals(((UninitializedObjectType)o).initialized);
+ }
+}
diff --git a/src/java/org/apache/bcel/verifier/structurals/package.html b/src/java/org/apache/bcel/verifier/structurals/package.html
new file mode 100644
index 00000000..915ff5e9
--- /dev/null
+++ b/src/java/org/apache/bcel/verifier/structurals/package.html
@@ -0,0 +1,27 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+$Id$
+-->
+</head>
+<body bgcolor="white">
+
+Provides a PassVerifier class mostly used internally by JustIce, yielding a control flow graph for public use as
+a nice side effect.
+
+<h2>Package Specification</h2>
+
+Contained in this package is a PassVerifier class for use with the JustIce verifier and its utility classes.
+Only the pass performing what Sun calls "Structural Constraints on Java Virtual Machine Code"
+has a PassVerifier class here. JustIce calls this pass "Pass 3b".
+
+<h2>Related Documentation</h2>
+
+For a simple demonstration of JustIce working, please see:
+<ul>
+ <li><a href="http://www.inf.fu-berlin.de/~ehaase/cgi-html/Verifier.html">A WWW front-end for JustIce.</a>
+</ul>
+
+</body>
+</html>