From f1f683f6481b8a9f550aa0e2be1bef966a5add22 Mon Sep 17 00:00:00 2001 From: Admin Date: Wed, 17 Oct 2018 13:02:58 +0200 Subject: [PATCH 1/3] Updated the BCEL project to the latest Apache BCEL version in order to have JaMoPP parse newer class files. --- .../.classpath | 14 +- .../.settings/org.eclipse.jdt.core.prefs | 7 +- .../META-INF/MANIFEST.MF | 8 +- .../src-bcel/org/apache/bcel/Const.java | 2330 +++++++++++++ .../src-bcel/org/apache/bcel/Constants.java | 1697 ++++++++++ .../org/apache/bcel/ExceptionConst.java | 126 + .../org/apache/bcel/ExceptionConstants.java | 88 + .../{bcel5_2_0 => bcel}/Repository.java | 524 +-- .../apache/bcel/classfile/AccessFlags.java | 219 ++ .../bcel/classfile/AnnotationDefault.java | 94 + .../classfile/AnnotationElementValue.java | 65 + .../bcel/classfile/AnnotationEntry.java | 168 + .../apache/bcel/classfile/Annotations.java | 114 + .../bcel/classfile/ArrayElementValue.java | 92 + .../org/apache/bcel/classfile/Attribute.java | 372 +++ .../classfile/AttributeReader.java | 118 +- .../bcel/classfile/BootstrapMethod.java | 169 + .../bcel/classfile/BootstrapMethods.java | 144 + .../bcel/classfile/ClassElementValue.java | 67 + .../bcel/classfile/ClassFormatException.java | 46 + .../classfile/ClassParser.java | 610 ++-- .../{bcel5_2_0 => bcel}/classfile/Code.java | 707 ++-- .../classfile/CodeException.java | 433 +-- .../org/apache/bcel/classfile/Constant.java | 215 ++ .../org/apache/bcel/classfile/ConstantCP.java | 151 + .../classfile/ConstantClass.java | 261 +- .../classfile/ConstantDouble.java | 243 +- .../bcel/classfile/ConstantFieldref.java | 71 + .../classfile/ConstantFloat.java | 245 +- .../classfile/ConstantInteger.java | 243 +- .../classfile/ConstantInterfaceMethodref.java | 71 + .../bcel/classfile/ConstantInvokeDynamic.java | 90 + .../classfile/ConstantLong.java | 243 +- .../bcel/classfile/ConstantMethodHandle.java | 120 + .../bcel/classfile/ConstantMethodType.java | 106 + .../bcel/classfile/ConstantMethodref.java | 71 + .../apache/bcel/classfile/ConstantModule.java | 134 + .../classfile/ConstantNameAndType.java | 300 +- .../classfile/ConstantObject.java | 64 +- .../bcel/classfile/ConstantPackage.java | 134 + .../classfile/ConstantPool.java | 726 ++-- .../classfile/ConstantString.java | 259 +- .../apache/bcel/classfile/ConstantUtf8.java | 211 ++ .../classfile/ConstantValue.java | 316 +- .../classfile/Deprecated.java | 287 +- .../bcel/classfile/DescendingVisitor.java | 546 +++ .../apache/bcel/classfile/ElementValue.java | 131 + .../bcel/classfile/ElementValuePair.java | 76 + .../apache/bcel/classfile/EmptyVisitor.java | 313 ++ .../bcel/classfile/EnclosingMethod.java | 106 + .../bcel/classfile/EnumElementValue.java | 86 + .../classfile/ExceptionTable.java | 363 +- .../{bcel5_2_0 => bcel}/classfile/Field.java | 390 +-- .../apache/bcel/classfile/FieldOrMethod.java | 293 ++ .../classfile/InnerClass.java | 432 +-- .../classfile/InnerClasses.java | 308 +- .../classfile/JavaClass.java | 1796 +++++----- .../classfile/LineNumber.java | 289 +- .../classfile/LineNumberTable.java | 425 +-- .../classfile/LocalVariable.java | 543 +-- .../classfile/LocalVariableTable.java | 395 ++- .../classfile/LocalVariableTypeTable.java | 150 + .../{bcel5_2_0 => bcel}/classfile/Method.java | 525 +-- .../bcel/classfile/MethodParameter.java | 116 + .../bcel/classfile/MethodParameters.java | 86 + .../org/apache/bcel/classfile/Node.java | 28 + .../classfile/PMGClass.java | 341 +- .../classfile/ParameterAnnotationEntry.java | 92 + .../bcel/classfile/ParameterAnnotations.java | 123 + .../RuntimeInvisibleAnnotations.java | 66 + .../RuntimeInvisibleParameterAnnotations.java | 44 + .../classfile/RuntimeVisibleAnnotations.java | 65 + .../RuntimeVisibleParameterAnnotations.java | 44 + .../classfile/Signature.java | 544 ++- .../bcel/classfile/SimpleElementValue.java | 225 ++ .../classfile/SourceFile.java | 296 +- .../classfile/StackMap.java | 315 +- .../apache/bcel/classfile/StackMapEntry.java | 436 +++ .../classfile/StackMapType.java | 329 +- .../classfile/Synthetic.java | 307 +- .../classfile/Unknown.java | 378 +-- .../classfile/UnknownAttributeReader.java | 50 + .../classfile/Utility.java | 2852 ++++++++-------- .../org/apache/bcel/classfile/Visitor.java | 159 + .../org/apache/bcel/classfile/package.html | 30 + .../{bcel5_2_0 => bcel}/generic/AALOAD.java | 101 +- .../{bcel5_2_0 => bcel}/generic/AASTORE.java | 101 +- .../generic/ACONST_NULL.java | 116 +- .../{bcel5_2_0 => bcel}/generic/ALOAD.java | 115 +- .../generic/ANEWARRAY.java | 158 +- .../{bcel5_2_0 => bcel}/generic/ARETURN.java | 103 +- .../generic/ARRAYLENGTH.java | 118 +- .../{bcel5_2_0 => bcel}/generic/ASTORE.java | 115 +- .../{bcel5_2_0 => bcel}/generic/ATHROW.java | 120 +- .../bcel/generic/AllocationInstruction.java | 26 + .../generic/AnnotationElementValueGen.java | 86 + .../bcel/generic/AnnotationEntryGen.java | 355 ++ .../bcel/generic/ArithmeticInstruction.java | 96 + .../bcel/generic/ArrayElementValueGen.java | 127 + .../apache/bcel/generic/ArrayInstruction.java | 86 + .../generic/ArrayType.java | 256 +- .../{bcel5_2_0 => bcel}/generic/BALOAD.java | 101 +- .../{bcel5_2_0 => bcel}/generic/BASTORE.java | 101 +- .../{bcel5_2_0 => bcel}/generic/BIPUSH.java | 218 +- .../generic/BREAKPOINT.java | 87 +- .../org/apache/bcel/generic/BasicType.java | 84 + .../generic/BranchHandle.java | 251 +- .../generic/BranchInstruction.java | 515 +-- .../{bcel5_2_0 => bcel}/generic/CALOAD.java | 101 +- .../{bcel5_2_0 => bcel}/generic/CASTORE.java | 101 +- .../generic/CHECKCAST.java | 168 +- .../generic/CPInstruction.java | 289 +- .../bcel/generic/ClassElementValueGen.java | 103 + .../org/apache/bcel/generic/ClassGen.java | 607 ++++ .../bcel/generic/ClassGenException.java | 42 + .../apache/bcel/generic/ClassObserver.java | 29 + .../generic/CodeExceptionGen.java | 371 ++- .../generic/CompoundInstruction.java | 76 +- .../generic/ConstantPoolGen.java | 1601 ++++----- .../bcel/generic/ConstantPushInstruction.java | 32 + .../bcel/generic/ConversionInstruction.java | 78 + .../{bcel5_2_0 => bcel}/generic/D2F.java | 101 +- .../{bcel5_2_0 => bcel}/generic/D2I.java | 101 +- .../{bcel5_2_0 => bcel}/generic/D2L.java | 101 +- .../{bcel5_2_0 => bcel}/generic/DADD.java | 103 +- .../{bcel5_2_0 => bcel}/generic/DALOAD.java | 101 +- .../{bcel5_2_0 => bcel}/generic/DASTORE.java | 101 +- .../{bcel5_2_0 => bcel}/generic/DCMPG.java | 109 +- .../{bcel5_2_0 => bcel}/generic/DCMPL.java | 109 +- .../{bcel5_2_0 => bcel}/generic/DCONST.java | 163 +- .../{bcel5_2_0 => bcel}/generic/DDIV.java | 103 +- .../{bcel5_2_0 => bcel}/generic/DLOAD.java | 115 +- .../{bcel5_2_0 => bcel}/generic/DMUL.java | 103 +- .../{bcel5_2_0 => bcel}/generic/DNEG.java | 97 +- .../{bcel5_2_0 => bcel}/generic/DREM.java | 103 +- .../{bcel5_2_0 => bcel}/generic/DRETURN.java | 101 +- .../{bcel5_2_0 => bcel}/generic/DSTORE.java | 115 +- .../{bcel5_2_0 => bcel}/generic/DSUB.java | 103 +- .../{bcel5_2_0 => bcel}/generic/DUP.java | 95 +- .../{bcel5_2_0 => bcel}/generic/DUP2.java | 95 +- .../{bcel5_2_0 => bcel}/generic/DUP2_X1.java | 91 +- .../{bcel5_2_0 => bcel}/generic/DUP2_X2.java | 91 +- .../{bcel5_2_0 => bcel}/generic/DUP_X1.java | 91 +- .../{bcel5_2_0 => bcel}/generic/DUP_X2.java | 91 +- .../apache/bcel/generic/ElementValueGen.java | 194 ++ .../bcel/generic/ElementValuePairGen.java | 115 + .../org/apache/bcel/generic/EmptyVisitor.java | 932 ++++++ .../bcel/generic/EnumElementValueGen.java | 142 + .../generic/ExceptionThrower.java | 84 +- .../{bcel5_2_0 => bcel}/generic/F2D.java | 101 +- .../{bcel5_2_0 => bcel}/generic/F2I.java | 101 +- .../{bcel5_2_0 => bcel}/generic/F2L.java | 101 +- .../{bcel5_2_0 => bcel}/generic/FADD.java | 101 +- .../{bcel5_2_0 => bcel}/generic/FALOAD.java | 101 +- .../{bcel5_2_0 => bcel}/generic/FASTORE.java | 101 +- .../{bcel5_2_0 => bcel}/generic/FCMPG.java | 110 +- .../{bcel5_2_0 => bcel}/generic/FCMPL.java | 110 +- .../{bcel5_2_0 => bcel}/generic/FCONST.java | 167 +- .../{bcel5_2_0 => bcel}/generic/FDIV.java | 101 +- .../{bcel5_2_0 => bcel}/generic/FLOAD.java | 115 +- .../{bcel5_2_0 => bcel}/generic/FMUL.java | 101 +- .../{bcel5_2_0 => bcel}/generic/FNEG.java | 97 +- .../{bcel5_2_0 => bcel}/generic/FREM.java | 101 +- .../{bcel5_2_0 => bcel}/generic/FRETURN.java | 101 +- .../{bcel5_2_0 => bcel}/generic/FSTORE.java | 115 +- .../{bcel5_2_0 => bcel}/generic/FSUB.java | 101 +- .../org/apache/bcel/generic/FieldGen.java | 381 +++ .../bcel/generic/FieldGenOrMethodGen.java | 191 ++ .../apache/bcel/generic/FieldInstruction.java | 82 + .../apache/bcel/generic/FieldObserver.java | 29 + .../apache/bcel/generic/FieldOrMethod.java | 139 + .../{bcel5_2_0 => bcel}/generic/GETFIELD.java | 162 +- .../generic/GETSTATIC.java | 158 +- .../org/apache/bcel/generic/GOTO.java | 99 + .../org/apache/bcel/generic/GOTO_W.java | 83 + .../apache/bcel/generic/GotoInstruction.java | 38 + .../{bcel5_2_0 => bcel}/generic/I2B.java | 101 +- .../{bcel5_2_0 => bcel}/generic/I2C.java | 101 +- .../{bcel5_2_0 => bcel}/generic/I2D.java | 101 +- .../{bcel5_2_0 => bcel}/generic/I2F.java | 101 +- .../{bcel5_2_0 => bcel}/generic/I2L.java | 101 +- .../{bcel5_2_0 => bcel}/generic/I2S.java | 97 +- .../{bcel5_2_0 => bcel}/generic/IADD.java | 101 +- .../{bcel5_2_0 => bcel}/generic/IALOAD.java | 103 +- .../{bcel5_2_0 => bcel}/generic/IAND.java | 97 +- .../{bcel5_2_0 => bcel}/generic/IASTORE.java | 103 +- .../{bcel5_2_0 => bcel}/generic/ICONST.java | 159 +- .../{bcel5_2_0 => bcel}/generic/IDIV.java | 124 +- .../{bcel5_2_0 => bcel}/generic/IFEQ.java | 130 +- .../{bcel5_2_0 => bcel}/generic/IFGE.java | 130 +- .../{bcel5_2_0 => bcel}/generic/IFGT.java | 130 +- .../{bcel5_2_0 => bcel}/generic/IFLE.java | 130 +- .../{bcel5_2_0 => bcel}/generic/IFLT.java | 130 +- .../{bcel5_2_0 => bcel}/generic/IFNE.java | 130 +- .../generic/IFNONNULL.java | 130 +- .../{bcel5_2_0 => bcel}/generic/IFNULL.java | 130 +- .../generic/IF_ACMPEQ.java | 130 +- .../generic/IF_ACMPNE.java | 130 +- .../generic/IF_ICMPEQ.java | 130 +- .../generic/IF_ICMPGE.java | 130 +- .../generic/IF_ICMPGT.java | 130 +- .../generic/IF_ICMPLE.java | 130 +- .../generic/IF_ICMPLT.java | 130 +- .../generic/IF_ICMPNE.java | 130 +- .../{bcel5_2_0 => bcel}/generic/IINC.java | 329 +- .../{bcel5_2_0 => bcel}/generic/ILOAD.java | 115 +- .../{bcel5_2_0 => bcel}/generic/IMPDEP1.java | 87 +- .../{bcel5_2_0 => bcel}/generic/IMPDEP2.java | 87 +- .../{bcel5_2_0 => bcel}/generic/IMUL.java | 101 +- .../{bcel5_2_0 => bcel}/generic/INEG.java | 97 +- .../generic/INSTANCEOF.java | 151 +- .../apache/bcel/generic/INVOKEDYNAMIC.java | 145 + .../generic/INVOKEINTERFACE.java | 272 +- .../apache/bcel/generic/INVOKESPECIAL.java | 92 + .../org/apache/bcel/generic/INVOKESTATIC.java | 89 + .../apache/bcel/generic/INVOKEVIRTUAL.java | 91 + .../{bcel5_2_0 => bcel}/generic/IOR.java | 97 +- .../{bcel5_2_0 => bcel}/generic/IREM.java | 124 +- .../{bcel5_2_0 => bcel}/generic/IRETURN.java | 101 +- .../{bcel5_2_0 => bcel}/generic/ISHL.java | 97 +- .../{bcel5_2_0 => bcel}/generic/ISHR.java | 97 +- .../{bcel5_2_0 => bcel}/generic/ISTORE.java | 115 +- .../{bcel5_2_0 => bcel}/generic/ISUB.java | 101 +- .../{bcel5_2_0 => bcel}/generic/IUSHR.java | 97 +- .../{bcel5_2_0 => bcel}/generic/IXOR.java | 97 +- .../generic/IfInstruction.java | 96 +- .../bcel/generic/IndexedInstruction.java | 32 + .../org/apache/bcel/generic/Instruction.java | 609 ++++ .../generic/InstructionComparator.java | 131 +- .../generic/InstructionConst.java} | 583 ++-- .../bcel/generic/InstructionConstants.java | 292 ++ .../bcel/generic/InstructionFactory.java | 780 +++++ .../generic/InstructionHandle.java | 615 ++-- .../apache/bcel/generic/InstructionList.java | 1257 +++++++ .../bcel/generic/InstructionListObserver.java | 29 + .../bcel/generic/InstructionTargeter.java | 45 + .../bcel/generic/InvokeInstruction.java | 137 + .../src-bcel/org/apache/bcel/generic/JSR.java | 90 + .../org/apache/bcel/generic/JSR_W.java | 83 + .../generic/JsrInstruction.java | 159 +- .../{bcel5_2_0 => bcel}/generic/L2D.java | 97 +- .../{bcel5_2_0 => bcel}/generic/L2F.java | 97 +- .../{bcel5_2_0 => bcel}/generic/L2I.java | 97 +- .../{bcel5_2_0 => bcel}/generic/LADD.java | 99 +- .../{bcel5_2_0 => bcel}/generic/LALOAD.java | 101 +- .../{bcel5_2_0 => bcel}/generic/LAND.java | 99 +- .../{bcel5_2_0 => bcel}/generic/LASTORE.java | 101 +- .../{bcel5_2_0 => bcel}/generic/LCMP.java | 112 +- .../{bcel5_2_0 => bcel}/generic/LCONST.java | 163 +- .../src-bcel/org/apache/bcel/generic/LDC.java | 157 + .../org/apache/bcel/generic/LDC2_W.java | 84 + .../org/apache/bcel/generic/LDC_W.java | 56 + .../{bcel5_2_0 => bcel}/generic/LDIV.java | 118 +- .../org/apache/bcel/generic/LLOAD.java | 55 + .../{bcel5_2_0 => bcel}/generic/LMUL.java | 99 +- .../{bcel5_2_0 => bcel}/generic/LNEG.java | 97 +- .../org/apache/bcel/generic/LOOKUPSWITCH.java | 104 + .../{bcel5_2_0 => bcel}/generic/LOR.java | 97 +- .../{bcel5_2_0 => bcel}/generic/LREM.java | 116 +- .../{bcel5_2_0 => bcel}/generic/LRETURN.java | 97 +- .../{bcel5_2_0 => bcel}/generic/LSHL.java | 97 +- .../{bcel5_2_0 => bcel}/generic/LSHR.java | 97 +- .../org/apache/bcel/generic/LSTORE.java | 55 + .../{bcel5_2_0 => bcel}/generic/LSUB.java | 99 +- .../{bcel5_2_0 => bcel}/generic/LUSHR.java | 97 +- .../{bcel5_2_0 => bcel}/generic/LXOR.java | 97 +- .../generic/LineNumberGen.java | 220 +- .../generic/LoadClass.java | 100 +- .../generic/LoadInstruction.java | 127 +- .../apache/bcel/generic/LocalVariableGen.java | 263 ++ .../generic/LocalVariableInstruction.java | 232 ++ .../generic/MONITORENTER.java | 110 +- .../generic/MONITOREXIT.java | 110 +- .../generic/MULTIANEWARRAY.java | 299 +- .../org/apache/bcel/generic/MethodGen.java | 1280 +++++++ .../apache/bcel/generic/MethodObserver.java | 29 + .../src-bcel/org/apache/bcel/generic/NEW.java | 76 + .../{bcel5_2_0 => bcel}/generic/NEWARRAY.java | 248 +- .../{bcel5_2_0 => bcel}/generic/NOP.java | 87 +- .../generic/NameSignatureInstruction.java | 63 + .../apache/bcel/generic/NamedAndTyped.java | 38 + .../generic/ObjectType.java | 319 +- .../{bcel5_2_0 => bcel}/generic/POP.java | 97 +- .../{bcel5_2_0 => bcel}/generic/POP2.java | 97 +- .../{bcel5_2_0 => bcel}/generic/PUSH.java | 370 +- .../org/apache/bcel/generic/PUTFIELD.java | 80 + .../generic/PUTSTATIC.java | 158 +- .../apache/bcel/generic/PopInstruction.java | 29 + .../generic/PushInstruction.java | 68 +- .../{bcel5_2_0 => bcel}/generic/RET.java | 287 +- .../{bcel5_2_0 => bcel}/generic/RETURN.java | 97 +- .../generic/ReferenceType.java | 660 ++-- .../bcel/generic/ReturnInstruction.java | 82 + .../generic/ReturnaddressType.java | 166 +- .../{bcel5_2_0 => bcel}/generic/SALOAD.java | 97 +- .../{bcel5_2_0 => bcel}/generic/SASTORE.java | 97 +- .../{bcel5_2_0 => bcel}/generic/SIPUSH.java | 214 +- .../{bcel5_2_0 => bcel}/generic/SWAP.java | 95 +- .../{bcel5_2_0 => bcel}/generic/SWITCH.java | 309 +- .../org/apache/bcel/generic/Select.java | 393 +++ .../bcel/generic/SimpleElementValueGen.java | 269 ++ .../apache/bcel/generic/StackConsumer.java | 30 + .../apache/bcel/generic/StackInstruction.java | 48 + .../apache/bcel/generic/StackProducer.java | 31 + .../generic/StoreInstruction.java | 127 +- .../org/apache/bcel/generic/TABLESWITCH.java | 113 + .../bcel/generic/TargetLostException.java | 66 + .../org/apache/bcel/generic/Type.java | 404 +++ .../apache/bcel/generic/TypedInstruction.java | 29 + .../bcel/generic/UnconditionalBranch.java | 29 + .../generic/VariableLengthInstruction.java | 32 + .../org/apache/bcel/generic/Visitor.java | 574 ++++ .../org/apache/bcel/generic/package.html | 32 + .../src-bcel/org/apache/bcel/package.html | 33 + .../util/AttributeHTML.java | 425 +-- .../util/BCELComparator.java | 90 +- .../org/apache/bcel/util/BCELFactory.java | 347 ++ .../org/apache/bcel/util/BCELifier.java | 301 ++ .../util/ByteSequence.java | 135 +- .../org/apache/bcel/util/Class2HTML.java | 238 ++ .../{bcel5_2_0 => bcel}/util/ClassLoader.java | 377 ++- .../bcel/util/ClassLoaderRepository.java | 123 + .../org/apache/bcel/util/ClassPath.java | 546 +++ .../apache/bcel/util/ClassPathRepository.java | 164 + .../org/apache/bcel/util/ClassQueue.java | 58 + .../org/apache/bcel/util/ClassSet.java | 70 + .../org/apache/bcel/util/ClassStack.java | 53 + .../org/apache/bcel/util/ClassVector.java | 61 + .../{bcel5_2_0 => bcel}/util/CodeHTML.java | 1148 +++---- .../util/ConstantHTML.java | 468 ++- .../apache/bcel/util/InstructionFinder.java | 420 +++ .../{bcel5_2_0 => bcel}/util/JavaWrapper.java | 233 +- .../MemorySensitiveClassPathRepository.java | 171 + .../{bcel5_2_0 => bcel}/util/MethodHTML.java | 316 +- .../org/apache/bcel/util/Repository.java | 72 + .../apache/bcel/util/SyntheticRepository.java | 54 + .../org/apache/bcel/util/package.html | 41 + .../bcel/verifier/GraphicalVerifier.java | 73 + .../apache/bcel/verifier/NativeVerifier.java | 73 + .../apache/bcel/verifier/PassVerifier.java | 105 + .../apache/bcel/verifier/TransitiveHull.java | 105 + .../bcel/verifier/VerificationResult.java | 127 + .../org/apache/bcel/verifier/Verifier.java | 242 ++ .../bcel/verifier/VerifierAppFrame.java | 421 +++ .../apache/bcel/verifier/VerifierFactory.java | 107 + .../verifier/VerifierFactoryListModel.java | 77 + .../verifier/VerifierFactoryObserver.java | 39 + .../apache/bcel/verifier/VerifyDialog.java | 564 ++++ .../exc/AssertionViolatedException.java | 86 + .../exc/ClassConstraintException.java | 52 + .../verifier/exc/CodeConstraintException.java | 41 + .../verifier/exc/InvalidMethodException.java | 34 + .../exc/LinkingConstraintException.java | 39 + .../bcel/verifier/exc/LoadingException.java | 44 + ...ocalVariableInfoInconsistentException.java | 46 + .../exc/StaticCodeConstraintException.java | 36 + ...ticCodeInstructionConstraintException.java | 39 + ...InstructionOperandConstraintException.java | 39 + .../StructuralCodeConstraintException.java | 46 + .../org/apache/bcel/verifier/exc/Utility.java | 40 + .../verifier/exc/VerificationException.java | 54 + .../VerifierConstraintViolatedException.java | 85 + .../org/apache/bcel/verifier/exc/package.html | 33 + .../org/apache/bcel/verifier/package.html | 34 + .../bcel/verifier/statics/DOUBLE_Upper.java | 42 + .../apache/bcel/verifier/statics/IntList.java | 51 + .../bcel/verifier/statics/LONG_Upper.java | 42 + .../verifier/statics/LocalVariableInfo.java | 110 + .../verifier/statics/LocalVariablesInfo.java | 74 + .../bcel/verifier/statics/Pass1Verifier.java | 200 ++ .../bcel/verifier/statics/Pass2Verifier.java | 1571 +++++++++ .../bcel/verifier/statics/Pass3aVerifier.java | 1342 ++++++++ .../statics/StringRepresentation.java | 407 +++ .../apache/bcel/verifier/statics/package.html | 35 + .../structurals/ControlFlowGraph.java | 477 +++ .../structurals/ExceptionHandler.java | 57 + .../structurals/ExceptionHandlers.java | 74 + .../structurals/ExecutionVisitor.java | 1274 +++++++ .../bcel/verifier/structurals/Frame.java | 142 + .../verifier/structurals/GenericArray.java | 36 + .../structurals/InstConstraintVisitor.java | 2962 +++++++++++++++++ .../structurals/InstructionContext.java | 107 + .../verifier/structurals/LocalVariables.java | 218 ++ .../verifier/structurals/OperandStack.java | 274 ++ .../verifier/structurals/Pass3bVerifier.java | 402 +++ .../bcel/verifier/structurals/Subroutine.java | 89 + .../verifier/structurals/Subroutines.java | 683 ++++ .../structurals/UninitializedObjectType.java | 70 + .../bcel/verifier/structurals/package.html | 36 + .../org/apache/bcel5_2_0/Constants.java | 766 ----- .../apache/bcel5_2_0/ExceptionConstants.java | 76 - .../bcel5_2_0/classfile/AccessFlags.java | 238 -- .../apache/bcel5_2_0/classfile/Attribute.java | 279 -- .../classfile/ClassFormatException.java | 37 - .../apache/bcel5_2_0/classfile/Constant.java | 189 -- .../bcel5_2_0/classfile/ConstantCP.java | 132 - .../bcel5_2_0/classfile/ConstantFieldref.java | 70 - .../classfile/ConstantInterfaceMethodref.java | 70 - .../classfile/ConstantMethodref.java | 70 - .../bcel5_2_0/classfile/ConstantUtf8.java | 117 - .../classfile/DescendingVisitor.java | 356 -- .../bcel5_2_0/classfile/EmptyVisitor.java | 161 - .../bcel5_2_0/classfile/FieldOrMethod.java | 207 -- .../org/apache/bcel5_2_0/classfile/Node.java | 28 - .../bcel5_2_0/classfile/StackMapEntry.java | 212 -- .../apache/bcel5_2_0/classfile/Visitor.java | 127 - .../apache/bcel5_2_0/classfile/package.html | 14 - .../generic/AllocationInstruction.java | 26 - .../generic/ArithmeticInstruction.java | 94 - .../bcel5_2_0/generic/ArrayInstruction.java | 81 - .../apache/bcel5_2_0/generic/BasicType.java | 81 - .../apache/bcel5_2_0/generic/ClassGen.java | 542 --- .../bcel5_2_0/generic/ClassGenException.java | 36 - .../bcel5_2_0/generic/ClassObserver.java | 29 - .../generic/ConstantPushInstruction.java | 32 - .../generic/ConversionInstruction.java | 76 - .../bcel5_2_0/generic/EmptyVisitor.java | 745 ----- .../apache/bcel5_2_0/generic/FieldGen.java | 358 -- .../generic/FieldGenOrMethodGen.java | 132 - .../bcel5_2_0/generic/FieldInstruction.java | 80 - .../bcel5_2_0/generic/FieldObserver.java | 29 - .../bcel5_2_0/generic/FieldOrMethod.java | 128 - .../org/apache/bcel5_2_0/generic/GOTO.java | 89 - .../org/apache/bcel5_2_0/generic/GOTO_W.java | 80 - .../bcel5_2_0/generic/GotoInstruction.java | 38 - .../bcel5_2_0/generic/INVOKESPECIAL.java | 77 - .../bcel5_2_0/generic/INVOKESTATIC.java | 74 - .../bcel5_2_0/generic/INVOKEVIRTUAL.java | 76 - .../bcel5_2_0/generic/IndexedInstruction.java | 32 - .../apache/bcel5_2_0/generic/Instruction.java | 293 -- .../bcel5_2_0/generic/InstructionFactory.java | 743 ----- .../bcel5_2_0/generic/InstructionList.java | 1266 ------- .../generic/InstructionListObserver.java | 29 - .../generic/InstructionTargeter.java | 35 - .../bcel5_2_0/generic/InvokeInstruction.java | 119 - .../org/apache/bcel5_2_0/generic/JSR.java | 86 - .../org/apache/bcel5_2_0/generic/JSR_W.java | 80 - .../org/apache/bcel5_2_0/generic/LDC.java | 149 - .../org/apache/bcel5_2_0/generic/LDC2_W.java | 82 - .../org/apache/bcel5_2_0/generic/LDC_W.java | 55 - .../org/apache/bcel5_2_0/generic/LLOAD.java | 54 - .../bcel5_2_0/generic/LOOKUPSWITCH.java | 96 - .../org/apache/bcel5_2_0/generic/LSTORE.java | 54 - .../bcel5_2_0/generic/LocalVariableGen.java | 208 -- .../generic/LocalVariableInstruction.java | 203 -- .../apache/bcel5_2_0/generic/MethodGen.java | 1087 ------ .../bcel5_2_0/generic/MethodObserver.java | 29 - .../org/apache/bcel5_2_0/generic/NEW.java | 76 - .../bcel5_2_0/generic/NamedAndTyped.java | 38 - .../apache/bcel5_2_0/generic/PUTFIELD.java | 80 - .../bcel5_2_0/generic/PopInstruction.java | 29 - .../bcel5_2_0/generic/ReturnInstruction.java | 79 - .../org/apache/bcel5_2_0/generic/Select.java | 237 -- .../bcel5_2_0/generic/StackConsumer.java | 30 - .../bcel5_2_0/generic/StackInstruction.java | 48 - .../bcel5_2_0/generic/StackProducer.java | 31 - .../apache/bcel5_2_0/generic/TABLESWITCH.java | 108 - .../generic/TargetLostException.java | 67 - .../org/apache/bcel5_2_0/generic/Type.java | 311 -- .../bcel5_2_0/generic/TypedInstruction.java | 29 - .../generic/UnconditionalBranch.java | 29 - .../generic/VariableLengthInstruction.java | 32 - .../org/apache/bcel5_2_0/generic/Visitor.java | 568 ---- .../org/apache/bcel5_2_0/generic/package.html | 16 - .../org/apache/bcel5_2_0/package.html | 17 - .../apache/bcel5_2_0/util/BCELFactory.java | 327 -- .../org/apache/bcel5_2_0/util/BCELifier.java | 269 -- .../org/apache/bcel5_2_0/util/Class2HTML.java | 232 -- .../bcel5_2_0/util/ClassLoaderRepository.java | 122 - .../org/apache/bcel5_2_0/util/ClassPath.java | 396 --- .../org/apache/bcel5_2_0/util/ClassQueue.java | 53 - .../org/apache/bcel5_2_0/util/ClassSet.java | 70 - .../org/apache/bcel5_2_0/util/ClassStack.java | 53 - .../apache/bcel5_2_0/util/ClassVector.java | 58 - .../bcel5_2_0/util/InstructionFinder.java | 473 --- .../org/apache/bcel5_2_0/util/Repository.java | 73 - .../bcel5_2_0/util/SyntheticRepository.java | 191 -- .../org/apache/bcel5_2_0/util/package.html | 25 - .../java/resource/ClassFileModelLoader.java | 32 +- 479 files changed, 61406 insertions(+), 36140 deletions(-) create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/Const.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/Constants.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/ExceptionConst.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/ExceptionConstants.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/Repository.java (63%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AccessFlags.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AnnotationDefault.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AnnotationElementValue.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AnnotationEntry.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Annotations.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ArrayElementValue.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Attribute.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/AttributeReader.java (69%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/BootstrapMethod.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/BootstrapMethods.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ClassElementValue.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ClassFormatException.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/ClassParser.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/Code.java (58%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/CodeException.java (71%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Constant.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantCP.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/ConstantClass.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/ConstantDouble.java (59%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantFieldref.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/ConstantFloat.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/ConstantInteger.java (58%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantInterfaceMethodref.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantInvokeDynamic.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/ConstantLong.java (56%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantMethodHandle.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantMethodType.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantMethodref.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantModule.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/ConstantNameAndType.java (62%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/ConstantObject.java (51%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantPackage.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/ConstantPool.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/ConstantString.java (60%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantUtf8.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/ConstantValue.java (56%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/Deprecated.java (60%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/DescendingVisitor.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ElementValue.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ElementValuePair.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/EmptyVisitor.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/EnclosingMethod.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/EnumElementValue.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/ExceptionTable.java (55%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/Field.java (56%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/FieldOrMethod.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/InnerClass.java (64%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/InnerClasses.java (51%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/JavaClass.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/LineNumber.java (54%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/LineNumberTable.java (55%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/LocalVariable.java (58%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/LocalVariableTable.java (51%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LocalVariableTypeTable.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/Method.java (56%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/MethodParameter.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/MethodParameters.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Node.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/PMGClass.java (58%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ParameterAnnotationEntry.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ParameterAnnotations.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeInvisibleAnnotations.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeInvisibleParameterAnnotations.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeVisibleAnnotations.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeVisibleParameterAnnotations.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/Signature.java (69%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/SimpleElementValue.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/SourceFile.java (63%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/StackMap.java (50%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/StackMapEntry.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/StackMapType.java (57%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/Synthetic.java (63%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/Unknown.java (57%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/UnknownAttributeReader.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/classfile/Utility.java (55%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Visitor.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/package.html rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/AALOAD.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/AASTORE.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/ACONST_NULL.java (58%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/ALOAD.java (51%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/ANEWARRAY.java (53%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/ARETURN.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/ARRAYLENGTH.java (54%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/ASTORE.java (51%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/ATHROW.java (56%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AllocationInstruction.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AnnotationElementValueGen.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AnnotationEntryGen.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArithmeticInstruction.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArrayElementValueGen.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArrayInstruction.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/ArrayType.java (64%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/BALOAD.java (61%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/BASTORE.java (61%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/BIPUSH.java (54%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/BREAKPOINT.java (54%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BasicType.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/BranchHandle.java (54%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/BranchInstruction.java (58%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/CALOAD.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/CASTORE.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/CHECKCAST.java (55%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/CPInstruction.java (54%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassElementValueGen.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassGen.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassGenException.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassObserver.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/CodeExceptionGen.java (70%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/CompoundInstruction.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/ConstantPoolGen.java (57%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ConstantPushInstruction.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ConversionInstruction.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/D2F.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/D2I.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/D2L.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/DADD.java (61%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/DALOAD.java (61%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/DASTORE.java (61%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/DCMPG.java (55%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/DCMPL.java (55%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/DCONST.java (56%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/DDIV.java (61%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/DLOAD.java (51%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/DMUL.java (61%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/DNEG.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/DREM.java (61%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/DRETURN.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/DSTORE.java (51%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/DSUB.java (61%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/DUP.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/DUP2.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/DUP2_X1.java (58%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/DUP2_X2.java (58%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/DUP_X1.java (57%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/DUP_X2.java (58%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ElementValueGen.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ElementValuePairGen.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/EmptyVisitor.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/EnumElementValueGen.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/ExceptionThrower.java (64%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/F2D.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/F2I.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/F2L.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/FADD.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/FALOAD.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/FASTORE.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/FCMPG.java (56%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/FCMPL.java (56%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/FCONST.java (55%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/FDIV.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/FLOAD.java (51%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/FMUL.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/FNEG.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/FREM.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/FRETURN.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/FSTORE.java (51%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/FSUB.java (60%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldGen.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldGenOrMethodGen.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldInstruction.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldObserver.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldOrMethod.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/GETFIELD.java (50%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/GETSTATIC.java (51%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GOTO.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GOTO_W.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GotoInstruction.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/I2B.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/I2C.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/I2D.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/I2F.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/I2L.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/I2S.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IADD.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IALOAD.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IAND.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IASTORE.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/ICONST.java (55%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IDIV.java (58%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IFEQ.java (54%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IFGE.java (54%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IFGT.java (54%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IFLE.java (54%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IFLT.java (54%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IFNE.java (54%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IFNONNULL.java (54%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IFNULL.java (53%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IF_ACMPEQ.java (54%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IF_ACMPNE.java (54%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IF_ICMPEQ.java (54%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IF_ICMPGE.java (54%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IF_ICMPGT.java (54%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IF_ICMPLE.java (54%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IF_ICMPLT.java (54%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IF_ICMPNE.java (54%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IINC.java (51%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/ILOAD.java (51%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IMPDEP1.java (53%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IMPDEP2.java (53%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IMUL.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/INEG.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/INSTANCEOF.java (54%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKEDYNAMIC.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/INVOKEINTERFACE.java (51%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKESPECIAL.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKESTATIC.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKEVIRTUAL.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IOR.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IREM.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IRETURN.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/ISHL.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/ISHR.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/ISTORE.java (51%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/ISUB.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IUSHR.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IXOR.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/IfInstruction.java (51%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IndexedInstruction.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Instruction.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/InstructionComparator.java (53%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0/generic/InstructionConstants.java => bcel/generic/InstructionConst.java} (58%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionConstants.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionFactory.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/InstructionHandle.java (64%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionList.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionListObserver.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionTargeter.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InvokeInstruction.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/JSR.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/JSR_W.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/JsrInstruction.java (64%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/L2D.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/L2F.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/L2I.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/LADD.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/LALOAD.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/LAND.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/LASTORE.java (61%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/LCMP.java (56%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/LCONST.java (55%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDC.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDC2_W.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDC_W.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/LDIV.java (58%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LLOAD.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/LMUL.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/LNEG.java (59%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LOOKUPSWITCH.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/LOR.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/LREM.java (57%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/LRETURN.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/LSHL.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/LSHR.java (60%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LSTORE.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/LSUB.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/LUSHR.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/LXOR.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/LineNumberGen.java (56%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/LoadClass.java (64%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/LoadInstruction.java (60%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LocalVariableGen.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LocalVariableInstruction.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/MONITORENTER.java (54%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/MONITOREXIT.java (54%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/MULTIANEWARRAY.java (55%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MethodGen.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MethodObserver.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NEW.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/NEWARRAY.java (54%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/NOP.java (53%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NameSignatureInstruction.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NamedAndTyped.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/ObjectType.java (57%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/POP.java (58%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/POP2.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/PUSH.java (52%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PUTFIELD.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/PUTSTATIC.java (51%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PopInstruction.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/PushInstruction.java (52%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/RET.java (56%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/RETURN.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/ReferenceType.java (74%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ReturnInstruction.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/ReturnaddressType.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/SALOAD.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/SASTORE.java (60%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/SIPUSH.java (54%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/SWAP.java (59%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/SWITCH.java (70%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Select.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SimpleElementValueGen.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StackConsumer.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StackInstruction.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StackProducer.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/generic/StoreInstruction.java (60%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/TABLESWITCH.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/TargetLostException.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Type.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/TypedInstruction.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/UnconditionalBranch.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/VariableLengthInstruction.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Visitor.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/package.html create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/package.html rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/util/AttributeHTML.java (56%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/util/BCELComparator.java (52%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/BCELFactory.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/BCELifier.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/util/ByteSequence.java (53%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/Class2HTML.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/util/ClassLoader.java (62%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassLoaderRepository.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassPath.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassPathRepository.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassQueue.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassSet.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassStack.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassVector.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/util/CodeHTML.java (54%) mode change 100755 => 100644 rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/util/ConstantHTML.java (59%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/InstructionFinder.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/util/JavaWrapper.java (60%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/MemorySensitiveClassPathRepository.java rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel5_2_0 => bcel}/util/MethodHTML.java (61%) mode change 100755 => 100644 create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/Repository.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/SyntheticRepository.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/package.html create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/GraphicalVerifier.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/NativeVerifier.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/PassVerifier.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/TransitiveHull.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerificationResult.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/Verifier.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierAppFrame.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierFactory.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierFactoryListModel.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierFactoryObserver.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifyDialog.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/AssertionViolatedException.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/ClassConstraintException.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/CodeConstraintException.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/InvalidMethodException.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/LinkingConstraintException.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/LoadingException.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/LocalVariableInfoInconsistentException.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StaticCodeConstraintException.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StaticCodeInstructionConstraintException.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StaticCodeInstructionOperandConstraintException.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StructuralCodeConstraintException.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/Utility.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/VerificationException.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/VerifierConstraintViolatedException.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/package.html create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/package.html create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/DOUBLE_Upper.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/IntList.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/LONG_Upper.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/LocalVariableInfo.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/LocalVariablesInfo.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/Pass1Verifier.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/Pass2Verifier.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/Pass3aVerifier.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/StringRepresentation.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/package.html create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ControlFlowGraph.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ExceptionHandler.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ExceptionHandlers.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ExecutionVisitor.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/Frame.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/GenericArray.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/InstructionContext.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/LocalVariables.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/OperandStack.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/Pass3bVerifier.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/Subroutine.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/Subroutines.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/UninitializedObjectType.java create mode 100644 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/package.html delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/Constants.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/ExceptionConstants.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/AccessFlags.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Attribute.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ClassFormatException.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Constant.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantCP.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantFieldref.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantInterfaceMethodref.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantMethodref.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantUtf8.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/DescendingVisitor.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/EmptyVisitor.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/FieldOrMethod.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Node.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/StackMapEntry.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Visitor.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/package.html delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/AllocationInstruction.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ArithmeticInstruction.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ArrayInstruction.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/BasicType.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ClassGen.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ClassGenException.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ClassObserver.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ConstantPushInstruction.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ConversionInstruction.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/EmptyVisitor.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FieldGen.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FieldGenOrMethodGen.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FieldInstruction.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FieldObserver.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FieldOrMethod.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/GOTO.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/GOTO_W.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/GotoInstruction.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/INVOKESPECIAL.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/INVOKESTATIC.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/INVOKEVIRTUAL.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IndexedInstruction.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/Instruction.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InstructionFactory.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InstructionList.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InstructionListObserver.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InstructionTargeter.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InvokeInstruction.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/JSR.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/JSR_W.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LDC.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LDC2_W.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LDC_W.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LLOAD.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LOOKUPSWITCH.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LSTORE.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LocalVariableGen.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LocalVariableInstruction.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/MethodGen.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/MethodObserver.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/NEW.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/NamedAndTyped.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/PUTFIELD.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/PopInstruction.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ReturnInstruction.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/Select.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/StackConsumer.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/StackInstruction.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/StackProducer.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/TABLESWITCH.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/TargetLostException.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/Type.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/TypedInstruction.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/UnconditionalBranch.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/VariableLengthInstruction.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/Visitor.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/package.html delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/package.html delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/BCELFactory.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/BCELifier.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/Class2HTML.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassLoaderRepository.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassPath.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassQueue.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassSet.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassStack.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassVector.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/InstructionFinder.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/Repository.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/SyntheticRepository.java delete mode 100755 Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/package.html diff --git a/Core/org.emftext.language.java.resource.bcel/.classpath b/Core/org.emftext.language.java.resource.bcel/.classpath index 0b4d0cf4..ea6ef586 100644 --- a/Core/org.emftext.language.java.resource.bcel/.classpath +++ b/Core/org.emftext.language.java.resource.bcel/.classpath @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/Core/org.emftext.language.java.resource.bcel/.settings/org.eclipse.jdt.core.prefs b/Core/org.emftext.language.java.resource.bcel/.settings/org.eclipse.jdt.core.prefs index 2787fd33..18860117 100644 --- a/Core/org.emftext.language.java.resource.bcel/.settings/org.eclipse.jdt.core.prefs +++ b/Core/org.emftext.language.java.resource.bcel/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,8 @@ -#Mon Oct 10 20:11:21 CEST 2011 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -79,4 +78,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Core/org.emftext.language.java.resource.bcel/META-INF/MANIFEST.MF b/Core/org.emftext.language.java.resource.bcel/META-INF/MANIFEST.MF index df823035..4deca7ba 100644 --- a/Core/org.emftext.language.java.resource.bcel/META-INF/MANIFEST.MF +++ b/Core/org.emftext.language.java.resource.bcel/META-INF/MANIFEST.MF @@ -4,7 +4,7 @@ Bundle-Name: Bcel Bundle-SymbolicName: org.emftext.language.java.resource.bcel Bundle-Version: 1.0.0.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Export-Package: org.apache.bcel5_2_0, - org.apache.bcel5_2_0.classfile, - org.apache.bcel5_2_0.generic, - org.apache.bcel5_2_0.util +Export-Package: org.apache.bcel, + org.apache.bcel.classfile, + org.apache.bcel.generic, + org.apache.bcel.util diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/Const.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/Const.java new file mode 100644 index 00000000..98003940 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/Const.java @@ -0,0 +1,2330 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel; + +import java.util.Arrays; +import java.util.Collections; + +/** + * Constants for the project, mostly defined in the JVM specification. + * + * @version $Id: Const.java 1806488 2017-08-28 19:03:22Z britter $ + * @since 6.0 (intended to replace the Constants interface) + */ +public final class Const { + + /** + * Java class file format Magic number (0xCAFEBABE) + * + * @see + * The ClassFile Structure in The Java Virtual Machine Specification + */ + public static final int JVM_CLASSFILE_MAGIC = 0xCAFEBABE; + + /** Major version number of class files for Java 1.1. + * @see #MINOR_1_1 + * */ + public static final short MAJOR_1_1 = 45; + + /** Minor version number of class files for Java 1.1. + * @see #MAJOR_1_1 + * */ + public static final short MINOR_1_1 = 3; + + /** Major version number of class files for Java 1.2. + * @see #MINOR_1_2 + * */ + public static final short MAJOR_1_2 = 46; + + /** Minor version number of class files for Java 1.2. + * @see #MAJOR_1_2 + * */ + public static final short MINOR_1_2 = 0; + + /** Major version number of class files for Java 1.2. + * @see #MINOR_1_2 + * */ + public static final short MAJOR_1_3 = 47; + + /** Minor version number of class files for Java 1.3. + * @see #MAJOR_1_3 + * */ + public static final short MINOR_1_3 = 0; + + /** Major version number of class files for Java 1.3. + * @see #MINOR_1_3 + * */ + public static final short MAJOR_1_4 = 48; + + /** Minor version number of class files for Java 1.4. + * @see #MAJOR_1_4 + * */ + public static final short MINOR_1_4 = 0; + + /** Major version number of class files for Java 1.4. + * @see #MINOR_1_4 + * */ + public static final short MAJOR_1_5 = 49; + + /** Minor version number of class files for Java 1.5. + * @see #MAJOR_1_5 + * */ + public static final short MINOR_1_5 = 0; + + /** Major version number of class files for Java 1.6. + * @see #MINOR_1_6 + * */ + public static final short MAJOR_1_6 = 50; + + /** Minor version number of class files for Java 1.6. + * @see #MAJOR_1_6 + * */ + public static final short MINOR_1_6 = 0; + + /** Major version number of class files for Java 1.7. + * @see #MINOR_1_7 + * */ + public static final short MAJOR_1_7 = 51; + + /** Minor version number of class files for Java 1.7. + * @see #MAJOR_1_7 + * */ + public static final short MINOR_1_7 = 0; + + /** Major version number of class files for Java 1.8. + * @see #MINOR_1_8 + * */ + public static final short MAJOR_1_8 = 52; + + /** Major version number of class files for Java 1.9. + * @see #MINOR_1_9 + * */ + public static final short MAJOR_1_9 = 53; + + /** Minor version number of class files for Java 1.8. + * @see #MAJOR_1_8 + * */ + public static final short MINOR_1_8 = 0; + + /** Minor version number of class files for Java 1.9. + * @see #MAJOR_1_9 + * */ + public static final short MINOR_1_9 = 0; + + /** Default major version number. Class file is for Java 1.1. + * @see #MAJOR_1_1 + * */ + public static final short MAJOR = MAJOR_1_1; + + /** Default major version number. Class file is for Java 1.1. + * @see #MAJOR_1_1 + * */ + public static final short MINOR = MINOR_1_1; + + /** Maximum value for an unsigned short. + */ + public static final int MAX_SHORT = 65535; // 2^16 - 1 + + /** Maximum value for an unsigned byte. + */ + public static final int MAX_BYTE = 255; // 2^8 - 1 + + /** One of the access flags for fields, methods, or classes. + * @see + * Flag definitions for Fields in the Java Virtual Machine Specification (Java SE 8 Edition). + * @see + * Flag definitions for Methods in the Java Virtual Machine Specification (Java SE 8 Edition). + * @see + * Flag definitions for Classes in the Java Virtual Machine Specification (Java SE 8 Edition). + */ + public static final short ACC_PUBLIC = 0x0001; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + public static final short ACC_PRIVATE = 0x0002; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + public static final short ACC_PROTECTED = 0x0004; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + public static final short ACC_STATIC = 0x0008; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + public static final short ACC_FINAL = 0x0010; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + public static final short ACC_SYNCHRONIZED = 0x0020; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + public static final short ACC_VOLATILE = 0x0040; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + public static final short ACC_BRIDGE = 0x0040; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + public static final short ACC_TRANSIENT = 0x0080; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + public static final short ACC_VARARGS = 0x0080; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + public static final short ACC_NATIVE = 0x0100; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + public static final short ACC_INTERFACE = 0x0200; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + public static final short ACC_ABSTRACT = 0x0400; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + public static final short ACC_STRICT = 0x0800; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + public static final short ACC_SYNTHETIC = 0x1000; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + public static final short ACC_ANNOTATION = 0x2000; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + public static final short ACC_ENUM = 0x4000; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + public static final short ACC_MANDATED = (short) 0x8000; + + // Applies to classes compiled by new compilers only + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + public static final short ACC_SUPER = 0x0020; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + public static final short MAX_ACC_FLAG = ACC_ENUM; + + /** + * The names of the access flags. + */ + private static final String[] ACCESS_NAMES = { + "public", "private", "protected", "static", "final", "synchronized", + "volatile", "transient", "native", "interface", "abstract", "strictfp", + "synthetic", "annotation", "enum" + }; + + /** @since 6.0 */ + public static final int ACCESS_NAMES_LENGTH = ACCESS_NAMES.length; + + /** + * @param index + * @return the ACCESS_NAMES entry at the given index + * @since 6.0 + */ + public static String getAccessName(final int index) { + return ACCESS_NAMES[index]; + } + + /* + * The description of the constant pool is at: + * http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4 + * References below are to the individual sections + */ + + /** + * Marks a constant pool entry as type UTF-8. + * @see + * The Constant Pool in The Java Virtual Machine Specification + */ + public static final byte CONSTANT_Utf8 = 1; + + /** + * Marks a constant pool entry as type Integer. + * @see + * The Constant Pool in The Java Virtual Machine Specification + */ + public static final byte CONSTANT_Integer = 3; + + /** + * Marks a constant pool entry as type Float. + * @see + * The Constant Pool in The Java Virtual Machine Specification + */ + public static final byte CONSTANT_Float = 4; + + /** + * Marks a constant pool entry as type Long. + * @see + * The Constant Pool in The Java Virtual Machine Specification + */ + public static final byte CONSTANT_Long = 5; + + /** + * Marks a constant pool entry as type Double. + * @see + * The Constant Pool in The Java Virtual Machine Specification + */ + public static final byte CONSTANT_Double = 6; + + /** + * Marks a constant pool entry as a Class + * @see + * The Constant Pool in The Java Virtual Machine Specification + */ + public static final byte CONSTANT_Class = 7; + + /** + * Marks a constant pool entry as a Field Reference. + * @see + * The Constant Pool in The Java Virtual Machine Specification + */ + public static final byte CONSTANT_Fieldref = 9; + + /** + * Marks a constant pool entry as type String + * @see + * The Constant Pool in The Java Virtual Machine Specification + */ + public static final byte CONSTANT_String = 8; + + /** Marks a constant pool entry as a Method Reference. + * @see + * The Constant Pool in The Java Virtual Machine Specification */ + public static final byte CONSTANT_Methodref = 10; + + /** + * Marks a constant pool entry as an Interface Method Reference. + * @see + * The Constant Pool in The Java Virtual Machine Specification + */ + public static final byte CONSTANT_InterfaceMethodref = 11; + + /** Marks a constant pool entry as a name and type. + * @see + * The Constant Pool in The Java Virtual Machine Specification */ + public static final byte CONSTANT_NameAndType = 12; + + /** + * Marks a constant pool entry as a Method Handle. + * @see + * The Constant Pool in The Java Virtual Machine Specification + */ + public static final byte CONSTANT_MethodHandle = 15; + + /** + * Marks a constant pool entry as a Method Type. + * @see + * The Constant Pool in The Java Virtual Machine Specification + */ + public static final byte CONSTANT_MethodType = 16; + + /** + * Marks a constant pool entry as an Invoke Dynamic + * @see + * The Constant Pool in The Java Virtual Machine Specification + */ + public static final byte CONSTANT_InvokeDynamic = 18; + + /** + * Marks a constant pool entry as a Module Reference. + * + *

Note: Early access Java 9 support- currently subject to change

+ * + * @see + * JPMS: Modules in the Java Language and JVM + * @since 6.1 + */ + public static final byte CONSTANT_Module = 19; + + /** + * Marks a constant pool entry as a Package Reference. + * + *

Note: Early access Java 9 support- currently subject to change

+ * + * @see + * JPMS: Modules in the Java Language and JVM + * @since 6.1 + */ + public static final byte CONSTANT_Package = 20; + + /** + * The names of the types of entries in a constant pool. + * Use getConstantName instead + */ + private static final 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", "", "", "CONSTANT_MethodHandle", + "CONSTANT_MethodType", "", "CONSTANT_InvokeDynamic", + "CONSTANT_Module", "CONSTANT_Package"}; + + /** + * + * @param index + * @return the CONSTANT_NAMES entry at the given index + * @since 6.0 + */ + public static String getConstantName(final int index) { + return CONSTANT_NAMES[index]; + } + + /** The name of the static initializer, also called "class + * initialization method" or "interface initialization + * method". This is "<clinit>". + */ + public static final String STATIC_INITIALIZER_NAME = ""; + + /** The name of every constructor method in a class, also called + * "instance initialization method". This is "<init>". + */ + public static final String CONSTRUCTOR_NAME = ""; + + /** + * The names of the interfaces implemented by arrays + */ + private static final String[] INTERFACES_IMPLEMENTED_BY_ARRAYS = {"java.lang.Cloneable", "java.io.Serializable"}; + + /** + * @since 6.0 + */ + public static Iterable getInterfacesImplementedByArrays() { + return Collections.unmodifiableList(Arrays.asList(INTERFACES_IMPLEMENTED_BY_ARRAYS)); + } + + /** + * Maximum Constant Pool entries. + * One of the limitations of the Java Virtual Machine. + * @see + * The Java Virtual Machine Specification, Java SE 8 Edition, page 330, chapter 4.11. + */ + public static final int MAX_CP_ENTRIES = 65535; + + /** + * Maximum code size (plus one; the code size must be LESS than this) + * One of the limitations of the Java Virtual Machine. + * Note vmspec2 page 152 ("Limitations") says: + * "The amount of code per non-native, non-abstract method is limited to 65536 bytes by + * the sizes of the indices in the exception_table of the Code attribute (§4.7.3), + * in the LineNumberTable attribute (§4.7.8), and in the LocalVariableTable attribute (§4.7.9)." + * However this should be taken as an upper limit rather than the defined maximum. + * On page 134 (4.8.1 Static Constants) of the same spec, it says: + * "The value of the code_length item must be less than 65536." + * The entry in the Limitations section has been removed from later versions of the spec; + * it is not present in the Java SE 8 edition. + * + * @see + * The Java Virtual Machine Specification, Java SE 8 Edition, page 104, chapter 4.7. + */ + public static final int MAX_CODE_SIZE = 65536; //bytes + + /** + * The maximum number of dimensions in an array ({@value}). + * One of the limitations of the Java Virtual Machine. + * + * @see + * Field Descriptors in The Java Virtual Machine Specification + */ + public static final int MAX_ARRAY_DIMENSIONS = 255; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short NOP = 0; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ACONST_NULL = 1; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ICONST_M1 = 2; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ICONST_0 = 3; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ICONST_1 = 4; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ICONST_2 = 5; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ICONST_3 = 6; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ICONST_4 = 7; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ICONST_5 = 8; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LCONST_0 = 9; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LCONST_1 = 10; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short FCONST_0 = 11; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short FCONST_1 = 12; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short FCONST_2 = 13; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DCONST_0 = 14; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DCONST_1 = 15; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short BIPUSH = 16; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short SIPUSH = 17; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LDC = 18; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LDC_W = 19; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LDC2_W = 20; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ILOAD = 21; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LLOAD = 22; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short FLOAD = 23; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DLOAD = 24; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ALOAD = 25; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ILOAD_0 = 26; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ILOAD_1 = 27; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ILOAD_2 = 28; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ILOAD_3 = 29; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LLOAD_0 = 30; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LLOAD_1 = 31; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LLOAD_2 = 32; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LLOAD_3 = 33; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short FLOAD_0 = 34; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short FLOAD_1 = 35; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short FLOAD_2 = 36; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short FLOAD_3 = 37; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DLOAD_0 = 38; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DLOAD_1 = 39; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DLOAD_2 = 40; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DLOAD_3 = 41; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ALOAD_0 = 42; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ALOAD_1 = 43; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ALOAD_2 = 44; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ALOAD_3 = 45; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IALOAD = 46; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LALOAD = 47; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short FALOAD = 48; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DALOAD = 49; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short AALOAD = 50; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short BALOAD = 51; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short CALOAD = 52; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short SALOAD = 53; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ISTORE = 54; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LSTORE = 55; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short FSTORE = 56; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DSTORE = 57; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ASTORE = 58; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ISTORE_0 = 59; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ISTORE_1 = 60; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ISTORE_2 = 61; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ISTORE_3 = 62; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LSTORE_0 = 63; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LSTORE_1 = 64; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LSTORE_2 = 65; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LSTORE_3 = 66; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short FSTORE_0 = 67; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short FSTORE_1 = 68; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short FSTORE_2 = 69; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short FSTORE_3 = 70; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DSTORE_0 = 71; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DSTORE_1 = 72; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DSTORE_2 = 73; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DSTORE_3 = 74; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ASTORE_0 = 75; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ASTORE_1 = 76; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ASTORE_2 = 77; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ASTORE_3 = 78; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IASTORE = 79; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LASTORE = 80; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short FASTORE = 81; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DASTORE = 82; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short AASTORE = 83; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short BASTORE = 84; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short CASTORE = 85; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short SASTORE = 86; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short POP = 87; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short POP2 = 88; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DUP = 89; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DUP_X1 = 90; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DUP_X2 = 91; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DUP2 = 92; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DUP2_X1 = 93; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DUP2_X2 = 94; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short SWAP = 95; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IADD = 96; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LADD = 97; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short FADD = 98; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DADD = 99; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ISUB = 100; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LSUB = 101; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short FSUB = 102; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DSUB = 103; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IMUL = 104; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LMUL = 105; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short FMUL = 106; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DMUL = 107; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IDIV = 108; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LDIV = 109; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short FDIV = 110; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DDIV = 111; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IREM = 112; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LREM = 113; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short FREM = 114; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DREM = 115; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short INEG = 116; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LNEG = 117; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short FNEG = 118; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DNEG = 119; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ISHL = 120; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LSHL = 121; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ISHR = 122; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LSHR = 123; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IUSHR = 124; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LUSHR = 125; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IAND = 126; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LAND = 127; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IOR = 128; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LOR = 129; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IXOR = 130; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LXOR = 131; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IINC = 132; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short I2L = 133; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short I2F = 134; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short I2D = 135; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short L2I = 136; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short L2F = 137; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short L2D = 138; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short F2I = 139; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short F2L = 140; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short F2D = 141; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short D2I = 142; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short D2L = 143; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short D2F = 144; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short I2B = 145; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short INT2BYTE = 145; // Old notation + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short I2C = 146; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short INT2CHAR = 146; // Old notation + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short I2S = 147; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short INT2SHORT = 147; // Old notation + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LCMP = 148; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short FCMPL = 149; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short FCMPG = 150; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DCMPL = 151; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DCMPG = 152; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IFEQ = 153; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IFNE = 154; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IFLT = 155; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IFGE = 156; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IFGT = 157; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IFLE = 158; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IF_ICMPEQ = 159; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IF_ICMPNE = 160; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IF_ICMPLT = 161; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IF_ICMPGE = 162; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IF_ICMPGT = 163; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IF_ICMPLE = 164; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IF_ACMPEQ = 165; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IF_ACMPNE = 166; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short GOTO = 167; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short JSR = 168; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short RET = 169; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short TABLESWITCH = 170; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LOOKUPSWITCH = 171; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IRETURN = 172; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short LRETURN = 173; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short FRETURN = 174; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short DRETURN = 175; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ARETURN = 176; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short RETURN = 177; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short GETSTATIC = 178; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short PUTSTATIC = 179; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short GETFIELD = 180; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short PUTFIELD = 181; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short INVOKEVIRTUAL = 182; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short INVOKESPECIAL = 183; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short INVOKENONVIRTUAL = 183; // Old name in JDK 1.0 + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short INVOKESTATIC = 184; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short INVOKEINTERFACE = 185; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short INVOKEDYNAMIC = 186; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short NEW = 187; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short NEWARRAY = 188; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ANEWARRAY = 189; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ARRAYLENGTH = 190; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short ATHROW = 191; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short CHECKCAST = 192; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short INSTANCEOF = 193; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short MONITORENTER = 194; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short MONITOREXIT = 195; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short WIDE = 196; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short MULTIANEWARRAY = 197; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IFNULL = 198; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short IFNONNULL = 199; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short GOTO_W = 200; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + public static final short JSR_W = 201; + + /** JVM internal opcode. + * @see + * Reserved opcodes in the Java Virtual Machine Specification */ + public static final short BREAKPOINT = 202; + + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + public static final short LDC_QUICK = 203; + + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + public static final short LDC_W_QUICK = 204; + + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + public static final short LDC2_W_QUICK = 205; + + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + public static final short GETFIELD_QUICK = 206; + + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + public static final short PUTFIELD_QUICK = 207; + + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + public static final short GETFIELD2_QUICK = 208; + + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + public static final short PUTFIELD2_QUICK = 209; + + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + public static final short GETSTATIC_QUICK = 210; + + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + public static final short PUTSTATIC_QUICK = 211; + + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + public static final short GETSTATIC2_QUICK = 212; + + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + public static final short PUTSTATIC2_QUICK = 213; + + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + public static final short INVOKEVIRTUAL_QUICK = 214; + + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + public static final short INVOKENONVIRTUAL_QUICK = 215; + + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + public static final short INVOKESUPER_QUICK = 216; + + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + public static final short INVOKESTATIC_QUICK = 217; + + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + public static final short INVOKEINTERFACE_QUICK = 218; + + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + public static final short INVOKEVIRTUALOBJECT_QUICK = 219; + + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + public static final short NEW_QUICK = 221; + + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + public static final short ANEWARRAY_QUICK = 222; + + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + public static final short MULTIANEWARRAY_QUICK = 223; + + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + public static final short CHECKCAST_QUICK = 224; + + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + public static final short INSTANCEOF_QUICK = 225; + + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + public static final short INVOKEVIRTUAL_QUICK_W = 226; + + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + public static final short GETFIELD_QUICK_W = 227; + + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + public static final short PUTFIELD_QUICK_W = 228; + + /** JVM internal opcode. + * @see + * Reserved opcodes in the Java Virtual Machine Specification */ + public static final short IMPDEP1 = 254; + + /** JVM internal opcode. + * @see + * Reserved opcodes in the Java Virtual Machine Specification */ + public static final short IMPDEP2 = 255; + + /** + * BCEL virtual instruction for pushing an arbitrary data type onto the stack. Will be converted to the appropriate JVM + * opcode when the class is dumped. + */ + public static final short PUSH = 4711; + + /** + * BCEL virtual instruction for either LOOKUPSWITCH or TABLESWITCH. Will be converted to the appropriate JVM + * opcode when the class is dumped. + */ + public static final short SWITCH = 4712; + + /** Illegal opcode. */ + public static final short UNDEFINED = -1; + + /** Illegal opcode. */ + public static final short UNPREDICTABLE = -2; + + /** Illegal opcode. */ + public static final short RESERVED = -3; + + /** Mnemonic for an illegal opcode. */ + public static final String ILLEGAL_OPCODE = ""; + + /** Mnemonic for an illegal type. */ + public static final String ILLEGAL_TYPE = ""; + + /** Boolean data type. + * @see + * Static Constraints in the Java Virtual Machine Specification */ + public static final byte T_BOOLEAN = 4; + + /** Char data type. + * @see + * Static Constraints in the Java Virtual Machine Specification */ + public static final byte T_CHAR = 5; + + /** Float data type. + * @see + * Static Constraints in the Java Virtual Machine Specification */ + public static final byte T_FLOAT = 6; + + /** Double data type. + * @see + * Static Constraints in the Java Virtual Machine Specification */ + public static final byte T_DOUBLE = 7; + + /** Byte data type. + * @see + * Static Constraints in the Java Virtual Machine Specification */ + public static final byte T_BYTE = 8; + + /** Short data type. + * @see + * Static Constraints in the Java Virtual Machine Specification */ + public static final byte T_SHORT = 9; + + /** Int data type. + * @see + * Static Constraints in the Java Virtual Machine Specification */ + public static final byte T_INT = 10; + + /** Long data type. + * @see + * Static Constraints in the Java Virtual Machine Specification */ + public static final byte T_LONG = 11; + + /** Void data type (non-standard). */ + public static final byte T_VOID = 12; // Non-standard + + /** Array data type. */ + public static final byte T_ARRAY = 13; + + /** Object data type. */ + public static final byte T_OBJECT = 14; + + /** Reference data type (deprecated). */ + public static final byte T_REFERENCE = 14; // Deprecated + + /** Unknown data type. */ + public static final byte T_UNKNOWN = 15; + + /** Address data type. */ + public static final byte T_ADDRESS = 16; + + /** The primitive type names corresponding to the T_XX constants, + * e.g., TYPE_NAMES[T_INT] = "int" + */ + private 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", "address" + }; + + /** + * The primitive type names corresponding to the T_XX constants, + * e.g., TYPE_NAMES[T_INT] = "int" + * @param index + * @return the type name + * @since 6.0 + */ + public static String getTypeName(final int index) { + return TYPE_NAMES[index]; + } + + /** The primitive class names corresponding to the T_XX constants, + * e.g., CLASS_TYPE_NAMES[T_INT] = "java.lang.Integer" + */ + private static final String[] CLASS_TYPE_NAMES = { + ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, + "java.lang.Boolean", "java.lang.Character", "java.lang.Float", + "java.lang.Double", "java.lang.Byte", "java.lang.Short", + "java.lang.Integer", "java.lang.Long", "java.lang.Void", + ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE + }; + + /** + * The primitive class names corresponding to the T_XX constants, + * e.g., CLASS_TYPE_NAMES[T_INT] = "java.lang.Integer" + * @param index + * @return the class name + * @since 6.0 + */ + public static String getClassTypeName(final int index) { + return CLASS_TYPE_NAMES[index]; + } + + /** The signature characters corresponding to primitive types, + * e.g., SHORT_TYPE_NAMES[T_INT] = "I" + */ + private 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 + }; + + /** + * + * @param index + * @return the short type name + * @since 6.0 + */ + public static String getShortTypeName(final int index) { + return SHORT_TYPE_NAMES[index]; + } + + + /** + * Number of byte code operands for each opcode, i.e., number of bytes after the tag byte + * itself. Indexed by opcode, so NO_OF_OPERANDS[BIPUSH] = the number of operands for a bipush + * instruction. + */ + private 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*/, 4/*invokedynamic*/, 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*/ + }; + + /** + * + * @param index + * @return Number of byte code operands + * @since 6.0 + */ + public static short getNoOfOperands(final int index) { + return NO_OF_OPERANDS[index]; + } + + /** + * How the byte code operands are to be interpreted for each opcode. + * Indexed by opcode. TYPE_OF_OPERANDS[ILOAD] = an array of shorts + * describing the data types for the instruction. + */ + private 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, T_BYTE, T_BYTE}/*invokedynamic*/, + {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*/ + }; + + /** + * @since 6.0 + */ + public static short getOperandType(final int opcode, final int index) { + return TYPE_OF_OPERANDS[opcode][index]; + } + + /** + * @since 6.0 + */ + public static long getOperandTypeCount(final int opcode) { + return TYPE_OF_OPERANDS[opcode].length; + } + + /** + * Names of opcodes. Indexed by opcode. OPCODE_NAMES[ALOAD] = "aload". + */ + private 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", "invokedynamic", "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" + }; + + /** + * @since 6.0 + */ + public static final int OPCODE_NAMES_LENGTH = OPCODE_NAMES.length; + + + /** + * @since 6.0 + */ + public static String getOpcodeName(final int index) { + return OPCODE_NAMES[index]; + } + + /** + * Number of words consumed on operand stack by instructions. + * Indexed by opcode. CONSUME_STACK[FALOAD] = number of words + * consumed from the stack by a faload instruction. + */ + private 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*/, UNPREDICTABLE/*invokedynamic*/, 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*/ + }; + + /** + * + * @param index + * @return Number of words consumed on operand stack + * @since 6.0 + */ + public static int getConsumeStack(final int index) { + return CONSUME_STACK[index]; + } + + + /** + * Number of words produced onto operand stack by instructions. + * Indexed by opcode. CONSUME_STACK[DALOAD] = number of words + * consumed from the stack by a daload instruction. + */ + private 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*/, UNPREDICTABLE/*invokedynamic*/, 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*/ + }; + + /** + * + * @param index + * @return Number of words produced onto operand stack + * @since 6.0 + */ + public static int getProduceStack(final int index) { + return PRODUCE_STACK[index]; + } + + /** 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 byte ATTR_RUNTIME_VISIBLE_ANNOTATIONS = 12; + public static final byte ATTR_RUNTIME_INVISIBLE_ANNOTATIONS = 13; + public static final byte ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS = 14; + public static final byte ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS = 15; + public static final byte ATTR_ANNOTATION_DEFAULT = 16; + public static final byte ATTR_LOCAL_VARIABLE_TYPE_TABLE = 17; + public static final byte ATTR_ENCLOSING_METHOD = 18; + public static final byte ATTR_STACK_MAP_TABLE = 19; + public static final byte ATTR_BOOTSTRAP_METHODS = 20; + public static final byte ATTR_METHOD_PARAMETERS = 21; + + public static final short KNOWN_ATTRIBUTES = 22; // count of attributes + + private static final String[] ATTRIBUTE_NAMES = { + "SourceFile", "ConstantValue", "Code", "Exceptions", + "LineNumberTable", "LocalVariableTable", + "InnerClasses", "Synthetic", "Deprecated", + "PMGClass", "Signature", "StackMap", + "RuntimeVisibleAnnotations", "RuntimeInvisibleAnnotations", + "RuntimeVisibleParameterAnnotations", "RuntimeInvisibleParameterAnnotations", + "AnnotationDefault", "LocalVariableTypeTable", "EnclosingMethod", "StackMapTable", + "BootstrapMethods", "MethodParameters" + }; + + /** + * + * @param index + * @return the attribute name + * @since 6.0 + */ + public static String getAttributeName(final int index) { + return ATTRIBUTE_NAMES[index]; + } + + /** 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; + + private static final String[] ITEM_NAMES = { + "Bogus", "Integer", "Float", "Double", "Long", + "Null", "InitObject", "Object", "NewObject" + }; + + /** + * + * @param index + * @return the item name + * @since 6.0 + */ + public static String getItemName(final int index) { + return ITEM_NAMES[index]; + } + + /** Constants used to identify StackMapEntry types. + * + * For those types which can specify a range, the + * constant names the lowest value. + */ + public static final int SAME_FRAME = 0; + public static final int SAME_LOCALS_1_STACK_ITEM_FRAME = 64; + public static final int SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED = 247; + public static final int CHOP_FRAME = 248; + public static final int SAME_FRAME_EXTENDED = 251; + public static final int APPEND_FRAME = 252; + public static final int FULL_FRAME = 255; + + /** Constants that define the maximum value of + * those constants which store ranges. */ + + public static final int SAME_FRAME_MAX = 63; + public static final int SAME_LOCALS_1_STACK_ITEM_FRAME_MAX = 127; + public static final int CHOP_FRAME_MAX = 250; + public static final int APPEND_FRAME_MAX = 254; + + + // Constants defining the behavior of the Method Handles (JVMS �5.4.3.5) + + public static final byte REF_getField = 1; + public static final byte REF_getStatic = 2; + public static final byte REF_putField = 3; + public static final byte REF_putStatic = 4; + public static final byte REF_invokeVirtual = 5; + public static final byte REF_invokeStatic = 6; + public static final byte REF_invokeSpecial = 7; + public static final byte REF_newInvokeSpecial = 8; + public static final byte REF_invokeInterface = 9; + + /** + * The names of the reference_kinds of a CONSTANT_MethodHandle_info. + */ + private static final String[] METHODHANDLE_NAMES = { + "", "getField", "getStatic", "putField", "putStatic", "invokeVirtual", + "invokeStatic", "invokeSpecial", "newInvokeSpecial", "invokeInterface" }; + + /** + * + * @param index + * @return the method handle name + * @since 6.0 + */ + public static String getMethodHandleName(final int index) { + return METHODHANDLE_NAMES[index]; + } + + private Const() { } // not instantiable + +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/Constants.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/Constants.java new file mode 100644 index 00000000..951a7b1c --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/Constants.java @@ -0,0 +1,1697 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel; + +/** + * Constants for the project, mostly defined in the JVM specification. + * + * @version $Id: Constants.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @deprecated (since 6.0) DO NOT USE - use Const instead + */ +@Deprecated +public interface Constants { + + /** Major version number of class files for Java 1.1. + * @see #MINOR_1_1 + * */ + short MAJOR_1_1 = 45; + + /** Minor version number of class files for Java 1.1. + * @see #MAJOR_1_1 + * */ + short MINOR_1_1 = 3; + + /** Major version number of class files for Java 1.2. + * @see #MINOR_1_2 + * */ + short MAJOR_1_2 = 46; + + /** Minor version number of class files for Java 1.2. + * @see #MAJOR_1_2 + * */ + short MINOR_1_2 = 0; + + /** Major version number of class files for Java 1.2. + * @see #MINOR_1_2 + * */ + short MAJOR_1_3 = 47; + + /** Minor version number of class files for Java 1.3. + * @see #MAJOR_1_3 + * */ + short MINOR_1_3 = 0; + + /** Major version number of class files for Java 1.3. + * @see #MINOR_1_3 + * */ + short MAJOR_1_4 = 48; + + /** Minor version number of class files for Java 1.4. + * @see #MAJOR_1_4 + * */ + short MINOR_1_4 = 0; + + /** Major version number of class files for Java 1.4. + * @see #MINOR_1_4 + * */ + short MAJOR_1_5 = 49; + + /** Minor version number of class files for Java 1.5. + * @see #MAJOR_1_5 + * */ + short MINOR_1_5 = 0; + + + /** Default major version number. Class file is for Java 1.1. + * @see #MAJOR_1_1 + * */ + short MAJOR = MAJOR_1_1; + + /** Default major version number. Class file is for Java 1.1. + * @see #MAJOR_1_1 + * */ + short MINOR = MINOR_1_1; + + /** Maximum value for an unsigned short. + */ + int MAX_SHORT = 65535; // 2^16 - 1 + + /** Maximum value for an unsigned byte. + */ + int MAX_BYTE = 255; // 2^8 - 1 + + /** One of the access flags for fields, methods, or classes. + * @see " + * Flag definitions for Fields in the Java Virtual Machine Specification (Java SE 8 Edition)." + * @see " + * Flag definitions for Methods in the Java Virtual Machine Specification (Java SE 8 Edition)." + * @see " + * Flag definitions for Classes in the Java Virtual Machine Specification (Java SE 8 Edition)." + */ + short ACC_PUBLIC = 0x0001; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + short ACC_PRIVATE = 0x0002; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + short ACC_PROTECTED = 0x0004; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + short ACC_STATIC = 0x0008; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + short ACC_FINAL = 0x0010; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + short ACC_SYNCHRONIZED = 0x0020; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + short ACC_VOLATILE = 0x0040; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + short ACC_BRIDGE = 0x0040; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + short ACC_TRANSIENT = 0x0080; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + short ACC_VARARGS = 0x0080; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + short ACC_NATIVE = 0x0100; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + short ACC_INTERFACE = 0x0200; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + short ACC_ABSTRACT = 0x0400; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + short ACC_STRICT = 0x0800; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + short ACC_SYNTHETIC = 0x1000; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + short ACC_ANNOTATION = 0x2000; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + short ACC_ENUM = 0x4000; + + // Applies to classes compiled by new compilers only + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + short ACC_SUPER = 0x0020; + + /** One of the access flags for fields, methods, or classes. + * @see #ACC_PUBLIC + */ + short MAX_ACC_FLAG = ACC_ENUM; + + /** The names of the access flags. */ + String[] ACCESS_NAMES = { + "public", "private", "protected", "static", "final", "synchronized", + "volatile", "transient", "native", "interface", "abstract", "strictfp", + "synthetic", "annotation", "enum" + }; + + /** Marks a constant pool entry as type UTF-8. */ + byte CONSTANT_Utf8 = 1; + + /** Marks a constant pool entry as type Integer. */ + byte CONSTANT_Integer = 3; + + /** Marks a constant pool entry as type Float. */ + byte CONSTANT_Float = 4; + + /** Marks a constant pool entry as type Long. */ + byte CONSTANT_Long = 5; + + /** Marks a constant pool entry as type Double. */ + byte CONSTANT_Double = 6; + + /** Marks a constant pool entry as a Class. */ + byte CONSTANT_Class = 7; + + /** Marks a constant pool entry as a Field Reference. */ + byte CONSTANT_Fieldref = 9; + + /** Marks a constant pool entry as type String. */ + byte CONSTANT_String = 8; + + /** Marks a constant pool entry as a Method Reference. */ + byte CONSTANT_Methodref = 10; + + /** Marks a constant pool entry as an Interface Method Reference. */ + byte CONSTANT_InterfaceMethodref = 11; + + /** Marks a constant pool entry as a name and type. */ + byte CONSTANT_NameAndType = 12; + + /** The names of the types of entries in a constant pool. */ + 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 "class + * initialization method" or "interface initialization + * method". This is "<clinit>". + */ + String STATIC_INITIALIZER_NAME = ""; + + /** The name of every constructor method in a class, also called + * "instance initialization method". This is "<init>". + */ + String CONSTRUCTOR_NAME = ""; + + /** The names of the interfaces implemented by arrays */ + String[] INTERFACES_IMPLEMENTED_BY_ARRAYS = {"java.lang.Cloneable", "java.io.Serializable"}; + + /** + * One of the limitations of the Java Virtual Machine. + * @see + * The Java Virtual Machine Specification, Second Edition, page 152, chapter 4.10. + */ + int MAX_CP_ENTRIES = 65535; + + /** + * One of the limitations of the Java Virtual Machine. + * @see + * The Java Virtual Machine Specification, Second Edition, page 152, chapter 4.10. + */ + int MAX_CODE_SIZE = 65536; //bytes + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short NOP = 0; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ACONST_NULL = 1; + + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ICONST_M1 = 2; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ICONST_0 = 3; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ICONST_1 = 4; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ICONST_2 = 5; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ICONST_3 = 6; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ICONST_4 = 7; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ICONST_5 = 8; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LCONST_0 = 9; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LCONST_1 = 10; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short FCONST_0 = 11; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short FCONST_1 = 12; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short FCONST_2 = 13; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DCONST_0 = 14; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DCONST_1 = 15; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short BIPUSH = 16; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short SIPUSH = 17; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LDC = 18; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LDC_W = 19; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LDC2_W = 20; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ILOAD = 21; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LLOAD = 22; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short FLOAD = 23; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DLOAD = 24; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ALOAD = 25; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ILOAD_0 = 26; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ILOAD_1 = 27; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ILOAD_2 = 28; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ILOAD_3 = 29; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LLOAD_0 = 30; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LLOAD_1 = 31; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LLOAD_2 = 32; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LLOAD_3 = 33; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short FLOAD_0 = 34; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short FLOAD_1 = 35; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short FLOAD_2 = 36; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short FLOAD_3 = 37; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DLOAD_0 = 38; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DLOAD_1 = 39; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DLOAD_2 = 40; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DLOAD_3 = 41; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ALOAD_0 = 42; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ALOAD_1 = 43; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ALOAD_2 = 44; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ALOAD_3 = 45; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IALOAD = 46; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LALOAD = 47; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short FALOAD = 48; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DALOAD = 49; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short AALOAD = 50; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short BALOAD = 51; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short CALOAD = 52; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short SALOAD = 53; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ISTORE = 54; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LSTORE = 55; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short FSTORE = 56; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DSTORE = 57; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ASTORE = 58; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ISTORE_0 = 59; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ISTORE_1 = 60; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ISTORE_2 = 61; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ISTORE_3 = 62; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LSTORE_0 = 63; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LSTORE_1 = 64; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LSTORE_2 = 65; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LSTORE_3 = 66; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short FSTORE_0 = 67; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short FSTORE_1 = 68; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short FSTORE_2 = 69; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short FSTORE_3 = 70; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DSTORE_0 = 71; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DSTORE_1 = 72; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DSTORE_2 = 73; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DSTORE_3 = 74; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ASTORE_0 = 75; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ASTORE_1 = 76; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ASTORE_2 = 77; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ASTORE_3 = 78; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IASTORE = 79; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LASTORE = 80; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short FASTORE = 81; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DASTORE = 82; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short AASTORE = 83; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short BASTORE = 84; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short CASTORE = 85; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short SASTORE = 86; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short POP = 87; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short POP2 = 88; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DUP = 89; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DUP_X1 = 90; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DUP_X2 = 91; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DUP2 = 92; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DUP2_X1 = 93; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DUP2_X2 = 94; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short SWAP = 95; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IADD = 96; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LADD = 97; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short FADD = 98; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DADD = 99; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ISUB = 100; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LSUB = 101; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short FSUB = 102; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DSUB = 103; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IMUL = 104; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LMUL = 105; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short FMUL = 106; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DMUL = 107; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IDIV = 108; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LDIV = 109; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short FDIV = 110; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DDIV = 111; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IREM = 112; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LREM = 113; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short FREM = 114; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DREM = 115; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short INEG = 116; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LNEG = 117; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short FNEG = 118; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DNEG = 119; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ISHL = 120; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LSHL = 121; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ISHR = 122; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LSHR = 123; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IUSHR = 124; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LUSHR = 125; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IAND = 126; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LAND = 127; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IOR = 128; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LOR = 129; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IXOR = 130; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LXOR = 131; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IINC = 132; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short I2L = 133; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short I2F = 134; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short I2D = 135; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short L2I = 136; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short L2F = 137; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short L2D = 138; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short F2I = 139; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short F2L = 140; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short F2D = 141; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short D2I = 142; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short D2L = 143; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short D2F = 144; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short I2B = 145; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short INT2BYTE = 145; // Old notion + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short I2C = 146; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short INT2CHAR = 146; // Old notion + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short I2S = 147; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short INT2SHORT = 147; // Old notion + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LCMP = 148; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short FCMPL = 149; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short FCMPG = 150; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DCMPL = 151; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DCMPG = 152; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IFEQ = 153; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IFNE = 154; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IFLT = 155; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IFGE = 156; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IFGT = 157; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IFLE = 158; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IF_ICMPEQ = 159; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IF_ICMPNE = 160; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IF_ICMPLT = 161; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IF_ICMPGE = 162; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IF_ICMPGT = 163; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IF_ICMPLE = 164; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IF_ACMPEQ = 165; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IF_ACMPNE = 166; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short GOTO = 167; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short JSR = 168; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short RET = 169; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short TABLESWITCH = 170; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LOOKUPSWITCH = 171; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IRETURN = 172; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short LRETURN = 173; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short FRETURN = 174; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short DRETURN = 175; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ARETURN = 176; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short RETURN = 177; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short GETSTATIC = 178; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short PUTSTATIC = 179; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short GETFIELD = 180; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short PUTFIELD = 181; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short INVOKEVIRTUAL = 182; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short INVOKESPECIAL = 183; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short INVOKENONVIRTUAL = 183; // Old name in JDK 1.0 + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short INVOKESTATIC = 184; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short INVOKEINTERFACE = 185; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short INVOKEDYNAMIC = 186; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short NEW = 187; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short NEWARRAY = 188; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ANEWARRAY = 189; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ARRAYLENGTH = 190; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short ATHROW = 191; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short CHECKCAST = 192; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short INSTANCEOF = 193; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short MONITORENTER = 194; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short MONITOREXIT = 195; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short WIDE = 196; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short MULTIANEWARRAY = 197; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IFNULL = 198; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short IFNONNULL = 199; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short GOTO_W = 200; + /** Java VM opcode. + * @see + * Opcode definitions in The Java Virtual Machine Specification */ + short JSR_W = 201; + + /** JVM internal opcode. + * @see + * Reserved opcodes in the Java Virtual Machine Specification */ + short BREAKPOINT = 202; + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + short LDC_QUICK = 203; + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + short LDC_W_QUICK = 204; + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + short LDC2_W_QUICK = 205; + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + short GETFIELD_QUICK = 206; + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + short PUTFIELD_QUICK = 207; + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + short GETFIELD2_QUICK = 208; + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + short PUTFIELD2_QUICK = 209; + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + short GETSTATIC_QUICK = 210; + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + short PUTSTATIC_QUICK = 211; + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + short GETSTATIC2_QUICK = 212; + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + short PUTSTATIC2_QUICK = 213; + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + short INVOKEVIRTUAL_QUICK = 214; + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + short INVOKENONVIRTUAL_QUICK = 215; + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + short INVOKESUPER_QUICK = 216; + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + short INVOKESTATIC_QUICK = 217; + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + short INVOKEINTERFACE_QUICK = 218; + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + short INVOKEVIRTUALOBJECT_QUICK = 219; + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + short NEW_QUICK = 221; + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + short ANEWARRAY_QUICK = 222; + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + short MULTIANEWARRAY_QUICK = 223; + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + short CHECKCAST_QUICK = 224; + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + short INSTANCEOF_QUICK = 225; + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + short INVOKEVIRTUAL_QUICK_W = 226; + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + short GETFIELD_QUICK_W = 227; + /** JVM internal opcode. + * @see + * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1) + * @see + * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification. */ + short PUTFIELD_QUICK_W = 228; + /** JVM internal opcode. + * @see + * Reserved opcodes in the Java Virtual Machine Specification */ + short IMPDEP1 = 254; + /** JVM internal opcode. + * @see + * Reserved opcodes in the Java Virtual Machine Specification */ + short IMPDEP2 = 255; + + /** + * BCEL virtual instruction for pushing an arbitrary data type onto the stack. Will be converted to the appropriate JVM + * opcode when the class is dumped. + */ + short PUSH = 4711; + /** + * BCEL virtual instruction for either LOOKUPSWITCH or TABLESWITCH. Will be converted to the appropriate JVM + * opcode when the class is dumped. + */ + short SWITCH = 4712; + + /** Illegal opcode. */ + short UNDEFINED = -1; + /** Illegal opcode. */ + short UNPREDICTABLE = -2; + /** Illegal opcode. */ + short RESERVED = -3; + /** Mnemonic for an illegal opcode. */ + String ILLEGAL_OPCODE = ""; + /** Mnemonic for an illegal type. */ + String ILLEGAL_TYPE = ""; + + /** Boolean data type. */ + byte T_BOOLEAN = 4; + /** Char data type. */ + byte T_CHAR = 5; + /** Float data type. */ + byte T_FLOAT = 6; + /** Double data type. */ + byte T_DOUBLE = 7; + /** Byte data type. */ + byte T_BYTE = 8; + /** Short data type. */ + byte T_SHORT = 9; + /** Int data type. */ + byte T_INT = 10; + /** Long data type. */ + byte T_LONG = 11; + + /** Void data type (non-standard). */ + byte T_VOID = 12; // Non-standard + /** Array data type. */ + byte T_ARRAY = 13; + /** Object data type. */ + byte T_OBJECT = 14; + /** Reference data type (deprecated). */ + byte T_REFERENCE = 14; // Deprecated + /** Unknown data type. */ + byte T_UNKNOWN = 15; + /** Address data type. */ + byte T_ADDRESS = 16; + + /** The primitive type names corresponding to the T_XX constants, + * e.g., TYPE_NAMES[T_INT] = "int" + */ + String[] TYPE_NAMES = { + ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, + "boolean", "char", "float", "double", "byte", "short", "int", "long", + "void", "array", "object", "unknown", "address" + }; + + /** The primitive class names corresponding to the T_XX constants, + * e.g., CLASS_TYPE_NAMES[T_INT] = "java.lang.Integer" + */ + String[] CLASS_TYPE_NAMES = { + ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, + "java.lang.Boolean", "java.lang.Character", "java.lang.Float", + "java.lang.Double", "java.lang.Byte", "java.lang.Short", + "java.lang.Integer", "java.lang.Long", "java.lang.Void", + ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE + }; + + /** The signature characters corresponding to primitive types, + * e.g., SHORT_TYPE_NAMES[T_INT] = "I" + */ + 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 for each opcode, i.e., number of bytes after the tag byte + * itself. Indexed by opcode, so NO_OF_OPERANDS[BIPUSH] = the number of operands for a bipush + * instruction. + */ + 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*/, 4/*invokedynamic*/, 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 for each opcode. + * Indexed by opcode. TYPE_OF_OPERANDS[ILOAD] = an array of shorts + * describing the data types for the instruction. + */ + 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, T_BYTE, T_BYTE}/*invokedynamic*/, + {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. Indexed by opcode. OPCODE_NAMES[ALOAD] = "aload". + */ + 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", "invokedynamic", "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. + * Indexed by opcode. CONSUME_STACK[FALOAD] = number of words + * consumed from the stack by a faload instruction. + */ + 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*/, UNPREDICTABLE/*invokedynamic*/, 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. + * Indexed by opcode. CONSUME_STACK[DALOAD] = number of words + * consumed from the stack by a daload instruction. + */ + 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*/, UNPREDICTABLE/*invokedynamic*/, 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. + */ + byte ATTR_UNKNOWN = -1; + byte ATTR_SOURCE_FILE = 0; + byte ATTR_CONSTANT_VALUE = 1; + byte ATTR_CODE = 2; + byte ATTR_EXCEPTIONS = 3; + byte ATTR_LINE_NUMBER_TABLE = 4; + byte ATTR_LOCAL_VARIABLE_TABLE = 5; + byte ATTR_INNER_CLASSES = 6; + byte ATTR_SYNTHETIC = 7; + byte ATTR_DEPRECATED = 8; + byte ATTR_PMG = 9; + byte ATTR_SIGNATURE = 10; + byte ATTR_STACK_MAP = 11; + byte ATTR_RUNTIMEVISIBLE_ANNOTATIONS = 12; + byte ATTR_RUNTIMEINVISIBLE_ANNOTATIONS = 13; + byte ATTR_RUNTIMEVISIBLE_PARAMETER_ANNOTATIONS = 14; + byte ATTR_RUNTIMEINVISIBLE_PARAMETER_ANNOTATIONS = 15; + byte ATTR_ANNOTATION_DEFAULT = 16; + + short KNOWN_ATTRIBUTES = 12;//should be 17 + + + // TODO: mutable public array!! + String[] ATTRIBUTE_NAMES = { + "SourceFile", "ConstantValue", "Code", "Exceptions", + "LineNumberTable", "LocalVariableTable", + "InnerClasses", "Synthetic", "Deprecated", + "PMGClass", "Signature", "StackMap", + "RuntimeVisibleAnnotations", "RuntimeInvisibleAnnotations", + "RuntimeVisibleParameterAnnotations", "RuntimeInvisibleParameterAnnotations", + "AnnotationDefault" + }; + + /** Constants used in the StackMap attribute. + */ + byte ITEM_Bogus = 0; + byte ITEM_Integer = 1; + byte ITEM_Float = 2; + byte ITEM_Double = 3; + byte ITEM_Long = 4; + byte ITEM_Null = 5; + byte ITEM_InitObject = 6; + byte ITEM_Object = 7; + byte ITEM_NewObject = 8; + + String[] ITEM_NAMES = { + "Bogus", "Integer", "Float", "Double", "Long", + "Null", "InitObject", "Object", "NewObject" + }; + +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/ExceptionConst.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/ExceptionConst.java new file mode 100644 index 00000000..b8345c9e --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/ExceptionConst.java @@ -0,0 +1,126 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel; + +/** + * Exception constants. + * @since 6.0 (intended to replace the InstructionConstant interface) + */ +public final class ExceptionConst { + + /** 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 + */ + private 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 + private static final Class[] EXCS_FIELD_AND_METHOD_RESOLUTION = { + NO_SUCH_FIELD_ERROR, ILLEGAL_ACCESS_ERROR, NO_SUCH_METHOD_ERROR + }; // Chapter 5.2 + private static final Class[] EXCS_INTERFACE_METHOD_RESOLUTION = new Class[0]; // Chapter 5.3 (as below) + private static final Class[] EXCS_STRING_RESOLUTION = new Class[0]; + // Chapter 5.4 (no errors but the ones that _always_ could happen! How stupid.) + private static final Class[] EXCS_ARRAY_EXCEPTION = { + NULL_POINTER_EXCEPTION, ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION + }; + + /** + * Enum corresponding to the various Exception Class arrays, + * used by {@link ExceptionConst#createExceptions(EXCS, Class...)} + */ + public enum EXCS { + EXCS_CLASS_AND_INTERFACE_RESOLUTION, + EXCS_FIELD_AND_METHOD_RESOLUTION, + EXCS_INTERFACE_METHOD_RESOLUTION, + EXCS_STRING_RESOLUTION, + EXCS_ARRAY_EXCEPTION, + } + + // helper method to merge exception class arrays + private static Class[] mergeExceptions(final Class[] input, final Class ... extraClasses) { + final int extraLen = extraClasses == null ? 0 : extraClasses.length; + final Class[] excs = new Class[input.length + extraLen]; + System.arraycopy(input, 0, excs, 0, input.length); + if (extraLen > 0) { + System.arraycopy(extraClasses, 0, excs, input.length, extraLen); + } + return excs; + } + + /** + * Creates a copy of the specified Exception Class array combined with any additional Exception classes. + * @param type the basic array type + * @param extraClasses additional classes, if any + * @return the merged array + */ + public static Class[] createExceptions(final EXCS type, final Class ... extraClasses) { + switch (type) { + case EXCS_CLASS_AND_INTERFACE_RESOLUTION: + return mergeExceptions(EXCS_CLASS_AND_INTERFACE_RESOLUTION, extraClasses); + case EXCS_ARRAY_EXCEPTION: + return mergeExceptions(EXCS_ARRAY_EXCEPTION, extraClasses); + case EXCS_FIELD_AND_METHOD_RESOLUTION: + return mergeExceptions(EXCS_FIELD_AND_METHOD_RESOLUTION, extraClasses); + case EXCS_INTERFACE_METHOD_RESOLUTION: + return mergeExceptions(EXCS_INTERFACE_METHOD_RESOLUTION, extraClasses); + case EXCS_STRING_RESOLUTION: + return mergeExceptions(EXCS_STRING_RESOLUTION, extraClasses); + default: + throw new AssertionError("Cannot happen; unexpected enum value: " + type); + } + } + + +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/ExceptionConstants.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/ExceptionConstants.java new file mode 100644 index 00000000..262e3d45 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/ExceptionConstants.java @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel; + +/** + * Exception constants. + * + * @version $Id: ExceptionConstants.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @deprecated (since 6.0) DO NOT USE - use ExceptionConst instead + */ +@Deprecated +public interface ExceptionConstants { + + /** The mother of all exceptions + */ + Class THROWABLE = Throwable.class; + /** Super class of any run-time exception + */ + Class RUNTIME_EXCEPTION = RuntimeException.class; + /** Super class of any linking exception (aka Linkage Error) + */ + Class LINKING_EXCEPTION = LinkageError.class; + /** Linking Exceptions + */ + Class CLASS_CIRCULARITY_ERROR = ClassCircularityError.class; + Class CLASS_FORMAT_ERROR = ClassFormatError.class; + Class EXCEPTION_IN_INITIALIZER_ERROR = ExceptionInInitializerError.class; + Class INCOMPATIBLE_CLASS_CHANGE_ERROR = IncompatibleClassChangeError.class; + Class ABSTRACT_METHOD_ERROR = AbstractMethodError.class; + Class ILLEGAL_ACCESS_ERROR = IllegalAccessError.class; + Class INSTANTIATION_ERROR = InstantiationError.class; + Class NO_SUCH_FIELD_ERROR = NoSuchFieldError.class; + Class NO_SUCH_METHOD_ERROR = NoSuchMethodError.class; + Class NO_CLASS_DEF_FOUND_ERROR = NoClassDefFoundError.class; + Class UNSATISFIED_LINK_ERROR = UnsatisfiedLinkError.class; + Class VERIFY_ERROR = VerifyError.class; + /* UnsupportedClassVersionError is new in JDK 1.2 */ +// Class UnsupportedClassVersionError = UnsupportedClassVersionError.class; + /** Run-Time Exceptions + */ + Class NULL_POINTER_EXCEPTION = NullPointerException.class; + Class ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION + = ArrayIndexOutOfBoundsException.class; + Class ARITHMETIC_EXCEPTION = ArithmeticException.class; + Class NEGATIVE_ARRAY_SIZE_EXCEPTION = NegativeArraySizeException.class; + Class CLASS_CAST_EXCEPTION = ClassCastException.class; + Class ILLEGAL_MONITOR_STATE = IllegalMonitorStateException.class; + + /** + * Pre-defined exception arrays according to chapters 5.1-5.4 of the Java Virtual + * Machine Specification + * @deprecated Do not use these arrays, use the static methods in the ExceptionConst implementation class instead + */ + @Deprecated + 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 + @Deprecated + Class[] EXCS_FIELD_AND_METHOD_RESOLUTION = { + NO_SUCH_FIELD_ERROR, ILLEGAL_ACCESS_ERROR, NO_SUCH_METHOD_ERROR + }; // Chapter 5.2 + @Deprecated + Class[] EXCS_INTERFACE_METHOD_RESOLUTION = new Class[0]; // Chapter 5.3 (as below) + @Deprecated + Class[] EXCS_STRING_RESOLUTION = new Class[0]; + // Chapter 5.4 (no errors but the ones that _always_ could happen! How stupid.) + @Deprecated + Class[] EXCS_ARRAY_EXCEPTION = { + NULL_POINTER_EXCEPTION, ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION + }; + +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/Repository.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/Repository.java old mode 100755 new mode 100644 similarity index 63% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/Repository.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/Repository.java index dd024472..44d6879a --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/Repository.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/Repository.java @@ -1,262 +1,262 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0; - -import java.io.IOException; - -import org.apache.bcel5_2_0.classfile.JavaClass; -import org.apache.bcel5_2_0.util.ClassPath; -import org.apache.bcel5_2_0.util.SyntheticRepository; - -/** - * The repository maintains informations about class interdependencies, e.g., - * whether a class is a sub-class of another. Delegates actual class loading - * to SyntheticRepository with current class path by default. - * - * @see org.apache.bcel5_2_0.util.Repository - * @see org.apache.bcel5_2_0.util.SyntheticRepository - * - * @version $Id: Repository.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public abstract class Repository { - - private static org.apache.bcel5_2_0.util.Repository _repository = SyntheticRepository.getInstance(); - - - /** @return currently used repository instance - */ - public static org.apache.bcel5_2_0.util.Repository getRepository() { - return _repository; - } - - - /** Set repository instance to be used for class loading - */ - public static void setRepository( org.apache.bcel5_2_0.util.Repository rep ) { - _repository = rep; - } - - - /** Lookup class somewhere found on your CLASSPATH, or whereever the - * repository instance looks for it. - * - * @return class object for given fully qualified class name - * @throws ClassNotFoundException if the class could not be found or - * parsed correctly - */ - public static JavaClass lookupClass( String class_name ) throws ClassNotFoundException { - return _repository.loadClass(class_name); - } - - - /** - * Try to find class source using the internal repository instance. - * @see Class - * @return JavaClass object for given runtime class - * @throws ClassNotFoundException if the class could not be found or - * parsed correctly - */ - public static JavaClass lookupClass( Class clazz ) throws ClassNotFoundException { - return _repository.loadClass(clazz); - } - - - /** - * @return class file object for given Java class by looking on the - * system class path; returns null if the class file can't be - * found - */ - public static ClassPath.ClassFile lookupClassFile( String class_name ) { - try { - ClassPath path = _repository.getClassPath(); - if (path == null) { - return null; - } - return path.getClassFile(class_name); - } catch (IOException e) { - return null; - } - } - - - /** Clear the repository. - */ - public static void clearCache() { - _repository.clear(); - } - - - /** - * Add clazz to repository if there isn't an equally named class already in there. - * - * @return old entry in repository - */ - public static JavaClass addClass( JavaClass clazz ) { - JavaClass old = _repository.findClass(clazz.getClassName()); - _repository.storeClass(clazz); - return old; - } - - - /** - * Remove class with given (fully qualified) name from repository. - */ - public static void removeClass( String clazz ) { - _repository.removeClass(_repository.findClass(clazz)); - } - - - /** - * Remove given class from repository. - */ - public static void removeClass( JavaClass clazz ) { - _repository.removeClass(clazz); - } - - - /** - * @return list of super classes of clazz in ascending order, i.e., - * Object is always the last element - * @throws ClassNotFoundException if any of the superclasses can't be found - */ - public static JavaClass[] getSuperClasses( JavaClass clazz ) throws ClassNotFoundException { - return clazz.getSuperClasses(); - } - - - /** - * @return list of super classes of clazz in ascending order, i.e., - * Object is always the last element. - * @throws ClassNotFoundException if the named class or any of its - * superclasses can't be found - */ - public static JavaClass[] getSuperClasses( String class_name ) throws ClassNotFoundException { - JavaClass jc = lookupClass(class_name); - return getSuperClasses(jc); - } - - - /** - * @return all interfaces implemented by class and its super - * classes and the interfaces that those interfaces extend, and so on. - * (Some people call this a transitive hull). - * @throws ClassNotFoundException if any of the class's - * superclasses or superinterfaces can't be found - */ - public static JavaClass[] getInterfaces( JavaClass clazz ) throws ClassNotFoundException { - return clazz.getAllInterfaces(); - } - - - /** - * @return all interfaces implemented by class and its super - * classes and the interfaces that extend those interfaces, and so on - * @throws ClassNotFoundException if the named class can't be found, - * or if any of its superclasses or superinterfaces can't be found - */ - public static JavaClass[] getInterfaces( String class_name ) throws ClassNotFoundException { - return getInterfaces(lookupClass(class_name)); - } - - - /** - * Equivalent to runtime "instanceof" operator. - * @return true, if clazz is an instance of super_class - * @throws ClassNotFoundException if any superclasses or superinterfaces - * of clazz can't be found - */ - public static boolean instanceOf( JavaClass clazz, JavaClass super_class ) - throws ClassNotFoundException { - return clazz.instanceOf(super_class); - } - - - /** - * @return true, if clazz is an instance of super_class - * @throws ClassNotFoundException if either clazz or super_class - * can't be found - */ - public static boolean instanceOf( String clazz, String super_class ) - throws ClassNotFoundException { - return instanceOf(lookupClass(clazz), lookupClass(super_class)); - } - - - /** - * @return true, if clazz is an instance of super_class - * @throws ClassNotFoundException if super_class can't be found - */ - public static boolean instanceOf( JavaClass clazz, String super_class ) - throws ClassNotFoundException { - return instanceOf(clazz, lookupClass(super_class)); - } - - - /** - * @return true, if clazz is an instance of super_class - * @throws ClassNotFoundException if clazz can't be found - */ - public static boolean instanceOf( String clazz, JavaClass super_class ) - throws ClassNotFoundException { - return instanceOf(lookupClass(clazz), super_class); - } - - - /** - * @return true, if clazz is an implementation of interface inter - * @throws ClassNotFoundException if any superclasses or superinterfaces - * of clazz can't be found - */ - public static boolean implementationOf( JavaClass clazz, JavaClass inter ) - throws ClassNotFoundException { - return clazz.implementationOf(inter); - } - - - /** - * @return true, if clazz is an implementation of interface inter - * @throws ClassNotFoundException if clazz, inter, or any superclasses - * or superinterfaces of clazz can't be found - */ - public static boolean implementationOf( String clazz, String inter ) - throws ClassNotFoundException { - return implementationOf(lookupClass(clazz), lookupClass(inter)); - } - - - /** - * @return true, if clazz is an implementation of interface inter - * @throws ClassNotFoundException if inter or any superclasses - * or superinterfaces of clazz can't be found - */ - public static boolean implementationOf( JavaClass clazz, String inter ) - throws ClassNotFoundException { - return implementationOf(clazz, lookupClass(inter)); - } - - - /** - * @return true, if clazz is an implementation of interface inter - * @throws ClassNotFoundException if clazz or any superclasses or - * superinterfaces of clazz can't be found - */ - public static boolean implementationOf( String clazz, JavaClass inter ) - throws ClassNotFoundException { - return implementationOf(lookupClass(clazz), inter); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel; + +import java.io.IOException; + +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.util.ClassPath; +import org.apache.bcel.util.SyntheticRepository; + +/** + * The repository maintains informations about class interdependencies, e.g., + * whether a class is a sub-class of another. Delegates actual class loading + * to SyntheticRepository with current class path by default. + * + * @see org.apache.bcel.util.Repository + * @see SyntheticRepository + * + * @version $Id: Repository.java 1749603 2016-06-21 20:50:19Z ggregory $ + */ +public abstract class Repository { + + private static org.apache.bcel.util.Repository repository = SyntheticRepository.getInstance(); + + + /** @return currently used repository instance + */ + public static org.apache.bcel.util.Repository getRepository() { + return repository; + } + + + /** Set repository instance to be used for class loading + */ + public static void setRepository( final org.apache.bcel.util.Repository rep ) { + repository = rep; + } + + + /** Lookup class somewhere found on your CLASSPATH, or whereever the + * repository instance looks for it. + * + * @return class object for given fully qualified class name + * @throws ClassNotFoundException if the class could not be found or + * parsed correctly + */ + public static JavaClass lookupClass( final String class_name ) throws ClassNotFoundException { + return repository.loadClass(class_name); + } + + + /** + * Try to find class source using the internal repository instance. + * @see Class + * @return JavaClass object for given runtime class + * @throws ClassNotFoundException if the class could not be found or + * parsed correctly + */ + public static JavaClass lookupClass( final Class clazz ) throws ClassNotFoundException { + return repository.loadClass(clazz); + } + + + /** + * @return class file object for given Java class by looking on the + * system class path; returns null if the class file can't be + * found + */ + public static ClassPath.ClassFile lookupClassFile( final String class_name ) { + try { + final ClassPath path = repository.getClassPath(); + if (path == null) { + return null; + } + return path.getClassFile(class_name); + } catch (final IOException e) { + return null; + } + } + + + /** Clear the repository. + */ + public static void clearCache() { + repository.clear(); + } + + + /** + * Add clazz to repository if there isn't an equally named class already in there. + * + * @return old entry in repository + */ + public static JavaClass addClass( final JavaClass clazz ) { + final JavaClass old = repository.findClass(clazz.getClassName()); + repository.storeClass(clazz); + return old; + } + + + /** + * Remove class with given (fully qualified) name from repository. + */ + public static void removeClass( final String clazz ) { + repository.removeClass(repository.findClass(clazz)); + } + + + /** + * Remove given class from repository. + */ + public static void removeClass( final JavaClass clazz ) { + repository.removeClass(clazz); + } + + + /** + * @return list of super classes of clazz in ascending order, i.e., + * Object is always the last element + * @throws ClassNotFoundException if any of the superclasses can't be found + */ + public static JavaClass[] getSuperClasses( final JavaClass clazz ) throws ClassNotFoundException { + return clazz.getSuperClasses(); + } + + + /** + * @return list of super classes of clazz in ascending order, i.e., + * Object is always the last element. + * @throws ClassNotFoundException if the named class or any of its + * superclasses can't be found + */ + public static JavaClass[] getSuperClasses( final String class_name ) throws ClassNotFoundException { + final JavaClass jc = lookupClass(class_name); + return getSuperClasses(jc); + } + + + /** + * @return all interfaces implemented by class and its super + * classes and the interfaces that those interfaces extend, and so on. + * (Some people call this a transitive hull). + * @throws ClassNotFoundException if any of the class's + * superclasses or superinterfaces can't be found + */ + public static JavaClass[] getInterfaces( final JavaClass clazz ) throws ClassNotFoundException { + return clazz.getAllInterfaces(); + } + + + /** + * @return all interfaces implemented by class and its super + * classes and the interfaces that extend those interfaces, and so on + * @throws ClassNotFoundException if the named class can't be found, + * or if any of its superclasses or superinterfaces can't be found + */ + public static JavaClass[] getInterfaces( final String class_name ) throws ClassNotFoundException { + return getInterfaces(lookupClass(class_name)); + } + + + /** + * Equivalent to runtime "instanceof" operator. + * @return true, if clazz is an instance of super_class + * @throws ClassNotFoundException if any superclasses or superinterfaces + * of clazz can't be found + */ + public static boolean instanceOf( final JavaClass clazz, final JavaClass super_class ) + throws ClassNotFoundException { + return clazz.instanceOf(super_class); + } + + + /** + * @return true, if clazz is an instance of super_class + * @throws ClassNotFoundException if either clazz or super_class + * can't be found + */ + public static boolean instanceOf( final String clazz, final String super_class ) + throws ClassNotFoundException { + return instanceOf(lookupClass(clazz), lookupClass(super_class)); + } + + + /** + * @return true, if clazz is an instance of super_class + * @throws ClassNotFoundException if super_class can't be found + */ + public static boolean instanceOf( final JavaClass clazz, final String super_class ) + throws ClassNotFoundException { + return instanceOf(clazz, lookupClass(super_class)); + } + + + /** + * @return true, if clazz is an instance of super_class + * @throws ClassNotFoundException if clazz can't be found + */ + public static boolean instanceOf( final String clazz, final JavaClass super_class ) + throws ClassNotFoundException { + return instanceOf(lookupClass(clazz), super_class); + } + + + /** + * @return true, if clazz is an implementation of interface inter + * @throws ClassNotFoundException if any superclasses or superinterfaces + * of clazz can't be found + */ + public static boolean implementationOf( final JavaClass clazz, final JavaClass inter ) + throws ClassNotFoundException { + return clazz.implementationOf(inter); + } + + + /** + * @return true, if clazz is an implementation of interface inter + * @throws ClassNotFoundException if clazz, inter, or any superclasses + * or superinterfaces of clazz can't be found + */ + public static boolean implementationOf( final String clazz, final String inter ) + throws ClassNotFoundException { + return implementationOf(lookupClass(clazz), lookupClass(inter)); + } + + + /** + * @return true, if clazz is an implementation of interface inter + * @throws ClassNotFoundException if inter or any superclasses + * or superinterfaces of clazz can't be found + */ + public static boolean implementationOf( final JavaClass clazz, final String inter ) + throws ClassNotFoundException { + return implementationOf(clazz, lookupClass(inter)); + } + + + /** + * @return true, if clazz is an implementation of interface inter + * @throws ClassNotFoundException if clazz or any superclasses or + * superinterfaces of clazz can't be found + */ + public static boolean implementationOf( final String clazz, final JavaClass inter ) + throws ClassNotFoundException { + return implementationOf(lookupClass(clazz), inter); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AccessFlags.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AccessFlags.java new file mode 100644 index 00000000..179274b2 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AccessFlags.java @@ -0,0 +1,219 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import org.apache.bcel.Const; + +/** + * Super class for all objects that have modifiers like private, final, ... I.e. classes, fields, and methods. + * + * @version $Id: AccessFlags.java 1748636 2016-06-15 20:45:17Z dbrosius $ + */ +public abstract class AccessFlags { + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @java.lang.Deprecated + protected int access_flags; // TODO not used externally at present + + public AccessFlags() { + } + + /** + * @param a + * inital access flags + */ + public AccessFlags(final int a) { + access_flags = a; + } + + /** + * @return Access flags of the object aka. "modifiers". + */ + public final int getAccessFlags() { + return access_flags; + } + + /** + * @return Access flags of the object aka. "modifiers". + */ + public final int getModifiers() { + return access_flags; + } + + /** + * Set access flags aka "modifiers". + * + * @param access_flags + * Access flags of the object. + */ + public final void setAccessFlags(final int access_flags) { + this.access_flags = access_flags; + } + + /** + * Set access flags aka "modifiers". + * + * @param access_flags + * Access flags of the object. + */ + public final void setModifiers(final int access_flags) { + setAccessFlags(access_flags); + } + + private void setFlag(final int flag, final boolean set) { + if ((access_flags & flag) != 0) { // Flag is set already + if (!set) { + access_flags ^= flag; + } + } else { // Flag not set + if (set) { + access_flags |= flag; + } + } + } + + public final void isPublic(final boolean flag) { + setFlag(Const.ACC_PUBLIC, flag); + } + + public final boolean isPublic() { + return (access_flags & Const.ACC_PUBLIC) != 0; + } + + public final void isPrivate(final boolean flag) { + setFlag(Const.ACC_PRIVATE, flag); + } + + public final boolean isPrivate() { + return (access_flags & Const.ACC_PRIVATE) != 0; + } + + public final void isProtected(final boolean flag) { + setFlag(Const.ACC_PROTECTED, flag); + } + + public final boolean isProtected() { + return (access_flags & Const.ACC_PROTECTED) != 0; + } + + public final void isStatic(final boolean flag) { + setFlag(Const.ACC_STATIC, flag); + } + + public final boolean isStatic() { + return (access_flags & Const.ACC_STATIC) != 0; + } + + public final void isFinal(final boolean flag) { + setFlag(Const.ACC_FINAL, flag); + } + + public final boolean isFinal() { + return (access_flags & Const.ACC_FINAL) != 0; + } + + public final void isSynchronized(final boolean flag) { + setFlag(Const.ACC_SYNCHRONIZED, flag); + } + + public final boolean isSynchronized() { + return (access_flags & Const.ACC_SYNCHRONIZED) != 0; + } + + public final void isVolatile(final boolean flag) { + setFlag(Const.ACC_VOLATILE, flag); + } + + public final boolean isVolatile() { + return (access_flags & Const.ACC_VOLATILE) != 0; + } + + public final void isTransient(final boolean flag) { + setFlag(Const.ACC_TRANSIENT, flag); + } + + public final boolean isTransient() { + return (access_flags & Const.ACC_TRANSIENT) != 0; + } + + public final void isNative(final boolean flag) { + setFlag(Const.ACC_NATIVE, flag); + } + + public final boolean isNative() { + return (access_flags & Const.ACC_NATIVE) != 0; + } + + public final void isInterface(final boolean flag) { + setFlag(Const.ACC_INTERFACE, flag); + } + + public final boolean isInterface() { + return (access_flags & Const.ACC_INTERFACE) != 0; + } + + public final void isAbstract(final boolean flag) { + setFlag(Const.ACC_ABSTRACT, flag); + } + + public final boolean isAbstract() { + return (access_flags & Const.ACC_ABSTRACT) != 0; + } + + public final void isStrictfp(final boolean flag) { + setFlag(Const.ACC_STRICT, flag); + } + + public final boolean isStrictfp() { + return (access_flags & Const.ACC_STRICT) != 0; + } + + public final void isSynthetic(final boolean flag) { + setFlag(Const.ACC_SYNTHETIC, flag); + } + + public final boolean isSynthetic() { + return (access_flags & Const.ACC_SYNTHETIC) != 0; + } + + public final void isAnnotation(final boolean flag) { + setFlag(Const.ACC_ANNOTATION, flag); + } + + public final boolean isAnnotation() { + return (access_flags & Const.ACC_ANNOTATION) != 0; + } + + public final void isEnum(final boolean flag) { + setFlag(Const.ACC_ENUM, flag); + } + + public final boolean isEnum() { + return (access_flags & Const.ACC_ENUM) != 0; + } + + public final void isVarArgs(final boolean flag) { + setFlag(Const.ACC_VARARGS, flag); + } + + public final boolean isVarArgs() { + return (access_flags & Const.ACC_VARARGS) != 0; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AnnotationDefault.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AnnotationDefault.java new file mode 100644 index 00000000..1ac4f921 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AnnotationDefault.java @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * Represents the default value of a annotation for a method info + * + * @version $Id: AnnotationDefault 1 2005-02-13 03:15:08Z dbrosius $ + * @since 6.0 + */ +public class AnnotationDefault extends Attribute { + + private ElementValue default_value; + + /** + * @param name_index Index pointing to the name Code + * @param length Content length in bytes + * @param input Input stream + * @param constant_pool Array of constants + */ + AnnotationDefault(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) throws IOException { + this(name_index, length, (ElementValue) null, constant_pool); + default_value = ElementValue.readElementValue(input, constant_pool); + } + + /** + * @param name_index Index pointing to the name Code + * @param length Content length in bytes + * @param defaultValue the annotation's default value + * @param constant_pool Array of constants + */ + public AnnotationDefault(final int name_index, final int length, final ElementValue defaultValue, final ConstantPool constant_pool) { + super(Const.ATTR_ANNOTATION_DEFAULT, name_index, length, constant_pool); + this.default_value = defaultValue; + } + + /** + * Called by objects that are traversing the nodes of the tree implicitely + * defined by the contents of a Java class. I.e., the hierarchy of methods, + * fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitAnnotationDefault(this); + } + + /** + * @param defaultValue the default value of this methodinfo's annotation + */ + public final void setDefaultValue(final ElementValue defaultValue) { + default_value = defaultValue; + } + + /** + * @return the default value + */ + public final ElementValue getDefaultValue() { + return default_value; + } + + @Override + public Attribute copy(final ConstantPool _constant_pool) { + return (Attribute) clone(); + } + + @Override + public final void dump(final DataOutputStream dos) throws IOException { + super.dump(dos); + default_value.dump(dos); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AnnotationElementValue.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AnnotationElementValue.java new file mode 100644 index 00000000..2ad29998 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AnnotationElementValue.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * @since 6.0 + */ +public class AnnotationElementValue extends ElementValue +{ + // For annotation element values, this is the annotation + private final AnnotationEntry annotationEntry; + + public AnnotationElementValue(final int type, final AnnotationEntry annotationEntry, + final ConstantPool cpool) + { + super(type, cpool); + if (type != ANNOTATION) { + throw new RuntimeException( + "Only element values of type annotation can be built with this ctor - type specified: " + type); + } + this.annotationEntry = annotationEntry; + } + + @Override + public void dump(final DataOutputStream dos) throws IOException + { + dos.writeByte(super.getType()); // u1 type of value (ANNOTATION == '@') + annotationEntry.dump(dos); + } + + @Override + public String stringifyValue() + { + return annotationEntry.toString(); + } + + @Override + public String toString() + { + return stringifyValue(); + } + + public AnnotationEntry getAnnotationEntry() + { + return annotationEntry; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AnnotationEntry.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AnnotationEntry.java new file mode 100644 index 00000000..5d6d5578 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AnnotationEntry.java @@ -0,0 +1,168 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.apache.bcel.Const; + +/** + * represents one annotation in the annotation table + * + * @version $Id: AnnotationEntry + * @since 6.0 + */ +public class AnnotationEntry implements Node { + + private final int type_index; + private final ConstantPool constant_pool; + private final boolean isRuntimeVisible; + + private List element_value_pairs; + + /* + * Factory method to create an AnnotionEntry from a DataInput + * + * @param input + * @param constant_pool + * @param isRuntimeVisible + * @return the entry + * @throws IOException + */ + public static AnnotationEntry read(final DataInput input, final ConstantPool constant_pool, final boolean isRuntimeVisible) throws IOException { + + final AnnotationEntry annotationEntry = new AnnotationEntry(input.readUnsignedShort(), constant_pool, isRuntimeVisible); + final int num_element_value_pairs = input.readUnsignedShort(); + annotationEntry.element_value_pairs = new ArrayList<>(); + for (int i = 0; i < num_element_value_pairs; i++) { + annotationEntry.element_value_pairs.add( + new ElementValuePair(input.readUnsignedShort(), ElementValue.readElementValue(input, constant_pool), + constant_pool)); + } + return annotationEntry; + } + + public AnnotationEntry(final int type_index, final ConstantPool constant_pool, final boolean isRuntimeVisible) { + this.type_index = type_index; + this.constant_pool = constant_pool; + this.isRuntimeVisible = isRuntimeVisible; + } + + public int getTypeIndex() { + return type_index; + } + + public ConstantPool getConstantPool() { + return constant_pool; + } + + public boolean isRuntimeVisible() { + return isRuntimeVisible; + } + + /** + * 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 + */ + @Override + public void accept(final Visitor v) { + v.visitAnnotationEntry(this); + } + + /** + * @return the annotation type name + */ + public String getAnnotationType() { + final ConstantUtf8 c = (ConstantUtf8) constant_pool.getConstant(type_index, Const.CONSTANT_Utf8); + return c.getBytes(); + } + + /** + * @return the annotation type index + */ + public int getAnnotationTypeIndex() { + return type_index; + } + + /** + * @return the number of element value pairs in this annotation entry + */ + public final int getNumElementValuePairs() { + return element_value_pairs.size(); + } + + /** + * @return the element value pairs in this annotation entry + */ + public ElementValuePair[] getElementValuePairs() { + // TODO return List + return element_value_pairs.toArray(new ElementValuePair[element_value_pairs.size()]); + } + + public void dump(final DataOutputStream dos) throws IOException { + dos.writeShort(type_index); // u2 index of type name in cpool + dos.writeShort(element_value_pairs.size()); // u2 element_value pair + // count + for (final ElementValuePair envp : element_value_pairs) { + envp.dump(dos); + } + } + + public void addElementNameValuePair(final ElementValuePair elementNameValuePair) { + element_value_pairs.add(elementNameValuePair); + } + + public String toShortString() { + final StringBuilder result = new StringBuilder(); + result.append("@"); + result.append(getAnnotationType()); + final ElementValuePair[] evPairs = getElementValuePairs(); + if (evPairs.length > 0) { + result.append("("); + for (final ElementValuePair element : evPairs) { + result.append(element.toShortString()); + } + result.append(")"); + } + return result.toString(); + } + + @Override + public String toString() { + return toShortString(); + } + + public static AnnotationEntry[] createAnnotationEntries(final Attribute[] attrs) { + // Find attributes that contain annotation data + final List accumulatedAnnotations = new ArrayList<>(attrs.length); + for (final Attribute attribute : attrs) { + if (attribute instanceof Annotations) { + final Annotations runtimeAnnotations = (Annotations) attribute; + Collections.addAll(accumulatedAnnotations, runtimeAnnotations.getAnnotationEntries()); + } + } + return accumulatedAnnotations.toArray(new AnnotationEntry[accumulatedAnnotations.size()]); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Annotations.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Annotations.java new file mode 100644 index 00000000..878db32b --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Annotations.java @@ -0,0 +1,114 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * base class for annotations + * + * @version $Id: Annotations + * @since 6.0 + */ +public abstract class Annotations extends Attribute { + + private AnnotationEntry[] annotation_table; + private final boolean isRuntimeVisible; + + /** + * @param annotation_type the subclass type of the annotation + * @param name_index Index pointing to the name Code + * @param length Content length in bytes + * @param input Input stream + * @param constant_pool Array of constants + */ + Annotations(final byte annotation_type, final int name_index, final int length, final DataInput input, + final ConstantPool constant_pool, final boolean isRuntimeVisible) throws IOException { + this(annotation_type, name_index, length, (AnnotationEntry[]) null, constant_pool, isRuntimeVisible); + final int annotation_table_length = input.readUnsignedShort(); + annotation_table = new AnnotationEntry[annotation_table_length]; + for (int i = 0; i < annotation_table_length; i++) { + annotation_table[i] = AnnotationEntry.read(input, constant_pool, isRuntimeVisible); + } + } + + /** + * @param annotation_type the subclass type of the annotation + * @param name_index Index pointing to the name Code + * @param length Content length in bytes + * @param annotation_table the actual annotations + * @param constant_pool Array of constants + */ + public Annotations(final byte annotation_type, final int name_index, final int length, final AnnotationEntry[] annotation_table, + final ConstantPool constant_pool, final boolean isRuntimeVisible) { + super(annotation_type, name_index, length, constant_pool); + this.annotation_table = annotation_table; + this.isRuntimeVisible = isRuntimeVisible; + } + + /** + * 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 + */ + @Override + public void accept(final Visitor v) { + v.visitAnnotation(this); + } + + /** + * @param annotation_table the entries to set in this annotation + */ + public final void setAnnotationTable(final AnnotationEntry[] annotation_table) { + this.annotation_table = annotation_table; + } + + /** + * returns the array of annotation entries in this annotation + */ + public AnnotationEntry[] getAnnotationEntries() { + return annotation_table; + } + + /** + * @return the number of annotation entries in this annotation + */ + public final int getNumAnnotations() { + if (annotation_table == null) { + return 0; + } + return annotation_table.length; + } + + public boolean isRuntimeVisible() { + return isRuntimeVisible; + } + + protected void writeAnnotations(final DataOutputStream dos) throws IOException { + if (annotation_table == null) { + return; + } + dos.writeShort(annotation_table.length); + for (final AnnotationEntry element : annotation_table) { + element.dump(dos); + } + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ArrayElementValue.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ArrayElementValue.java new file mode 100644 index 00000000..07d57ea7 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ArrayElementValue.java @@ -0,0 +1,92 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * @since 6.0 + */ +public class ArrayElementValue extends ElementValue +{ + // For array types, this is the array + private final ElementValue[] evalues; + + @Override + public String toString() + { + final StringBuilder sb = new StringBuilder(); + sb.append("{"); + for (int i = 0; i < evalues.length; i++) + { + sb.append(evalues[i]); + if ((i + 1) < evalues.length) { + sb.append(","); + } + } + sb.append("}"); + return sb.toString(); + } + + public ArrayElementValue(final int type, final ElementValue[] datums, final ConstantPool cpool) + { + super(type, cpool); + if (type != ARRAY) { + throw new RuntimeException( + "Only element values of type array can be built with this ctor - type specified: " + type); + } + this.evalues = datums; + } + + @Override + public void dump(final DataOutputStream dos) throws IOException + { + dos.writeByte(super.getType()); // u1 type of value (ARRAY == '[') + dos.writeShort(evalues.length); + for (final ElementValue evalue : evalues) { + evalue.dump(dos); + } + } + + @Override + public String stringifyValue() + { + final StringBuilder sb = new StringBuilder(); + sb.append("["); + for (int i = 0; i < evalues.length; i++) + { + sb.append(evalues[i].stringifyValue()); + if ((i + 1) < evalues.length) { + sb.append(","); + } + } + sb.append("]"); + return sb.toString(); + } + + public ElementValue[] getElementValuesArray() + { + return evalues; + } + + public int getElementValuesArraySize() + { + return evalues.length; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Attribute.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Attribute.java new file mode 100644 index 00000000..0afe641d --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Attribute.java @@ -0,0 +1,372 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import org.apache.bcel.Const; + +/** + * Abstract super class for Attribute objects. Currently the + * ConstantValue, SourceFile, Code, + * Exceptiontable, LineNumberTable, + * LocalVariableTable, InnerClasses and + * Synthetic attributes are supported. The Unknown + * attribute stands for non-standard-attributes. + * + * @version $Id: Attribute.java 1806724 2017-08-30 19:22:35Z britter $ + * @see ConstantValue + * @see SourceFile + * @see Code + * @see Unknown + * @see ExceptionTable + * @see LineNumberTable + * @see LocalVariableTable + * @see InnerClasses + * @see Synthetic + * @see Deprecated + * @see Signature + */ +public abstract class Attribute implements Cloneable, Node { + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @java.lang.Deprecated + protected int name_index; // Points to attribute name in constant pool TODO make private (has getter & setter) + + /** + * @deprecated (since 6.0) (since 6.0) will be made private; do not access directly, use getter/setter + */ + @java.lang.Deprecated + protected int length; // Content length of attribute field TODO make private (has getter & setter) + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @java.lang.Deprecated + protected byte tag; // Tag to distinguish subclasses TODO make private & final; supposed to be immutable + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @java.lang.Deprecated + protected ConstantPool constant_pool; // TODO make private (has getter & setter) + + protected Attribute(final byte tag, final int name_index, final int length, final 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 + */ + @Override + public abstract void accept(Visitor v); + + /** + * Dump attribute to file stream in binary format. + * + * @param file + * Output file stream + * @throws IOException + */ + public void dump(final DataOutputStream file) throws IOException + { + file.writeShort(name_index); + file.writeInt(length); + } + + private static final Map readers = new HashMap<>(); + + /** + * Add an Attribute reader capable of parsing (user-defined) attributes + * named "name". You should not add readers for the standard attributes such + * as "LineNumberTable", because those are handled internally. + * + * @param name the name of the attribute as stored in the class file + * @param r the reader object + * @deprecated (6.0) Use {@link #addAttributeReader(String, UnknownAttributeReader)} instead + */ + @java.lang.Deprecated + public static void addAttributeReader(final String name, final AttributeReader r) + { + readers.put(name, r); + } + + /** + * Add an Attribute reader capable of parsing (user-defined) attributes + * named "name". You should not add readers for the standard attributes such + * as "LineNumberTable", because those are handled internally. + * + * @param name the name of the attribute as stored in the class file + * @param r the reader object + */ + public static void addAttributeReader(final String name, final UnknownAttributeReader r) + { + readers.put(name, r); + } + + /** + * Remove attribute reader + * + * @param name the name of the attribute as stored in the class file + */ + public static void removeAttributeReader(final String name) + { + readers.remove(name); + } + + /** + * 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 + * @throws IOException + * @throws ClassFormatException + */ + public static Attribute readAttribute(final DataInputStream file, final ConstantPool constant_pool) + throws IOException, ClassFormatException + { + return readAttribute((DataInput) file, constant_pool); + } + + /** + * 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 + * @throws IOException + * @throws ClassFormatException + * @since 6.0 + */ + public static Attribute readAttribute(final DataInput file, final ConstantPool constant_pool) + throws IOException, ClassFormatException + { + byte tag = Const.ATTR_UNKNOWN; // Unknown attribute + // Get class name from constant pool via `name_index' indirection + final int name_index = file.readUnsignedShort(); + final ConstantUtf8 c = (ConstantUtf8) constant_pool.getConstant(name_index, Const.CONSTANT_Utf8); + final String name = c.getBytes(); + + // Length of data in bytes + final int length = file.readInt(); + + // Compare strings to find known attribute + for (byte i = 0; i < Const.KNOWN_ATTRIBUTES; i++) + { + if (name.equals(Const.getAttributeName(i))) + { + tag = i; // found! + break; + } + } + + // Call proper constructor, depending on `tag' + switch (tag) + { + case Const.ATTR_UNKNOWN: + final Object r = readers.get(name); + if (r instanceof UnknownAttributeReader) + { + return ((UnknownAttributeReader) r).createAttribute(name_index, length, file, constant_pool); + } + return new Unknown(name_index, length, file, constant_pool); + case Const.ATTR_CONSTANT_VALUE: + return new ConstantValue(name_index, length, file, constant_pool); + case Const.ATTR_SOURCE_FILE: + return new SourceFile(name_index, length, file, constant_pool); + case Const.ATTR_CODE: + return new Code(name_index, length, file, constant_pool); + case Const.ATTR_EXCEPTIONS: + return new ExceptionTable(name_index, length, file, constant_pool); + case Const.ATTR_LINE_NUMBER_TABLE: + return new LineNumberTable(name_index, length, file, constant_pool); + case Const.ATTR_LOCAL_VARIABLE_TABLE: + return new LocalVariableTable(name_index, length, file, constant_pool); + case Const.ATTR_INNER_CLASSES: + return new InnerClasses(name_index, length, file, constant_pool); + case Const.ATTR_SYNTHETIC: + return new Synthetic(name_index, length, file, constant_pool); + case Const.ATTR_DEPRECATED: + return new Deprecated(name_index, length, file, constant_pool); + case Const.ATTR_PMG: + return new PMGClass(name_index, length, file, constant_pool); + case Const.ATTR_SIGNATURE: + return new Signature(name_index, length, file, constant_pool); + case Const.ATTR_STACK_MAP: + // old style stack map: unneeded for JDK5 and below; + // illegal(?) for JDK6 and above. So just delete with a warning. + System.err.println("Warning: Obsolete StackMap attribute ignored."); + return new Unknown(name_index, length, file, constant_pool); + case Const.ATTR_RUNTIME_VISIBLE_ANNOTATIONS: + return new RuntimeVisibleAnnotations(name_index, length, file, constant_pool); + case Const.ATTR_RUNTIME_INVISIBLE_ANNOTATIONS: + return new RuntimeInvisibleAnnotations(name_index, length, file, constant_pool); + case Const.ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS: + return new RuntimeVisibleParameterAnnotations(name_index, length, file, constant_pool); + case Const.ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS: + return new RuntimeInvisibleParameterAnnotations(name_index, length, file, constant_pool); + case Const.ATTR_ANNOTATION_DEFAULT: + return new AnnotationDefault(name_index, length, file, constant_pool); + case Const.ATTR_LOCAL_VARIABLE_TYPE_TABLE: + return new LocalVariableTypeTable(name_index, length, file, constant_pool); + case Const.ATTR_ENCLOSING_METHOD: + return new EnclosingMethod(name_index, length, file, constant_pool); + case Const.ATTR_STACK_MAP_TABLE: + // read new style stack map: StackMapTable. The rest of the code + // calls this a StackMap for historical reasons. + return new StackMap(name_index, length, file, constant_pool); + case Const.ATTR_BOOTSTRAP_METHODS: + return new BootstrapMethods(name_index, length, file, constant_pool); + case Const.ATTR_METHOD_PARAMETERS: + return new MethodParameters(name_index, length, file, constant_pool); + default: + // Never reached + throw new IllegalStateException("Unrecognized attribute type tag parsed: " + tag); + } + } + + /** + * @return Name of attribute + * @since 6.0 + */ + public String getName() + { + final ConstantUtf8 c = (ConstantUtf8) constant_pool.getConstant(name_index, Const.CONSTANT_Utf8); + return c.getBytes(); + } + + /** + * @return Length of attribute field in bytes. + */ + public final int getLength() + { + return length; + } + + /** + * @param length length in bytes. + */ + public final void setLength(final int length) + { + this.length = length; + } + + /** + * @param name_index of attribute. + */ + public final void setNameIndex(final 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(final 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 + */ + @Override + public Object clone() + { + Attribute attr = null; + try + { + attr = (Attribute) super.clone(); + } + catch (final CloneNotSupportedException e) + { + throw new Error("Clone Not Supported"); // never happens + } + return attr; + } + + /** + * @return deep copy of this attribute + */ + public abstract Attribute copy(ConstantPool _constant_pool); + + /** + * @return attribute name. + */ + @Override + public String toString() + { + return Const.getAttributeName(tag); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/AttributeReader.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AttributeReader.java old mode 100755 new mode 100644 similarity index 69% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/AttributeReader.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AttributeReader.java index 2e10b295..7b897d62 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/AttributeReader.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AttributeReader.java @@ -1,58 +1,60 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -/** - * Unknown (non-standard) attributes may be read via user-defined factory - * objects that can be registered with the Attribute.addAttributeReader - * method. These factory objects should implement this interface. - - * @see Attribute - * @version $Id: AttributeReader.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public interface AttributeReader { - - /** - When this attribute reader is added via the static method - Attribute.addAttributeReader, an attribute name is associated with it. - As the class file parser parses attributes, it will call various - AttributeReaders based on the name of the attributes it is - constructing. - - @param name_index An index into the constant pool, indexing a - ConstantUtf8 that represents the name of the attribute. - - @param length The length of the data contained in the attribute. This - is written into the constant pool and should agree with what the - factory expects the length to be. - - @param file This is the data input stream that the factory needs to read - its data from. - - @param constant_pool This is the constant pool associated with the - Attribute that we are constructing. - - @return The user-defined AttributeReader should take this data and use - it to construct an attribute. In the case of errors, a null can be - returned which will cause the parsing of the class file to fail. - - @see Attribute#addAttributeReader( String, AttributeReader ) - */ - public Attribute createAttribute( int name_index, int length, java.io.DataInputStream file, - ConstantPool constant_pool ); -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +/** + * Unknown (non-standard) attributes may be read via user-defined factory + * objects that can be registered with the Attribute.addAttributeReader + * method. These factory objects should implement this interface. + + * @see Attribute + * @version $Id: AttributeReader.java 1806200 2017-08-25 16:33:06Z ggregory $ + * + * @deprecated Use UnknownAttributeReader instead + */ +@java.lang.Deprecated +public interface AttributeReader { + + /** + When this attribute reader is added via the static method + Attribute.addAttributeReader, an attribute name is associated with it. + As the class file parser parses attributes, it will call various + AttributeReaders based on the name of the attributes it is + constructing. + + @param name_index An index into the constant pool, indexing a + ConstantUtf8 that represents the name of the attribute. + + @param length The length of the data contained in the attribute. This + is written into the constant pool and should agree with what the + factory expects the length to be. + + @param file This is the data input stream that the factory needs to read + its data from. + + @param constant_pool This is the constant pool associated with the + Attribute that we are constructing. + + @return The user-defined AttributeReader should take this data and use + it to construct an attribute. In the case of errors, a null can be + returned which will cause the parsing of the class file to fail. + + @see Attribute#addAttributeReader( String, AttributeReader ) + */ + Attribute createAttribute( int name_index, int length, java.io.DataInputStream file, ConstantPool constant_pool ); +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/BootstrapMethod.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/BootstrapMethod.java new file mode 100644 index 00000000..988e15c9 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/BootstrapMethod.java @@ -0,0 +1,169 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; + +import org.apache.bcel.Const; + +/** + * This class represents a bootstrap method attribute, i.e., the bootstrap + * method ref, the number of bootstrap arguments and an array of the + * bootstrap arguments. + * + * @see + * The class File Format : The BootstrapMethods Attribute + * @since 6.0 + */ +public class BootstrapMethod implements Cloneable { + + /** Index of the CONSTANT_MethodHandle_info structure in the constant_pool table */ + private int bootstrap_method_ref; + + /** Array of references to the constant_pool table */ + private int[] bootstrap_arguments; + + + /** + * Initialize from another object. + */ + public BootstrapMethod(final BootstrapMethod c) { + this(c.getBootstrapMethodRef(), c.getBootstrapArguments()); + } + + /** + * Construct object from input stream. + * + * @param input Input stream + * @throws IOException + */ + BootstrapMethod(final DataInput input) throws IOException { + this(input.readUnsignedShort(), input.readUnsignedShort()); + + for (int i = 0; i < bootstrap_arguments.length; i++) { + bootstrap_arguments[i] = input.readUnsignedShort(); + } + } + + // helper method + private BootstrapMethod(final int bootstrap_method_ref, final int num_bootstrap_arguments) { + this(bootstrap_method_ref, new int[num_bootstrap_arguments]); + } + + /** + * @param bootstrap_method_ref int index into constant_pool of CONSTANT_MethodHandle + * @param bootstrap_arguments int[] indices into constant_pool of CONSTANT__info + */ + public BootstrapMethod(final int bootstrap_method_ref, final int[] bootstrap_arguments) { + this.bootstrap_method_ref = bootstrap_method_ref; + this.bootstrap_arguments = bootstrap_arguments; + } + + /** + * @return index into constant_pool of bootstrap_method + */ + public int getBootstrapMethodRef() { + return bootstrap_method_ref; + } + + /** + * @param bootstrap_method_ref int index into constant_pool of CONSTANT_MethodHandle + */ + public void setBootstrapMethodRef(final int bootstrap_method_ref) { + this.bootstrap_method_ref = bootstrap_method_ref; + } + + /** + * @return int[] of bootstrap_method indices into constant_pool of CONSTANT__info + */ + public int[] getBootstrapArguments() { + return bootstrap_arguments; + } + + /** + * @return count of number of boostrap arguments + */ + public int getNumBootstrapArguments() { + return bootstrap_arguments.length; + } + + /** + * @param bootstrap_arguments int[] indices into constant_pool of CONSTANT__info + */ + public void setBootstrapArguments(final int[] bootstrap_arguments) { + this.bootstrap_arguments = bootstrap_arguments; + } + + /** + * @return String representation. + */ + @Override + public final String toString() { + return "BootstrapMethod(" + bootstrap_method_ref + ", " + bootstrap_arguments.length + ", " + + Arrays.toString(bootstrap_arguments) + ")"; + } + + /** + * @return Resolved string representation + */ + public final String toString( final ConstantPool constant_pool ) { + final StringBuilder buf = new StringBuilder(); + String bootstrap_method_name; + bootstrap_method_name = constant_pool.constantToString(bootstrap_method_ref, + Const.CONSTANT_MethodHandle); + buf.append(Utility.compactClassName(bootstrap_method_name)); + final int num_bootstrap_arguments = bootstrap_arguments.length; + if (num_bootstrap_arguments > 0) { + buf.append("\n Method Arguments:"); + for (int i = 0; i < num_bootstrap_arguments; i++) { + buf.append("\n ").append(i).append(": "); + buf.append(constant_pool.constantToString(constant_pool.getConstant(bootstrap_arguments[i]))); + } + } + return buf.toString(); + } + + /** + * Dump object to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + public final void dump(final DataOutputStream file) throws IOException { + file.writeShort(bootstrap_method_ref); + file.writeShort(bootstrap_arguments.length); + for (final int bootstrap_argument : bootstrap_arguments) { + file.writeShort(bootstrap_argument); + } + } + + /** + * @return deep copy of this object + */ + public BootstrapMethod copy() { + try { + return (BootstrapMethod) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/BootstrapMethods.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/BootstrapMethods.java new file mode 100644 index 00000000..994cb759 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/BootstrapMethods.java @@ -0,0 +1,144 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class represents a BootstrapMethods attribute. + * + * @see + * The class File Format : The BootstrapMethods Attribute + * @since 6.0 + */ +public class BootstrapMethods extends Attribute { + + private BootstrapMethod[] bootstrap_methods; // TODO this could be made final (setter is not used) + + /** + * Initialize from another object. Note that both objects use the same + * references (shallow copy). Use clone() for a physical copy. + */ + public BootstrapMethods(final BootstrapMethods c) { + this(c.getNameIndex(), c.getLength(), c.getBootstrapMethods(), c.getConstantPool()); + } + + + /** + * @param name_index Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param bootstrap_methods array of bootstrap methods + * @param constant_pool Array of constants + */ + public BootstrapMethods(final int name_index, final int length, final BootstrapMethod[] bootstrap_methods, final ConstantPool constant_pool) { + super(Const.ATTR_BOOTSTRAP_METHODS, name_index, length, constant_pool); + this.bootstrap_methods = bootstrap_methods; + } + + /** + * Construct object from Input stream. + * + * @param name_index Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param input Input stream + * @param constant_pool Array of constants + * @throws IOException + */ + BootstrapMethods(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) throws IOException { + this(name_index, length, (BootstrapMethod[]) null, constant_pool); + + final int num_bootstrap_methods = input.readUnsignedShort(); + bootstrap_methods = new BootstrapMethod[num_bootstrap_methods]; + for (int i = 0; i < num_bootstrap_methods; i++) { + bootstrap_methods[i] = new BootstrapMethod(input); + } + } + + /** + * @return array of bootstrap method "records" + */ + public final BootstrapMethod[] getBootstrapMethods() { + return bootstrap_methods; + } + + /** + * @param bootstrap_methods the array of bootstrap methods + */ + public final void setBootstrapMethods(final BootstrapMethod[] bootstrap_methods) { + this.bootstrap_methods = bootstrap_methods; + } + + /** + * @param v Visitor object + */ + @Override + public void accept(final Visitor v) { + v.visitBootstrapMethods(this); + } + + /** + * @return deep copy of this attribute + */ + @Override + public BootstrapMethods copy(final ConstantPool _constant_pool) { + final BootstrapMethods c = (BootstrapMethods) clone(); + c.bootstrap_methods = new BootstrapMethod[bootstrap_methods.length]; + + for (int i = 0; i < bootstrap_methods.length; i++) { + c.bootstrap_methods[i] = bootstrap_methods[i].copy(); + } + c.setConstantPool(_constant_pool); + return c; + } + + /** + * Dump bootstrap methods attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + @Override + public final void dump(final DataOutputStream file) throws IOException { + super.dump(file); + + file.writeShort(bootstrap_methods.length); + for (final BootstrapMethod bootstrap_method : bootstrap_methods) { + bootstrap_method.dump(file); + } + } + + /** + * @return String representation. + */ + @Override + public final String toString() { + final StringBuilder buf = new StringBuilder(); + buf.append("BootstrapMethods("); + buf.append(bootstrap_methods.length); + buf.append("):\n"); + for (int i = 0; i < bootstrap_methods.length; i++) { + buf.append(" ").append(i).append(": "); + buf.append(bootstrap_methods[i].toString(super.getConstantPool())).append("\n"); + } + return buf.toString(); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ClassElementValue.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ClassElementValue.java new file mode 100644 index 00000000..16820161 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ClassElementValue.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * @since 6.0 + */ +public class ClassElementValue extends ElementValue +{ + // For primitive types and string type, this points to the value entry in + // the cpool + // For 'class' this points to the class entry in the cpool + private final int idx; + + public ClassElementValue(final int type, final int idx, final ConstantPool cpool) + { + super(type, cpool); + this.idx = idx; + } + + public int getIndex() + { + return idx; + } + + public String getClassString() + { + final ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(idx, + Const.CONSTANT_Utf8); + return c.getBytes(); + } + + @Override + public String stringifyValue() + { + final ConstantUtf8 cu8 = (ConstantUtf8) super.getConstantPool().getConstant(idx, + Const.CONSTANT_Utf8); + return cu8.getBytes(); + } + + @Override + public void dump(final DataOutputStream dos) throws IOException + { + dos.writeByte(super.getType()); // u1 kind of value + dos.writeShort(idx); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ClassFormatException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ClassFormatException.java new file mode 100644 index 00000000..ec52dc27 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ClassFormatException.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +/** + * Thrown when the BCEL attempts to read a class file and determines + * that the file is malformed or otherwise cannot be interpreted as a + * class file. + * + * @version $Id: ClassFormatException.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class ClassFormatException extends RuntimeException { + + private static final long serialVersionUID = -3569097343160139969L; + + public ClassFormatException() { + super(); + } + + + public ClassFormatException(final String s) { + super(s); + } + + /** + * @since 6.0 + */ + public ClassFormatException(final String message, final Throwable cause) { + super(message, cause); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ClassParser.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ClassParser.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ClassParser.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ClassParser.java index 8b315608..37d3a34e --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ClassParser.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ClassParser.java @@ -1,302 +1,308 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.BufferedInputStream; -import java.io.DataInputStream; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import org.apache.bcel5_2_0.Constants; - -/** - * Wrapper class that parses a given Java .class file. The method parse returns a - * JavaClass 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 - * JVM specification 1.0. See this paper for - * further details about the structure of a bytecode file. - * - * @version $Id: ClassParser.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public final class ClassParser { - - private DataInputStream file; - private boolean fileOwned; - private String file_name; - private String zip_file; - 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; - fileOwned = false; - 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) { - this.file = (DataInputStream) file; - } else { - this.file = new DataInputStream(new BufferedInputStream(file, BUFSIZE)); - } - } - - - /** Parse class from given .class file. - * - * @param file_name file name - */ - public ClassParser(String file_name) throws IOException { - is_zip = false; - this.file_name = file_name; - fileOwned = true; - } - - - /** Parse class from given .class file in a ZIP-archive - * - * @param zip_file zip file name - * @param file_name file name - */ - public ClassParser(String zip_file, String file_name) { - is_zip = true; - fileOwned = true; - this.zip_file = zip_file; - this.file_name = file_name; - } - - - /** - * Parse the given Java class file and return an object that represents - * the contained data, i.e., constants, methods, fields and commands. - * A ClassFormatException 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 - * @throws IOException - * @throws ClassFormatException - */ - public JavaClass parse() throws IOException, ClassFormatException { - ZipFile zip = null; - try { - if (fileOwned) { - if (is_zip) { - zip = new ZipFile(zip_file); - ZipEntry entry = zip.getEntry(file_name); - file = new DataInputStream(new BufferedInputStream(zip.getInputStream(entry), - BUFSIZE)); - } else { - file = new DataInputStream(new BufferedInputStream(new FileInputStream( - file_name), BUFSIZE)); - } - } - /****************** 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)); - // } - // } - } catch (IOException ioe) { - // this is just temporary to find the cause for the strange - // ClassFormatException that is raised randomly during the JaMoPP - // bulk tests - ioe.printStackTrace(); - throw ioe; - } finally { - // Read everything of interest, so close the file - if (fileOwned) { - 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 class. - * @throws IOException - * @throws ClassFormatException - */ - private final void readAttributes() throws IOException, ClassFormatException { - 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. - * @throws IOException - * @throws ClassFormatException - */ - private final void readClassInfo() throws IOException, ClassFormatException { - 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 ClassFormatException("Class can't be both final and abstract"); - } - class_name_index = file.readUnsignedShort(); - superclass_name_index = file.readUnsignedShort(); - } - - - /** - * Read constant pool entries. - * @throws IOException - * @throws ClassFormatException - */ - private final void readConstantPool() throws IOException, ClassFormatException { - constant_pool = new ConstantPool(file); - } - - - /** - * Read information about the fields of the class, i.e., its variables. - * @throws IOException - * @throws ClassFormatException - */ - private final void readFields() throws IOException, ClassFormatException { - 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. - * @throws IOException - * @throws ClassFormatException - */ - private final void readID() throws IOException, ClassFormatException { - int magic = 0xCAFEBABE; - if (file.readInt() != magic) { - throw new ClassFormatException(file_name + " is not a Java .class file"); - } - } - - - /** - * Read information about the interfaces implemented by this class. - * @throws IOException - * @throws ClassFormatException - */ - private final void readInterfaces() throws IOException, ClassFormatException { - 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. - * @throws IOException - * @throws ClassFormatException - */ - private final void readMethods() throws IOException, ClassFormatException { - 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. - * @throws IOException - * @throws ClassFormatException - */ - private final void readVersion() throws IOException, ClassFormatException { - minor = file.readUnsignedShort(); - major = file.readUnsignedShort(); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.BufferedInputStream; +import java.io.DataInputStream; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import org.apache.bcel.Const; + +/** + * Wrapper class that parses a given Java .class file. The method parse returns a + * JavaClass 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 + * JVM specification 1.0. See this paper for + * further details about the structure of a bytecode file. + * + * @version $Id: ClassParser.java 1749603 2016-06-21 20:50:19Z ggregory $ + */ +public final class ClassParser { + + private DataInputStream dataInputStream; + private final boolean fileOwned; + private final String file_name; + private String zip_file; + private int class_name_index; + private int superclass_name_index; + private int major; // Compiler version + private int 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 final boolean is_zip; // Loaded from zip file + private static final int BUFSIZE = 8192; + + + /** + * Parse class from the given stream. + * + * @param inputStream Input stream + * @param file_name File name + */ + public ClassParser(final InputStream inputStream, final String file_name) { + this.file_name = file_name; + fileOwned = false; + final String clazz = inputStream.getClass().getName(); // Not a very clean solution ... + is_zip = clazz.startsWith("java.util.zip.") || clazz.startsWith("java.util.jar."); + if (inputStream instanceof DataInputStream) { + this.dataInputStream = (DataInputStream) inputStream; + } else { + this.dataInputStream = new DataInputStream(new BufferedInputStream(inputStream, BUFSIZE)); + } + } + + + /** Parse class from given .class file. + * + * @param file_name file name + */ + public ClassParser(final String file_name) { + is_zip = false; + this.file_name = file_name; + fileOwned = true; + } + + + /** Parse class from given .class file in a ZIP-archive + * + * @param zip_file zip file name + * @param file_name file name + */ + public ClassParser(final String zip_file, final String file_name) { + is_zip = true; + fileOwned = true; + this.zip_file = zip_file; + this.file_name = file_name; + } + + + /** + * Parse the given Java class file and return an object that represents + * the contained data, i.e., constants, methods, fields and commands. + * A ClassFormatException 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 + * @throws IOException + * @throws ClassFormatException + */ + public JavaClass parse() throws IOException, ClassFormatException { + ZipFile zip = null; + try { + if (fileOwned) { + if (is_zip) { + zip = new ZipFile(zip_file); + final ZipEntry entry = zip.getEntry(file_name); + + if (entry == null) { + throw new IOException("File " + file_name + " not found"); + } + + dataInputStream = new DataInputStream(new BufferedInputStream(zip.getInputStream(entry), + BUFSIZE)); + } else { + dataInputStream = new DataInputStream(new BufferedInputStream(new FileInputStream( + file_name), BUFSIZE)); + } + } + /****************** 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)); + // } + // } + } finally { + // Read everything of interest, so close the file + if (fileOwned) { + try { + if (dataInputStream != null) { + dataInputStream.close(); + } + } catch (final IOException ioe) { + //ignore close exceptions + } + } + try { + if (zip != null) { + zip.close(); + } + } catch (final IOException ioe) { + //ignore close exceptions + } + } + // 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 class. + * @throws IOException + * @throws ClassFormatException + */ + private void readAttributes() throws IOException, ClassFormatException { + final int attributes_count = dataInputStream.readUnsignedShort(); + attributes = new Attribute[attributes_count]; + for (int i = 0; i < attributes_count; i++) { + attributes[i] = Attribute.readAttribute(dataInputStream, constant_pool); + } + } + + + /** + * Read information about the class and its super class. + * @throws IOException + * @throws ClassFormatException + */ + private void readClassInfo() throws IOException, ClassFormatException { + access_flags = dataInputStream.readUnsignedShort(); + /* Interfaces are implicitely abstract, the flag should be set + * according to the JVM specification. + */ + if ((access_flags & Const.ACC_INTERFACE) != 0) { + access_flags |= Const.ACC_ABSTRACT; + } + if (((access_flags & Const.ACC_ABSTRACT) != 0) + && ((access_flags & Const.ACC_FINAL) != 0)) { + throw new ClassFormatException("Class " + file_name + " can't be both final and abstract"); + } + class_name_index = dataInputStream.readUnsignedShort(); + superclass_name_index = dataInputStream.readUnsignedShort(); + } + + + /** + * Read constant pool entries. + * @throws IOException + * @throws ClassFormatException + */ + private void readConstantPool() throws IOException, ClassFormatException { + constant_pool = new ConstantPool(dataInputStream); + } + + + /** + * Read information about the fields of the class, i.e., its variables. + * @throws IOException + * @throws ClassFormatException + */ + private void readFields() throws IOException, ClassFormatException { + final int fields_count = dataInputStream.readUnsignedShort(); + fields = new Field[fields_count]; + for (int i = 0; i < fields_count; i++) { + fields[i] = new Field(dataInputStream, 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. + * @throws IOException + * @throws ClassFormatException + */ + private void readID() throws IOException, ClassFormatException { + if (dataInputStream.readInt() != Const.JVM_CLASSFILE_MAGIC) { + throw new ClassFormatException(file_name + " is not a Java .class file"); + } + } + + + /** + * Read information about the interfaces implemented by this class. + * @throws IOException + * @throws ClassFormatException + */ + private void readInterfaces() throws IOException, ClassFormatException { + final int interfaces_count = dataInputStream.readUnsignedShort(); + interfaces = new int[interfaces_count]; + for (int i = 0; i < interfaces_count; i++) { + interfaces[i] = dataInputStream.readUnsignedShort(); + } + } + + + /** + * Read information about the methods of the class. + * @throws IOException + * @throws ClassFormatException + */ + private void readMethods() throws IOException, ClassFormatException { + final int methods_count = dataInputStream.readUnsignedShort(); + methods = new Method[methods_count]; + for (int i = 0; i < methods_count; i++) { + methods[i] = new Method(dataInputStream, constant_pool); + } + } + + + /** + * Read major and minor version of compiler which created the file. + * @throws IOException + * @throws ClassFormatException + */ + private void readVersion() throws IOException, ClassFormatException { + minor = dataInputStream.readUnsignedShort(); + major = dataInputStream.readUnsignedShort(); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Code.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Code.java old mode 100755 new mode 100644 similarity index 58% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Code.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Code.java index a746617a..95e3f34a --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Code.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Code.java @@ -1,352 +1,355 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class represents a chunk of Java byte code contained in a - * method. It is instantiated by the - * Attribute.readAttribute() method. A Code - * attribute contains informations about operand stack, local - * variables, byte code and the exceptions handled within this - * method. - * - * This attribute has attributes itself, namely LineNumberTable which - * is used for debugging purposes and LocalVariableTable which - * contains information about the local variables. - * - * @version $Id: Code.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 Code - * @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 Code - * @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 - * @throws 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 the attributes to set for this Code - */ - 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 ) { - StringBuilder buf = new StringBuilder(100); - buf.append("Code(max_stack = ").append(max_stack).append(", max_locals = ").append( - max_locals).append(", code_length = ").append(code_length).append(")\n").append( - Utility.codeToString(code, constant_pool, 0, -1, verbose)); - if (exception_table_length > 0) { - buf.append("\nException handler(s) = \n").append("From\tTo\tHandler\tType\n"); - for (int i = 0; i < exception_table_length; i++) { - buf.append(exception_table[i].toString(constant_pool, verbose)).append("\n"); - } - } - if (attributes_count > 0) { - buf.append("\nAttribute(s) = \n"); - for (int i = 0; i < attributes_count; i++) { - buf.append(attributes[i].toString()).append("\n"); - } - } - return buf.toString(); - } - - - /** - * @return String representation of code chunk. - */ - public final String toString() { - return toString(true); - } - - - /** - * @return deep copy of this attribute - * - * @param _constant_pool the constant pool to duplicate - */ - public Attribute copy( ConstantPool _constant_pool ) { - Code c = (Code) clone(); - if (code != null) { - c.code = new byte[code.length]; - System.arraycopy(code, 0, c.code, 0, code.length); - } - 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; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class represents a chunk of Java byte code contained in a + * method. It is instantiated by the + * Attribute.readAttribute() method. A Code + * attribute contains informations about operand stack, local + * variables, byte code and the exceptions handled within this + * method. + * + * This attribute has attributes itself, namely LineNumberTable which + * is used for debugging purposes and LocalVariableTable which + * contains information about the local variables. + * + * @version $Id: Code.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @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 // TODO this could be made final (setter is not used) + private int max_locals; // Number of local variables // TODO this could be made final (setter is not used) + private byte[] code; // Actual byte code + private CodeException[] exception_table; // Table of handled exceptions + 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(final 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 Code + * @param length Content length in bytes + * @param file Input stream + * @param constant_pool Array of constants + */ + Code(final int name_index, final int length, final DataInput file, final 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); + final int 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. + */ + final int 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' + */ + final int 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. + */ + super.setLength(length); + } + + + /** + * @param name_index Index pointing to the name Code + * @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(final int name_index, final int length, final int max_stack, final int max_locals, final byte[] code, + final CodeException[] exception_table, final Attribute[] attributes, final ConstantPool constant_pool) { + super(Const.ATTR_CODE, name_index, length, constant_pool); + this.max_stack = max_stack; + this.max_locals = max_locals; + this.code = code != null ? code : new byte[0]; + this.exception_table = exception_table != null ? exception_table : new CodeException[0]; + this.attributes = attributes != null ? attributes : new Attribute[0]; + super.setLength(calculateLength()); // Adjust 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitCode(this); + } + + + /** + * Dump code attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + @Override + public final void dump( final 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 (final CodeException exception : exception_table) { + exception.dump(file); + } + file.writeShort(attributes.length); + for (final Attribute attribute : attributes) { + attribute.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 (final Attribute attribute : attributes) { + if (attribute instanceof LineNumberTable) { + return (LineNumberTable) attribute; + } + } + return null; + } + + + /** + * @return LocalVariableTable of Code, if it has one + */ + public LocalVariableTable getLocalVariableTable() { + for (final Attribute attribute : attributes) { + if (attribute instanceof LocalVariableTable) { + return (LocalVariableTable) attribute; + } + } + 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 int getInternalLength() { + return 2 /*max_stack*/+ 2 /*max_locals*/+ 4 /*code length*/ + + code.length /*byte-code*/ + + 2 /*exception-table length*/ + + 8 * (exception_table == null ? 0 : 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 int calculateLength() { + int len = 0; + if (attributes != null) { + for (final Attribute attribute : attributes) { + len += attribute.getLength() + 6 /*attribute header size*/; + } + } + return len + getInternalLength(); + } + + + /** + * @param attributes the attributes to set for this Code + */ + public final void setAttributes( final Attribute[] attributes ) { + this.attributes = attributes != null ? attributes : new Attribute[0]; + super.setLength(calculateLength()); // Adjust length + } + + + /** + * @param code byte code + */ + public final void setCode( final byte[] code ) { + this.code = code != null ? code : new byte[0]; + super.setLength(calculateLength()); // Adjust length + } + + + /** + * @param exception_table exception table + */ + public final void setExceptionTable( final CodeException[] exception_table ) { + this.exception_table = exception_table != null ? exception_table : new CodeException[0]; + super.setLength(calculateLength()); // Adjust length + } + + + /** + * @param max_locals maximum number of local variables + */ + public final void setMaxLocals( final int max_locals ) { + this.max_locals = max_locals; + } + + + /** + * @param max_stack maximum stack size + */ + public final void setMaxStack( final int max_stack ) { + this.max_stack = max_stack; + } + + + /** + * @return String representation of code chunk. + */ + public final String toString( final boolean verbose ) { + final StringBuilder buf = new StringBuilder(100); // CHECKSTYLE IGNORE MagicNumber + buf.append("Code(max_stack = ").append(max_stack).append(", max_locals = ").append( + max_locals).append(", code_length = ").append(code.length).append(")\n").append( + Utility.codeToString(code, super.getConstantPool(), 0, -1, verbose)); + if (exception_table.length > 0) { + buf.append("\nException handler(s) = \n").append("From\tTo\tHandler\tType\n"); + for (final CodeException exception : exception_table) { + buf.append(exception.toString(super.getConstantPool(), verbose)).append("\n"); + } + } + if (attributes.length > 0) { + buf.append("\nAttribute(s) = "); + for (final Attribute attribute : attributes) { + buf.append("\n").append(attribute); + } + } + return buf.toString(); + } + + + /** + * @return String representation of code chunk. + */ + @Override + public final String toString() { + return toString(true); + } + + + /** + * @return deep copy of this attribute + * + * @param _constant_pool the constant pool to duplicate + */ + @Override + public Attribute copy( final ConstantPool _constant_pool ) { + final Code c = (Code) clone(); + if (code != null) { + c.code = new byte[code.length]; + System.arraycopy(code, 0, c.code, 0, code.length); + } + c.setConstantPool(_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.length]; + for (int i = 0; i < attributes.length; i++) { + c.attributes[i] = attributes[i].copy(_constant_pool); + } + return c; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/CodeException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/CodeException.java old mode 100755 new mode 100644 similarity index 71% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/CodeException.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/CodeException.java index 007d2298..0c642f0a --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/CodeException.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/CodeException.java @@ -1,215 +1,218 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.Serializable; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class represents an entry in the exception table of the Code - * attribute and is used only there. It contains a range in which a - * particular exception handler is active. - * - * @version $Id: CodeException.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @see Code - */ -public final class CodeException implements Cloneable, Constants, Node, Serializable { - - 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 - * @throws 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 - * @throws 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 the type of exception that is caught - */ - 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 = "(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; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; +import org.apache.bcel.Constants; + +/** + * This class represents an entry in the exception table of the Code + * attribute and is used only there. It contains a range in which a + * particular exception handler is active. + * + * @version $Id: CodeException.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see Code + */ +public final class CodeException implements Cloneable, Node, Constants { + + 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(final CodeException c) { + this(c.getStartPC(), c.getEndPC(), c.getHandlerPC(), c.getCatchType()); + } + + + /** + * Construct object from file stream. + * @param file Input stream + * @throws IOException + */ + CodeException(final DataInput 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(final int start_pc, final int end_pc, final int handler_pc, final 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitCodeException(this); + } + + + /** + * Dump code exception to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + public final void dump( final 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 the type of exception that is caught + */ + public final void setCatchType( final int catch_type ) { + this.catch_type = catch_type; + } + + + /** + * @param end_pc end of handled block + */ + public final void setEndPC( final int end_pc ) { + this.end_pc = end_pc; + } + + + /** + * @param handler_pc where the actual code is + */ + public final void setHandlerPC( final int handler_pc ) { // TODO unused + this.handler_pc = handler_pc; + } + + + /** + * @param start_pc start of handled block + */ + public final void setStartPC( final int start_pc ) { // TODO unused + this.start_pc = start_pc; + } + + + /** + * @return String representation. + */ + @Override + 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( final ConstantPool cp, final boolean verbose ) { + String str; + if (catch_type == 0) { + str = "(0)"; + } else { + str = Utility.compactClassName(cp.getConstantString(catch_type, Const.CONSTANT_Class), false) + + (verbose ? "(" + catch_type + ")" : ""); + } + return start_pc + "\t" + end_pc + "\t" + handler_pc + "\t" + str; + } + + + public final String toString( final ConstantPool cp ) { + return toString(cp, true); + } + + + /** + * @return deep copy of this object + */ + public CodeException copy() { + try { + return (CodeException) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Constant.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Constant.java new file mode 100644 index 00000000..7199dd1b --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Constant.java @@ -0,0 +1,215 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; +import org.apache.bcel.util.BCELComparator; + +/** + * 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: Constant.java 1816490 2017-11-27 18:56:00Z ggregory $ + */ +public abstract class Constant implements Cloneable, Node { + + private static BCELComparator bcelComparator = new BCELComparator() { + + @Override + public boolean equals( final Object o1, final Object o2 ) { + final Constant THIS = (Constant) o1; + final Constant THAT = (Constant) o2; + return THIS.toString().equals(THAT.toString()); + } + + + @Override + public int hashCode( final Object o ) { + final Constant THIS = (Constant) o; + return THIS.toString().hashCode(); + } + }; + /* 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. + */ + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @java.lang.Deprecated + protected byte tag; // TODO should be private & final + + + Constant(final 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 + */ + @Override + 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. + */ + @Override + public String toString() { + return Const.getConstantName(tag) + "[" + tag + "]"; + } + + + /** + * @return deep copy of this constant + */ + public Constant copy() { + try { + return (Constant) super.clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } + + + @Override + public Object clone() { + try { + return super.clone(); + } catch (final CloneNotSupportedException e) { + throw new Error("Clone Not Supported"); // never happens + } + } + + + /** + * Read one constant from the given input, the type depends on a tag byte. + * + * @param input Input stream + * @return Constant object + * @since 6.0 made public + */ + public static Constant readConstant( final DataInput input ) throws IOException, + ClassFormatException { + final byte b = input.readByte(); // Read tag byte + switch (b) { + case Const.CONSTANT_Class: + return new ConstantClass(input); + case Const.CONSTANT_Fieldref: + return new ConstantFieldref(input); + case Const.CONSTANT_Methodref: + return new ConstantMethodref(input); + case Const.CONSTANT_InterfaceMethodref: + return new ConstantInterfaceMethodref(input); + case Const.CONSTANT_String: + return new ConstantString(input); + case Const.CONSTANT_Integer: + return new ConstantInteger(input); + case Const.CONSTANT_Float: + return new ConstantFloat(input); + case Const.CONSTANT_Long: + return new ConstantLong(input); + case Const.CONSTANT_Double: + return new ConstantDouble(input); + case Const.CONSTANT_NameAndType: + return new ConstantNameAndType(input); + case Const.CONSTANT_Utf8: + return ConstantUtf8.getInstance(input); + case Const.CONSTANT_MethodHandle: + return new ConstantMethodHandle(input); + case Const.CONSTANT_MethodType: + return new ConstantMethodType(input); + case Const.CONSTANT_InvokeDynamic: + return new ConstantInvokeDynamic(input); + case Const.CONSTANT_Module: + return new ConstantModule(input); + case Const.CONSTANT_Package: + return new ConstantPackage(input); + default: + throw new ClassFormatException("Invalid byte tag in constant pool: " + b); + } + } + + + /** + * @return Comparison strategy object + */ + public static BCELComparator getComparator() { + return bcelComparator; + } + + + /** + * @param comparator Comparison strategy object + */ + public static void setComparator( final BCELComparator comparator ) { + bcelComparator = comparator; + } + + + /** + * Return value as defined by given BCELComparator strategy. + * By default two Constant objects are said to be equal when + * the result of toString() is equal. + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals( final Object obj ) { + return bcelComparator.equals(this, obj); + } + + + /** + * Return value as defined by given BCELComparator strategy. + * By default return the hashcode of the result of toString(). + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return bcelComparator.hashCode(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantCP.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantCP.java new file mode 100644 index 00000000..485fbc13 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantCP.java @@ -0,0 +1,151 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * Abstract super class for Fieldref, Methodref, InterfaceMethodref and + * InvokeDynamic constants. + * + * @version $Id: ConstantCP.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see ConstantFieldref + * @see ConstantMethodref + * @see ConstantInterfaceMethodref + * @see ConstantInvokeDynamic + */ +public abstract class ConstantCP extends Constant { + + /** References to the constants containing the class and the field signature + */ + // Note that this field is used to store the + // bootstrap_method_attr_index of a ConstantInvokeDynamic. + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @java.lang.Deprecated + protected int class_index; // TODO make private (has getter & setter) + // This field has the same meaning for all subclasses. + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @java.lang.Deprecated + protected int name_and_type_index; // TODO make private (has getter & setter) + + + /** + * Initialize from another object. + */ + public ConstantCP(final ConstantCP c) { + this(c.getTag(), c.getClassIndex(), c.getNameAndTypeIndex()); + } + + + /** + * Initialize instance from file data. + * + * @param tag Constant type tag + * @param file Input stream + * @throws IOException + */ + ConstantCP(final byte tag, final DataInput 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(final byte tag, final int class_index, final 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 + * @throws IOException + */ + @Override + public final void dump( final DataOutputStream file ) throws IOException { + file.writeByte(super.getTag()); + file.writeShort(class_index); + file.writeShort(name_and_type_index); + } + + + /** + * @return Reference (index) to class this constant refers to. + */ + public final int getClassIndex() { + return class_index; + } + + + /** + * @param class_index points to Constant_class + */ + public final void setClassIndex( final int class_index ) { + this.class_index = class_index; + } + + + /** + * @return Reference (index) to signature of the field. + */ + public final int getNameAndTypeIndex() { + return name_and_type_index; + } + + + /** + * @param name_and_type_index points to Constant_NameAndType + */ + public final void setNameAndTypeIndex( final int name_and_type_index ) { + this.name_and_type_index = name_and_type_index; + } + + + /** + * @return Class this field belongs to. + */ + public String getClass( final ConstantPool cp ) { + return cp.constantToString(class_index, Const.CONSTANT_Class); + } + + + /** + * @return String representation. + * + * not final as ConstantInvokeDynamic needs to modify + */ + @Override + public String toString() { + return super.toString() + "(class_index = " + class_index + ", name_and_type_index = " + + name_and_type_index + ")"; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantClass.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantClass.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantClass.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantClass.java index aa67cad8..5b10110f --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantClass.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantClass.java @@ -1,129 +1,132 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class is derived from the abstract - * Constant class - * and represents a reference to a (external) class. - * - * @version $Id: ConstantClass.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 - * @throws IOException - */ - ConstantClass(DataInputStream file) throws IOException { - this(file.readUnsignedShort()); - } - - - /** - * @param name_index Name index in constant pool. Should refer to a - * ConstantUtf8. - */ - 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 - * @throws 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 the name index in the constant pool of this Constant Class - */ - 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 + ")"; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class is derived from the abstract {@link Constant} + * and represents a reference to a (external) class. + * + * @version $Id: ConstantClass.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @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(final ConstantClass c) { + this(c.getNameIndex()); + } + + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException + */ + ConstantClass(final DataInput file) throws IOException { + this(file.readUnsignedShort()); + } + + + /** + * @param name_index Name index in constant pool. Should refer to a + * ConstantUtf8. + */ + public ConstantClass(final int name_index) { + super(Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitConstantClass(this); + } + + + /** + * Dump constant class to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + @Override + public final void dump( final DataOutputStream file ) throws IOException { + file.writeByte(super.getTag()); + file.writeShort(name_index); + } + + + /** + * @return Name index in constant pool of class name. + */ + public final int getNameIndex() { + return name_index; + } + + + /** + * @param name_index the name index in the constant pool of this Constant Class + */ + public final void setNameIndex( final int name_index ) { + this.name_index = name_index; + } + + + /** @return String object + */ + @Override + public Object getConstantValue( final ConstantPool cp ) { + final Constant c = cp.getConstant(name_index, Const.CONSTANT_Utf8); + return ((ConstantUtf8) c).getBytes(); + } + + + /** @return dereferenced string + */ + public String getBytes( final ConstantPool cp ) { + return (String) getConstantValue(cp); + } + + + /** + * @return String representation. + */ + @Override + public final String toString() { + return super.toString() + "(name_index = " + name_index + ")"; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantDouble.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantDouble.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantDouble.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantDouble.java index 831ca968..e2622332 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantDouble.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantDouble.java @@ -1,120 +1,123 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class is derived from the abstract - * Constant class - * and represents a reference to a Double object. - * - * @version $Id: ConstantDouble.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 - * @throws 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 - * @throws 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 the raw bytes that represent the double value - */ - 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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class is derived from the abstract {@link Constant} + * and represents a reference to a Double object. + * + * @version $Id: ConstantDouble.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see Constant + */ +public final class ConstantDouble extends Constant implements ConstantObject { + + private double bytes; + + + /** + * @param bytes Data + */ + public ConstantDouble(final double bytes) { + super(Const.CONSTANT_Double); + this.bytes = bytes; + } + + + /** + * Initialize from another object. + */ + public ConstantDouble(final ConstantDouble c) { + this(c.getBytes()); + } + + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException + */ + ConstantDouble(final DataInput 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitConstantDouble(this); + } + + + /** + * Dump constant double to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + @Override + public final void dump( final DataOutputStream file ) throws IOException { + file.writeByte(super.getTag()); + file.writeDouble(bytes); + } + + + /** + * @return data, i.e., 8 bytes. + */ + public final double getBytes() { + return bytes; + } + + + /** + * @param bytes the raw bytes that represent the double value + */ + public final void setBytes( final double bytes ) { + this.bytes = bytes; + } + + + /** + * @return String representation. + */ + @Override + public final String toString() { + return super.toString() + "(bytes = " + bytes + ")"; + } + + + /** @return Double object + */ + @Override + public Object getConstantValue( final ConstantPool cp ) { + return new Double(bytes); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantFieldref.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantFieldref.java new file mode 100644 index 00000000..1b13742b --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantFieldref.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class represents a constant pool reference to a field. + * + * @version $Id: ConstantFieldref.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public final class ConstantFieldref extends ConstantCP { + + /** + * Initialize from another object. + */ + public ConstantFieldref(final ConstantFieldref c) { + super(Const.CONSTANT_Fieldref, c.getClassIndex(), c.getNameAndTypeIndex()); + } + + + /** + * Initialize instance from input data. + * + * @param input input stream + * @throws IOException + */ + ConstantFieldref(final DataInput input) throws IOException { + super(Const.CONSTANT_Fieldref, input); + } + + + /** + * @param class_index Reference to the class containing the Field + * @param name_and_type_index and the Field signature + */ + public ConstantFieldref(final int class_index, final int name_and_type_index) { + super(Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitConstantFieldref(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantFloat.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantFloat.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantFloat.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantFloat.java index 023ff4c0..259fe48f --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantFloat.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantFloat.java @@ -1,121 +1,124 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class is derived from the abstract - * Constant class - * and represents a reference to a float object. - * - * @version $Id: ConstantFloat.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 - * @throws 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 - * @throws 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 the raw bytes that represent this float - */ - 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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class is derived from the abstract {@link Constant} + * and represents a reference to a float object. + * + * @version $Id: ConstantFloat.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see Constant + */ +public final class ConstantFloat extends Constant implements ConstantObject { + + private float bytes; + + + /** + * @param bytes Data + */ + public ConstantFloat(final float bytes) { + super(Const.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(final ConstantFloat c) { + this(c.getBytes()); + } + + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException + */ + ConstantFloat(final DataInput 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitConstantFloat(this); + } + + + /** + * Dump constant float to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + @Override + public final void dump( final DataOutputStream file ) throws IOException { + file.writeByte(super.getTag()); + file.writeFloat(bytes); + } + + + /** + * @return data, i.e., 4 bytes. + */ + public final float getBytes() { + return bytes; + } + + + /** + * @param bytes the raw bytes that represent this float + */ + public final void setBytes( final float bytes ) { + this.bytes = bytes; + } + + + /** + * @return String representation. + */ + @Override + public final String toString() { + return super.toString() + "(bytes = " + bytes + ")"; + } + + + /** @return Float object + */ + @Override + public Object getConstantValue( final ConstantPool cp ) { + return new Float(bytes); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantInteger.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantInteger.java old mode 100755 new mode 100644 similarity index 58% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantInteger.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantInteger.java index b4b8c347..e5cab54b --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantInteger.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantInteger.java @@ -1,120 +1,123 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class is derived from the abstract - * Constant class - * and represents a reference to an int object. - * - * @version $Id: ConstantInteger.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 - * @throws 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 - * @throws 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 the raw bytes that represent this integer - */ - 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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class is derived from the abstract {@link Constant} + * and represents a reference to an int object. + * + * @version $Id: ConstantInteger.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see Constant + */ +public final class ConstantInteger extends Constant implements ConstantObject { + + private int bytes; + + + /** + * @param bytes Data + */ + public ConstantInteger(final int bytes) { + super(Const.CONSTANT_Integer); + this.bytes = bytes; + } + + + /** + * Initialize from another object. + */ + public ConstantInteger(final ConstantInteger c) { + this(c.getBytes()); + } + + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException + */ + ConstantInteger(final DataInput 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitConstantInteger(this); + } + + + /** + * Dump constant integer to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + @Override + public final void dump( final DataOutputStream file ) throws IOException { + file.writeByte(super.getTag()); + file.writeInt(bytes); + } + + + /** + * @return data, i.e., 4 bytes. + */ + public final int getBytes() { + return bytes; + } + + + /** + * @param bytes the raw bytes that represent this integer + */ + public final void setBytes( final int bytes ) { + this.bytes = bytes; + } + + + /** + * @return String representation. + */ + @Override + public final String toString() { + return super.toString() + "(bytes = " + bytes + ")"; + } + + + /** @return Integer object + */ + @Override + public Object getConstantValue( final ConstantPool cp ) { + return Integer.valueOf(bytes); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantInterfaceMethodref.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantInterfaceMethodref.java new file mode 100644 index 00000000..bf7620f8 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantInterfaceMethodref.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class represents a constant pool reference to an interface method. + * + * @version $Id: ConstantInterfaceMethodref.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public final class ConstantInterfaceMethodref extends ConstantCP { + + /** + * Initialize from another object. + */ + public ConstantInterfaceMethodref(final ConstantInterfaceMethodref c) { + super(Const.CONSTANT_InterfaceMethodref, c.getClassIndex(), c.getNameAndTypeIndex()); + } + + + /** + * Initialize instance from input data. + * + * @param input input stream + * @throws IOException + */ + ConstantInterfaceMethodref(final DataInput input) throws IOException { + super(Const.CONSTANT_InterfaceMethodref, input); + } + + + /** + * @param class_index Reference to the class containing the method + * @param name_and_type_index and the method signature + */ + public ConstantInterfaceMethodref(final int class_index, final int name_and_type_index) { + super(Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitConstantInterfaceMethodref(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantInvokeDynamic.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantInvokeDynamic.java new file mode 100644 index 00000000..5c23745f --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantInvokeDynamic.java @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class is derived from the abstract {@link Constant} + * and represents a reference to a invoke dynamic. + * + * @see Constant + * @see + * The CONSTANT_InvokeDynamic_info Structure in The Java Virtual Machine Specification + * @since 6.0 + */ +public final class ConstantInvokeDynamic extends ConstantCP { + + /** + * Initialize from another object. + */ + public ConstantInvokeDynamic(final ConstantInvokeDynamic c) { + this(c.getBootstrapMethodAttrIndex(), c.getNameAndTypeIndex()); + } + + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException + */ + ConstantInvokeDynamic(final DataInput file) throws IOException { + this(file.readShort(), file.readShort()); + } + + + public ConstantInvokeDynamic(final int bootstrap_method_attr_index, final int name_and_type_index) { + super(Const.CONSTANT_InvokeDynamic, bootstrap_method_attr_index, name_and_type_index); + } + + + /** + * Called by objects that are traversing the nodes of the tree implicitly + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitConstantInvokeDynamic(this); + } + + /** + * @return Reference (index) to bootstrap method this constant refers to. + * + * Note that this method is a functional duplicate of getClassIndex + * for use by ConstantInvokeDynamic. + * @since 6.0 + */ + public final int getBootstrapMethodAttrIndex() { + return super.getClassIndex(); // AKA bootstrap_method_attr_index + } + + /** + * @return String representation + */ + @Override + public final String toString() { + return super.toString().replace("class_index", "bootstrap_method_attr_index"); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantLong.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantLong.java old mode 100755 new mode 100644 similarity index 56% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantLong.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantLong.java index b950c636..ec44efac --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantLong.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantLong.java @@ -1,120 +1,123 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class is derived from the abstract - * Constant class - * and represents a reference to a long object. - * - * @version $Id: ConstantLong.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 - * @throws 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 - * @throws 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 thr raw bytes that represent this long - */ - 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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class is derived from the abstract {@link Constant} + * and represents a reference to a long object. + * + * @version $Id: ConstantLong.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see Constant + */ +public final class ConstantLong extends Constant implements ConstantObject { + + private long bytes; + + + /** + * @param bytes Data + */ + public ConstantLong(final long bytes) { + super(Const.CONSTANT_Long); + this.bytes = bytes; + } + + + /** + * Initialize from another object. + */ + public ConstantLong(final ConstantLong c) { + this(c.getBytes()); + } + + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException + */ + ConstantLong(final DataInput 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitConstantLong(this); + } + + + /** + * Dump constant long to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + @Override + public final void dump( final DataOutputStream file ) throws IOException { + file.writeByte(super.getTag()); + file.writeLong(bytes); + } + + + /** + * @return data, i.e., 8 bytes. + */ + public final long getBytes() { + return bytes; + } + + + /** + * @param bytes the raw bytes that represent this long + */ + public final void setBytes( final long bytes ) { + this.bytes = bytes; + } + + + /** + * @return String representation. + */ + @Override + public final String toString() { + return super.toString() + "(bytes = " + bytes + ")"; + } + + + /** @return Long object + */ + @Override + public Object getConstantValue( final ConstantPool cp ) { + return Long.valueOf(bytes); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantMethodHandle.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantMethodHandle.java new file mode 100644 index 00000000..29fc2248 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantMethodHandle.java @@ -0,0 +1,120 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class is derived from the abstract {@link Constant} + * and represents a reference to a method handle. + * + * @see Constant + * @since 6.0 + */ +public final class ConstantMethodHandle extends Constant { + + private int reference_kind; + private int reference_index; + + + /** + * Initialize from another object. + */ + public ConstantMethodHandle(final ConstantMethodHandle c) { + this(c.getReferenceKind(), c.getReferenceIndex()); + } + + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException + */ + ConstantMethodHandle(final DataInput file) throws IOException { + this(file.readUnsignedByte(), file.readUnsignedShort()); + } + + + public ConstantMethodHandle(final int reference_kind, final int reference_index) { + super(Const.CONSTANT_MethodHandle); + this.reference_kind = reference_kind; + this.reference_index = reference_index; + } + + + /** + * Called by objects that are traversing the nodes of the tree implicitly + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitConstantMethodHandle(this); + } + + + /** + * Dump method kind and index to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + @Override + public final void dump( final DataOutputStream file ) throws IOException { + file.writeByte(super.getTag()); + file.writeByte(reference_kind); + file.writeShort(reference_index); + } + + + public int getReferenceKind() { + return reference_kind; + } + + + public void setReferenceKind(final int reference_kind) { + this.reference_kind = reference_kind; + } + + + public int getReferenceIndex() { + return reference_index; + } + + + public void setReferenceIndex(final int reference_index) { + this.reference_index = reference_index; + } + + + /** + * @return String representation + */ + @Override + public final String toString() { + return super.toString() + "(reference_kind = " + reference_kind + + ", reference_index = " + reference_index + ")"; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantMethodType.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantMethodType.java new file mode 100644 index 00000000..72234051 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantMethodType.java @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class is derived from the abstract {@link Constant} + * and represents a reference to a method type. + * + * @see Constant + * @since 6.0 + */ +public final class ConstantMethodType extends Constant { + + private int descriptor_index; + + + /** + * Initialize from another object. + */ + public ConstantMethodType(final ConstantMethodType c) { + this(c.getDescriptorIndex()); + } + + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException + */ + ConstantMethodType(final DataInput file) throws IOException { + this(file.readUnsignedShort()); + } + + + public ConstantMethodType(final int descriptor_index) { + super(Const.CONSTANT_MethodType); + this.descriptor_index = descriptor_index; + } + + + /** + * Called by objects that are traversing the nodes of the tree implicitly + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitConstantMethodType(this); + } + + + /** + * Dump name and signature index to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + @Override + public final void dump( final DataOutputStream file ) throws IOException { + file.writeByte(super.getTag()); + file.writeShort(descriptor_index); + } + + + public int getDescriptorIndex() { + return descriptor_index; + } + + + public void setDescriptorIndex(final int descriptor_index) { + this.descriptor_index = descriptor_index; + } + + + /** + * @return String representation + */ + @Override + public final String toString() { + return super.toString() + "(descriptor_index = " + descriptor_index + ")"; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantMethodref.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantMethodref.java new file mode 100644 index 00000000..959c479b --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantMethodref.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class represents a constant pool reference to a method. + * + * @version $Id: ConstantMethodref.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public final class ConstantMethodref extends ConstantCP { + + /** + * Initialize from another object. + */ + public ConstantMethodref(final ConstantMethodref c) { + super(Const.CONSTANT_Methodref, c.getClassIndex(), c.getNameAndTypeIndex()); + } + + + /** + * Initialize instance from input data. + * + * @param input input stream + * @throws IOException + */ + ConstantMethodref(final DataInput input) throws IOException { + super(Const.CONSTANT_Methodref, input); + } + + + /** + * @param class_index Reference to the class containing the method + * @param name_and_type_index and the method signature + */ + public ConstantMethodref(final int class_index, final int name_and_type_index) { + super(Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitConstantMethodref(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantModule.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantModule.java new file mode 100644 index 00000000..2d746aea --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantModule.java @@ -0,0 +1,134 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class is derived from the abstract {@link Constant} + * and represents a reference to a module. + * + *

Note: Early access Java 9 support- currently subject to change

+ * + * @see Constant + * @since 6.1 + */ +public final class ConstantModule extends Constant implements ConstantObject { + + private int name_index; + + + /** + * Initialize from another object. + */ + public ConstantModule(final ConstantModule c) { + this(c.getNameIndex()); + } + + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException + */ + ConstantModule(final DataInput file) throws IOException { + this(file.readUnsignedShort()); + } + + + /** + * @param name_index Name index in constant pool. Should refer to a + * ConstantUtf8. + */ + public ConstantModule(final int name_index) { + super(Const.CONSTANT_Module); + this.name_index = name_index; + } + + + /** + * Called by objects that are traversing the nodes of the tree implicitly + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitConstantModule(this); + } + + + /** + * Dump constant module to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + @Override + public final void dump( final DataOutputStream file ) throws IOException { + file.writeByte(super.getTag()); + file.writeShort(name_index); + } + + + /** + * @return Name index in constant pool of module name. + */ + public final int getNameIndex() { + return name_index; + } + + + /** + * @param name_index the name index in the constant pool of this Constant Module + */ + public final void setNameIndex( final int name_index ) { + this.name_index = name_index; + } + + + /** @return String object + */ + @Override + public Object getConstantValue( final ConstantPool cp ) { + final Constant c = cp.getConstant(name_index, Const.CONSTANT_Utf8); + return ((ConstantUtf8) c).getBytes(); + } + + + /** @return dereferenced string + */ + public String getBytes( final ConstantPool cp ) { + return (String) getConstantValue(cp); + } + + + /** + * @return String representation. + */ + @Override + public final String toString() { + return super.toString() + "(name_index = " + name_index + ")"; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantNameAndType.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantNameAndType.java old mode 100755 new mode 100644 similarity index 62% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantNameAndType.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantNameAndType.java index 2c6846f1..3267fa60 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantNameAndType.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantNameAndType.java @@ -1,149 +1,151 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class is derived from the abstract - * Constant class - * and represents a reference to the name and signature - * of a field or method. - * - * @version $Id: ConstantNameAndType.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 - * @throws IOException - */ - ConstantNameAndType(DataInputStream file) throws IOException { - this(file.readUnsignedShort(), 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 - * @throws 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 the name index of this constant - */ - public final void setNameIndex( int name_index ) { - this.name_index = name_index; - } - - - /** - * @param signature_index the signature index in the constant pool of this type - */ - 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 + ")"; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class is derived from the abstract {@link Constant} + * and represents a reference to the name and signature + * of a field or method. + * + * @version $Id: ConstantNameAndType.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @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(final ConstantNameAndType c) { + this(c.getNameIndex(), c.getSignatureIndex()); + } + + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException + */ + ConstantNameAndType(final DataInput file) throws IOException { + this(file.readUnsignedShort(), file.readUnsignedShort()); + } + + + /** + * @param name_index Name of field/method + * @param signature_index and its signature + */ + public ConstantNameAndType(final int name_index, final int signature_index) { + super(Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitConstantNameAndType(this); + } + + + /** + * Dump name and signature index to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + @Override + public final void dump( final DataOutputStream file ) throws IOException { + file.writeByte(super.getTag()); + 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( final ConstantPool cp ) { + return cp.constantToString(getNameIndex(), Const.CONSTANT_Utf8); + } + + + /** + * @return Index in constant pool of field/method signature. + */ + public final int getSignatureIndex() { + return signature_index; + } + + + /** @return signature + */ + public final String getSignature( final ConstantPool cp ) { + return cp.constantToString(getSignatureIndex(), Const.CONSTANT_Utf8); + } + + + /** + * @param name_index the name index of this constant + */ + public final void setNameIndex( final int name_index ) { + this.name_index = name_index; + } + + + /** + * @param signature_index the signature index in the constant pool of this type + */ + public final void setSignatureIndex( final int signature_index ) { + this.signature_index = signature_index; + } + + + /** + * @return String representation + */ + @Override + public final String toString() { + return super.toString() + "(name_index = " + name_index + ", signature_index = " + + signature_index + ")"; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantObject.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantObject.java old mode 100755 new mode 100644 similarity index 51% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantObject.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantObject.java index 10d611dd..8c056e58 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantObject.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantObject.java @@ -1,32 +1,32 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -/** - * This interface denotes those constants that have a "natural" value, - * such as ConstantLong, ConstantString, etc.. - * - * @version $Id: ConstantObject.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @see Constant - */ -public interface ConstantObject { - - /** @return object representing the constant, e.g., Long for ConstantLong - */ - public abstract Object getConstantValue( ConstantPool cp ); -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +/** + * This interface denotes those constants that have a "natural" value, + * such as ConstantLong, ConstantString, etc.. + * + * @version $Id: ConstantObject.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see Constant + */ +public interface ConstantObject { + + /** @return object representing the constant, e.g., Long for ConstantLong + */ + Object getConstantValue( ConstantPool cp ); +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantPackage.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantPackage.java new file mode 100644 index 00000000..ed432847 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantPackage.java @@ -0,0 +1,134 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class is derived from the abstract {@link Constant} + * and represents a reference to a package. + * + *

Note: Early access Java 9 support- currently subject to change

+ * + * @see Constant + * @since 6.1 + */ +public final class ConstantPackage extends Constant implements ConstantObject { + + private int name_index; + + + /** + * Initialize from another object. + */ + public ConstantPackage(final ConstantPackage c) { + this(c.getNameIndex()); + } + + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException + */ + ConstantPackage(final DataInput file) throws IOException { + this(file.readUnsignedShort()); + } + + + /** + * @param name_index Name index in constant pool. Should refer to a + * ConstantUtf8. + */ + public ConstantPackage(final int name_index) { + super(Const.CONSTANT_Package); + 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitConstantPackage(this); + } + + + /** + * Dump constant package to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + @Override + public final void dump( final DataOutputStream file ) throws IOException { + file.writeByte(super.getTag()); + file.writeShort(name_index); + } + + + /** + * @return Name index in constant pool of package name. + */ + public final int getNameIndex() { + return name_index; + } + + + /** + * @param name_index the name index in the constant pool of this Constant Package + */ + public final void setNameIndex( final int name_index ) { + this.name_index = name_index; + } + + + /** @return String object + */ + @Override + public Object getConstantValue( final ConstantPool cp ) { + final Constant c = cp.getConstant(name_index, Const.CONSTANT_Utf8); + return ((ConstantUtf8) c).getBytes(); + } + + + /** @return dereferenced string + */ + public String getBytes( final ConstantPool cp ) { + return (String) getConstantValue(cp); + } + + + /** + * @return String representation. + */ + @Override + public final String toString() { + return super.toString() + "(name_index = " + name_index + ")"; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantPool.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantPool.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantPool.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantPool.java index 31216424..0ce9a528 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantPool.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantPool.java @@ -1,354 +1,372 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.Serializable; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class represents the constant pool, i.e., a table of constants, of - * a parsed classfile. It may contain null references, due to the JVM - * specification that skips an entry after an 8-byte constant (double, - * long) entry. Those interested in generating constant pools - * programatically should see - * ConstantPoolGen. - - * @version $Id: ConstantPool.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @see Constant - * @see org.apache.bcel5_2_0.generic.ConstantPoolGen - * @author M. Dahm - */ -public class ConstantPool implements Cloneable, Node, Serializable { - - 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 - * @throws IOException - * @throws ClassFormatException - */ - ConstantPool(DataInputStream file) throws IOException, ClassFormatException { - 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 c Constant to be printed - * @return String representation - */ - public String constantToString( Constant c ) throws ClassFormatException { - 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(); - StringBuilder buf = new StringBuilder(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 ClassFormatException { - Constant c = getConstant(index, tag); - return constantToString(c); - } - - - /** - * Dump constant pool to file stream in binary format. - * - * @param file Output file stream - * @throws 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 ClassFormatException("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 - * @throws ClassFormatException - */ - public Constant getConstant( int index, byte tag ) throws ClassFormatException { - Constant c; - c = getConstant(index); - if (c == null) { - throw new ClassFormatException("Constant pool at index " + index + " is null."); - } - if (c.getTag() != tag) { - throw new ClassFormatException("Expected class `" + Constants.CONSTANT_NAMES[tag] - + "' at index " + index + " and got " + c); - } - return 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 - * @throws ClassFormatException - */ - public String getConstantString( int index, byte tag ) throws ClassFormatException { - Constant c; - int i; - 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() { - StringBuilder buf = new StringBuilder(); - for (int i = 1; i < constant_pool_count; i++) { - buf.append(i).append(")").append(constant_pool[i]).append("\n"); - } - return buf.toString(); - } - - - /** - * @return deep copy of this constant pool - */ - public ConstantPool copy() { - ConstantPool c = null; - try { - c = (ConstantPool) clone(); - 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(); - } - } - } catch (CloneNotSupportedException e) { - } - return c; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class represents the constant pool, i.e., a table of constants, of + * a parsed classfile. It may contain null references, due to the JVM + * specification that skips an entry after an 8-byte constant (double, + * long) entry. Those interested in generating constant pools + * programatically should see + * ConstantPoolGen. + + * @version $Id: ConstantPool.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see Constant + * @see org.apache.bcel.generic.ConstantPoolGen + */ +public class ConstantPool implements Cloneable, Node { + + private Constant[] constant_pool; + + + /** + * @param constant_pool Array of constants + */ + public ConstantPool(final Constant[] constant_pool) { + this.constant_pool = constant_pool; + } + + + /** + * Read constants from given input stream. + * + * @param input Input stream + * @throws IOException + * @throws ClassFormatException + */ + public ConstantPool(final DataInput input) throws IOException, ClassFormatException { + byte tag; + final int constant_pool_count = input.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(input); + /* 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 == Const.CONSTANT_Double) || (tag == Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitConstantPool(this); + } + + + /** + * Resolve constant to a string representation. + * + * @param c Constant to be printed + * @return String representation + */ + public String constantToString( Constant c ) throws ClassFormatException { + String str; + int i; + final byte tag = c.getTag(); + switch (tag) { + case Const.CONSTANT_Class: + i = ((ConstantClass) c).getNameIndex(); + c = getConstant(i, Const.CONSTANT_Utf8); + str = Utility.compactClassName(((ConstantUtf8) c).getBytes(), false); + break; + case Const.CONSTANT_String: + i = ((ConstantString) c).getStringIndex(); + c = getConstant(i, Const.CONSTANT_Utf8); + str = "\"" + escape(((ConstantUtf8) c).getBytes()) + "\""; + break; + case Const.CONSTANT_Utf8: + str = ((ConstantUtf8) c).getBytes(); + break; + case Const.CONSTANT_Double: + str = String.valueOf(((ConstantDouble) c).getBytes()); + break; + case Const.CONSTANT_Float: + str = String.valueOf(((ConstantFloat) c).getBytes()); + break; + case Const.CONSTANT_Long: + str = String.valueOf(((ConstantLong) c).getBytes()); + break; + case Const.CONSTANT_Integer: + str = String.valueOf(((ConstantInteger) c).getBytes()); + break; + case Const.CONSTANT_NameAndType: + str = constantToString(((ConstantNameAndType) c).getNameIndex(), + Const.CONSTANT_Utf8) + + " " + constantToString(((ConstantNameAndType) c).getSignatureIndex(), + Const.CONSTANT_Utf8); + break; + case Const.CONSTANT_InterfaceMethodref: + case Const.CONSTANT_Methodref: + case Const.CONSTANT_Fieldref: + str = constantToString(((ConstantCP) c).getClassIndex(), Const.CONSTANT_Class) + + "." + constantToString(((ConstantCP) c).getNameAndTypeIndex(), + Const.CONSTANT_NameAndType); + break; + case Const.CONSTANT_MethodHandle: + // Note that the ReferenceIndex may point to a Fieldref, Methodref or + // InterfaceMethodref - so we need to peek ahead to get the actual type. + final ConstantMethodHandle cmh = (ConstantMethodHandle) c; + str = Const.getMethodHandleName(cmh.getReferenceKind()) + + " " + constantToString(cmh.getReferenceIndex(), + getConstant(cmh.getReferenceIndex()).getTag()); + break; + case Const.CONSTANT_MethodType: + final ConstantMethodType cmt = (ConstantMethodType) c; + str = constantToString(cmt.getDescriptorIndex(), Const.CONSTANT_Utf8); + break; + case Const.CONSTANT_InvokeDynamic: + final ConstantInvokeDynamic cid = (ConstantInvokeDynamic) c; + str = cid.getBootstrapMethodAttrIndex() + + ":" + constantToString(cid.getNameAndTypeIndex(), + Const.CONSTANT_NameAndType); + break; + default: // Never reached + throw new RuntimeException("Unknown constant type " + tag); + } + return str; + } + + + private static String escape( final String str ) { + final int len = str.length(); + final StringBuilder buf = new StringBuilder(len + 5); + final 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( final int index, final byte tag ) throws ClassFormatException { + final Constant c = getConstant(index, tag); + return constantToString(c); + } + + + /** + * Dump constant pool to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + public void dump( final DataOutputStream file ) throws IOException { + file.writeShort(constant_pool.length); + for (int i = 1; i < constant_pool.length; 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( final int index ) { + if (index >= constant_pool.length || index < 0) { + throw new ClassFormatException("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 + * @throws ClassFormatException + */ + public Constant getConstant( final int index, final byte tag ) throws ClassFormatException { + Constant c; + c = getConstant(index); + if (c == null) { + throw new ClassFormatException("Constant pool at index " + index + " is null."); + } + if (c.getTag() != tag) { + throw new ClassFormatException("Expected class `" + Const.getConstantName(tag) + + "' at index " + index + " and got " + c); + } + return 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 + * @throws ClassFormatException + */ + public String getConstantString( final int index, final byte tag ) throws ClassFormatException { + Constant c; + int i; + 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 Const.CONSTANT_Class: + i = ((ConstantClass) c).getNameIndex(); + break; + case Const.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, Const.CONSTANT_Utf8); + return ((ConstantUtf8) c).getBytes(); + } + + + /** + * @return Length of constant pool. + */ + public int getLength() { + return constant_pool == null ? 0 : constant_pool.length; + } + + + /** + * @param constant Constant to set + */ + public void setConstant( final int index, final Constant constant ) { + constant_pool[index] = constant; + } + + + /** + * @param constant_pool + */ + public void setConstantPool( final Constant[] constant_pool ) { + this.constant_pool = constant_pool; + } + + + /** + * @return String representation. + */ + @Override + public String toString() { + final StringBuilder buf = new StringBuilder(); + for (int i = 1; i < constant_pool.length; i++) { + buf.append(i).append(")").append(constant_pool[i]).append("\n"); + } + return buf.toString(); + } + + + /** + * @return deep copy of this constant pool + */ + public ConstantPool copy() { + ConstantPool c = null; + try { + c = (ConstantPool) clone(); + c.constant_pool = new Constant[constant_pool.length]; + for (int i = 1; i < constant_pool.length; i++) { + if (constant_pool[i] != null) { + c.constant_pool[i] = constant_pool[i].copy(); + } + } + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return c; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantString.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantString.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantString.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantString.java index be5cbdbd..17bc0b77 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantString.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantString.java @@ -1,128 +1,131 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class is derived from the abstract - * Constant class - * and represents a reference to a String object. - * - * @version $Id: ConstantString.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 - * @throws IOException - */ - ConstantString(DataInputStream file) throws IOException { - this(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 - * @throws 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 the index into the constant of the string value - */ - 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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class is derived from the abstract {@link Constant} + * and represents a reference to a String object. + * + * @version $Id: ConstantString.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @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(final ConstantString c) { + this(c.getStringIndex()); + } + + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException + */ + ConstantString(final DataInput file) throws IOException { + this(file.readUnsignedShort()); + } + + + /** + * @param string_index Index of Constant_Utf8 in constant pool + */ + public ConstantString(final int string_index) { + super(Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitConstantString(this); + } + + + /** + * Dump constant field reference to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + @Override + public final void dump( final DataOutputStream file ) throws IOException { + file.writeByte(super.getTag()); + file.writeShort(string_index); + } + + + /** + * @return Index in constant pool of the string (ConstantUtf8). + */ + public final int getStringIndex() { + return string_index; + } + + + /** + * @param string_index the index into the constant of the string value + */ + public final void setStringIndex( final int string_index ) { + this.string_index = string_index; + } + + + /** + * @return String representation. + */ + @Override + public final String toString() { + return super.toString() + "(string_index = " + string_index + ")"; + } + + + /** @return String object + */ + @Override + public Object getConstantValue( final ConstantPool cp ) { + final Constant c = cp.getConstant(string_index, Const.CONSTANT_Utf8); + return ((ConstantUtf8) c).getBytes(); + } + + + /** @return dereferenced string + */ + public String getBytes( final ConstantPool cp ) { + return (String) getConstantValue(cp); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantUtf8.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantUtf8.java new file mode 100644 index 00000000..82d5aff6 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantUtf8.java @@ -0,0 +1,211 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; + +import org.apache.bcel.Const; + +/** + * This class is derived from the abstract {@link Constant} + * and represents a reference to a Utf8 encoded string. + * + * @version $Id: ConstantUtf8.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see Constant + */ +public final class ConstantUtf8 extends Constant { + + private final String bytes; + + // TODO these should perhaps be AtomicInt? + private static volatile int considered = 0; + private static volatile int hits = 0; + private static volatile int skipped = 0; + private static volatile int created = 0; + + // Set the size to 0 or below to skip caching entirely + private static final int MAX_CACHED_SIZE = + Integer.getInteger("bcel.maxcached.size", 200).intValue();// CHECKSTYLE IGNORE MagicNumber + private static final boolean BCEL_STATISTICS = Boolean.getBoolean("bcel.statistics"); + + + private static class CACHE_HOLDER { + + private static final int MAX_CACHE_ENTRIES = 20000; + private static final int INITIAL_CACHE_CAPACITY = (int)(MAX_CACHE_ENTRIES/0.75); + + private static final HashMap CACHE = + new LinkedHashMap(INITIAL_CACHE_CAPACITY, 0.75f, true) { + private static final long serialVersionUID = -8506975356158971766L; + + @Override + protected boolean removeEldestEntry(final Map.Entry eldest) { + return size() > MAX_CACHE_ENTRIES; + } + }; + + } + + // for accesss by test code + static void printStats() { + System.err.println("Cache hit " + hits + "/" + considered +", " + skipped + " skipped"); + System.err.println("Total of " + created + " ConstantUtf8 objects created"); + } + + // for accesss by test code + static void clearStats() { + hits = considered = skipped = created = 0; + } + + static { + if (BCEL_STATISTICS) { + Runtime.getRuntime().addShutdownHook(new Thread() { + @Override + public void run() { + printStats(); + } + }); + } + } + + /** + * @since 6.0 + */ + public static ConstantUtf8 getCachedInstance(final String s) { + if (s.length() > MAX_CACHED_SIZE) { + skipped++; + return new ConstantUtf8(s); + } + considered++; + synchronized (ConstantUtf8.class) { // might be better with a specific lock object + ConstantUtf8 result = CACHE_HOLDER.CACHE.get(s); + if (result != null) { + hits++; + return result; + } + result = new ConstantUtf8(s); + CACHE_HOLDER.CACHE.put(s, result); + return result; + } + } + + /** + * @since 6.0 + */ + public static ConstantUtf8 getInstance(final String s) { + return new ConstantUtf8(s); + } + + /** + * @since 6.0 + */ + public static ConstantUtf8 getInstance (final DataInput input) throws IOException { + return getInstance(input.readUTF()); + } + + /** + * Initialize from another object. + */ + public ConstantUtf8(final ConstantUtf8 c) { + this(c.getBytes()); + } + + + /** + * Initialize instance from file data. + * + * @param file Input stream + * @throws IOException + */ + ConstantUtf8(final DataInput file) throws IOException { + super(Const.CONSTANT_Utf8); + bytes = file.readUTF(); + created++; + } + + + /** + * @param bytes Data + */ + public ConstantUtf8(final String bytes) { + super(Const.CONSTANT_Utf8); + if (bytes == null) { + throw new IllegalArgumentException("bytes must not be null!"); + } + this.bytes = bytes; + created++; + } + + + /** + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitConstantUtf8(this); + } + + + /** + * Dump String in Utf8 format to file stream. + * + * @param file Output file stream + * @throws IOException + */ + @Override + public final void dump( final DataOutputStream file ) throws IOException { + file.writeByte(super.getTag()); + file.writeUTF(bytes); + } + + + /** + * @return Data converted to string. + */ + public final String getBytes() { + return bytes; + } + + + /** + * @param bytes the raw bytes of this Utf-8 + * @deprecated (since 6.0) + */ + @java.lang.Deprecated + public final void setBytes( final String bytes ) { + throw new UnsupportedOperationException(); + } + + + /** + * @return String representation + */ + @Override + public final String toString() { + return super.toString() + "(\"" + Utility.replace(bytes, "\n", "\\n") + "\")"; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantValue.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantValue.java old mode 100755 new mode 100644 similarity index 56% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantValue.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantValue.java index 671d9b44..c5b0d2e6 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantValue.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantValue.java @@ -1,156 +1,160 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class is derived from Attribute and represents a constant - * value, i.e., a default value for initializing a class field. - * This class is instantiated by the Attribute.readAttribute() method. - * - * @version $Id: ConstantValue.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 - * @throws IOException - */ - ConstantValue(int name_index, int length, DataInputStream file, ConstantPool constant_pool) - throws IOException { - this(name_index, length, 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 - * @throws 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 the index info the constant pool of this constant value - */ - public final void setConstantValueIndex( int constantvalue_index ) { - this.constantvalue_index = constantvalue_index; - } - - - /** - * @return String representation of constant value. - */ - public final String toString() { - 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 = "\"" + Utility.convertString(((ConstantUtf8) c).getBytes()) + "\""; - break; - default: - throw new IllegalStateException("Type of ConstValue invalid: " + c); - } - return buf; - } - - - /** - * @return deep copy of this attribute - */ - public Attribute copy( ConstantPool _constant_pool ) { - ConstantValue c = (ConstantValue) clone(); - c.constant_pool = _constant_pool; - return c; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class is derived from Attribute and represents a constant + * value, i.e., a default value for initializing a class field. + * This class is instantiated by the Attribute.readAttribute() method. + * + * @version $Id: ConstantValue.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @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(final ConstantValue c) { + this(c.getNameIndex(), c.getLength(), c.getConstantValueIndex(), c.getConstantPool()); + } + + + /** + * Construct object from input stream. + * @param name_index Name index in constant pool + * @param length Content length in bytes + * @param input Input stream + * @param constant_pool Array of constants + * @throws IOException + */ + ConstantValue(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) + throws IOException { + this(name_index, length, input.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(final int name_index, final int length, final int constantvalue_index, + final ConstantPool constant_pool) { + super(Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitConstantValue(this); + } + + + /** + * Dump constant value attribute to file stream on binary format. + * + * @param file Output file stream + * @throws IOException + */ + @Override + public final void dump( final 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 the index info the constant pool of this constant value + */ + public final void setConstantValueIndex( final int constantvalue_index ) { + this.constantvalue_index = constantvalue_index; + } + + + /** + * @return String representation of constant value. + */ + @Override + public final String toString() { + Constant c = super.getConstantPool().getConstant(constantvalue_index); + String buf; + int i; + // Print constant to string depending on its type + switch (c.getTag()) { + case Const.CONSTANT_Long: + buf = String.valueOf(((ConstantLong) c).getBytes()); + break; + case Const.CONSTANT_Float: + buf = String.valueOf(((ConstantFloat) c).getBytes()); + break; + case Const.CONSTANT_Double: + buf = String.valueOf(((ConstantDouble) c).getBytes()); + break; + case Const.CONSTANT_Integer: + buf = String.valueOf(((ConstantInteger) c).getBytes()); + break; + case Const.CONSTANT_String: + i = ((ConstantString) c).getStringIndex(); + c = super.getConstantPool().getConstant(i, Const.CONSTANT_Utf8); + buf = "\"" + Utility.convertString(((ConstantUtf8) c).getBytes()) + "\""; + break; + default: + throw new IllegalStateException("Type of ConstValue invalid: " + c); + } + return buf; + } + + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy( final ConstantPool _constant_pool ) { + final ConstantValue c = (ConstantValue) clone(); + c.setConstantPool(_constant_pool); + return c; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Deprecated.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Deprecated.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Deprecated.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Deprecated.java index 0623063e..a5aba52c --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Deprecated.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Deprecated.java @@ -1,141 +1,146 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class is derived from Attribute and denotes that this is a - * deprecated method. - * It is instantiated from the Attribute.readAttribute() method. - * - * @version $Id: Deprecated.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 - */ - 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 - * @throws 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 - * @throws 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 the raw bytes that represents this byte array - */ - 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 = new byte[bytes.length]; - System.arraycopy(bytes, 0, c.bytes, 0, bytes.length); - } - c.constant_pool = _constant_pool; - return c; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class is derived from Attribute and denotes that this is a + * deprecated method. + * It is instantiated from the Attribute.readAttribute() method. + * + * @version $Id: Deprecated.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @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(final 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 + */ + public Deprecated(final int name_index, final int length, final byte[] bytes, final ConstantPool constant_pool) { + super(Const.ATTR_DEPRECATED, name_index, length, constant_pool); + this.bytes = bytes; + } + + + /** + * Construct object from input stream. + * + * @param name_index Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param input Input stream + * @param constant_pool Array of constants + * @throws IOException + */ + Deprecated(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) + throws IOException { + this(name_index, length, (byte[]) null, constant_pool); + if (length > 0) { + bytes = new byte[length]; + input.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitDeprecated(this); + } + + + /** + * Dump source file attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + @Override + public final void dump( final DataOutputStream file ) throws IOException { + super.dump(file); + if (super.getLength() > 0) { + file.write(bytes, 0, super.getLength()); + } + } + + + /** + * @return data bytes. + */ + public final byte[] getBytes() { + return bytes; + } + + + /** + * @param bytes the raw bytes that represents this byte array + */ + public final void setBytes( final byte[] bytes ) { + this.bytes = bytes; + } + + + /** + * @return attribute name + */ + @Override + public final String toString() { + return Const.getAttributeName(Const.ATTR_DEPRECATED); + } + + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy( final ConstantPool _constant_pool ) { + final Deprecated c = (Deprecated) clone(); + if (bytes != null) { + c.bytes = new byte[bytes.length]; + System.arraycopy(bytes, 0, c.bytes, 0, bytes.length); + } + c.setConstantPool(_constant_pool); + return c; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/DescendingVisitor.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/DescendingVisitor.java new file mode 100644 index 00000000..1c3f70f6 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/DescendingVisitor.java @@ -0,0 +1,546 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +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: DescendingVisitor.java 1806489 2017-08-28 19:05:57Z britter $ + */ +public class DescendingVisitor implements Visitor +{ + private final JavaClass clazz; + + private final Visitor visitor; + + private final 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(final int level) + { + final int size = stack.size(); + if ((size < 2) || (level < 0)) + { + return null; + } + 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(final JavaClass clazz, final Visitor visitor) + { + this.clazz = clazz; + this.visitor = visitor; + } + + /** + * Start traversal. + */ + public void visit() + { + clazz.accept(this); + } + + @Override + public void visitJavaClass(final JavaClass _clazz) + { + stack.push(_clazz); + _clazz.accept(visitor); + final Field[] fields = _clazz.getFields(); + for (final Field field : fields) { + field.accept(this); + } + final Method[] methods = _clazz.getMethods(); + for (final Method method : methods) { + method.accept(this); + } + final Attribute[] attributes = _clazz.getAttributes(); + for (final Attribute attribute : attributes) { + attribute.accept(this); + } + _clazz.getConstantPool().accept(this); + stack.pop(); + } + + /** + * @since 6.0 + */ + @Override + public void visitAnnotation(final Annotations annotation) + { + stack.push(annotation); + annotation.accept(visitor); + final AnnotationEntry[] entries = annotation.getAnnotationEntries(); + for (final AnnotationEntry entrie : entries) { + entrie.accept(this); + } + stack.pop(); + } + + /** + * @since 6.0 + */ + @Override + public void visitAnnotationEntry(final AnnotationEntry annotationEntry) + { + stack.push(annotationEntry); + annotationEntry.accept(visitor); + stack.pop(); + } + + @Override + public void visitField(final Field field) + { + stack.push(field); + field.accept(visitor); + final Attribute[] attributes = field.getAttributes(); + for (final Attribute attribute : attributes) { + attribute.accept(this); + } + stack.pop(); + } + + @Override + public void visitConstantValue(final ConstantValue cv) + { + stack.push(cv); + cv.accept(visitor); + stack.pop(); + } + + @Override + public void visitMethod(final Method method) + { + stack.push(method); + method.accept(visitor); + final Attribute[] attributes = method.getAttributes(); + for (final Attribute attribute : attributes) { + attribute.accept(this); + } + stack.pop(); + } + + @Override + public void visitExceptionTable(final ExceptionTable table) + { + stack.push(table); + table.accept(visitor); + stack.pop(); + } + + @Override + public void visitCode(final Code code) + { + stack.push(code); + code.accept(visitor); + final CodeException[] table = code.getExceptionTable(); + for (final CodeException element : table) { + element.accept(this); + } + final Attribute[] attributes = code.getAttributes(); + for (final Attribute attribute : attributes) { + attribute.accept(this); + } + stack.pop(); + } + + @Override + public void visitCodeException(final CodeException ce) + { + stack.push(ce); + ce.accept(visitor); + stack.pop(); + } + + @Override + public void visitLineNumberTable(final LineNumberTable table) + { + stack.push(table); + table.accept(visitor); + final LineNumber[] numbers = table.getLineNumberTable(); + for (final LineNumber number : numbers) { + number.accept(this); + } + stack.pop(); + } + + @Override + public void visitLineNumber(final LineNumber number) + { + stack.push(number); + number.accept(visitor); + stack.pop(); + } + + @Override + public void visitLocalVariableTable(final LocalVariableTable table) + { + stack.push(table); + table.accept(visitor); + final LocalVariable[] vars = table.getLocalVariableTable(); + for (final LocalVariable var : vars) { + var.accept(this); + } + stack.pop(); + } + + @Override + public void visitStackMap(final StackMap table) + { + stack.push(table); + table.accept(visitor); + final StackMapEntry[] vars = table.getStackMap(); + for (final StackMapEntry var : vars) { + var.accept(this); + } + stack.pop(); + } + + @Override + public void visitStackMapEntry(final StackMapEntry var) + { + stack.push(var); + var.accept(visitor); + stack.pop(); + } + + @Override + public void visitLocalVariable(final LocalVariable var) + { + stack.push(var); + var.accept(visitor); + stack.pop(); + } + + @Override + public void visitConstantPool(final ConstantPool cp) + { + stack.push(cp); + cp.accept(visitor); + final Constant[] constants = cp.getConstantPool(); + for (int i = 1; i < constants.length; i++) + { + if (constants[i] != null) + { + constants[i].accept(this); + } + } + stack.pop(); + } + + @Override + public void visitConstantClass(final ConstantClass constant) + { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + @Override + public void visitConstantDouble(final ConstantDouble constant) + { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + @Override + public void visitConstantFieldref(final ConstantFieldref constant) + { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + @Override + public void visitConstantFloat(final ConstantFloat constant) + { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + @Override + public void visitConstantInteger(final ConstantInteger constant) + { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + @Override + public void visitConstantInterfaceMethodref( + final ConstantInterfaceMethodref constant) + { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + /** + * @since 6.0 + */ + @Override + public void visitConstantInvokeDynamic( + final ConstantInvokeDynamic constant) + { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + @Override + public void visitConstantLong(final ConstantLong constant) + { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + @Override + public void visitConstantMethodref(final ConstantMethodref constant) + { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + @Override + public void visitConstantNameAndType(final ConstantNameAndType constant) + { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + @Override + public void visitConstantString(final ConstantString constant) + { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + @Override + public void visitConstantUtf8(final ConstantUtf8 constant) + { + stack.push(constant); + constant.accept(visitor); + stack.pop(); + } + + @Override + public void visitInnerClasses(final InnerClasses ic) + { + stack.push(ic); + ic.accept(visitor); + final InnerClass[] ics = ic.getInnerClasses(); + for (final InnerClass ic2 : ics) { + ic2.accept(this); + } + stack.pop(); + } + + @Override + public void visitInnerClass(final InnerClass inner) + { + stack.push(inner); + inner.accept(visitor); + stack.pop(); + } + + /** + * @since 6.0 + */ + @Override + public void visitBootstrapMethods(final BootstrapMethods bm) + { + stack.push(bm); + bm.accept(visitor); + // BootstrapMethod[] bms = bm.getBootstrapMethods(); + // for (int i = 0; i < bms.length; i++) + // { + // bms[i].accept(this); + // } + stack.pop(); + } + + @Override + public void visitDeprecated(final Deprecated attribute) + { + stack.push(attribute); + attribute.accept(visitor); + stack.pop(); + } + + @Override + public void visitSignature(final Signature attribute) + { + stack.push(attribute); + attribute.accept(visitor); + stack.pop(); + } + + @Override + public void visitSourceFile(final SourceFile attribute) + { + stack.push(attribute); + attribute.accept(visitor); + stack.pop(); + } + + @Override + public void visitSynthetic(final Synthetic attribute) + { + stack.push(attribute); + attribute.accept(visitor); + stack.pop(); + } + + @Override + public void visitUnknown(final Unknown attribute) + { + stack.push(attribute); + attribute.accept(visitor); + stack.pop(); + } + + /** + * @since 6.0 + */ + @Override + public void visitAnnotationDefault(final AnnotationDefault obj) + { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** + * @since 6.0 + */ + @Override + public void visitEnclosingMethod(final EnclosingMethod obj) + { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** + * @since 6.0 + */ + @Override + public void visitLocalVariableTypeTable(final LocalVariableTypeTable obj) + { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** + * @since 6.0 + */ + @Override + public void visitParameterAnnotation(final ParameterAnnotations obj) + { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** + * @since 6.0 + */ + @Override + public void visitMethodParameters(final MethodParameters obj) + { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** @since 6.0 */ + @Override + public void visitConstantMethodType(final ConstantMethodType obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** @since 6.0 */ + @Override + public void visitConstantMethodHandle(final ConstantMethodHandle obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** @since 6.0 */ + @Override + public void visitParameterAnnotationEntry(final ParameterAnnotationEntry obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** @since 6.1 */ + @Override + public void visitConstantPackage(final ConstantPackage obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } + + /** @since 6.1 */ + @Override + public void visitConstantModule(final ConstantModule obj) { + stack.push(obj); + obj.accept(visitor); + stack.pop(); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ElementValue.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ElementValue.java new file mode 100644 index 00000000..ffd7bb96 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ElementValue.java @@ -0,0 +1,131 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * @version $Id: ElementValue + * @since 6.0 + */ +public abstract class ElementValue +{ + /** + * @deprecated (since 6.0) will be made private and final; do not access directly, use getter + */ + @java.lang.Deprecated + protected int type; // TODO should be final + + /** + * @deprecated (since 6.0) will be made private and final; do not access directly, use getter + */ + @java.lang.Deprecated + protected ConstantPool cpool; // TODO should be final + + @Override + public String toString() + { + return stringifyValue(); + } + + protected ElementValue(final int type, final ConstantPool cpool) + { + this.type = type; + this.cpool = cpool; + } + + public int getElementValueType() + { + return type; + } + + public abstract String stringifyValue(); + + public abstract void dump(DataOutputStream dos) throws IOException; + + public static final byte STRING = 's'; + public static final byte ENUM_CONSTANT = 'e'; + public static final byte CLASS = 'c'; + public static final byte ANNOTATION = '@'; + public static final byte ARRAY = '['; + public static final byte PRIMITIVE_INT = 'I'; + public static final byte PRIMITIVE_BYTE = 'B'; + public static final byte PRIMITIVE_CHAR = 'C'; + public static final byte PRIMITIVE_DOUBLE = 'D'; + public static final byte PRIMITIVE_FLOAT = 'F'; + public static final byte PRIMITIVE_LONG = 'J'; + public static final byte PRIMITIVE_SHORT = 'S'; + public static final byte PRIMITIVE_BOOLEAN = 'Z'; + + public static ElementValue readElementValue(final DataInput input, final ConstantPool cpool) throws IOException + { + final byte type = input.readByte(); + switch (type) + { + case PRIMITIVE_BYTE: + case PRIMITIVE_CHAR: + case PRIMITIVE_DOUBLE: + case PRIMITIVE_FLOAT: + case PRIMITIVE_INT: + case PRIMITIVE_LONG: + case PRIMITIVE_SHORT: + case PRIMITIVE_BOOLEAN: + case STRING: + return new SimpleElementValue(type, input.readUnsignedShort(), cpool); + + case ENUM_CONSTANT: + return new EnumElementValue(ENUM_CONSTANT, input.readUnsignedShort(), input.readUnsignedShort(), cpool); + + case CLASS: + return new ClassElementValue(CLASS, input.readUnsignedShort(), cpool); + + case ANNOTATION: + // TODO isRuntimeVisible + return new AnnotationElementValue(ANNOTATION, AnnotationEntry.read(input, cpool, false), cpool); + + case ARRAY: + final int numArrayVals = input.readUnsignedShort(); + final ElementValue[] evalues = new ElementValue[numArrayVals]; + for (int j = 0; j < numArrayVals; j++) + { + evalues[j] = ElementValue.readElementValue(input, cpool); + } + return new ArrayElementValue(ARRAY, evalues, cpool); + + default: + throw new RuntimeException("Unexpected element value kind in annotation: " + type); + } + } + + /** @since 6.0 */ + final ConstantPool getConstantPool() { + return cpool; + } + + /** @since 6.0 */ + final int getType() { + return type; + } + + public String toShortString() + { + return stringifyValue(); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ElementValuePair.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ElementValuePair.java new file mode 100644 index 00000000..672aebe5 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ElementValuePair.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * an annotation's element value pair + * + * @version $Id: ElementValuePair + * @since 6.0 + */ +public class ElementValuePair +{ + private final ElementValue elementValue; + + private final ConstantPool constantPool; + + private final int elementNameIndex; + + public ElementValuePair(final int elementNameIndex, final ElementValue elementValue, + final ConstantPool constantPool) + { + this.elementValue = elementValue; + this.elementNameIndex = elementNameIndex; + this.constantPool = constantPool; + } + + public String getNameString() + { + final ConstantUtf8 c = (ConstantUtf8) constantPool.getConstant( + elementNameIndex, Const.CONSTANT_Utf8); + return c.getBytes(); + } + + public final ElementValue getValue() + { + return elementValue; + } + + public int getNameIndex() + { + return elementNameIndex; + } + + public String toShortString() + { + final StringBuilder result = new StringBuilder(); + result.append(getNameString()).append("=").append( + getValue().toShortString()); + return result.toString(); + } + + protected void dump(final DataOutputStream dos) throws IOException { + dos.writeShort(elementNameIndex); // u2 name of the element + elementValue.dump(dos); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/EmptyVisitor.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/EmptyVisitor.java new file mode 100644 index 00000000..89b343b5 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/EmptyVisitor.java @@ -0,0 +1,313 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +/** + * 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: EmptyVisitor.java 1782852 2017-02-13 20:19:41Z markt $ + */ +public class EmptyVisitor implements Visitor +{ + protected EmptyVisitor() + { + } + + /** + * @since 6.0 + */ + @Override + public void visitAnnotation(final Annotations obj) + { + } + + /** + * @since 6.0 + */ + @Override + public void visitParameterAnnotation(final ParameterAnnotations obj) + { + } + + /** + * @since 6.0 + */ + @Override + public void visitAnnotationEntry(final AnnotationEntry obj) + { + } + + /** + * @since 6.0 + */ + @Override + public void visitAnnotationDefault(final AnnotationDefault obj) + { + } + + @Override + public void visitCode(final Code obj) + { + } + + @Override + public void visitCodeException(final CodeException obj) + { + } + + @Override + public void visitConstantClass(final ConstantClass obj) + { + } + + @Override + public void visitConstantDouble(final ConstantDouble obj) + { + } + + @Override + public void visitConstantFieldref(final ConstantFieldref obj) + { + } + + @Override + public void visitConstantFloat(final ConstantFloat obj) + { + } + + @Override + public void visitConstantInteger(final ConstantInteger obj) + { + } + + @Override + public void visitConstantInterfaceMethodref(final ConstantInterfaceMethodref obj) + { + } + + @Override + public void visitConstantInvokeDynamic(final ConstantInvokeDynamic obj) + { + } + + @Override + public void visitConstantLong(final ConstantLong obj) + { + } + + @Override + public void visitConstantMethodref(final ConstantMethodref obj) + { + } + + @Override + public void visitConstantNameAndType(final ConstantNameAndType obj) + { + } + + @Override + public void visitConstantPool(final ConstantPool obj) + { + } + + @Override + public void visitConstantString(final ConstantString obj) + { + } + + @Override + public void visitConstantUtf8(final ConstantUtf8 obj) + { + } + + @Override + public void visitConstantValue(final ConstantValue obj) + { + } + + @Override + public void visitDeprecated(final Deprecated obj) + { + } + + @Override + public void visitExceptionTable(final ExceptionTable obj) + { + } + + @Override + public void visitField(final Field obj) + { + } + + @Override + public void visitInnerClass(final InnerClass obj) + { + } + + @Override + public void visitInnerClasses(final InnerClasses obj) + { + } + + /** + * @since 6.0 + */ + @Override + public void visitBootstrapMethods(final BootstrapMethods obj) + { + } + + @Override + public void visitJavaClass(final JavaClass obj) + { + } + + @Override + public void visitLineNumber(final LineNumber obj) + { + } + + @Override + public void visitLineNumberTable(final LineNumberTable obj) + { + } + + @Override + public void visitLocalVariable(final LocalVariable obj) + { + } + + @Override + public void visitLocalVariableTable(final LocalVariableTable obj) + { + } + + @Override + public void visitMethod(final Method obj) + { + } + + @Override + public void visitSignature(final Signature obj) + { + } + + @Override + public void visitSourceFile(final SourceFile obj) + { + } + + @Override + public void visitSynthetic(final Synthetic obj) + { + } + + @Override + public void visitUnknown(final Unknown obj) + { + } + + @Override + public void visitStackMap(final StackMap obj) + { + } + + @Override + public void visitStackMapEntry(final StackMapEntry obj) + { + } + + /** + * @since 6.0 + @Override + public void visitStackMapTable(StackMapTable obj) + { + } + */ + + /** + * @since 6.0 + @Override + public void visitStackMapTableEntry(StackMapTableEntry obj) + { + } + */ + + /** + * @since 6.0 + */ + @Override + public void visitEnclosingMethod(final EnclosingMethod obj) + { + } + + /** + * @since 6.0 + */ + @Override + public void visitLocalVariableTypeTable(final LocalVariableTypeTable obj) + { + } + + /** + * @since 6.0 + */ + @Override + public void visitMethodParameters(final MethodParameters obj) + { + } + + /** + * @since 6.0 + */ + @Override + public void visitConstantMethodType(final ConstantMethodType obj) + { + } + + /** + * @since 6.0 + */ + @Override + public void visitConstantMethodHandle(final ConstantMethodHandle constantMethodHandle) { + } + + /** + * @since 6.0 + */ + @Override + public void visitParameterAnnotationEntry(final ParameterAnnotationEntry parameterAnnotationEntry) { + } + + /** + * @since 6.1 + */ + @Override + public void visitConstantPackage(final ConstantPackage constantPackage) { + } + + /** + * @since 6.1 + */ + @Override + public void visitConstantModule(final ConstantModule constantModule) { + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/EnclosingMethod.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/EnclosingMethod.java new file mode 100644 index 00000000..88cbd507 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/EnclosingMethod.java @@ -0,0 +1,106 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This attribute exists for local or + * anonymous classes and ... there can be only one. + * + * @since 6.0 + */ +public class EnclosingMethod extends Attribute { + + // Pointer to the CONSTANT_Class_info structure representing the + // innermost class that encloses the declaration of the current class. + private int classIndex; + + // If the current class is not immediately enclosed by a method or + // constructor, then the value of the method_index item must be zero. + // Otherwise, the value of the method_index item must point to a + // CONSTANT_NameAndType_info structure representing the name and the + // type of a method in the class referenced by the class we point + // to in the class_index. *It is the compiler responsibility* to + // ensure that the method identified by this index is the closest + // lexically enclosing method that includes the local/anonymous class. + private int methodIndex; + + // Ctors - and code to read an attribute in. + EnclosingMethod(final int nameIndex, final int len, final DataInput input, final ConstantPool cpool) throws IOException { + this(nameIndex, len, input.readUnsignedShort(), input.readUnsignedShort(), cpool); + } + + private EnclosingMethod(final int nameIndex, final int len, final int classIdx,final int methodIdx, final ConstantPool cpool) { + super(Const.ATTR_ENCLOSING_METHOD, nameIndex, len, cpool); + classIndex = classIdx; + methodIndex = methodIdx; + } + + @Override + public void accept(final Visitor v) { + v.visitEnclosingMethod(this); + } + + @Override + public Attribute copy(final ConstantPool constant_pool) { + return (Attribute) clone(); + } + + // Accessors + public final int getEnclosingClassIndex() { + return classIndex; + } + + public final int getEnclosingMethodIndex() { + return methodIndex; + } + + public final void setEnclosingClassIndex(final int idx) { + classIndex = idx; + } + + public final void setEnclosingMethodIndex(final int idx) { + methodIndex = idx; + } + + public final ConstantClass getEnclosingClass() { + final ConstantClass c = + (ConstantClass)super.getConstantPool().getConstant(classIndex,Const.CONSTANT_Class); + return c; + } + + public final ConstantNameAndType getEnclosingMethod() { + if (methodIndex == 0) { + return null; + } + final ConstantNameAndType nat = + (ConstantNameAndType)super.getConstantPool().getConstant(methodIndex,Const.CONSTANT_NameAndType); + return nat; + } + + @Override + public final void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(classIndex); + file.writeShort(methodIndex); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/EnumElementValue.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/EnumElementValue.java new file mode 100644 index 00000000..ec5d82dc --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/EnumElementValue.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * @since 6.0 + */ +public class EnumElementValue extends ElementValue +{ + // For enum types, these two indices point to the type and value + private final int typeIdx; + + private final int valueIdx; + + public EnumElementValue(final int type, final int typeIdx, final int valueIdx, + final ConstantPool cpool) + { + super(type, cpool); + if (type != ENUM_CONSTANT) { + throw new RuntimeException( + "Only element values of type enum can be built with this ctor - type specified: " + type); + } + this.typeIdx = typeIdx; + this.valueIdx = valueIdx; + } + + @Override + public void dump(final DataOutputStream dos) throws IOException + { + dos.writeByte(super.getType()); // u1 type of value (ENUM_CONSTANT == 'e') + dos.writeShort(typeIdx); // u2 + dos.writeShort(valueIdx); // u2 + } + + @Override + public String stringifyValue() + { + final ConstantUtf8 cu8 = (ConstantUtf8) super.getConstantPool().getConstant(valueIdx, + Const.CONSTANT_Utf8); + return cu8.getBytes(); + } + + public String getEnumTypeString() + { + final ConstantUtf8 cu8 = (ConstantUtf8) super.getConstantPool().getConstant(typeIdx, + Const.CONSTANT_Utf8); + return cu8.getBytes();// Utility.signatureToString(cu8.getBytes()); + } + + public String getEnumValueString() + { + final ConstantUtf8 cu8 = (ConstantUtf8) super.getConstantPool().getConstant(valueIdx, + Const.CONSTANT_Utf8); + return cu8.getBytes(); + } + + public int getValueIndex() + { + return valueIdx; + } + + public int getTypeIndex() + { + return typeIdx; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ExceptionTable.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ExceptionTable.java old mode 100755 new mode 100644 similarity index 55% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ExceptionTable.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ExceptionTable.java index ba091e55..db7bb8b3 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ExceptionTable.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ExceptionTable.java @@ -1,181 +1,182 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * 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 ExceptionTable for historical reasons; The - * Java Virtual Machine Specification, Second Edition defines this - * attribute using the name Exceptions (which is inconsistent - * with the other classes). - * - * @version $Id: ExceptionTable.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 - * @throws 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 - * @throws 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 the list of exception indexes - * 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() { - StringBuilder buf = new StringBuilder(""); - 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(); - if (exception_index_table != null) { - c.exception_index_table = new int[exception_index_table.length]; - System.arraycopy(exception_index_table, 0, c.exception_index_table, 0, - exception_index_table.length); - } - c.constant_pool = _constant_pool; - return c; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * 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 ExceptionTable for historical reasons; The + * Java Virtual Machine Specification, Second Edition defines this + * attribute using the name Exceptions (which is inconsistent + * with the other classes). + * + * @version $Id: ExceptionTable.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see Code + */ +public final class ExceptionTable extends Attribute { + + 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(final 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(final int name_index, final int length, final int[] exception_index_table, + final ConstantPool constant_pool) { + super(Const.ATTR_EXCEPTIONS, name_index, length, constant_pool); + this.exception_index_table = exception_index_table != null ? exception_index_table : new int[0]; + } + + + /** + * Construct object from input stream. + * @param name_index Index in constant pool + * @param length Content length in bytes + * @param input Input stream + * @param constant_pool Array of constants + * @throws IOException + */ + ExceptionTable(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) throws IOException { + this(name_index, length, (int[]) null, constant_pool); + final int number_of_exceptions = input.readUnsignedShort(); + exception_index_table = new int[number_of_exceptions]; + for (int i = 0; i < number_of_exceptions; i++) { + exception_index_table[i] = input.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitExceptionTable(this); + } + + + /** + * Dump exceptions attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + @Override + public final void dump( final DataOutputStream file ) throws IOException { + super.dump(file); + file.writeShort(exception_index_table.length); + for (final int index : exception_index_table) { + file.writeShort(index); + } + } + + + /** + * @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 exception_index_table == null ? 0 : exception_index_table.length; + } + + + /** + * @return class names of thrown exceptions + */ + public final String[] getExceptionNames() { + final String[] names = new String[exception_index_table.length]; + for (int i = 0; i < exception_index_table.length; i++) { + names[i] = super.getConstantPool().getConstantString(exception_index_table[i], + Const.CONSTANT_Class).replace('/', '.'); + } + return names; + } + + + /** + * @param exception_index_table the list of exception indexes + * Also redefines number_of_exceptions according to table length. + */ + public final void setExceptionIndexTable( final int[] exception_index_table ) { + this.exception_index_table = exception_index_table != null ? exception_index_table : new int[0]; + } + + + /** + * @return String representation, i.e., a list of thrown exceptions. + */ + @Override + public final String toString() { + final StringBuilder buf = new StringBuilder(); + String str; + buf.append("Exceptions: "); + for (int i = 0; i < exception_index_table.length; i++) { + str = super.getConstantPool().getConstantString(exception_index_table[i], Const.CONSTANT_Class); + buf.append(Utility.compactClassName(str, false)); + if (i < exception_index_table.length - 1) { + buf.append(", "); + } + } + return buf.toString(); + } + + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy( final ConstantPool _constant_pool ) { + final ExceptionTable c = (ExceptionTable) clone(); + if (exception_index_table != null) { + c.exception_index_table = new int[exception_index_table.length]; + System.arraycopy(exception_index_table, 0, c.exception_index_table, 0, + exception_index_table.length); + } + c.setConstantPool(_constant_pool); + return c; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Field.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Field.java old mode 100755 new mode 100644 similarity index 56% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Field.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Field.java index b8253936..96da080a --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Field.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Field.java @@ -1,191 +1,199 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.generic.Type; -import org.apache.bcel5_2_0.util.BCELComparator; - -/** - * This class represents the field info structure, i.e., the representation - * for a variable in the class. See JVM specification for details. - * - * @version $Id: Field.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public final class Field extends FieldOrMethod { - - private static BCELComparator _cmp = new BCELComparator() { - - public boolean equals( Object o1, Object o2 ) { - Field THIS = (Field) o1; - Field THAT = (Field) o2; - return THIS.getName().equals(THAT.getName()) - && THIS.getSignature().equals(THAT.getSignature()); - } - - - public int hashCode( Object o ) { - Field THIS = (Field) o; - return THIS.getSignature().hashCode() ^ THIS.getName().hashCode(); - } - }; - - - /** - * 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, - ClassFormatException { - 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(); - StringBuilder buf = new StringBuilder(64); - buf.append(access).append(signature).append(" ").append(name); - ConstantValue cv = getConstantValue(); - if (cv != null) { - buf.append(" = ").append(cv); - } - for (int i = 0; i < attributes_count; i++) { - Attribute a = attributes[i]; - if (!(a instanceof ConstantValue)) { - buf.append(" [").append(a.toString()).append("]"); - } - } - return buf.toString(); - } - - - /** - * @return deep copy of this field - */ - public final Field copy( ConstantPool _constant_pool ) { - return (Field) copy_(_constant_pool); - } - - - /** - * @return type of field - */ - public Type getType() { - return Type.getReturnType(getSignature()); - } - - - /** - * @return Comparison strategy object - */ - public static BCELComparator getComparator() { - return _cmp; - } - - - /** - * @param comparator Comparison strategy object - */ - public static void setComparator( BCELComparator comparator ) { - _cmp = comparator; - } - - - /** - * Return value as defined by given BCELComparator strategy. - * By default two Field objects are said to be equal when - * their names and signatures are equal. - * - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals( Object obj ) { - return _cmp.equals(this, obj); - } - - - /** - * Return value as defined by given BCELComparator strategy. - * By default return the hashcode of the field's name XOR signature. - * - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - return _cmp.hashCode(this); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.IOException; + +import org.apache.bcel.Const; +import org.apache.bcel.generic.Type; +import org.apache.bcel.util.BCELComparator; + +/** + * This class represents the field info structure, i.e., the representation + * for a variable in the class. See JVM specification for details. + * + * @version $Id: Field.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public final class Field extends FieldOrMethod { + + private static BCELComparator bcelComparator = new BCELComparator() { + + @Override + public boolean equals( final Object o1, final Object o2 ) { + final Field THIS = (Field) o1; + final Field THAT = (Field) o2; + return THIS.getName().equals(THAT.getName()) + && THIS.getSignature().equals(THAT.getSignature()); + } + + + @Override + public int hashCode( final Object o ) { + final Field THIS = (Field) o; + return THIS.getSignature().hashCode() ^ THIS.getName().hashCode(); + } + }; + + + /** + * Initialize from another object. Note that both objects use the same + * references (shallow copy). Use clone() for a physical copy. + */ + public Field(final Field c) { + super(c); + } + + + /** + * Construct object from file stream. + * @param file Input stream + */ + Field(final DataInput file, final ConstantPool constant_pool) throws IOException, + ClassFormatException { + 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(final int access_flags, final int name_index, final int signature_index, final Attribute[] attributes, + final 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitField(this); + } + + + /** + * @return constant value associated with this field (may be null) + */ + public final ConstantValue getConstantValue() { + for (final Attribute attribute : super.getAttributes()) { + if (attribute.getTag() == Const.ATTR_CONSTANT_VALUE) { + return (ConstantValue) attribute; + } + } + 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. + */ + @Override + public final String toString() { + String name; + String signature; + String access; // Short cuts to constant pool + + // Get names from constant pool + access = Utility.accessToString(super.getAccessFlags()); + access = access.isEmpty() ? "" : (access + " "); + signature = Utility.signatureToString(getSignature()); + name = getName(); + final StringBuilder buf = new StringBuilder(64); // CHECKSTYLE IGNORE MagicNumber + buf.append(access).append(signature).append(" ").append(name); + final ConstantValue cv = getConstantValue(); + if (cv != null) { + buf.append(" = ").append(cv); + } + for (final Attribute attribute : super.getAttributes()) { + if (!(attribute instanceof ConstantValue)) { + buf.append(" [").append(attribute).append("]"); + } + } + return buf.toString(); + } + + + /** + * @return deep copy of this field + */ + public final Field copy( final ConstantPool _constant_pool ) { + return (Field) copy_(_constant_pool); + } + + + /** + * @return type of field + */ + public Type getType() { + return Type.getReturnType(getSignature()); + } + + + /** + * @return Comparison strategy object + */ + public static BCELComparator getComparator() { + return bcelComparator; + } + + + /** + * @param comparator Comparison strategy object + */ + public static void setComparator( final BCELComparator comparator ) { + bcelComparator = comparator; + } + + + /** + * Return value as defined by given BCELComparator strategy. + * By default two Field objects are said to be equal when + * their names and signatures are equal. + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals( final Object obj ) { + return bcelComparator.equals(this, obj); + } + + + /** + * Return value as defined by given BCELComparator strategy. + * By default return the hashcode of the field's name XOR signature. + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return bcelComparator.hashCode(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/FieldOrMethod.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/FieldOrMethod.java new file mode 100644 index 00000000..331d9835 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/FieldOrMethod.java @@ -0,0 +1,293 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * Abstract super class for fields and methods. + * + * @version $Id: FieldOrMethod.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public abstract class FieldOrMethod extends AccessFlags implements Cloneable, Node { + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @java.lang.Deprecated + protected int name_index; // Points to field name in constant pool + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @java.lang.Deprecated + protected int signature_index; // Points to encoded signature + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @java.lang.Deprecated + protected Attribute[] attributes; // Collection of attributes + + /** + * @deprecated (since 6.0) will be removed (not needed) + */ + @java.lang.Deprecated + protected int attributes_count; // No. of attributes + + // @since 6.0 + private AnnotationEntry[] annotationEntries; // annotations defined on the field or method + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @java.lang.Deprecated + protected ConstantPool constant_pool; + + private String signatureAttributeString = null; + private boolean searchedForSignatureAttribute = false; + + FieldOrMethod() { + } + + + /** + * Initialize from another object. Note that both objects use the same + * references (shallow copy). Use clone() for a physical copy. + */ + protected FieldOrMethod(final FieldOrMethod c) { + this(c.getAccessFlags(), c.getNameIndex(), c.getSignatureIndex(), c.getAttributes(), c + .getConstantPool()); + } + + + /** + * Construct object from file stream. + * @param file Input stream + * @throws IOException + * @throws ClassFormatException + * @deprecated (6.0) Use {@link #FieldOrMethod(java.io.DataInput, ConstantPool)} instead. + */ + @java.lang.Deprecated + protected FieldOrMethod(final DataInputStream file, final ConstantPool constant_pool) throws IOException, + ClassFormatException { + this((DataInput) file, constant_pool); + } + + /** + * Construct object from file stream. + * @param file Input stream + * @throws IOException + * @throws ClassFormatException + */ + protected FieldOrMethod(final DataInput file, final ConstantPool constant_pool) throws IOException, ClassFormatException { + this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), null, + constant_pool); + final int attributes_count = file.readUnsignedShort(); + attributes = new Attribute[attributes_count]; + for (int i = 0; i < attributes_count; i++) { + attributes[i] = Attribute.readAttribute(file, constant_pool); + } + this.attributes_count = attributes_count; // init deprecated field + } + + + /** + * @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(final int access_flags, final int name_index, final int signature_index, + final Attribute[] attributes, final ConstantPool constant_pool) { + super(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 + * @throws IOException + */ + public final void dump( final DataOutputStream file ) throws IOException { + file.writeShort(super.getAccessFlags()); + file.writeShort(name_index); + file.writeShort(signature_index); + file.writeShort(attributes.length); + for (final Attribute attribute : attributes) { + attribute.dump(file); + } + } + + + /** + * @return Collection of object attributes. + */ + public final Attribute[] getAttributes() { + return attributes; + } + + + /** + * @param attributes Collection of object attributes. + */ + public final void setAttributes( final Attribute[] attributes ) { + this.attributes = attributes; + this.attributes_count = attributes != null ? attributes.length : 0; // init deprecated field + } + + + /** + * @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( final 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( final 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( final 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, Const.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, Const.CONSTANT_Utf8); + return c.getBytes(); + } + + + /** + * @return deep copy of this field + */ + protected FieldOrMethod copy_( final ConstantPool _constant_pool ) { + FieldOrMethod c = null; + + try { + c = (FieldOrMethod)clone(); + } catch(final CloneNotSupportedException e) { + // ignored, but will cause NPE ... + } + + c.constant_pool = constant_pool; + c.attributes = new Attribute[attributes.length]; + c.attributes_count = attributes_count; // init deprecated field + + for (int i = 0; i < attributes.length; i++) { + c.attributes[i] = attributes[i].copy(constant_pool); + } + + return c; + } + + /** + * @return Annotations on the field or method + * @since 6.0 + */ + public AnnotationEntry[] getAnnotationEntries() { + if (annotationEntries == null) { + annotationEntries = AnnotationEntry.createAnnotationEntries(getAttributes()); + } + + return annotationEntries; + } + + /** + * Hunts for a signature attribute on the member and returns its contents. So where the 'regular' signature + * may be (Ljava/util/Vector;)V the signature attribute may in fact say 'Ljava/lang/Vector<Ljava/lang/String>;' + * Coded for performance - searches for the attribute only when requested - only searches for it once. + * @since 6.0 + */ + public final String getGenericSignature() + { + if (!searchedForSignatureAttribute) + { + boolean found = false; + for (int i = 0; !found && i < attributes.length; i++) + { + if (attributes[i] instanceof Signature) + { + signatureAttributeString = ((Signature) attributes[i]) + .getSignature(); + found = true; + } + } + searchedForSignatureAttribute = true; + } + return signatureAttributeString; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/InnerClass.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/InnerClass.java old mode 100755 new mode 100644 similarity index 64% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/InnerClass.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/InnerClass.java index 825eb261..ca34f1c8 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/InnerClass.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/InnerClass.java @@ -1,215 +1,217 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.Serializable; - -import org.apache.bcel5_2_0.Constants; - -/** - * 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: InnerClass.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @see InnerClasses - */ -public final class InnerClass implements Cloneable, Node, Serializable { - - 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 - * @throws 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 - * @throws 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 access flags for this inner class - */ - public final void setInnerAccessFlags( int inner_access_flags ) { - this.inner_access_flags = inner_access_flags; - } - - - /** - * @param inner_class_index index into the constant pool for this class - */ - public final void setInnerClassIndex( int inner_class_index ) { - this.inner_class_index = inner_class_index; - } - - - /** - * @param inner_name_index index into the constant pool for this class's name - */ - public final void setInnerNameIndex( int inner_name_index ) { - this.inner_name_index = inner_name_index; - } - - - /** - * @param outer_class_index index into the constant pool for the owning class - */ - 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 = ""; - } - if (inner_name_index != 0) { - inner_name = ((ConstantUtf8) constant_pool.getConstant(inner_name_index, - Constants.CONSTANT_Utf8)).getBytes(); - } else { - inner_name = ""; - } - 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; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * 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: InnerClass.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @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(final InnerClass c) { + this(c.getInnerClassIndex(), c.getOuterClassIndex(), c.getInnerNameIndex(), c + .getInnerAccessFlags()); + } + + + /** + * Construct object from file stream. + * @param file Input stream + * @throws IOException + */ + InnerClass(final DataInput 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(final int inner_class_index, final int outer_class_index, final int inner_name_index, + final 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitInnerClass(this); + } + + + /** + * Dump inner class attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + public final void dump( final 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 access flags for this inner class + */ + public final void setInnerAccessFlags( final int inner_access_flags ) { + this.inner_access_flags = inner_access_flags; + } + + + /** + * @param inner_class_index index into the constant pool for this class + */ + public final void setInnerClassIndex( final int inner_class_index ) { + this.inner_class_index = inner_class_index; + } + + + /** + * @param inner_name_index index into the constant pool for this class's name + */ + public final void setInnerNameIndex( final int inner_name_index ) { // TODO unused + this.inner_name_index = inner_name_index; + } + + + /** + * @param outer_class_index index into the constant pool for the owning class + */ + public final void setOuterClassIndex( final int outer_class_index ) { // TODO unused + this.outer_class_index = outer_class_index; + } + + + /** + * @return String representation. + */ + @Override + 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( final ConstantPool constant_pool ) { + String outer_class_name; + String inner_name; + String inner_class_name = constant_pool.getConstantString(inner_class_index, + Const.CONSTANT_Class); + inner_class_name = Utility.compactClassName(inner_class_name); + if (outer_class_index != 0) { + outer_class_name = constant_pool.getConstantString(outer_class_index, + Const.CONSTANT_Class); + outer_class_name = " of class " + Utility.compactClassName(outer_class_name); + } else { + outer_class_name = ""; + } + if (inner_name_index != 0) { + inner_name = ((ConstantUtf8) constant_pool.getConstant(inner_name_index, + Const.CONSTANT_Utf8)).getBytes(); + } else { + inner_name = "(anonymous)"; + } + String access = Utility.accessToString(inner_access_flags, true); + access = access.isEmpty() ? "" : (access + " "); + return " " + access + inner_name + "=class " + inner_class_name + outer_class_name; + } + + + /** + * @return deep copy of this object + */ + public InnerClass copy() { + try { + return (InnerClass) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/InnerClasses.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/InnerClasses.java old mode 100755 new mode 100644 similarity index 51% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/InnerClasses.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/InnerClasses.java index 90c31cdc..9faaf6ab --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/InnerClasses.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/InnerClasses.java @@ -1,151 +1,157 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class is derived from Attribute and denotes that this class - * is an Inner class of another. - * to the source file of this class. - * It is instantiated from the Attribute.readAttribute() method. - * - * @version $Id: InnerClasses.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 - */ - 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 - * @throws 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 - * @throws 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 the array of 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() { - StringBuilder buf = new StringBuilder(); - for (int i = 0; i < number_of_classes; i++) { - buf.append(inner_classes[i].toString(constant_pool)).append("\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; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class is derived from Attribute and denotes that this class + * is an Inner class of another. + * to the source file of this class. + * It is instantiated from the Attribute.readAttribute() method. + * + * @version $Id: InnerClasses.java 1749603 2016-06-21 20:50:19Z ggregory $ + * @see Attribute + */ +public final class InnerClasses extends Attribute { + + private InnerClass[] inner_classes; + + + /** + * Initialize from another object. Note that both objects use the same + * references (shallow copy). Use clone() for a physical copy. + */ + public InnerClasses(final 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 + */ + public InnerClasses(final int name_index, final int length, final InnerClass[] inner_classes, + final ConstantPool constant_pool) { + super(Const.ATTR_INNER_CLASSES, name_index, length, constant_pool); + this.inner_classes = inner_classes != null ? inner_classes : new InnerClass[0]; + } + + + /** + * Construct object from input stream. + * + * @param name_index Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param input Input stream + * @param constant_pool Array of constants + * @throws IOException + */ + InnerClasses(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) + throws IOException { + this(name_index, length, (InnerClass[]) null, constant_pool); + final int number_of_classes = input.readUnsignedShort(); + inner_classes = new InnerClass[number_of_classes]; + for (int i = 0; i < number_of_classes; i++) { + inner_classes[i] = new InnerClass(input); + } + } + + + /** + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitInnerClasses(this); + } + + + /** + * Dump source file attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + @Override + public final void dump( final DataOutputStream file ) throws IOException { + super.dump(file); + file.writeShort(inner_classes.length); + for (final InnerClass inner_class : inner_classes) { + inner_class.dump(file); + } + } + + + /** + * @return array of inner class "records" + */ + public final InnerClass[] getInnerClasses() { + return inner_classes; + } + + + /** + * @param inner_classes the array of inner classes + */ + public final void setInnerClasses( final InnerClass[] inner_classes ) { + this.inner_classes = inner_classes != null ? inner_classes : new InnerClass[0]; + } + + + /** + * @return String representation. + */ + @Override + public final String toString() { + final StringBuilder buf = new StringBuilder(); + buf.append("InnerClasses("); + buf.append(inner_classes.length); + buf.append("):\n"); + for (final InnerClass inner_class : inner_classes) { + buf.append(inner_class.toString(super.getConstantPool())).append("\n"); + } + return buf.toString(); + } + + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy( final ConstantPool _constant_pool ) { + // TODO this could be recoded to use a lower level constructor after creating a copy of the inner classes + final InnerClasses c = (InnerClasses) clone(); + c.inner_classes = new InnerClass[inner_classes.length]; + for (int i = 0; i < inner_classes.length; i++) { + c.inner_classes[i] = inner_classes[i].copy(); + } + c.setConstantPool(_constant_pool); + return c; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/JavaClass.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/JavaClass.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/JavaClass.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/JavaClass.java index 652a3156..fe615c8a --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/JavaClass.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/JavaClass.java @@ -1,867 +1,929 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.StringTokenizer; -import java.util.TreeSet; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.generic.Type; -import org.apache.bcel5_2_0.util.BCELComparator; -import org.apache.bcel5_2_0.util.ClassQueue; -import org.apache.bcel5_2_0.util.SyntheticRepository; - -/** - * Represents a Java class, i.e., the data structures, constant pool, - * fields, methods and commands contained in a Java .class file. - * See JVM specification for details. - * The intent of this class is to represent a parsed or otherwise existing - * class file. Those interested in programatically generating classes - * should see the ClassGen class. - - * @version $Id: JavaClass.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @see org.apache.bcel5_2_0.generic.ClassGen - * @author M. Dahm - */ -public class JavaClass extends AccessFlags implements Cloneable, Node, Comparable { - - private String file_name; - private String package_name; - private String source_file_name = ""; - 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 - private static BCELComparator _cmp = new BCELComparator() { - - public boolean equals( Object o1, Object o2 ) { - JavaClass THIS = (JavaClass) o1; - JavaClass THAT = (JavaClass) o2; - return THIS.getClassName().equals(THAT.getClassName()); - } - - - public int hashCode( Object o ) { - JavaClass THIS = (JavaClass) o; - return THIS.getClassName().hashCode(); - } - }; - /** - * In cases where we go ahead and create something, - * use the default SyntheticRepository, because we - * don't know any better. - */ - private transient org.apache.bcel5_2_0.util.Repository repository = SyntheticRepository - .getInstance(); - - - /** - * Constructor gets all contents as arguments. - * - * @param class_name_index Index into constant pool referencing a - * ConstantClass that represents this class. - * @param superclass_name_index Index into constant pool referencing a - * ConstantClass that represents this class's superclass. - * @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) { - interfaces = new int[0]; - } - if (attributes == null) { - 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; - } - } - /* 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_index Class name - * @param superclass_name_index 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 - * @throws IOException - */ - public void dump( File file ) throws IOException { - String parent = file.getParent(); - if (parent != null) { - File dir = new File(parent); - dir.mkdirs(); - } - DataOutputStream dos = null; - try { - dos = new DataOutputStream(new FileOutputStream(file)); - dump(dos); - } finally { - if (dos != null) { - dos.close(); - } - } - } - - - /** - * 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); - } catch (IOException e) { - e.printStackTrace(); - } finally { - try { - ds.close(); - } catch (IOException e2) { - e2.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.flush(); - } - - - /** - * @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. Like the JVM spec - * mandates for the classfile format, these fields are those specific to - * this class, and not those of the superclass or superinterfaces. - */ - 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 Indices in constant pool of implemented interfaces. - */ - public int[] getInterfaceIndices() { - return interfaces; - } - - - /** - * @return Major number of class file version. - */ - public int getMajor() { - return major; - } - - - /** - * @return Methods of the class. - */ - public Method[] getMethods() { - return methods; - } - - - /** - * @return A org.apache.bcel.classfile.Method corresponding to - * java.lang.reflect.Method if any - */ - public Method getMethod( java.lang.reflect.Method m ) { - for (int i = 0; i < methods.length; i++) { - Method method = methods[i]; - if (m.getName().equals(method.getName()) && (m.getModifiers() == method.getModifiers()) - && Type.getSignature(m).equals(method.getSignature())) { - return method; - } - } - return null; - } - - - /** - * @return Minor number of class file 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 - debug = Boolean.getBoolean("JavaClass.debug"); - // 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 + " "); - StringBuilder buf = new StringBuilder(128); - buf.append(access).append(Utility.classOrInterface(access_flags)).append(" ").append( - class_name).append(" extends ").append( - Utility.compactClassName(superclass_name, false)).append('\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").append(file_name).append('\n'); - buf.append("compiled from\t\t").append(source_file_name).append('\n'); - buf.append("compiler version\t").append(major).append(".").append(minor).append('\n'); - buf.append("access flags\t\t").append(access_flags).append('\n'); - buf.append("constant pool\t\t").append(constant_pool.getLength()).append(" entries\n"); - buf.append("ACC_SUPER flag\t\t").append(isSuper()).append("\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").append(fields.length).append(" fields:\n"); - for (int i = 0; i < fields.length; i++) { - buf.append("\t").append(fields[i]).append('\n'); - } - } - if (methods.length > 0) { - buf.append("\n").append(methods.length).append(" methods:\n"); - for (int i = 0; i < methods.length; i++) { - buf.append("\t").append(methods[i]).append('\n'); - } - } - return buf.toString(); - } - - - private static final String indent( Object obj ) { - StringTokenizer tok = new StringTokenizer(obj.toString(), "\n"); - StringBuilder buf = new StringBuilder(); - while (tok.hasMoreTokens()) { - buf.append("\t").append(tok.nextToken()).append("\n"); - } - return buf.toString(); - } - - - /** - * @return deep copy of this class - */ - public JavaClass copy() { - JavaClass c = null; - try { - c = (JavaClass) clone(); - 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); - } - } catch (CloneNotSupportedException e) { - } - return c; - } - - - 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; - } - - - /********************* New repository functionality *********************/ - /** - * Gets the ClassRepository which holds its definition. By default - * this is the same as SyntheticRepository.getInstance(); - */ - public org.apache.bcel5_2_0.util.Repository getRepository() { - return repository; - } - - - /** - * Sets the ClassRepository which loaded the JavaClass. - * Should be called immediately after parsing is done. - */ - public void setRepository( org.apache.bcel5_2_0.util.Repository repository ) { - this.repository = repository; - } - - - /** Equivalent to runtime "instanceof" operator. - * - * @return true if this JavaClass is derived from the super class - * @throws ClassNotFoundException if superclasses or superinterfaces - * of this object can't be found - */ - public final boolean instanceOf( JavaClass super_class ) throws ClassNotFoundException { - if (this.equals(super_class)) { - return true; - } - JavaClass[] super_classes = getSuperClasses(); - for (int i = 0; i < super_classes.length; i++) { - if (super_classes[i].equals(super_class)) { - return true; - } - } - if (super_class.isInterface()) { - return implementationOf(super_class); - } - return false; - } - - - /** - * @return true, if this class is an implementation of interface inter - * @throws ClassNotFoundException if superclasses or superinterfaces - * of this class can't be found - */ - public boolean implementationOf( JavaClass inter ) throws ClassNotFoundException { - if (!inter.isInterface()) { - throw new IllegalArgumentException(inter.getClassName() + " is no interface"); - } - if (this.equals(inter)) { - return true; - } - JavaClass[] super_interfaces = getAllInterfaces(); - for (int i = 0; i < super_interfaces.length; i++) { - if (super_interfaces[i].equals(inter)) { - return true; - } - } - return false; - } - - - /** - * @return the superclass for this JavaClass object, or null if this - * is java.lang.Object - * @throws ClassNotFoundException if the superclass can't be found - */ - public JavaClass getSuperClass() throws ClassNotFoundException { - if ("java.lang.Object".equals(getClassName())) { - return null; - } - return repository.loadClass(getSuperclassName()); - } - - - /** - * @return list of super classes of this class in ascending order, i.e., - * java.lang.Object is always the last element - * @throws ClassNotFoundException if any of the superclasses can't be found - */ - public JavaClass[] getSuperClasses() throws ClassNotFoundException { - JavaClass clazz = this; - List allSuperClasses = new ArrayList(); - for (clazz = clazz.getSuperClass(); clazz != null; clazz = clazz.getSuperClass()) { - allSuperClasses.add(clazz); - } - return (JavaClass[]) allSuperClasses.toArray(new JavaClass[allSuperClasses.size()]); - } - - - /** - * Get interfaces directly implemented by this JavaClass. - */ - public JavaClass[] getInterfaces() throws ClassNotFoundException { - String[] _interfaces = getInterfaceNames(); - JavaClass[] classes = new JavaClass[_interfaces.length]; - for (int i = 0; i < _interfaces.length; i++) { - classes[i] = repository.loadClass(_interfaces[i]); - } - return classes; - } - - - /** - * Get all interfaces implemented by this JavaClass (transitively). - */ - public JavaClass[] getAllInterfaces() throws ClassNotFoundException { - ClassQueue queue = new ClassQueue(); - Set allInterfaces = new TreeSet(); - queue.enqueue(this); - while (!queue.empty()) { - JavaClass clazz = queue.dequeue(); - JavaClass souper = clazz.getSuperClass(); - JavaClass[] _interfaces = clazz.getInterfaces(); - if (clazz.isInterface()) { - allInterfaces.add(clazz); - } else { - if (souper != null) { - queue.enqueue(souper); - } - } - for (int i = 0; i < _interfaces.length; i++) { - queue.enqueue(_interfaces[i]); - } - } - return (JavaClass[]) allInterfaces.toArray(new JavaClass[allInterfaces.size()]); - } - - - /** - * @return Comparison strategy object - */ - public static BCELComparator getComparator() { - return _cmp; - } - - - /** - * @param comparator Comparison strategy object - */ - public static void setComparator( BCELComparator comparator ) { - _cmp = comparator; - } - - - /** - * Return value as defined by given BCELComparator strategy. - * By default two JavaClass objects are said to be equal when - * their class names are equal. - * - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals( Object obj ) { - return _cmp.equals(this, obj); - } - - - /** - * Return the natural ordering of two JavaClasses. - * This ordering is based on the class name - */ - public int compareTo( Object obj ) { - return getClassName().compareTo(((JavaClass) obj).getClassName()); - } - - - /** - * Return value as defined by given BCELComparator strategy. - * By default return the hashcode of the class name. - * - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - return _cmp.hashCode(this); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.StringTokenizer; +import java.util.TreeSet; + +import org.apache.bcel.Const; +import org.apache.bcel.generic.Type; +import org.apache.bcel.util.BCELComparator; +import org.apache.bcel.util.ClassQueue; +import org.apache.bcel.util.SyntheticRepository; + +/** + * Represents a Java class, i.e., the data structures, constant pool, + * fields, methods and commands contained in a Java .class file. + * See JVM specification for details. + * The intent of this class is to represent a parsed or otherwise existing + * class file. Those interested in programatically generating classes + * should see the ClassGen class. + + * @version $Id: JavaClass.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see org.apache.bcel.generic.ClassGen + */ +public class JavaClass extends AccessFlags implements Cloneable, Node, Comparable { + + private String file_name; + private String package_name; + private String source_file_name = ""; + private int class_name_index; + private int superclass_name_index; + private String class_name; + private String superclass_name; + private int major; + private int 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 AnnotationEntry[] annotations; // annotations defined on the class + private byte source = HEAP; // Generated in memory + private boolean isAnonymous = false; + private boolean isNested = false; + private boolean computedNestedTypeStatus = false; + public static final byte HEAP = 1; + public static final byte FILE = 2; + public static final byte ZIP = 3; + private static final boolean debug = Boolean.getBoolean("JavaClass.debug"); // Debugging on/off + + private static BCELComparator bcelComparator = new BCELComparator() { + + @Override + public boolean equals( final Object o1, final Object o2 ) { + final JavaClass THIS = (JavaClass) o1; + final JavaClass THAT = (JavaClass) o2; + return THIS.getClassName().equals(THAT.getClassName()); + } + + + @Override + public int hashCode( final Object o ) { + final JavaClass THIS = (JavaClass) o; + return THIS.getClassName().hashCode(); + } + }; + /** + * In cases where we go ahead and create something, + * use the default SyntheticRepository, because we + * don't know any better. + */ + private transient org.apache.bcel.util.Repository repository = SyntheticRepository + .getInstance(); + + + /** + * Constructor gets all contents as arguments. + * + * @param class_name_index Index into constant pool referencing a + * ConstantClass that represents this class. + * @param superclass_name_index Index into constant pool referencing a + * ConstantClass that represents this class's superclass. + * @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(final int class_name_index, final int superclass_name_index, final String file_name, final int major, + final int minor, final int access_flags, final ConstantPool constant_pool, int[] interfaces, + Field[] fields, Method[] methods, Attribute[] attributes, final byte source) { + super(access_flags); + if (interfaces == null) { + interfaces = new int[0]; + } + if (attributes == null) { + 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.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 (final Attribute attribute : attributes) { + if (attribute instanceof SourceFile) { + source_file_name = ((SourceFile) attribute).getSourceFileName(); + break; + } + } + /* 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, Const.CONSTANT_Class); + class_name = Utility.compactClassName(class_name, false); + final 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, + Const.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++) { + final String str = constant_pool.getConstantString(interfaces[i], Const.CONSTANT_Class); + interface_names[i] = Utility.compactClassName(str, false); + } + } + + + /** + * Constructor gets all contents as arguments. + * + * @param class_name_index Class name + * @param superclass_name_index 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(final int class_name_index, final int superclass_name_index, final String file_name, final int major, + final int minor, final int access_flags, final ConstantPool constant_pool, final int[] interfaces, + final Field[] fields, final Method[] methods, final 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitJavaClass(this); + } + + + /* Print debug information depending on `JavaClass.debug' + */ + static void Debug( final String str ) { + if (debug) { + System.out.println(str); + } + } + + + /** + * Dump class to a file. + * + * @param file Output file + * @throws IOException + */ + public void dump(final File file) throws IOException { + final String parent = file.getParent(); + if (parent != null) { + final File dir = new File(parent); + if (!dir.mkdirs()) { // either was not created or already existed + if (!dir.isDirectory()) { + throw new IOException("Could not create the directory " + dir); + } + } + } + try (DataOutputStream dos = new DataOutputStream(new FileOutputStream(file))) { + dump(dos); + } + } + + + /** + * Dump class to a file named file_name. + * + * @param _file_name Output file name + * @throws IOException + */ + public void dump( final String _file_name ) throws IOException { + dump(new File(_file_name)); + } + + + /** + * @return class in binary format + */ + public byte[] getBytes() { + final ByteArrayOutputStream s = new ByteArrayOutputStream(); + final DataOutputStream ds = new DataOutputStream(s); + try { + dump(ds); + } catch (final IOException e) { + e.printStackTrace(); + } finally { + try { + ds.close(); + } catch (final IOException e2) { + e2.printStackTrace(); + } + } + return s.toByteArray(); + } + + + /** + * Dump Java class to output stream in binary format. + * + * @param file Output stream + * @throws IOException + */ + public void dump( final OutputStream file ) throws IOException { + dump(new DataOutputStream(file)); + } + + + /** + * Dump Java class to output stream in binary format. + * + * @param file Output stream + * @throws IOException + */ + public void dump( final DataOutputStream file ) throws IOException { + file.writeInt(Const.JVM_CLASSFILE_MAGIC); + file.writeShort(minor); + file.writeShort(major); + constant_pool.dump(file); + file.writeShort(super.getAccessFlags()); + file.writeShort(class_name_index); + file.writeShort(superclass_name_index); + file.writeShort(interfaces.length); + for (final int interface1 : interfaces) { + file.writeShort(interface1); + } + file.writeShort(fields.length); + for (final Field field : fields) { + field.dump(file); + } + file.writeShort(methods.length); + for (final Method method : methods) { + method.dump(file); + } + if (attributes != null) { + file.writeShort(attributes.length); + for (final Attribute attribute : attributes) { + attribute.dump(file); + } + } else { + file.writeShort(0); + } + file.flush(); + } + + + /** + * @return Attributes of the class. + */ + public Attribute[] getAttributes() { + return attributes; + } + + /** + * @return Annotations on the class + * @since 6.0 + */ + public AnnotationEntry[] getAnnotationEntries() { + if (annotations == null) { + annotations = AnnotationEntry.createAnnotationEntries(getAttributes()); + } + + return annotations; + } + + /** + * @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. Like the JVM spec + * mandates for the classfile format, these fields are those specific to + * this class, and not those of the superclass or superinterfaces. + */ + 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 Indices in constant pool of implemented interfaces. + */ + public int[] getInterfaceIndices() { + return interfaces; + } + + + /** + * @return Major number of class file version. + */ + public int getMajor() { + return major; + } + + + /** + * @return Methods of the class. + */ + public Method[] getMethods() { + return methods; + } + + + /** + * @return A {@link Method} corresponding to + * java.lang.reflect.Method if any + */ + public Method getMethod( final java.lang.reflect.Method m ) { + for (final Method method : methods) { + if (m.getName().equals(method.getName()) && (m.getModifiers() == method.getModifiers()) + && Type.getSignature(m).equals(method.getSignature())) { + return method; + } + } + return null; + } + + + /** + * @return Minor number of class file version. + */ + public int getMinor() { + return minor; + } + + + /** + * @return sbsolute path to file where this class was read from + */ + public String getSourceFileName() { + return source_file_name; + } + + + /** + * returns the super class name of this class. In the case that this class is + * java.lang.Object, it will return itself (java.lang.Object). This is probably incorrect + * but isn't fixed at this time to not break existing clients. + * + * @return Superclass name. + */ + public String getSuperclassName() { + return superclass_name; + } + + + /** + * @return Class name index. + */ + public int getSuperclassNameIndex() { + return superclass_name_index; + } + + /** + * @param attributes . + */ + public void setAttributes( final Attribute[] attributes ) { + this.attributes = attributes; + } + + + /** + * @param class_name . + */ + public void setClassName( final String class_name ) { + this.class_name = class_name; + } + + + /** + * @param class_name_index . + */ + public void setClassNameIndex( final int class_name_index ) { + this.class_name_index = class_name_index; + } + + + /** + * @param constant_pool . + */ + public void setConstantPool( final ConstantPool constant_pool ) { + this.constant_pool = constant_pool; + } + + + /** + * @param fields . + */ + public void setFields( final Field[] fields ) { + this.fields = fields; + } + + + /** + * Set File name of class, aka SourceFile attribute value + */ + public void setFileName( final String file_name ) { + this.file_name = file_name; + } + + + /** + * @param interface_names . + */ + public void setInterfaceNames( final String[] interface_names ) { + this.interface_names = interface_names; + } + + + /** + * @param interfaces . + */ + public void setInterfaces( final int[] interfaces ) { + this.interfaces = interfaces; + } + + + /** + * @param major . + */ + public void setMajor( final int major ) { + this.major = major; + } + + + /** + * @param methods . + */ + public void setMethods( final Method[] methods ) { + this.methods = methods; + } + + + /** + * @param minor . + */ + public void setMinor( final int minor ) { + this.minor = minor; + } + + + /** + * Set absolute path to file this class was read from. + */ + public void setSourceFileName( final String source_file_name ) { + this.source_file_name = source_file_name; + } + + + /** + * @param superclass_name . + */ + public void setSuperclassName( final String superclass_name ) { + this.superclass_name = superclass_name; + } + + + /** + * @param superclass_name_index . + */ + public void setSuperclassNameIndex( final int superclass_name_index ) { + this.superclass_name_index = superclass_name_index; + } + + + /** + * @return String representing class contents. + */ + @Override + public String toString() { + String access = Utility.accessToString(super.getAccessFlags(), true); + access = access.isEmpty() ? "" : (access + " "); + final StringBuilder buf = new StringBuilder(128); + buf.append(access).append(Utility.classOrInterface(super.getAccessFlags())).append(" ").append( + class_name).append(" extends ").append( + Utility.compactClassName(superclass_name, false)).append('\n'); + final 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").append(file_name).append('\n'); + buf.append("compiled from\t\t").append(source_file_name).append('\n'); + buf.append("compiler version\t").append(major).append(".").append(minor).append('\n'); + buf.append("access flags\t\t").append(super.getAccessFlags()).append('\n'); + buf.append("constant pool\t\t").append(constant_pool.getLength()).append(" entries\n"); + buf.append("ACC_SUPER flag\t\t").append(isSuper()).append("\n"); + if (attributes.length > 0) { + buf.append("\nAttribute(s):\n"); + for (final Attribute attribute : attributes) { + buf.append(indent(attribute)); + } + } + final AnnotationEntry[] annotations = getAnnotationEntries(); + if (annotations!=null && annotations.length>0) { + buf.append("\nAnnotation(s):\n"); + for (final AnnotationEntry annotation : annotations) { + buf.append(indent(annotation)); + } + } + if (fields.length > 0) { + buf.append("\n").append(fields.length).append(" fields:\n"); + for (final Field field : fields) { + buf.append("\t").append(field).append('\n'); + } + } + if (methods.length > 0) { + buf.append("\n").append(methods.length).append(" methods:\n"); + for (final Method method : methods) { + buf.append("\t").append(method).append('\n'); + } + } + return buf.toString(); + } + + + private static String indent( final Object obj ) { + final StringTokenizer tok = new StringTokenizer(obj.toString(), "\n"); + final StringBuilder buf = new StringBuilder(); + while (tok.hasMoreTokens()) { + buf.append("\t").append(tok.nextToken()).append("\n"); + } + return buf.toString(); + } + + + /** + * @return deep copy of this class + */ + public JavaClass copy() { + JavaClass c = null; + try { + c = (JavaClass) clone(); + c.constant_pool = constant_pool.copy(); + c.interfaces = interfaces.clone(); + c.interface_names = 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); + } + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return c; + } + + + public final boolean isSuper() { + return (super.getAccessFlags() & Const.ACC_SUPER) != 0; + } + + + public final boolean isClass() { + return (super.getAccessFlags() & Const.ACC_INTERFACE) == 0; + } + + /** + * @since 6.0 + */ + public final boolean isAnonymous() { + computeNestedTypeStatus(); + return this.isAnonymous; + } + + /** + * @since 6.0 + */ + public final boolean isNested() { + computeNestedTypeStatus(); + return this.isNested; + } + + private void computeNestedTypeStatus() { + if (computedNestedTypeStatus) { + return; + } + for (final Attribute attribute : this.attributes) { + if (attribute instanceof InnerClasses) { + final InnerClass[] innerClasses = ((InnerClasses) attribute).getInnerClasses(); + for (final InnerClass innerClasse : innerClasses) { + boolean innerClassAttributeRefersToMe = false; + String inner_class_name = constant_pool.getConstantString(innerClasse.getInnerClassIndex(), + Const.CONSTANT_Class); + inner_class_name = Utility.compactClassName(inner_class_name); + if (inner_class_name.equals(getClassName())) { + innerClassAttributeRefersToMe = true; + } + if (innerClassAttributeRefersToMe) { + this.isNested = true; + if (innerClasse.getInnerNameIndex() == 0) { + this.isAnonymous = true; + } + } + } + } + } + this.computedNestedTypeStatus = true; + } + + + /** @return returns either HEAP (generated), FILE, or ZIP + */ + public final byte getSource() { + return source; + } + + + /********************* New repository functionality *********************/ + /** + * Gets the ClassRepository which holds its definition. By default + * this is the same as SyntheticRepository.getInstance(); + */ + public org.apache.bcel.util.Repository getRepository() { + return repository; + } + + + /** + * Sets the ClassRepository which loaded the JavaClass. + * Should be called immediately after parsing is done. + */ + public void setRepository( final org.apache.bcel.util.Repository repository ) { // TODO make protected? + this.repository = repository; + } + + + /** Equivalent to runtime "instanceof" operator. + * + * @return true if this JavaClass is derived from the super class + * @throws ClassNotFoundException if superclasses or superinterfaces + * of this object can't be found + */ + public final boolean instanceOf( final JavaClass super_class ) throws ClassNotFoundException { + if (this.equals(super_class)) { + return true; + } + final JavaClass[] super_classes = getSuperClasses(); + for (final JavaClass super_classe : super_classes) { + if (super_classe.equals(super_class)) { + return true; + } + } + if (super_class.isInterface()) { + return implementationOf(super_class); + } + return false; + } + + + /** + * @return true, if this class is an implementation of interface inter + * @throws ClassNotFoundException if superclasses or superinterfaces + * of this class can't be found + */ + public boolean implementationOf( final JavaClass inter ) throws ClassNotFoundException { + if (!inter.isInterface()) { + throw new IllegalArgumentException(inter.getClassName() + " is no interface"); + } + if (this.equals(inter)) { + return true; + } + final JavaClass[] super_interfaces = getAllInterfaces(); + for (final JavaClass super_interface : super_interfaces) { + if (super_interface.equals(inter)) { + return true; + } + } + return false; + } + + + /** + * @return the superclass for this JavaClass object, or null if this + * is java.lang.Object + * @throws ClassNotFoundException if the superclass can't be found + */ + public JavaClass getSuperClass() throws ClassNotFoundException { + if ("java.lang.Object".equals(getClassName())) { + return null; + } + return repository.loadClass(getSuperclassName()); + } + + + /** + * @return list of super classes of this class in ascending order, i.e., + * java.lang.Object is always the last element + * @throws ClassNotFoundException if any of the superclasses can't be found + */ + public JavaClass[] getSuperClasses() throws ClassNotFoundException { + JavaClass clazz = this; + final List allSuperClasses = new ArrayList<>(); + for (clazz = clazz.getSuperClass(); clazz != null; clazz = clazz.getSuperClass()) { + allSuperClasses.add(clazz); + } + return allSuperClasses.toArray(new JavaClass[allSuperClasses.size()]); + } + + + /** + * Get interfaces directly implemented by this JavaClass. + */ + public JavaClass[] getInterfaces() throws ClassNotFoundException { + final String[] _interfaces = getInterfaceNames(); + final JavaClass[] classes = new JavaClass[_interfaces.length]; + for (int i = 0; i < _interfaces.length; i++) { + classes[i] = repository.loadClass(_interfaces[i]); + } + return classes; + } + + + /** + * Get all interfaces implemented by this JavaClass (transitively). + */ + public JavaClass[] getAllInterfaces() throws ClassNotFoundException { + final ClassQueue queue = new ClassQueue(); + final Set allInterfaces = new TreeSet<>(); + queue.enqueue(this); + while (!queue.empty()) { + final JavaClass clazz = queue.dequeue(); + final JavaClass souper = clazz.getSuperClass(); + final JavaClass[] _interfaces = clazz.getInterfaces(); + if (clazz.isInterface()) { + allInterfaces.add(clazz); + } else { + if (souper != null) { + queue.enqueue(souper); + } + } + for (final JavaClass _interface : _interfaces) { + queue.enqueue(_interface); + } + } + return allInterfaces.toArray(new JavaClass[allInterfaces.size()]); + } + + + /** + * @return Comparison strategy object + */ + public static BCELComparator getComparator() { + return bcelComparator; + } + + + /** + * @param comparator Comparison strategy object + */ + public static void setComparator( final BCELComparator comparator ) { + bcelComparator = comparator; + } + + + /** + * Return value as defined by given BCELComparator strategy. + * By default two JavaClass objects are said to be equal when + * their class names are equal. + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals( final Object obj ) { + return bcelComparator.equals(this, obj); + } + + + /** + * Return the natural ordering of two JavaClasses. + * This ordering is based on the class name + * @since 6.0 + */ + @Override + public int compareTo( final JavaClass obj ) { + return getClassName().compareTo(obj.getClassName()); + } + + + /** + * Return value as defined by given BCELComparator strategy. + * By default return the hashcode of the class name. + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return bcelComparator.hashCode(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/LineNumber.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LineNumber.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/LineNumber.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LineNumber.java index ca59b115..6d6f86b9 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/LineNumber.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LineNumber.java @@ -1,141 +1,148 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.Serializable; - -/** - * 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: LineNumber.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @see LineNumberTable - */ -public final class LineNumber implements Cloneable, Node, Serializable { - - 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 - * @throws 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 - * @throws 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 the source line number - */ - public final void setLineNumber( int line_number ) { - this.line_number = line_number; - } - - - /** - * @param start_pc the pc for this line number - */ - 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; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * 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: LineNumber.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see LineNumberTable + */ +public final class LineNumber implements Cloneable, Node { + + /** Program Counter (PC) corresponds to line */ + private short start_pc; + + /** number in source file */ + private short line_number; + + /** + * Initialize from another object. + * + * @param c the object to copy + */ + public LineNumber(final LineNumber c) { + this(c.getStartPC(), c.getLineNumber()); + } + + + /** + * Construct object from file stream. + * + * @param file Input stream + * @throws IOEXception if an I/O Exception occurs in readUnsignedShort + */ + LineNumber(final DataInput 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(final int start_pc, final int line_number) { + this.start_pc = (short) start_pc; + this.line_number = (short)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 + */ + @Override + public void accept( final Visitor v ) { + v.visitLineNumber(this); + } + + + /** + * Dump line number/pc pair to file stream in binary format. + * + * @param file Output file stream + * @throws IOEXception if an I/O Exception occurs in writeShort + */ + public final void dump( final DataOutputStream file ) throws IOException { + file.writeShort(start_pc); + file.writeShort(line_number); + } + + + /** + * @return Corresponding source line + */ + public final int getLineNumber() { + return 0xffff & line_number; + } + + + /** + * @return PC in code + */ + public final int getStartPC() { + return 0xffff & start_pc; + } + + + /** + * @param line_number the source line number + */ + public final void setLineNumber( final int line_number ) { + this.line_number = (short) line_number; + } + + + /** + * @param start_pc the pc for this line number + */ + public final void setStartPC( final int start_pc ) { + this.start_pc = (short) start_pc; + } + + + /** + * @return String representation + */ + @Override + public final String toString() { + return "LineNumber(" + start_pc + ", " + line_number + ")"; + } + + + /** + * @return deep copy of this object + */ + public LineNumber copy() { + try { + return (LineNumber) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/LineNumberTable.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LineNumberTable.java old mode 100755 new mode 100644 similarity index 55% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/LineNumberTable.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LineNumberTable.java index 5a92a8ab..698b37cb --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/LineNumberTable.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LineNumberTable.java @@ -1,209 +1,216 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class represents a table of line numbers for debugging - * purposes. This attribute is used by the Code attribute. It - * contains pairs of PCs and line numbers. - * - * @version $Id: LineNumberTable.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 - * @param constant_pool Array of constants - * @throws IOException - */ - 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 - * @throws 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 the line number entries for this 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() { - StringBuilder buf = new StringBuilder(); - StringBuilder line = new StringBuilder(); - String newLine = System.getProperty("line.separator", "\n"); - 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(newLine); - buf.append(line.toString()); - 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) { - 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) { - r = i - 1; - } else { - 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); - /* It's possible that we did not find any valid entry for the bytecode - * offset we were looking for. - */ - if (min_index < 0) { - return -1; - } - 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; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class represents a table of line numbers for debugging + * purposes. This attribute is used by the Code attribute. It + * contains pairs of PCs and line numbers. + * + * @version $Id: LineNumberTable.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see Code + * @see LineNumber + */ +public final class LineNumberTable extends Attribute { + + private static final int MAX_LINE_LENGTH = 72; + 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(final 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(final int name_index, final int length, final LineNumber[] line_number_table, + final ConstantPool constant_pool) { + super(Const.ATTR_LINE_NUMBER_TABLE, name_index, length, constant_pool); + this.line_number_table = line_number_table; + } + + + /** + * Construct object from input stream. + * @param name_index Index of name + * @param length Content length in bytes + * @param input Input stream + * @param constant_pool Array of constants + * @throws IOEXception if an I/O Exception occurs in readUnsignedShort + */ + LineNumberTable(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) + throws IOException { + this(name_index, length, (LineNumber[]) null, constant_pool); + final int line_number_table_length = input.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(input); + } + } + + + /** + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitLineNumberTable(this); + } + + + /** + * Dump line number table attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOEXception if an I/O Exception occurs in writeShort + */ + @Override + public final void dump( final DataOutputStream file ) throws IOException { + super.dump(file); + file.writeShort(line_number_table.length); + for (final LineNumber lineNumber : line_number_table) { + lineNumber.dump(file); + } + } + + + /** + * @return Array of (pc offset, line number) pairs. + */ + public final LineNumber[] getLineNumberTable() { + return line_number_table; + } + + + /** + * @param line_number_table the line number entries for this table + */ + public final void setLineNumberTable( final LineNumber[] line_number_table ) { + this.line_number_table = line_number_table; + } + + + /** + * @return String representation. + */ + @Override + public final String toString() { + final StringBuilder buf = new StringBuilder(); + final StringBuilder line = new StringBuilder(); + final String newLine = System.getProperty("line.separator", "\n"); + 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() > MAX_LINE_LENGTH) && (i < line_number_table.length - 1)) { + line.append(newLine); + 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( final int pos ) { + int l = 0; + int r = line_number_table.length - 1; + if (r < 0) { + return -1; + } + int min_index = -1; + int min = -1; + /* Do a binary search since the array is ordered. + */ + do { + final int i = (l + r) / 2; + final int j = line_number_table[i].getStartPC(); + if (j == pos) { + return line_number_table[i].getLineNumber(); + } else if (pos < j) { + r = i - 1; + } else { + 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); + /* It's possible that we did not find any valid entry for the bytecode + * offset we were looking for. + */ + if (min_index < 0) { + return -1; + } + return line_number_table[min_index].getLineNumber(); + } + + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy( final ConstantPool _constant_pool ) { + // TODO could use the lower level constructor and thereby allow + // line_number_table to be made final + final 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.setConstantPool(_constant_pool); + return c; + } + + + public final int getTableLength() { + return line_number_table == null ? 0 : line_number_table.length; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/LocalVariable.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LocalVariable.java old mode 100755 new mode 100644 similarity index 58% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/LocalVariable.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LocalVariable.java index 52892885..5c14904d --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/LocalVariable.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LocalVariable.java @@ -1,249 +1,294 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.Serializable; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class represents a local variable within a method. It contains its - * scope, name, signature and index on the method's frame. - * - * @version $Id: LocalVariable.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @see LocalVariableTable - */ -public final class LocalVariable implements Constants, Cloneable, Node, Serializable { - - 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 - * @throws 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 - * @throws 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 the length of this local variable - */ - public final void setLength( int length ) { - this.length = length; - } - - - /** - * @param name_index the index into the constant pool for the name of this variable - */ - public final void setNameIndex( int name_index ) { - this.name_index = name_index; - } - - - /** - * @param signature_index the index into the constant pool for the signature of this variable - */ - public final void setSignatureIndex( int signature_index ) { - this.signature_index = signature_index; - } - - - /** - * @param index the index in the local variable table of this variable - */ - 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; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; +import org.apache.bcel.Constants; + +/** + * This class represents a local variable within a method. It contains its + * scope, name, signature and index on the method's frame. + * + * @version $Id: LocalVariable.java 1806728 2017-08-30 19:34:23Z britter $ + * @see LocalVariableTable + */ +public final class LocalVariable implements Cloneable, Node, Constants { + + 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; + private int orig_index; // never changes; used to match up with LocalVariableTypeTable entries + + + /** + * Initialize from another object. Note that both objects use the same + * references (shallow copy). Use copy() for a physical copy. + */ + public LocalVariable(final LocalVariable c) { + this(c.getStartPC(), c.getLength(), c.getNameIndex(), c.getSignatureIndex(), c.getIndex(), + c.getConstantPool()); + this.orig_index = c.getOrigIndex(); + } + + + /** + * Construct object from file stream. + * @param file Input stream + * @throws IOException + */ + LocalVariable(final DataInput file, final 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(final int start_pc, final int length, final int name_index, final int signature_index, final int index, + final 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; + this.orig_index = index; + } + + + /** + * @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 + * @param orig_index Variable is `index'th local variable on the method's frame prior to any changes + */ + public LocalVariable(final int start_pc, final int length, final int name_index, final int signature_index, final int index, + final ConstantPool constant_pool, final int orig_index) { + 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; + this.orig_index = orig_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 + */ + @Override + public void accept( final Visitor v ) { + v.visitLocalVariable(this); + } + + + /** + * Dump local variable to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + public final void dump( final 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, Const.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, Const.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 index of register where variable was originally stored + */ + public final int getOrigIndex() { + return orig_index; + } + + + /** + * @return Start of range where he variable is valid + */ + public final int getStartPC() { + return start_pc; + } + + + /* + * Helper method shared with LocalVariableTypeTable + */ + final String toStringShared( final boolean typeTable ) { + final String name = getName(); + final String signature = Utility.signatureToString(getSignature(), false); + final String label = "LocalVariable" + (typeTable ? "Types" : "" ); + return label + "(start_pc = " + start_pc + ", length = " + length + ", index = " + + index + ":" + signature + " " + name + ")"; + } + + + /** + * @param constant_pool Constant pool to be used for this object. + */ + public final void setConstantPool( final ConstantPool constant_pool ) { + this.constant_pool = constant_pool; + } + + + /** + * @param length the length of this local variable + */ + public final void setLength( final int length ) { + this.length = length; + } + + + /** + * @param name_index the index into the constant pool for the name of this variable + */ + public final void setNameIndex( final int name_index ) { // TODO unused + this.name_index = name_index; + } + + + /** + * @param signature_index the index into the constant pool for the signature of this variable + */ + public final void setSignatureIndex( final int signature_index ) { // TODO unused + this.signature_index = signature_index; + } + + + /** + * @param index the index in the local variable table of this variable + */ + public final void setIndex( final int index ) { // TODO unused + this.index = index; + } + + + /** + * @param start_pc Specify range where the local variable is valid. + */ + public final void setStartPC( final int start_pc ) { // TODO unused + this.start_pc = start_pc; + } + + + /** + * @return string representation. + */ + @Override + public final String toString() { + return toStringShared(false); + } + + + /** + * @return deep copy of this object + */ + public LocalVariable copy() { + try { + return (LocalVariable) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/LocalVariableTable.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LocalVariableTable.java old mode 100755 new mode 100644 similarity index 51% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/LocalVariableTable.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LocalVariableTable.java index 2c9d22b8..9e9822c8 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/LocalVariableTable.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LocalVariableTable.java @@ -1,198 +1,197 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class represents colection of local variables in a - * method. This attribute is contained in the Code attribute. - * - * @version $Id: LocalVariableTable.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 - * @throws 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 - * @throws 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 - * - * @param index the variable slot - * - * @return the first LocalVariable that matches the slot or null if not found - * - * @deprecated since 5.2 because multiple variables can share the - * same slot, use getLocalVariable(int index, int pc) instead. - */ - 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; - } - - - /** - * @return matching variable using index when variable is used at supplied pc - * - * @param index the variable slot - * @param pc the current pc that this variable is alive - * - * @return the LocalVariable that matches or null if not found - */ - public final LocalVariable getLocalVariable( int index, int pc ) { - for (int i = 0; i < local_variable_table_length; i++) { - if (local_variable_table[i].getIndex() == index) { - int start_pc = local_variable_table[i].getStartPC(); - int end_pc = start_pc + local_variable_table[i].getLength(); - if ((pc >= start_pc) && (pc < end_pc)) { - 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() { - StringBuilder buf = new StringBuilder(""); - 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; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class represents colection of local variables in a + * method. This attribute is contained in the Code attribute. + * + * @version $Id: LocalVariableTable.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see Code + * @see LocalVariable + */ +public class LocalVariableTable extends Attribute { + + 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(final 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(final int name_index, final int length, final LocalVariable[] local_variable_table, + final ConstantPool constant_pool) { + super(Const.ATTR_LOCAL_VARIABLE_TABLE, name_index, length, constant_pool); + this.local_variable_table = local_variable_table; + } + + + /** + * Construct object from input stream. + * @param name_index Index in constant pool + * @param length Content length in bytes + * @param input Input stream + * @param constant_pool Array of constants + * @throws IOException + */ + LocalVariableTable(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) + throws IOException { + this(name_index, length, (LocalVariable[]) null, constant_pool); + final int local_variable_table_length = input.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(input, 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitLocalVariableTable(this); + } + + + /** + * Dump local variable table attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + @Override + public final void dump( final DataOutputStream file ) throws IOException { + super.dump(file); + file.writeShort(local_variable_table.length); + for (final LocalVariable variable : local_variable_table) { + variable.dump(file); + } + } + + + /** + * @return Array of local variables of method. + */ + public final LocalVariable[] getLocalVariableTable() { + return local_variable_table; + } + + + /** + * + * @param index the variable slot + * + * @return the first LocalVariable that matches the slot or null if not found + * + * @deprecated since 5.2 because multiple variables can share the + * same slot, use getLocalVariable(int index, int pc) instead. + */ + @java.lang.Deprecated + public final LocalVariable getLocalVariable( final int index ) { + for (final LocalVariable variable : local_variable_table) { + if (variable.getIndex() == index) { + return variable; + } + } + return null; + } + + + /** + * + * @param index the variable slot + * @param pc the current pc that this variable is alive + * + * @return the LocalVariable that matches or null if not found + */ + public final LocalVariable getLocalVariable( final int index, final int pc ) { + for (final LocalVariable variable : local_variable_table) { + if (variable.getIndex() == index) { + final int start_pc = variable.getStartPC(); + final int end_pc = start_pc + variable.getLength(); + if ((pc >= start_pc) && (pc <= end_pc)) { + return variable; + } + } + } + return null; + } + + + public final void setLocalVariableTable( final LocalVariable[] local_variable_table ) { + this.local_variable_table = local_variable_table; + } + + + /** + * @return String representation. + */ + @Override + public final String toString() { + final StringBuilder buf = new StringBuilder(); + for (int i = 0; i < local_variable_table.length; i++) { + buf.append(local_variable_table[i]); + if (i < local_variable_table.length - 1) { + buf.append('\n'); + } + } + return buf.toString(); + } + + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy( final ConstantPool _constant_pool ) { + final 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.setConstantPool(_constant_pool); + return c; + } + + + public final int getTableLength() { + return local_variable_table == null ? 0 : local_variable_table.length; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LocalVariableTypeTable.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LocalVariableTypeTable.java new file mode 100644 index 00000000..1ed60ba9 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LocalVariableTypeTable.java @@ -0,0 +1,150 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +// The new table is used when generic types are about... + +//LocalVariableTable_attribute { +// u2 attribute_name_index; +// u4 attribute_length; +// u2 local_variable_table_length; +// { u2 start_pc; +// u2 length; +// u2 name_index; +// u2 descriptor_index; +// u2 index; +// } local_variable_table[local_variable_table_length]; +// } + +//LocalVariableTypeTable_attribute { +// u2 attribute_name_index; +// u4 attribute_length; +// u2 local_variable_type_table_length; +// { +// u2 start_pc; +// u2 length; +// u2 name_index; +// u2 signature_index; +// u2 index; +// } local_variable_type_table[local_variable_type_table_length]; +// } +// J5TODO: Needs some testing ! + +/** + * @since 6.0 + */ +public class LocalVariableTypeTable extends Attribute { + + private LocalVariable[] local_variable_type_table; // variables + + public LocalVariableTypeTable(final LocalVariableTypeTable c) { + this(c.getNameIndex(), c.getLength(), c.getLocalVariableTypeTable(), c.getConstantPool()); + } + + public LocalVariableTypeTable(final int name_index, final int length, final LocalVariable[] local_variable_table, final ConstantPool constant_pool) { + super(Const.ATTR_LOCAL_VARIABLE_TYPE_TABLE, name_index, length, constant_pool); + this.local_variable_type_table = local_variable_table; + } + + LocalVariableTypeTable(final int nameIdx, final int len, final DataInput input, final ConstantPool cpool) throws IOException { + this(nameIdx, len, (LocalVariable[]) null, cpool); + + final int local_variable_type_table_length = input.readUnsignedShort(); + local_variable_type_table = new LocalVariable[local_variable_type_table_length]; + + for (int i = 0; i < local_variable_type_table_length; i++) { + local_variable_type_table[i] = new LocalVariable(input, cpool); + } + } + + @Override + public void accept(final Visitor v) { + v.visitLocalVariableTypeTable(this); + } + + @Override + public final void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeShort(local_variable_type_table.length); + for (final LocalVariable variable : local_variable_type_table) { + variable.dump(file); + } + } + + public final LocalVariable[] getLocalVariableTypeTable() { + return local_variable_type_table; + } + + public final LocalVariable getLocalVariable(final int index) { + for (final LocalVariable variable : local_variable_type_table) { + if (variable.getIndex() == index) { + return variable; + } + } + + return null; + } + + public final void setLocalVariableTable(final LocalVariable[] local_variable_table) { + this.local_variable_type_table = local_variable_table; + } + + /** + * @return String representation. + */ + @Override + public final String toString() { + final StringBuilder buf = new StringBuilder(); + + for (int i = 0; i < local_variable_type_table.length; i++) { + buf.append(local_variable_type_table[i].toStringShared(true)); + + if (i < local_variable_type_table.length - 1) { + buf.append('\n'); + } + } + + return buf.toString(); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constant_pool) { + final LocalVariableTypeTable c = (LocalVariableTypeTable) clone(); + + c.local_variable_type_table = new LocalVariable[local_variable_type_table.length]; + for (int i = 0; i < local_variable_type_table.length; i++) { + c.local_variable_type_table[i] = local_variable_type_table[i].copy(); + } + + c.setConstantPool(constant_pool); + return c; + } + + public final int getTableLength() { + return local_variable_type_table == null ? 0 : local_variable_type_table.length; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Method.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Method.java old mode 100755 new mode 100644 similarity index 56% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Method.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Method.java index 889e8e3b..a490f11f --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Method.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Method.java @@ -1,255 +1,270 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.generic.Type; -import org.apache.bcel5_2_0.util.BCELComparator; - -/** - * 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: Method.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public final class Method extends FieldOrMethod { - - private static BCELComparator _cmp = new BCELComparator() { - - public boolean equals( Object o1, Object o2 ) { - Method THIS = (Method) o1; - Method THAT = (Method) o2; - return THIS.getName().equals(THAT.getName()) - && THIS.getSignature().equals(THAT.getSignature()); - } - - - public int hashCode( Object o ) { - Method THIS = (Method) o; - return THIS.getSignature().hashCode() ^ THIS.getName().hashCode(); - } - }; - - - /** - * 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 - * @throws IOException - * @throws ClassFormatException - */ - Method(DataInputStream file, ConstantPool constant_pool) throws IOException, - ClassFormatException { - 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 null; - } - return code.getLocalVariableTable(); - } - - - /** @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 null; - } - return code.getLineNumberTable(); - } - - - /** - * 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; - String name, signature, access; // Short cuts to constant pool - StringBuilder buf; - 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 StringBuilder(signature); - for (int i = 0; i < attributes_count; i++) { - Attribute a = attributes[i]; - if (!((a instanceof Code) || (a instanceof ExceptionTable))) { - buf.append(" [").append(a.toString()).append("]"); - } - } - ExceptionTable e = getExceptionTable(); - if (e != null) { - String str = e.toString(); - if (!str.equals("")) { - buf.append("\n\t\tthrows ").append(str); - } - } - return buf.toString(); - } - - - /** - * @return deep copy of this method - */ - public final Method copy( ConstantPool _constant_pool ) { - return (Method) copy_(_constant_pool); - } - - - /** - * @return return type of method - */ - public Type getReturnType() { - return Type.getReturnType(getSignature()); - } - - - /** - * @return array of method argument types - */ - public Type[] getArgumentTypes() { - return Type.getArgumentTypes(getSignature()); - } - - - /** - * @return Comparison strategy object - */ - public static BCELComparator getComparator() { - return _cmp; - } - - - /** - * @param comparator Comparison strategy object - */ - public static void setComparator( BCELComparator comparator ) { - _cmp = comparator; - } - - - /** - * Return value as defined by given BCELComparator strategy. - * By default two method objects are said to be equal when - * their names and signatures are equal. - * - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals( Object obj ) { - return _cmp.equals(this, obj); - } - - - /** - * Return value as defined by given BCELComparator strategy. - * By default return the hashcode of the method's name XOR signature. - * - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - return _cmp.hashCode(this); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.IOException; + +import org.apache.bcel.Const; +import org.apache.bcel.generic.Type; +import org.apache.bcel.util.BCELComparator; + +/** + * 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: Method.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public final class Method extends FieldOrMethod { + + private static BCELComparator bcelComparator = new BCELComparator() { + + @Override + public boolean equals( final Object o1, final Object o2 ) { + final Method THIS = (Method) o1; + final Method THAT = (Method) o2; + return THIS.getName().equals(THAT.getName()) + && THIS.getSignature().equals(THAT.getSignature()); + } + + + @Override + public int hashCode( final Object o ) { + final Method THIS = (Method) o; + return THIS.getSignature().hashCode() ^ THIS.getName().hashCode(); + } + }; + + // annotations defined on the parameters of a method + private ParameterAnnotationEntry[] parameterAnnotationEntries; + + /** + * 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(final Method c) { + super(c); + } + + + /** + * Construct object from file stream. + * @param file Input stream + * @throws IOException + * @throws ClassFormatException + */ + Method(final DataInput file, final ConstantPool constant_pool) throws IOException, + ClassFormatException { + 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(final int access_flags, final int name_index, final int signature_index, final Attribute[] attributes, + final 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitMethod(this); + } + + + /** + * @return Code attribute of method, if any + */ + public final Code getCode() { + for (final Attribute attribute : super.getAttributes()) { + if (attribute instanceof Code) { + return (Code) attribute; + } + } + 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 (final Attribute attribute : super.getAttributes()) { + if (attribute instanceof ExceptionTable) { + return (ExceptionTable) attribute; + } + } + return null; + } + + + /** @return LocalVariableTable of code attribute if any, i.e. the call is forwarded + * to the Code atribute. + */ + public final LocalVariableTable getLocalVariableTable() { + final Code code = getCode(); + if (code == null) { + return null; + } + return code.getLocalVariableTable(); + } + + + /** @return LineNumberTable of code attribute if any, i.e. the call is forwarded + * to the Code atribute. + */ + public final LineNumberTable getLineNumberTable() { + final Code code = getCode(); + if (code == null) { + return null; + } + return code.getLineNumberTable(); + } + + + /** + * Return string representation close to declaration format, + * `public static void main(String[] args) throws IOException', e.g. + * + * @return String representation of the method. + */ + @Override + public final String toString() { + final String access = Utility.accessToString(super.getAccessFlags()); + // Get name and signature from constant pool + ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(super.getSignatureIndex(), Const.CONSTANT_Utf8); + String signature = c.getBytes(); + c = (ConstantUtf8) super.getConstantPool().getConstant(super.getNameIndex(), Const.CONSTANT_Utf8); + final String name = c.getBytes(); + signature = Utility.methodSignatureToString(signature, name, access, true, + getLocalVariableTable()); + final StringBuilder buf = new StringBuilder(signature); + for (final Attribute attribute : super.getAttributes()) { + if (!((attribute instanceof Code) || (attribute instanceof ExceptionTable))) { + buf.append(" [").append(attribute).append("]"); + } + } + final ExceptionTable e = getExceptionTable(); + if (e != null) { + final String str = e.toString(); + if (!str.isEmpty()) { + buf.append("\n\t\tthrows ").append(str); + } + } + return buf.toString(); + } + + + /** + * @return deep copy of this method + */ + public final Method copy( final ConstantPool _constant_pool ) { + return (Method) copy_(_constant_pool); + } + + + /** + * @return return type of method + */ + public Type getReturnType() { + return Type.getReturnType(getSignature()); + } + + + /** + * @return array of method argument types + */ + public Type[] getArgumentTypes() { + return Type.getArgumentTypes(getSignature()); + } + + + /** + * @return Comparison strategy object + */ + public static BCELComparator getComparator() { + return bcelComparator; + } + + + /** + * @param comparator Comparison strategy object + */ + public static void setComparator( final BCELComparator comparator ) { + bcelComparator = comparator; + } + + + /** + * Return value as defined by given BCELComparator strategy. + * By default two method objects are said to be equal when + * their names and signatures are equal. + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals( final Object obj ) { + return bcelComparator.equals(this, obj); + } + + + /** + * Return value as defined by given BCELComparator strategy. + * By default return the hashcode of the method's name XOR signature. + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return bcelComparator.hashCode(this); + } + + /** + * @return Annotations on the parameters of a method + * @since 6.0 + */ + public ParameterAnnotationEntry[] getParameterAnnotationEntries() { + if (parameterAnnotationEntries == null) { + parameterAnnotationEntries = ParameterAnnotationEntry.createParameterAnnotationEntries(getAttributes()); + } + return parameterAnnotationEntries; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/MethodParameter.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/MethodParameter.java new file mode 100644 index 00000000..4d2a1481 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/MethodParameter.java @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * Entry of the parameters table. + * + * @see + * The class File Format : The MethodParameters Attribute + * @since 6.0 + */ +public class MethodParameter implements Cloneable { + + /** Index of the CONSTANT_Utf8_info structure in the constant_pool table representing the name of the parameter */ + private int name_index; + + /** The access flags */ + private int access_flags; + + public MethodParameter() { + } + + /** + * Construct object from input stream. + * + * @param input Input stream + * @throws java.io.IOException + * @throws ClassFormatException + */ + MethodParameter(final DataInput input) throws IOException { + name_index = input.readUnsignedShort(); + access_flags = input.readUnsignedShort(); + } + + public int getNameIndex() { + return name_index; + } + + public void setNameIndex(final int name_index) { + this.name_index = name_index; + } + + /** + * Returns the name of the parameter. + */ + public String getParameterName(final ConstantPool constant_pool) { + if (name_index == 0) { + return null; + } + return ((ConstantUtf8) constant_pool.getConstant(name_index, Const.CONSTANT_Utf8)).getBytes(); + } + + public int getAccessFlags() { + return access_flags; + } + + public void setAccessFlags(final int access_flags) { + this.access_flags = access_flags; + } + + public boolean isFinal() { + return (access_flags & Const.ACC_FINAL) != 0; + } + + public boolean isSynthetic() { + return (access_flags & Const.ACC_SYNTHETIC) != 0; + } + + public boolean isMandated() { + return (access_flags & Const.ACC_MANDATED) != 0; + } + + /** + * Dump object to file stream on binary format. + * + * @param file Output file stream + * @throws IOException + */ + public final void dump(final DataOutputStream file) throws IOException { + file.writeShort(name_index); + file.writeShort(access_flags); + } + + /** + * @return deep copy of this object + */ + public MethodParameter copy() { + try { + return (MethodParameter) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + return null; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/MethodParameters.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/MethodParameters.java new file mode 100644 index 00000000..f27ccba4 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/MethodParameters.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class represents a MethodParameters attribute. + * + * @see + * The class File Format : The MethodParameters Attribute + * @since 6.0 + */ +public class MethodParameters extends Attribute { + + private MethodParameter[] parameters = new MethodParameter[0]; + + MethodParameters(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) throws IOException { + super(Const.ATTR_METHOD_PARAMETERS, name_index, length, constant_pool); + + final int parameters_count = input.readUnsignedByte(); + parameters = new MethodParameter[parameters_count]; + for (int i = 0; i < parameters_count; i++) { + parameters[i] = new MethodParameter(input); + } + } + + public MethodParameter[] getParameters() { + return parameters; + } + + public void setParameters(final MethodParameter[] parameters) { + this.parameters = parameters; + } + + @Override + public void accept(final Visitor v) { + v.visitMethodParameters(this); + } + + @Override + public Attribute copy(final ConstantPool _constant_pool) { + final MethodParameters c = (MethodParameters) clone(); + c.parameters = new MethodParameter[parameters.length]; + + for (int i = 0; i < parameters.length; i++) { + c.parameters[i] = parameters[i].copy(); + } + c.setConstantPool(_constant_pool); + return c; + } + + /** + * Dump method parameters attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + @Override + public void dump(final DataOutputStream file) throws IOException { + super.dump(file); + file.writeByte(parameters.length); + for (final MethodParameter parameter : parameters) { + parameter.dump(file); + } + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Node.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Node.java new file mode 100644 index 00000000..32c27907 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Node.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +/** + * Denote class to have an accept method(); + * + * @version $Id: Node.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public interface Node { + + void accept( Visitor obj ); +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/PMGClass.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/PMGClass.java old mode 100755 new mode 100644 similarity index 58% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/PMGClass.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/PMGClass.java index 393b5666..40ede360 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/PMGClass.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/PMGClass.java @@ -1,168 +1,173 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class is derived from Attribute and represents a reference - * to a PMG attribute. - * - * @version $Id: PMGClass.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 - * @throws 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 pmg_index index in constant pool for source file name - * @param pmg_class_index Index in constant pool to CONSTANT_Utf8 - * @param constant_pool Array of constants - */ - 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 - * @throws 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 pmg_class_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 pmg_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(); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class is derived from Attribute and represents a reference + * to a PMG attribute. + * + * @version $Id: PMGClass.java 1749603 2016-06-21 20:50:19Z ggregory $ + * @see Attribute + */ +public final class PMGClass extends Attribute { + + private int pmg_class_index; + private int pmg_index; + + + /** + * Initialize from another object. Note that both objects use the same + * references (shallow copy). Use copy() for a physical copy. + */ + public PMGClass(final PMGClass c) { + this(c.getNameIndex(), c.getLength(), c.getPMGIndex(), c.getPMGClassIndex(), c + .getConstantPool()); + } + + + /** + * Construct object from input stream. + * @param name_index Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param input Input stream + * @param constant_pool Array of constants + * @throws IOException + */ + PMGClass(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) + throws IOException { + this(name_index, length, input.readUnsignedShort(), input.readUnsignedShort(), constant_pool); + } + + + /** + * @param name_index Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param pmg_index index in constant pool for source file name + * @param pmg_class_index Index in constant pool to CONSTANT_Utf8 + * @param constant_pool Array of constants + */ + public PMGClass(final int name_index, final int length, final int pmg_index, final int pmg_class_index, + final ConstantPool constant_pool) { + super(Const.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 + */ + @Override + public void accept( final 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 + * @throws IOException + */ + @Override + public final void dump( final 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 pmg_class_index + */ + public final void setPMGClassIndex( final 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 pmg_index + */ + public final void setPMGIndex( final int pmg_index ) { + this.pmg_index = pmg_index; + } + + + /** + * @return PMG name. + */ + public final String getPMGName() { + final ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(pmg_index, + Const.CONSTANT_Utf8); + return c.getBytes(); + } + + + /** + * @return PMG class name. + */ + public final String getPMGClassName() { + final ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(pmg_class_index, + Const.CONSTANT_Utf8); + return c.getBytes(); + } + + + /** + * @return String representation + */ + @Override + public final String toString() { + return "PMGClass(" + getPMGName() + ", " + getPMGClassName() + ")"; + } + + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy( final ConstantPool _constant_pool ) { + return (Attribute) clone(); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ParameterAnnotationEntry.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ParameterAnnotationEntry.java new file mode 100644 index 00000000..339ef7be --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ParameterAnnotationEntry.java @@ -0,0 +1,92 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * represents one parameter annotation in the parameter annotation table + * + * @version $Id: ParameterAnnotationEntry + * @since 6.0 + */ +public class ParameterAnnotationEntry implements Node { + + private final AnnotationEntry[] annotation_table; + + + /** + * Construct object from input stream. + * + * @param input Input stream + * @throws IOException + */ + ParameterAnnotationEntry(final DataInput input, final ConstantPool constant_pool) throws IOException { + final int annotation_table_length = input.readUnsignedShort(); + annotation_table = new AnnotationEntry[annotation_table_length]; + for (int i = 0; i < annotation_table_length; i++) { + // TODO isRuntimeVisible + annotation_table[i] = AnnotationEntry.read(input, constant_pool, false); + } + } + + + /** + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitParameterAnnotationEntry(this); + } + + /** + * returns the array of annotation entries in this annotation + */ + public AnnotationEntry[] getAnnotationEntries() { + return annotation_table; + } + + public void dump(final DataOutputStream dos) throws IOException { + dos.writeShort(annotation_table.length); + for (final AnnotationEntry entry : annotation_table) { + entry.dump(dos); + } + } + + public static ParameterAnnotationEntry[] createParameterAnnotationEntries(final Attribute[] attrs) { + // Find attributes that contain parameter annotation data + final List accumulatedAnnotations = new ArrayList<>(attrs.length); + for (final Attribute attribute : attrs) { + if (attribute instanceof ParameterAnnotations) { + final ParameterAnnotations runtimeAnnotations = (ParameterAnnotations)attribute; + Collections.addAll(accumulatedAnnotations, runtimeAnnotations.getParameterAnnotationEntries()); + } + } + return accumulatedAnnotations.toArray(new ParameterAnnotationEntry[accumulatedAnnotations.size()]); + } +} + diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ParameterAnnotations.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ParameterAnnotations.java new file mode 100644 index 00000000..83cc95d2 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ParameterAnnotations.java @@ -0,0 +1,123 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * base class for parameter annotations + * + * @version $Id: ParameterAnnotations + * @since 6.0 + */ +public abstract class ParameterAnnotations extends Attribute { + + /** Table of parameter annotations */ + private ParameterAnnotationEntry[] parameter_annotation_table; + + /** + * @param parameter_annotation_type the subclass type of the parameter annotation + * @param name_index Index pointing to the name Code + * @param length Content length in bytes + * @param input Input stream + * @param constant_pool Array of constants + */ + ParameterAnnotations(final byte parameter_annotation_type, final int name_index, final int length, + final DataInput input, final ConstantPool constant_pool) throws IOException { + this(parameter_annotation_type, name_index, length, (ParameterAnnotationEntry[]) null, + constant_pool); + final int num_parameters = input.readUnsignedByte(); + parameter_annotation_table = new ParameterAnnotationEntry[num_parameters]; + for (int i = 0; i < num_parameters; i++) { + parameter_annotation_table[i] = new ParameterAnnotationEntry(input, constant_pool); + } + } + + + /** + * @param parameter_annotation_type the subclass type of the parameter annotation + * @param name_index Index pointing to the name Code + * @param length Content length in bytes + * @param parameter_annotation_table the actual parameter annotations + * @param constant_pool Array of constants + */ + public ParameterAnnotations(final byte parameter_annotation_type, final int name_index, final int length, + final ParameterAnnotationEntry[] parameter_annotation_table, final ConstantPool constant_pool) { + super(parameter_annotation_type, name_index, length, constant_pool); + this.parameter_annotation_table = parameter_annotation_table; + } + + + /** + * Called by objects that are traversing the nodes of the tree implicitely + * defined by the contents of a Java class. I.e., the hierarchy of methods, + * fields, attributes, etc. spawns a tree of objects. + * + * @param v Visitor object + */ + @Override + public void accept( final Visitor v ) { + v.visitParameterAnnotation(this); + } + + + /** + * @param parameter_annotation_table the entries to set in this parameter annotation + */ + public final void setParameterAnnotationTable(final ParameterAnnotationEntry[] parameter_annotation_table ) { + this.parameter_annotation_table = parameter_annotation_table; + } + + + /** + * @return the parameter annotation entry table + */ + public final ParameterAnnotationEntry[] getParameterAnnotationTable() { + return parameter_annotation_table; + } + + + /** + * returns the array of parameter annotation entries in this parameter annotation + */ + public ParameterAnnotationEntry[] getParameterAnnotationEntries() { + return parameter_annotation_table; + } + + @Override + public void dump(final DataOutputStream dos) throws IOException + { + super.dump(dos); + dos.writeByte(parameter_annotation_table.length); + + for (final ParameterAnnotationEntry element : parameter_annotation_table) { + element.dump(dos); + } + + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy( final ConstantPool constant_pool ) { + return (Attribute) clone(); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeInvisibleAnnotations.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeInvisibleAnnotations.java new file mode 100644 index 00000000..b71d720e --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeInvisibleAnnotations.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * represents an annotation that is represented in the class file but is not + * provided to the JVM. + * + * @version $Id: RuntimeInvisibleAnnotations + * @since 6.0 + */ +public class RuntimeInvisibleAnnotations extends Annotations +{ + /** + * @param name_index + * Index pointing to the name Code + * @param length + * Content length in bytes + * @param input + * Input stream + * @param constant_pool + * Array of constants + */ + public RuntimeInvisibleAnnotations(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) + throws IOException + { + super(Const.ATTR_RUNTIME_INVISIBLE_ANNOTATIONS, name_index, length, input, constant_pool, false); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constant_pool) + { + return (Attribute) clone(); + } + + @Override + public final void dump(final DataOutputStream dos) throws IOException + { + super.dump(dos); + writeAnnotations(dos); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeInvisibleParameterAnnotations.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeInvisibleParameterAnnotations.java new file mode 100644 index 00000000..1910bd7b --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeInvisibleParameterAnnotations.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * Represents a parameter annotation that is represented in the class file + * but is not provided to the JVM. + * + * @version $Id: RuntimeInvisibleParameterAnnotations + * @since 6.0 + */ +public class RuntimeInvisibleParameterAnnotations extends ParameterAnnotations { + + /** + * @param name_index Index pointing to the name Code + * @param length Content length in bytes + * @param input Input stream + * @param constant_pool Array of constants + */ + public RuntimeInvisibleParameterAnnotations(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) + throws IOException { + super(Const.ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS, name_index, length, input, constant_pool); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeVisibleAnnotations.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeVisibleAnnotations.java new file mode 100644 index 00000000..3cfdcf60 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeVisibleAnnotations.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * represents an annotation that is represented in the class file and is + * provided to the JVM. + * + * @version $Id: RuntimeVisibleAnnotations + * @since 6.0 + */ +public class RuntimeVisibleAnnotations extends Annotations +{ + /** + * @param name_index + * Index pointing to the name Code + * @param length + * Content length in bytes + * @param input + * Input stream + * @param constant_pool + * Array of constants + */ + public RuntimeVisibleAnnotations(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) throws IOException + { + super(Const.ATTR_RUNTIME_VISIBLE_ANNOTATIONS, name_index, length, input, constant_pool, true); + } + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy(final ConstantPool constant_pool) + { + return (Attribute) clone(); + } + + @Override + public final void dump(final DataOutputStream dos) throws IOException + { + super.dump(dos); + writeAnnotations(dos); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeVisibleParameterAnnotations.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeVisibleParameterAnnotations.java new file mode 100644 index 00000000..306bdee0 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeVisibleParameterAnnotations.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * Represents a parameter annotation that is represented in the class file + * and is provided to the JVM. + * + * @version $Id: RuntimeVisibleParameterAnnotations + * @since 6.0 + */ +public class RuntimeVisibleParameterAnnotations extends ParameterAnnotations { + + /** + * @param name_index Index pointing to the name Code + * @param length Content length in bytes + * @param input Input stream + * @param constant_pool Array of constants + */ + public RuntimeVisibleParameterAnnotations(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) + throws IOException { + super(Const.ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS, name_index, length, input, constant_pool); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Signature.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Signature.java old mode 100755 new mode 100644 similarity index 69% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Signature.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Signature.java index 1ff83396..82ff4574 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Signature.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Signature.java @@ -1,274 +1,270 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.ByteArrayInputStream; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class is derived from Attribute and represents a reference - * to a GJ attribute. - * - * @version $Id: Signature.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 - * @throws 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 signature_index Index in constant pool to CONSTANT_Utf8 - * @param constant_pool Array of constants - */ - 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"); - v.visitSignature(this); - } - - - /** - * Dump source file attribute to file stream in binary format. - * - * @param file Output file stream - * @throws 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 the index info the constant pool of this signature - */ - 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 final void matchIdent( MyByteArrayInputStream in, StringBuilder 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)) { - StringBuilder buf2 = new StringBuilder(); - 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; - } - StringBuilder buf2 = new StringBuilder(); - 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, StringBuilder 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); - StringBuilder buf = new StringBuilder(); - 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(); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.ByteArrayInputStream; +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class is derived from Attribute and represents a reference + * to a GJ attribute. + * + * @version $Id: Signature.java 1749603 2016-06-21 20:50:19Z ggregory $ + * @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(final 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 input Input stream + * @param constant_pool Array of constants + * @throws IOException + */ + Signature(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) + throws IOException { + this(name_index, length, input.readUnsignedShort(), constant_pool); + } + + + /** + * @param name_index Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param signature_index Index in constant pool to CONSTANT_Utf8 + * @param constant_pool Array of constants + */ + public Signature(final int name_index, final int length, final int signature_index, final ConstantPool constant_pool) { + super(Const.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 + */ + @Override + public void accept( final Visitor v ) { + //System.err.println("Visiting non-standard Signature object"); + v.visitSignature(this); + } + + + /** + * Dump source file attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + @Override + public final void dump( final 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 the index info the constant pool of this signature + */ + public final void setSignatureIndex( final int signature_index ) { + this.signature_index = signature_index; + } + + + /** + * @return GJ signature. + */ + public final String getSignature() { + final ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(signature_index, + Const.CONSTANT_Utf8); + return c.getBytes(); + } + + /** + * Extends ByteArrayInputStream to make 'unreading' chars possible. + */ + private static final class MyByteArrayInputStream extends ByteArrayInputStream { + + MyByteArrayInputStream(final String data) { + super(data.getBytes()); + } + + + final String getData() { + return new String(buf); + } + + + final void unread() { + if (pos > 0) { + pos--; + } + } + } + + + private static boolean identStart( final int ch ) { + return ch == 'T' || ch == 'L'; + } + + + private static void matchIdent( final MyByteArrayInputStream in, final StringBuilder 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)) { + final StringBuilder buf2 = new StringBuilder(); + 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; + } + final StringBuilder buf2 = new StringBuilder(); + 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 void matchGJIdent( final MyByteArrayInputStream in, final StringBuilder 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( final String s ) { + //System.out.println("Sig:" + s); + final StringBuilder buf = new StringBuilder(); + matchGJIdent(new MyByteArrayInputStream(s), buf); + return buf.toString(); + } + + + // @since 6.0 is no longer final + public static boolean isFormalParameterList( final String s ) { + return s.startsWith("<") && (s.indexOf(':') > 0); + } + + + // @since 6.0 is no longer final + public static boolean isActualParameterList( final String s ) { + return s.startsWith("L") && s.endsWith(">;"); + } + + + /** + * @return String representation + */ + @Override + public final String toString() { + final String s = getSignature(); + return "Signature: " + s; + } + + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy( final ConstantPool _constant_pool ) { + return (Attribute) clone(); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/SimpleElementValue.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/SimpleElementValue.java new file mode 100644 index 00000000..5572452a --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/SimpleElementValue.java @@ -0,0 +1,225 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * @since 6.0 + */ +public class SimpleElementValue extends ElementValue +{ + private int index; + + public SimpleElementValue(final int type, final int index, final ConstantPool cpool) + { + super(type, cpool); + this.index = index; + } + + /** + * @return Value entry index in the cpool + */ + public int getIndex() + { + return index; + } + + public void setIndex(final int index) + { + this.index = index; + } + + public String getValueString() + { + if (super.getType() != STRING) { + throw new RuntimeException( + "Dont call getValueString() on a non STRING ElementValue"); + } + final ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(getIndex(), + Const.CONSTANT_Utf8); + return c.getBytes(); + } + + public int getValueInt() + { + if (super.getType() != PRIMITIVE_INT) { + throw new RuntimeException( + "Dont call getValueString() on a non STRING ElementValue"); + } + final ConstantInteger c = (ConstantInteger) super.getConstantPool().getConstant(getIndex(), + Const.CONSTANT_Integer); + return c.getBytes(); + } + + public byte getValueByte() + { + if (super.getType() != PRIMITIVE_BYTE) { + throw new RuntimeException( + "Dont call getValueByte() on a non BYTE ElementValue"); + } + final ConstantInteger c = (ConstantInteger) super.getConstantPool().getConstant(getIndex(), + Const.CONSTANT_Integer); + return (byte) c.getBytes(); + } + + public char getValueChar() + { + if (super.getType() != PRIMITIVE_CHAR) { + throw new RuntimeException( + "Dont call getValueChar() on a non CHAR ElementValue"); + } + final ConstantInteger c = (ConstantInteger) super.getConstantPool().getConstant(getIndex(), + Const.CONSTANT_Integer); + return (char) c.getBytes(); + } + + public long getValueLong() + { + if (super.getType() != PRIMITIVE_LONG) { + throw new RuntimeException( + "Dont call getValueLong() on a non LONG ElementValue"); + } + final ConstantLong j = (ConstantLong) super.getConstantPool().getConstant(getIndex()); + return j.getBytes(); + } + + public float getValueFloat() + { + if (super.getType() != PRIMITIVE_FLOAT) { + throw new RuntimeException( + "Dont call getValueFloat() on a non FLOAT ElementValue"); + } + final ConstantFloat f = (ConstantFloat) super.getConstantPool().getConstant(getIndex()); + return f.getBytes(); + } + + public double getValueDouble() + { + if (super.getType() != PRIMITIVE_DOUBLE) { + throw new RuntimeException( + "Dont call getValueDouble() on a non DOUBLE ElementValue"); + } + final ConstantDouble d = (ConstantDouble) super.getConstantPool().getConstant(getIndex()); + return d.getBytes(); + } + + public boolean getValueBoolean() + { + if (super.getType() != PRIMITIVE_BOOLEAN) { + throw new RuntimeException( + "Dont call getValueBoolean() on a non BOOLEAN ElementValue"); + } + final ConstantInteger bo = (ConstantInteger) super.getConstantPool().getConstant(getIndex()); + return bo.getBytes() != 0; + } + + public short getValueShort() + { + if (super.getType() != PRIMITIVE_SHORT) { + throw new RuntimeException( + "Dont call getValueShort() on a non SHORT ElementValue"); + } + final ConstantInteger s = (ConstantInteger) super.getConstantPool().getConstant(getIndex()); + return (short) s.getBytes(); + } + + @Override + public String toString() + { + return stringifyValue(); + } + + // Whatever kind of value it is, return it as a string + @Override + public String stringifyValue() + { + final ConstantPool cpool = super.getConstantPool(); + final int _type = super.getType(); + switch (_type) + { + case PRIMITIVE_INT: + final ConstantInteger c = (ConstantInteger) cpool.getConstant(getIndex(), + Const.CONSTANT_Integer); + return Integer.toString(c.getBytes()); + case PRIMITIVE_LONG: + final ConstantLong j = (ConstantLong) cpool.getConstant(getIndex(), + Const.CONSTANT_Long); + return Long.toString(j.getBytes()); + case PRIMITIVE_DOUBLE: + final ConstantDouble d = (ConstantDouble) cpool.getConstant(getIndex(), + Const.CONSTANT_Double); + return Double.toString(d.getBytes()); + case PRIMITIVE_FLOAT: + final ConstantFloat f = (ConstantFloat) cpool.getConstant(getIndex(), + Const.CONSTANT_Float); + return Float.toString(f.getBytes()); + case PRIMITIVE_SHORT: + final ConstantInteger s = (ConstantInteger) cpool.getConstant(getIndex(), + Const.CONSTANT_Integer); + return Integer.toString(s.getBytes()); + case PRIMITIVE_BYTE: + final ConstantInteger b = (ConstantInteger) cpool.getConstant(getIndex(), + Const.CONSTANT_Integer); + return Integer.toString(b.getBytes()); + case PRIMITIVE_CHAR: + final ConstantInteger ch = (ConstantInteger) cpool.getConstant( + getIndex(), Const.CONSTANT_Integer); + return String.valueOf((char)ch.getBytes()); + case PRIMITIVE_BOOLEAN: + final ConstantInteger bo = (ConstantInteger) cpool.getConstant( + getIndex(), Const.CONSTANT_Integer); + if (bo.getBytes() == 0) { + return "false"; + } + return "true"; + case STRING: + final ConstantUtf8 cu8 = (ConstantUtf8) cpool.getConstant(getIndex(), + Const.CONSTANT_Utf8); + return cu8.getBytes(); + default: + throw new RuntimeException("SimpleElementValue class does not know how to stringify type " + _type); + } + } + + @Override + public void dump(final DataOutputStream dos) throws IOException + { + final int _type = super.getType(); + dos.writeByte(_type); // u1 kind of value + switch (_type) + { + case PRIMITIVE_INT: + case PRIMITIVE_BYTE: + case PRIMITIVE_CHAR: + case PRIMITIVE_FLOAT: + case PRIMITIVE_LONG: + case PRIMITIVE_BOOLEAN: + case PRIMITIVE_SHORT: + case PRIMITIVE_DOUBLE: + case STRING: + dos.writeShort(getIndex()); + break; + default: + throw new RuntimeException("SimpleElementValue doesnt know how to write out type " + _type); + } + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/SourceFile.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/SourceFile.java old mode 100755 new mode 100644 similarity index 63% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/SourceFile.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/SourceFile.java index 3218c405..2b183327 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/SourceFile.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/SourceFile.java @@ -1,146 +1,150 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class is derived from Attribute and represents a reference - * to the source file of this class. At most one SourceFile attribute - * should appear per classfile. The intention of this class is that it is - * instantiated from the Attribute.readAttribute() method. - * - * @version $Id: SourceFile.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 - * @throws 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, which - * should represent the string "SourceFile". - * @param length Content length in bytes, the value should be 2. - * @param constant_pool The constant pool that this attribute is - * associated with. - * @param sourcefile_index Index in constant pool to CONSTANT_Utf8. This - * string will be interpreted as the name of the file from which this - * class was compiled. It will not be interpreted as indicating the name - * of the directory contqining the file or an absolute path; this - * information has to be supplied the consumer of this attribute - in - * many cases, the JVM. - */ - 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 - * @throws 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(); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class is derived from Attribute and represents a reference + * to the source file of this class. At most one SourceFile attribute + * should appear per classfile. The intention of this class is that it is + * instantiated from the Attribute.readAttribute() method. + * + * @version $Id: SourceFile.java 1749603 2016-06-21 20:50:19Z ggregory $ + * @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(final SourceFile c) { + this(c.getNameIndex(), c.getLength(), c.getSourceFileIndex(), c.getConstantPool()); + } + + + /** + * Construct object from input stream. + * @param name_index Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param input Input stream + * @param constant_pool Array of constants + * @throws IOException + */ + SourceFile(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) + throws IOException { + this(name_index, length, input.readUnsignedShort(), constant_pool); + } + + + /** + * @param name_index Index in constant pool to CONSTANT_Utf8, which + * should represent the string "SourceFile". + * @param length Content length in bytes, the value should be 2. + * @param constant_pool The constant pool that this attribute is + * associated with. + * @param sourcefile_index Index in constant pool to CONSTANT_Utf8. This + * string will be interpreted as the name of the file from which this + * class was compiled. It will not be interpreted as indicating the name + * of the directory contqining the file or an absolute path; this + * information has to be supplied the consumer of this attribute - in + * many cases, the JVM. + */ + public SourceFile(final int name_index, final int length, final int sourcefile_index, final ConstantPool constant_pool) { + super(Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitSourceFile(this); + } + + + /** + * Dump source file attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + @Override + public final void dump( final 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( final int sourcefile_index ) { + this.sourcefile_index = sourcefile_index; + } + + + /** + * @return Source file name. + */ + public final String getSourceFileName() { + final ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(sourcefile_index, + Const.CONSTANT_Utf8); + return c.getBytes(); + } + + + /** + * @return String representation + */ + @Override + public final String toString() { + return "SourceFile: " + getSourceFileName(); + } + + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy( final ConstantPool _constant_pool ) { + return (Attribute) clone(); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/StackMap.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/StackMap.java old mode 100755 new mode 100644 similarity index 50% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/StackMap.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/StackMap.java index eb723569..d83e1c2a --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/StackMap.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/StackMap.java @@ -1,154 +1,161 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class represents a stack map attribute used for - * preverification of Java classes for the Java 2 Micro Edition - * (J2ME). This attribute is used by the KVM and contained - * within the Code attribute of a method. See CLDC specification - * paragraph 5.3.1.2 - * - * @version $Id: StackMap.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 - * @param constant_pool Array of constants - * @throws IOException - */ - 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 - * @throws 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() { - StringBuilder buf = new StringBuilder("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; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class represents a stack map attribute used for + * preverification of Java classes for the Java 2 Micro Edition + * (J2ME). This attribute is used by the KVM and contained + * within the Code attribute of a method. See CLDC specification + * �5.3.1.2 + * + * @version $Id: StackMap.java 1811017 2017-10-03 17:43:26Z britter $ + * @see Code + * @see StackMapEntry + * @see StackMapType + */ +public final class StackMap extends Attribute { + + 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(final int name_index, final int length, final StackMapEntry[] map, final ConstantPool constant_pool) { + super(Const.ATTR_STACK_MAP, name_index, length, constant_pool); + this.map = map; + } + + + /** + * Construct object from input stream. + * + * @param name_index Index of name + * @param length Content length in bytes + * @param input Input stream + * @param constant_pool Array of constants + * @throws IOException + */ + StackMap(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) throws IOException { + this(name_index, length, (StackMapEntry[]) null, constant_pool); + final int map_length = input.readUnsignedShort(); + map = new StackMapEntry[map_length]; + for (int i = 0; i < map_length; i++) { + map[i] = new StackMapEntry(input, constant_pool); + } + } + + + /** + * Dump stack map table attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + @Override + public final void dump( final DataOutputStream file ) throws IOException { + super.dump(file); + file.writeShort(map.length); + for (final StackMapEntry entry : map) { + entry.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( final StackMapEntry[] map ) { + this.map = map; + int len = 2; // Length of 'number_of_entries' field prior to the array of stack maps + for (final StackMapEntry element : map) { + len += element.getMapEntrySize(); + } + setLength(len); + } + + + /** + * @return String representation. + */ + @Override + public final String toString() { + final StringBuilder buf = new StringBuilder("StackMap("); + for (int i = 0; i < map.length; i++) { + buf.append(map[i]); + if (i < map.length - 1) { + buf.append(", "); + } + } + buf.append(')'); + return buf.toString(); + } + + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy( final ConstantPool _constant_pool ) { + final 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.setConstantPool(_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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackMap(this); + } + + + public final int getMapLength() { + return map == null ? 0 : map.length; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/StackMapEntry.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/StackMapEntry.java new file mode 100644 index 00000000..4c1ec29e --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/StackMapEntry.java @@ -0,0 +1,436 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import org.apache.bcel.Const; + +/** + * 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: StackMapEntry.java 1808136 2017-09-12 16:51:32Z britter $ + * @see StackMap + * @see StackMapType + */ +public final class StackMapEntry implements Node, Cloneable +{ + + private int frame_type; + private int byte_code_offset; + private StackMapType[] types_of_locals; + private StackMapType[] types_of_stack_items; + private ConstantPool constant_pool; + + + /** + * Construct object from input stream. + * + * @param input Input stream + * @throws IOException + */ + StackMapEntry(final DataInput input, final ConstantPool constantPool) throws IOException { + this(input.readByte() & 0xFF, -1, null, null, constantPool); + + if (frame_type >= Const.SAME_FRAME && frame_type <= Const.SAME_FRAME_MAX) { + byte_code_offset = frame_type - Const.SAME_FRAME; + } else if (frame_type >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && + frame_type <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { + byte_code_offset = frame_type - Const.SAME_LOCALS_1_STACK_ITEM_FRAME; + types_of_stack_items = new StackMapType[1]; + types_of_stack_items[0] = new StackMapType(input, constantPool); + } else if (frame_type == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { + byte_code_offset = input.readShort(); + types_of_stack_items = new StackMapType[1]; + types_of_stack_items[0] = new StackMapType(input, constantPool); + } else if (frame_type >= Const.CHOP_FRAME && frame_type <= Const.CHOP_FRAME_MAX) { + byte_code_offset = input.readShort(); + } else if (frame_type == Const.SAME_FRAME_EXTENDED) { + byte_code_offset = input.readShort(); + } else if (frame_type >= Const.APPEND_FRAME && frame_type <= Const.APPEND_FRAME_MAX) { + byte_code_offset = input.readShort(); + final int number_of_locals = frame_type - 251; + types_of_locals = new StackMapType[number_of_locals]; + for (int i = 0; i < number_of_locals; i++) { + types_of_locals[i] = new StackMapType(input, constantPool); + } + } else if (frame_type == Const.FULL_FRAME) { + byte_code_offset = input.readShort(); + final int number_of_locals = input.readShort(); + types_of_locals = new StackMapType[number_of_locals]; + for (int i = 0; i < number_of_locals; i++) { + types_of_locals[i] = new StackMapType(input, constantPool); + } + final int number_of_stack_items = input.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(input, constantPool); + } + } else { + /* Can't happen */ + throw new ClassFormatException ("Invalid frame type found while parsing stack map table: " + frame_type); + } + } + + /** + * DO NOT USE + * + * @param byteCodeOffset + * @param numberOfLocals NOT USED + * @param typesOfLocals array of {@link StackMapType}s of locals + * @param numberOfStackItems NOT USED + * @param typesOfStackItems array ot {@link StackMapType}s of stack items + * @param constantPool the constant pool + * @deprecated Since 6.0, use {@link #StackMapEntry(int, int, StackMapType[], StackMapType[], ConstantPool)} + * instead + */ + @java.lang.Deprecated + public StackMapEntry(final int byteCodeOffset, final int numberOfLocals, + final StackMapType[] typesOfLocals, final int numberOfStackItems, + final StackMapType[] typesOfStackItems, final ConstantPool constantPool) { + this.byte_code_offset = byteCodeOffset; + this.types_of_locals = typesOfLocals != null ? typesOfLocals : new StackMapType[0]; + this.types_of_stack_items = typesOfStackItems != null ? typesOfStackItems : new StackMapType[0]; + this.constant_pool = constantPool; + } + + /** + * Create an instance + * + * @param tag the frame_type to use + * @param byteCodeOffset + * @param typesOfLocals array of {@link StackMapType}s of locals + * @param typesOfStackItems array ot {@link StackMapType}s of stack items + * @param constantPool the constant pool + */ + public StackMapEntry(final int tag, final int byteCodeOffset, + final StackMapType[] typesOfLocals, + final StackMapType[] typesOfStackItems, final ConstantPool constantPool) { + this.frame_type = tag; + this.byte_code_offset = byteCodeOffset; + this.types_of_locals = typesOfLocals != null ? typesOfLocals : new StackMapType[0]; + this.types_of_stack_items = typesOfStackItems != null ? typesOfStackItems : new StackMapType[0]; + this.constant_pool = constantPool; + } + + + /** + * Dump stack map entry + * + * @param file Output file stream + * @throws IOException + */ + public final void dump( final DataOutputStream file ) throws IOException { + file.write(frame_type); + if (frame_type >= Const.SAME_FRAME && frame_type <= Const.SAME_FRAME_MAX) { + // nothing to be done + } else if (frame_type >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && + frame_type <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { + types_of_stack_items[0].dump(file); + } else if (frame_type == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { + file.writeShort(byte_code_offset); + types_of_stack_items[0].dump(file); + } else if (frame_type >= Const.CHOP_FRAME && frame_type <= Const.CHOP_FRAME_MAX) { + file.writeShort(byte_code_offset); + } else if (frame_type == Const.SAME_FRAME_EXTENDED) { + file.writeShort(byte_code_offset); + } else if (frame_type >= Const.APPEND_FRAME && frame_type <= Const.APPEND_FRAME_MAX) { + file.writeShort(byte_code_offset); + for (final StackMapType type : types_of_locals) { + type.dump(file); + } + } else if (frame_type == Const.FULL_FRAME) { + file.writeShort(byte_code_offset); + file.writeShort(types_of_locals.length); + for (final StackMapType type : types_of_locals) { + type.dump(file); + } + file.writeShort(types_of_stack_items.length); + for (final StackMapType type : types_of_stack_items) { + type.dump(file); + } + } else { + /* Can't happen */ + throw new ClassFormatException ("Invalid Stack map table tag: " + frame_type); + } + } + + + /** + * @return String representation. + */ + @Override + public final String toString() { + final StringBuilder buf = new StringBuilder(64); + buf.append("("); + if (frame_type >= Const.SAME_FRAME && frame_type <= Const.SAME_FRAME_MAX) { + buf.append("SAME"); + } else if (frame_type >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && + frame_type <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { + buf.append("SAME_LOCALS_1_STACK"); + } else if (frame_type == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { + buf.append("SAME_LOCALS_1_STACK_EXTENDED"); + } else if (frame_type >= Const.CHOP_FRAME && frame_type <= Const.CHOP_FRAME_MAX) { + buf.append("CHOP ").append(String.valueOf(251-frame_type)); + } else if (frame_type == Const.SAME_FRAME_EXTENDED) { + buf.append("SAME_EXTENDED"); + } else if (frame_type >= Const.APPEND_FRAME && frame_type <= Const.APPEND_FRAME_MAX) { + buf.append("APPEND ").append(String.valueOf(frame_type-251)); + } else if (frame_type == Const.FULL_FRAME) { + buf.append("FULL"); + } else { + buf.append("UNKNOWN (").append(frame_type).append(")"); + } + buf.append(", offset delta=").append(byte_code_offset); + if (types_of_locals.length > 0) { + buf.append(", locals={"); + for (int i = 0; i < types_of_locals.length; i++) { + buf.append(types_of_locals[i]); + if (i < types_of_locals.length - 1) { + buf.append(", "); + } + } + buf.append("}"); + } + if (types_of_stack_items.length > 0) { + buf.append(", stack items={"); + for (int i = 0; i < types_of_stack_items.length; i++) { + buf.append(types_of_stack_items[i]); + if (i < types_of_stack_items.length - 1) { + buf.append(", "); + } + } + buf.append("}"); + } + buf.append(")"); + return buf.toString(); + } + + + /** + * Calculate stack map entry size + * + */ + int getMapEntrySize() { + if (frame_type >= Const.SAME_FRAME && frame_type <= Const.SAME_FRAME_MAX) { + return 1; + } else if (frame_type >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && + frame_type <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { + return 1 + (types_of_stack_items[0].hasIndex() ? 3 : 1); + } else if (frame_type == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { + return 3 + (types_of_stack_items[0].hasIndex() ? 3 : 1); + } else if (frame_type >= Const.CHOP_FRAME && frame_type <= Const.CHOP_FRAME_MAX) { + return 3; + } else if (frame_type == Const.SAME_FRAME_EXTENDED) { + return 3; + } else if (frame_type >= Const.APPEND_FRAME && frame_type <= Const.APPEND_FRAME_MAX) { + int len = 3; + for (final StackMapType types_of_local : types_of_locals) { + len += types_of_local.hasIndex() ? 3 : 1; + } + return len; + } else if (frame_type == Const.FULL_FRAME) { + int len = 7; + for (final StackMapType types_of_local : types_of_locals) { + len += types_of_local.hasIndex() ? 3 : 1; + } + for (final StackMapType types_of_stack_item : types_of_stack_items) { + len += types_of_stack_item.hasIndex() ? 3 : 1; + } + return len; + } else { + throw new RuntimeException("Invalid StackMap frame_type: " + frame_type); + } + } + + + public void setFrameType( final int f ) { + if (f >= Const.SAME_FRAME && f <= Const.SAME_FRAME_MAX) { + byte_code_offset = f - Const.SAME_FRAME; + } else if (f >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && + f <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { + byte_code_offset = f - Const.SAME_LOCALS_1_STACK_ITEM_FRAME; + } else if (f == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { // CHECKSTYLE IGNORE EmptyBlock + } else if (f >= Const.CHOP_FRAME && f <= Const.CHOP_FRAME_MAX) { // CHECKSTYLE IGNORE EmptyBlock + } else if (f == Const.SAME_FRAME_EXTENDED) { // CHECKSTYLE IGNORE EmptyBlock + } else if (f >= Const.APPEND_FRAME && f <= Const.APPEND_FRAME_MAX) { // CHECKSTYLE IGNORE EmptyBlock + } else if (f == Const.FULL_FRAME) { // CHECKSTYLE IGNORE EmptyBlock + } else { + throw new RuntimeException("Invalid StackMap frame_type"); + } + frame_type = f; + } + + + public int getFrameType() { + return frame_type; + } + + + public void setByteCodeOffset( final int new_offset ) { + if (new_offset < 0 || new_offset > 32767) { + throw new RuntimeException("Invalid StackMap offset: " + new_offset); + } + + if (frame_type >= Const.SAME_FRAME && + frame_type <= Const.SAME_FRAME_MAX) { + if (new_offset > Const.SAME_FRAME_MAX) { + frame_type = Const.SAME_FRAME_EXTENDED; + } else { + frame_type = new_offset; + } + } else if (frame_type >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && + frame_type <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { + if (new_offset > Const.SAME_FRAME_MAX) { + frame_type = Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED; + } else { + frame_type = Const.SAME_LOCALS_1_STACK_ITEM_FRAME + new_offset; + } + } else if (frame_type == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { // CHECKSTYLE IGNORE EmptyBlock + } else if (frame_type >= Const.CHOP_FRAME && + frame_type <= Const.CHOP_FRAME_MAX) { // CHECKSTYLE IGNORE EmptyBlock + } else if (frame_type == Const.SAME_FRAME_EXTENDED) { // CHECKSTYLE IGNORE EmptyBlock + } else if (frame_type >= Const.APPEND_FRAME && + frame_type <= Const.APPEND_FRAME_MAX) { // CHECKSTYLE IGNORE EmptyBlock + } else if (frame_type == Const.FULL_FRAME) { // CHECKSTYLE IGNORE EmptyBlock + } else { + throw new RuntimeException("Invalid StackMap frame_type: " + frame_type); + } + byte_code_offset = new_offset; + } + + + /** + * Update the distance (as an offset delta) from this StackMap + * entry to the next. Note that this might cause the the + * frame type to change. Note also that delta may be negative. + * + * @param delta offset delta + */ + public void updateByteCodeOffset(final int delta) { + setByteCodeOffset(byte_code_offset + delta); + } + + + public int getByteCodeOffset() { + return byte_code_offset; + } + + + /** + * + * @deprecated since 6.0 + */ + @java.lang.Deprecated + public void setNumberOfLocals( final int n ) { // TODO unused + } + + + public int getNumberOfLocals() { + return types_of_locals.length; + } + + + public void setTypesOfLocals( final StackMapType[] types ) { + types_of_locals = types != null ? types : new StackMapType[0]; + } + + + public StackMapType[] getTypesOfLocals() { + return types_of_locals; + } + + + /** + * + * @deprecated since 6.0 + */ + @java.lang.Deprecated + public void setNumberOfStackItems( final int n ) { // TODO unused + } + + + public int getNumberOfStackItems() { + return types_of_stack_items.length; + } + + + public void setTypesOfStackItems( final StackMapType[] types ) { + types_of_stack_items = types != null ? types : new StackMapType[0]; + } + + + public StackMapType[] getTypesOfStackItems() { + return types_of_stack_items; + } + + + /** + * @return deep copy of this object + */ + public StackMapEntry copy() { + StackMapEntry e; + try { + e = (StackMapEntry) clone(); + } catch (final CloneNotSupportedException ex) { + throw new Error("Clone Not Supported"); + } + + e.types_of_locals = new StackMapType[types_of_locals.length]; + for (int i = 0; i < types_of_locals.length; i++) { + e.types_of_locals[i] = types_of_locals[i].copy(); + } + e.types_of_stack_items = new StackMapType[types_of_stack_items.length]; + for (int i = 0; i < types_of_stack_items.length; i++) { + e.types_of_stack_items[i] = types_of_stack_items[i].copy(); + } + return e; + } + + + /** + * 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 + */ + @Override + public void accept( final 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( final ConstantPool constant_pool ) { + this.constant_pool = constant_pool; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/StackMapType.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/StackMapType.java old mode 100755 new mode 100644 similarity index 57% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/StackMapType.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/StackMapType.java index 771a6742..a7bda56d --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/StackMapType.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/StackMapType.java @@ -1,162 +1,167 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class represents the type of a local variable or item on stack - * used in the StackMap entries. - * - * @version $Id: StackMapType.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 - * @throws 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 - * @throws 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) { - if (index < 0) { - return ", class="; - } - 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; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class represents the type of a local variable or item on stack + * used in the StackMap entries. + * + * @version $Id: StackMapType.java 1749603 2016-06-21 20:50:19Z ggregory $ + * @see StackMapEntry + * @see StackMap + * @see Const + */ +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 + * @throws IOException + */ + StackMapType(final DataInput file, final ConstantPool constant_pool) throws IOException { + this(file.readByte(), -1, constant_pool); + if (hasIndex()) { + this.index = file.readShort(); + } + this.constant_pool = constant_pool; + } + + + /** + * @param type type tag as defined in the Constants interface + * @param index index to constant pool, or byte code offset + */ + public StackMapType(final byte type, final int index, final ConstantPool constant_pool) { + if ((type < Const.ITEM_Bogus) || (type > Const.ITEM_NewObject)) { + throw new RuntimeException("Illegal type for StackMapType: " + type); + } + this.type = type; + this.index = index; + this.constant_pool = constant_pool; + } + + + public void setType( final byte t ) { + if ((t < Const.ITEM_Bogus) || (t > Const.ITEM_NewObject)) { + throw new RuntimeException("Illegal type for StackMapType: " + t); + } + type = t; + } + + + public byte getType() { + return type; + } + + + public void setIndex( final 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 + * @throws IOException + */ + public final void dump( final 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 == Const.ITEM_Object || type == Const.ITEM_NewObject; + } + + + private String printIndex() { + if (type == Const.ITEM_Object) { + if (index < 0) { + return ", class="; + } + return ", class=" + constant_pool.constantToString(index, Const.CONSTANT_Class); + } else if (type == Const.ITEM_NewObject) { + return ", offset=" + index; + } else { + return ""; + } + } + + + /** + * @return String representation + */ + @Override + public final String toString() { + return "(type=" + Const.getItemName(type) + printIndex() + ")"; + } + + + /** + * @return deep copy of this object + */ + public StackMapType copy() { + try { + return (StackMapType) clone(); + } catch (final CloneNotSupportedException e) { + // TODO should this throw? + } + 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( final ConstantPool constant_pool ) { + this.constant_pool = constant_pool; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Synthetic.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Synthetic.java old mode 100755 new mode 100644 similarity index 63% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Synthetic.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Synthetic.java index d3839cf0..c3503265 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Synthetic.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Synthetic.java @@ -1,151 +1,156 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class is derived from Attribute and declares this class as - * `synthetic', i.e., it needs special handling. The JVM specification - * states "A class member that does not appear in the source code must be - * marked using a Synthetic attribute." It may appear in the ClassFile - * attribute table, a field_info table or a method_info table. This class - * is intended to be instantiated from the - * Attribute.readAttribute() method. - * - * @version $Id: Synthetic.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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, which - * should represent the string "Synthetic". - * @param length Content length in bytes - should be zero. - * @param bytes Attribute contents - * @param constant_pool The constant pool this attribute is associated - * with. - */ - 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 - * @throws 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 - * @throws 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() { - StringBuilder buf = new StringBuilder("Synthetic"); - if (length > 0) { - buf.append(" ").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 = new byte[bytes.length]; - System.arraycopy(bytes, 0, c.bytes, 0, bytes.length); - } - c.constant_pool = _constant_pool; - return c; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; + +/** + * This class is derived from Attribute and declares this class as + * `synthetic', i.e., it needs special handling. The JVM specification + * states "A class member that does not appear in the source code must be + * marked using a Synthetic attribute." It may appear in the ClassFile + * attribute table, a field_info table or a method_info table. This class + * is intended to be instantiated from the + * Attribute.readAttribute() method. + * + * @version $Id: Synthetic.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @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(final Synthetic c) { + this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool()); + } + + + /** + * @param name_index Index in constant pool to CONSTANT_Utf8, which + * should represent the string "Synthetic". + * @param length Content length in bytes - should be zero. + * @param bytes Attribute contents + * @param constant_pool The constant pool this attribute is associated + * with. + */ + public Synthetic(final int name_index, final int length, final byte[] bytes, final ConstantPool constant_pool) { + super(Const.ATTR_SYNTHETIC, name_index, length, constant_pool); + this.bytes = bytes; + } + + + /** + * Construct object from input stream. + * + * @param name_index Index in constant pool to CONSTANT_Utf8 + * @param length Content length in bytes + * @param input Input stream + * @param constant_pool Array of constants + * @throws IOException + */ + Synthetic(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) + throws IOException { + this(name_index, length, (byte[]) null, constant_pool); + if (length > 0) { + bytes = new byte[length]; + input.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitSynthetic(this); + } + + + /** + * Dump source file attribute to file stream in binary format. + * + * @param file Output file stream + * @throws IOException + */ + @Override + public final void dump( final DataOutputStream file ) throws IOException { + super.dump(file); + if (super.getLength() > 0) { + file.write(bytes, 0, super.getLength()); + } + } + + + /** + * @return data bytes. + */ + public final byte[] getBytes() { + return bytes; + } + + + /** + * @param bytes + */ + public final void setBytes( final byte[] bytes ) { + this.bytes = bytes; + } + + + /** + * @return String representation. + */ + @Override + public final String toString() { + final StringBuilder buf = new StringBuilder("Synthetic"); + if (super.getLength() > 0) { + buf.append(" ").append(Utility.toHexString(bytes)); + } + return buf.toString(); + } + + + /** + * @return deep copy of this attribute + */ + @Override + public Attribute copy( final ConstantPool _constant_pool ) { + final Synthetic c = (Synthetic) clone(); + if (bytes != null) { + c.bytes = new byte[bytes.length]; + System.arraycopy(bytes, 0, c.bytes, 0, bytes.length); + } + c.setConstantPool(_constant_pool); + return c; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Unknown.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Unknown.java old mode 100755 new mode 100644 similarity index 57% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Unknown.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Unknown.java index 35a7c864..c53511d2 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Unknown.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Unknown.java @@ -1,189 +1,189 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class represents a reference to an unknown (i.e., - * application-specific) attribute of a class. It is instantiated from the - * Attribute.readAttribute() method. Applications that need to - * read in application-specific attributes should create an AttributeReader implementation and - * attach it via Attribute.addAttributeReader. - - * - * @version $Id: Unknown.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @see org.apache.bcel5_2_0.classfile.Attribute - * @see org.apache.bcel5_2_0.classfile.AttributeReader - * @author M. Dahm - */ -public final class Unknown extends Attribute { - - private byte[] bytes; - private String name; - private static Map 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 - * @throws 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 - * @throws 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 the bytes to set - */ - 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 = new byte[bytes.length]; - System.arraycopy(bytes, 0, c.bytes, 0, bytes.length); - } - c.constant_pool = _constant_pool; - return c; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import org.apache.bcel.Const; + +/** + * This class represents a reference to an unknown (i.e., + * application-specific) attribute of a class. It is instantiated from the + * {@link Attribute#readAttribute(java.io.DataInput, ConstantPool)} method. + * Applications that need to read in application-specific attributes should create an + * {@link UnknownAttributeReader} implementation and attach it via + * {@link Attribute#addAttributeReader(String, UnknownAttributeReader)}. + + * + * @version $Id: Unknown.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see Attribute + * @see UnknownAttributeReader + */ +public final class Unknown extends Attribute { + + private byte[] bytes; + private final String name; + private static final Map unknown_attributes = new HashMap<>(); + + + /** @return array of unknown attributes, but just one for each kind. + */ + static Unknown[] getUnknownAttributes() { + final Unknown[] unknowns = new Unknown[unknown_attributes.size()]; + unknown_attributes.values().toArray(unknowns); + 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(final 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(final int name_index, final int length, final byte[] bytes, final ConstantPool constant_pool) { + super(Const.ATTR_UNKNOWN, name_index, length, constant_pool); + this.bytes = bytes; + name = ((ConstantUtf8) constant_pool.getConstant(name_index, Const.CONSTANT_Utf8)) + .getBytes(); + unknown_attributes.put(name, this); + } + + + /** + * Construct object from input stream. + * + * @param name_index Index in constant pool + * @param length Content length in bytes + * @param input Input stream + * @param constant_pool Array of constants + * @throws IOException + */ + Unknown(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) + throws IOException { + this(name_index, length, (byte[]) null, constant_pool); + if (length > 0) { + bytes = new byte[length]; + input.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitUnknown(this); + } + + + /** + * Dump unknown bytes to file stream. + * + * @param file Output file stream + * @throws IOException + */ + @Override + public final void dump( final DataOutputStream file ) throws IOException { + super.dump(file); + if (super.getLength() > 0) { + file.write(bytes, 0, super.getLength()); + } + } + + + /** + * @return data bytes. + */ + public final byte[] getBytes() { + return bytes; + } + + + /** + * @return name of attribute. + */ + @Override + public final String getName() { + return name; + } + + + /** + * @param bytes the bytes to set + */ + public final void setBytes( final byte[] bytes ) { + this.bytes = bytes; + } + + + /** + * @return String representation. + */ + @Override + public final String toString() { + if (super.getLength() == 0 || bytes == null) { + return "(Unknown attribute " + name + ")"; + } + String hex; + if (super.getLength() > 10) { + final 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 + */ + @Override + public Attribute copy( final ConstantPool _constant_pool ) { + final Unknown c = (Unknown) clone(); + if (bytes != null) { + c.bytes = new byte[bytes.length]; + System.arraycopy(bytes, 0, c.bytes, 0, bytes.length); + } + c.setConstantPool(_constant_pool); + return c; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/UnknownAttributeReader.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/UnknownAttributeReader.java new file mode 100644 index 00000000..a7f56c96 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/UnknownAttributeReader.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.bcel.classfile; + +/** + * Unknown (non-standard) attributes may be read via user-defined factory + * objects that can be registered with the Attribute.addAttributeReader + * method. These factory objects should implement this interface. + * + * @see Attribute + * @version $Id: UnknownAttributeReader.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @since 6.0 + */ +public interface UnknownAttributeReader { + + /** + * When this attribute reader is added via the static method Attribute.addAttributeReader, + * an attribute name is associated with it. As the class file parser parses attributes, + * it will call various AttributeReaders based on the name of the attributes it is constructing. + * + * @param name_index An index into the constant pool, indexing a ConstantUtf8 + * that represents the name of the attribute. + * @param length The length of the data contained in the attribute. This is written + * into the constant pool and should agree with what the factory expects the length to be. + * @param file This is the data input that the factory needs to read its data from. + * @param constant_pool This is the constant pool associated with the Attribute that we are constructing. + * + * @return The user-defined AttributeReader should take this data and use + * it to construct an attribute. In the case of errors, a null can be + * returned which will cause the parsing of the class file to fail. + * + * @see Attribute#addAttributeReader(String, UnknownAttributeReader) + */ + Attribute createAttribute( int name_index, int length, java.io.DataInput file, ConstantPool constant_pool ); +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Utility.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Utility.java old mode 100755 new mode 100644 similarity index 55% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Utility.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Utility.java index c1cd9bd9..1e324c16 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Utility.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Utility.java @@ -1,1344 +1,1508 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.CharArrayReader; -import java.io.CharArrayWriter; -import java.io.FilterReader; -import java.io.FilterWriter; -import java.io.IOException; -import java.io.PrintStream; -import java.io.PrintWriter; -import java.io.Reader; -import java.io.Writer; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.zip.GZIPInputStream; -import java.util.zip.GZIPOutputStream; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.util.ByteSequence; - -/** - * Utility functions that do not really belong to any class in particular. - * - * @version $Id: Utility.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public abstract class Utility { - - private static int unwrap( ThreadLocal tl ) { - return ((Integer) tl.get()).intValue(); - } - - - private static void wrap( ThreadLocal tl, int value ) { - tl.set(new Integer(value)); - } - - private static ThreadLocal consumed_chars = new ThreadLocal() { - - protected Object initialValue() { - return new Integer(0); - } - };/* 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 ) { - StringBuilder buf = new StringBuilder(); - 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]).append(" "); - } - } - 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 - * (number of opcodes, not bytes!) - * @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 ) { - StringBuilder buf = new StringBuilder(code.length * 20); // Should be sufficient - ByteSequence stream = new ByteSequence(code); - try { - for (int i = 0; i < index; i++) { - 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).append(codeToString(stream, constant_pool, verbose)) - .append('\n'); - } - } - } catch (IOException e) { - System.out.println(buf.toString()); - e.printStackTrace(); - throw new ClassFormatException("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; - StringBuilder buf = new StringBuilder(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 = ").append(default_offset).append(", low = ").append(low) - .append(", high = ").append(high).append("("); - 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 = ").append(default_offset).append(", npairs = ").append( - npairs).append(" ("); - for (int i = 0; i < npairs; i++) { - match[i] = bytes.readInt(); - jump_table[i] = offset + bytes.readInt(); - buf.append("(").append(match[i]).append(", ").append(jump_table[i]).append(")"); - 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#").append((bytes.getIndex() - 1) + bytes.readShort()); - break; - /* 32-bit wide jumps - */ - case Constants.GOTO_W: - case Constants.JSR_W: - buf.append("\t\t#").append(((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%").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 Constants.WIDE: - wide = true; - buf.append("\t(wide)"); - break; - /* Array of basic type. - */ - case Constants.NEWARRAY: - buf.append("\t\t<").append(Constants.TYPE_NAMES[bytes.readByte()]).append(">"); - break; - /* Access object/class fields. - */ - case Constants.GETFIELD: - case Constants.GETSTATIC: - case Constants.PUTFIELD: - case Constants.PUTSTATIC: - index = bytes.readUnsignedShort(); - buf.append("\t\t").append( - constant_pool.constantToString(index, Constants.CONSTANT_Fieldref)).append( - (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<").append( - constant_pool.constantToString(index, Constants.CONSTANT_Class)) - .append(">").append((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").append( - constant_pool.constantToString(index, Constants.CONSTANT_Methodref)) - .append((verbose ? " (" + index + ")" : "")); - break; - case Constants.INVOKEINTERFACE: - index = bytes.readUnsignedShort(); - int nargs = bytes.readUnsignedByte(); // historical, redundant - buf.append("\t").append( - constant_pool - .constantToString(index, Constants.CONSTANT_InterfaceMethodref)) - .append(verbose ? " (" + index + ")\t" : "").append(nargs).append("\t") - .append(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").append( - constant_pool.constantToString(index, constant_pool.getConstant(index) - .getTag())).append((verbose ? " (" + index + ")" : "")); - break; - case Constants.LDC: - index = bytes.readUnsignedByte(); - buf.append("\t\t").append( - constant_pool.constantToString(index, constant_pool.getConstant(index) - .getTag())).append((verbose ? " (" + index + ")" : "")); - break; - /* Array of references. - */ - case Constants.ANEWARRAY: - index = bytes.readUnsignedShort(); - buf.append("\t\t<").append( - compactClassName(constant_pool.getConstantString(index, - Constants.CONSTANT_Class), false)).append(">").append( - (verbose ? " (" + index + ")" : "")); - break; - /* Multidimensional array of references. - */ - case Constants.MULTIANEWARRAY: { - index = bytes.readUnsignedShort(); - int dimensions = bytes.readUnsignedByte(); - buf.append("\t<").append( - compactClassName(constant_pool.getConstantString(index, - Constants.CONSTANT_Class), false)).append(">\t").append(dimensions) - .append((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%").append(vindex).append("\t").append(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, java/lang/String becomes - * String. - * - * @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 str, i.e., chop off the prefix, - * if the - * class name starts with this string and the flag chopit is true. - * Slashes / are converted to dots .. - * - * @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, java/lang/String becomes - * java.lang.String, - * e.g.. If chopit is true the prefix java.lang - * 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); - } - - - /** - * @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 ClassFormatException { - StringBuilder buf = new StringBuilder("("); - String str; - if (argv != null) { - for (int i = 0; i < argv.length; i++) { - str = getSignature(argv[i]); - if (str.endsWith("V")) { - throw new ClassFormatException("Invalid type: " + argv[i]); - } - buf.append(str); - } - } - str = getSignature(ret); - buf.append(")").append(str); - return buf.toString(); - } - - - /** - * @param signature Method signature - * @return Array of argument types - * @throws ClassFormatException - */ - public static final String[] methodSignatureArgumentTypes( String signature ) - throws ClassFormatException { - return methodSignatureArgumentTypes(signature, true); - } - - - /** - * @param signature Method signature - * @param chopit Shorten class names ? - * @return Array of argument types - * @throws ClassFormatException - */ - public static final String[] methodSignatureArgumentTypes( String signature, boolean chopit ) - throws ClassFormatException { - List vec = new ArrayList(); - int index; - try { // Read all declarations between for `(' and `)' - if (signature.charAt(0) != '(') { - throw new ClassFormatException("Invalid method signature: " + signature); - } - index = 1; // current string position - while (signature.charAt(index) != ')') { - vec.add(signatureToString(signature.substring(index), chopit)); - //corrected concurrent private static field acess - index += unwrap(consumed_chars); // update position - } - } catch (StringIndexOutOfBoundsException e) { // Should never occur - throw new ClassFormatException("Invalid method signature: " + signature); - } - return (String[]) vec.toArray(new String[vec.size()]); - } - - - /** - * @param signature Method signature - * @return return type of method - * @throws ClassFormatException - */ - public static final String methodSignatureReturnType( String signature ) - throws ClassFormatException { - return methodSignatureReturnType(signature, true); - } - - - /** - * @param signature Method signature - * @param chopit Shorten class names ? - * @return return type of method - * @throws ClassFormatException - */ - public static final String methodSignatureReturnType( String signature, boolean chopit ) - throws ClassFormatException { - 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 ClassFormatException("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: - * - * ::= | 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: - * - * ::= - * - * A method signature represents the arguments that the method expects, and - * the value that it returns. - * ::= () - * ::= * - * - * This method converts such a string into a Java type declaration like - * `void main(String[])' and throws a `ClassFormatException' when the parsed - * type is invalid. - * - * @param signature Method signature - * @param name Method name - * @param access Method access rights - * @return Java type declaration - * @throws ClassFormatException - */ - public static final String methodSignatureToString( String signature, String name, - String access, boolean chopit, LocalVariableTable vars ) throws ClassFormatException { - StringBuilder buf = new StringBuilder("("); - 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 ClassFormatException("Invalid method signature: " + signature); - } - index = 1; // current string position - while (signature.charAt(index) != ')') { - String param_type = signatureToString(signature.substring(index), chopit); - buf.append(param_type); - if (vars != null) { - LocalVariable l = vars.getLocalVariable(var_index); - if (l != null) { - buf.append(" ").append(l.getName()); - } - } else { - buf.append(" arg").append(var_index); - } - if ("double".equals(param_type) || "long".equals(param_type)) { - var_index += 2; - } else { - var_index++; - } - buf.append(", "); - //corrected concurrent private static field acess - index += unwrap(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 ClassFormatException("Invalid method signature: " + signature); - } - if (buf.length() > 1) { - 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 old in str with new. - * - * @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; - StringBuilder buf = new StringBuilder(); - 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: - * - *
-     *  ::= 
-     *       ::= ||
-     *        ::= B|C|D|F|I|J|S|Z
-     *      ::= L;
-     *       ::= [
-     *
-     * 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; ... an object of the given class
-     * S short signed short
-     * Z boolean true or false
-     * [ ... array
-     * 
- * - * This method converts this string into a Java type declaration such as - * `String[]' and throws a `ClassFormatException' 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 ClassFormatException - */ - public static final String signatureToString( String signature, boolean chopit ) { - //corrected concurrent private static field acess - wrap(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 ClassFormatException("Invalid signature: " + signature); - } - //corrected concurrent private static field acess - wrap(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; - StringBuilder brackets; - String type; - int consumed_chars; // Shadows global var - brackets = new StringBuilder(); // 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 `' - type = signatureToString(signature.substring(n), chopit); - //corrected concurrent private static field acess - //Utility.consumed_chars += consumed_chars; is replaced by: - int _temp = unwrap(Utility.consumed_chars) + consumed_chars; - wrap(Utility.consumed_chars, _temp); - return type + brackets.toString(); - } - case 'V': - return "void"; - default: - throw new ClassFormatException("Invalid signature: `" + signature + "'"); - } - } catch (StringIndexOutOfBoundsException e) { // Should never occur - throw new ClassFormatException("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 ) { - StringBuilder buf = new StringBuilder(); - 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) { - buf.append('L').append(type.replace('.', '/')).append(';'); - } - 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 Constants - * - * @param signature in format described above - * @return type of method signature - * @see Constants - */ - public static final byte typeOfMethodSignature( String signature ) throws ClassFormatException { - int index; - try { - if (signature.charAt(0) != '(') { - throw new ClassFormatException("Invalid method signature: " + signature); - } - index = signature.lastIndexOf(')') + 1; - return typeOfSignature(signature.substring(index)); - } catch (StringIndexOutOfBoundsException e) { - throw new ClassFormatException("Invalid method signature: " + signature); - } - } - - - /** - * Return type of signature as a byte value as defined in Constants - * - * @param signature in format described above - * @return type of signature - * @see Constants - */ - public static final byte typeOfSignature( String signature ) throws ClassFormatException { - 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 ClassFormatException("Invalid method signature: " + signature); - } - } catch (StringIndexOutOfBoundsException e) { - throw new ClassFormatException("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(Locale.ENGLISH); - 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 ) { - StringBuilder buf = new StringBuilder(); - for (int i = 0; i < bytes.length; i++) { - short b = byteToShort(bytes[i]); - String hex = Integer.toString(b, 0x10); - if (b < 0x10) { - 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); - } - 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 ) { - return printArray(obj, braces, false); - } - - - public static final String printArray( Object[] obj, boolean braces, boolean quote ) { - if (obj == null) { - return null; - } - StringBuilder buf = new StringBuilder(); - if (braces) { - buf.append('{'); - } - for (int i = 0; i < obj.length; i++) { - if (obj[i] != null) { - buf.append((quote ? "\"" : "")).append(obj[i].toString()).append( - (quote ? "\"" : "")); - } 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

  • the ASCII value as a - * hexadecimal string, if the value is not in the range - * 200..247
  • a Java identifier char not used in a lowercase - * hexadecimal string, if the value is in the range - * 200..247
    • - * - *

      This operation inflates the original byte array by roughly 40-50%

      - * - * @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); - } - jw.close(); - return caw.toString(); - } - - - /** Decode a string back to a byte array. - * - * @param s the string 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; - static int[] CHAR_MAP = new int[FREE_CHARS]; - static int[] MAP_CHAR = new int[256]; // Reverse map - private static final char ESCAPE_CHAR = '$'; - static { - int j = 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 decode() - */ - 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; - } - 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; - } - 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 encode() - */ - 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); - } - } - - - /** - * Escape all occurences of newline chars '\n', quotes \", etc. - */ - public static final String convertString( String label ) { - char[] ch = label.toCharArray(); - StringBuilder buf = new StringBuilder(); - 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(); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.bcel.classfile; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.CharArrayReader; +import java.io.CharArrayWriter; +import java.io.FilterReader; +import java.io.FilterWriter; +import java.io.IOException; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.io.Reader; +import java.io.Writer; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; + +import org.apache.bcel.Const; +import org.apache.bcel.util.ByteSequence; + +/** + * Utility functions that do not really belong to any class in particular. + * + * @version $Id: Utility.java 1808131 2017-09-12 16:36:55Z britter $ + */ +// @since 6.0 methods are no longer final +public abstract class Utility { + + private static int unwrap( final ThreadLocal tl ) { + return tl.get().intValue(); + } + + + private static void wrap( final ThreadLocal tl, final int value ) { + tl.set(Integer.valueOf(value)); + } + + private static ThreadLocal consumed_chars = new ThreadLocal() { + + @Override + protected Integer initialValue() { + return Integer.valueOf(0); + } + };/* 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 String accessToString( final 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 String accessToString( final int access_flags, final boolean for_class ) { + final StringBuilder buf = new StringBuilder(); + int p = 0; + for (int i = 0; p < Const.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 == Const.ACC_SUPER) || (p == Const.ACC_INTERFACE))) { + continue; + } + buf.append(Const.getAccessName(i)).append(" "); + } + } + return buf.toString().trim(); + } + + + /** + * @param access_flags the class flags + * + * @return "class" or "interface", depending on the ACC_INTERFACE flag + */ + public static String classOrInterface( final int access_flags ) { + return ((access_flags & Const.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 + * (number of opcodes, not bytes!) + * @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 String codeToString( final byte[] code, final ConstantPool constant_pool, final int index, + final int length, final boolean verbose ) { + final StringBuilder buf = new StringBuilder(code.length * 20); // Should be sufficient // CHECKSTYLE IGNORE MagicNumber + try (ByteSequence stream = new ByteSequence(code)) { + for (int i = 0; i < index; i++) { + codeToString(stream, constant_pool, verbose); + } + for (int i = 0; stream.available() > 0; i++) { + if ((length < 0) || (i < length)) { + final String indices = fillup(stream.getIndex() + ":", 6, true, ' '); + buf.append(indices).append(codeToString(stream, constant_pool, verbose)).append('\n'); + } + } + } catch (final IOException e) { + throw new ClassFormatException("Byte code error: " + buf.toString(), e); + } + return buf.toString(); + } + + + public static String codeToString( final byte[] code, final ConstantPool constant_pool, final int index, final 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 + * + * @throws IOException if a failure from reading from the bytes argument occurs + */ + public static String codeToString( final ByteSequence bytes, final ConstantPool constant_pool, + final boolean verbose ) throws IOException { + final short opcode = (short) bytes.readUnsignedByte(); + int default_offset = 0; + int low; + int high; + int npairs; + int index; + int vindex; + int constant; + int[] match; + int[] jump_table; + int no_pad_bytes = 0; + int offset; + final StringBuilder buf = new StringBuilder(Const.getOpcodeName(opcode)); + /* Special case: Skip (0-3) padding bytes, i.e., the + * following bytes are 4-byte-aligned + */ + if ((opcode == Const.TABLESWITCH) || (opcode == Const.LOOKUPSWITCH)) { + final 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 " + + Const.getOpcodeName(opcode) + ":" + b); + } + } + // Both cases have a field default_offset in common + default_offset = bytes.readInt(); + } + switch (opcode) { + /* Table switch has variable length arguments. + */ + case Const.TABLESWITCH: + low = bytes.readInt(); + high = bytes.readInt(); + offset = bytes.getIndex() - 12 - no_pad_bytes - 1; + default_offset += offset; + buf.append("\tdefault = ").append(default_offset).append(", low = ").append(low) + .append(", high = ").append(high).append("("); + 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 Const.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 = ").append(default_offset).append(", npairs = ").append( + npairs).append(" ("); + for (int i = 0; i < npairs; i++) { + match[i] = bytes.readInt(); + jump_table[i] = offset + bytes.readInt(); + buf.append("(").append(match[i]).append(", ").append(jump_table[i]).append(")"); + if (i < npairs - 1) { + buf.append(", "); + } + } + buf.append(")"); + } + break; + /* Two address bytes + offset from start of byte stream form the + * jump target + */ + case Const.GOTO: + case Const.IFEQ: + case Const.IFGE: + case Const.IFGT: + case Const.IFLE: + case Const.IFLT: + case Const.JSR: + case Const.IFNE: + case Const.IFNONNULL: + case Const.IFNULL: + case Const.IF_ACMPEQ: + case Const.IF_ACMPNE: + case Const.IF_ICMPEQ: + case Const.IF_ICMPGE: + case Const.IF_ICMPGT: + case Const.IF_ICMPLE: + case Const.IF_ICMPLT: + case Const.IF_ICMPNE: + buf.append("\t\t#").append((bytes.getIndex() - 1) + bytes.readShort()); + break; + /* 32-bit wide jumps + */ + case Const.GOTO_W: + case Const.JSR_W: + buf.append("\t\t#").append((bytes.getIndex() - 1) + bytes.readInt()); + break; + /* Index byte references local variable (register) + */ + case Const.ALOAD: + case Const.ASTORE: + case Const.DLOAD: + case Const.DSTORE: + case Const.FLOAD: + case Const.FSTORE: + case Const.ILOAD: + case Const.ISTORE: + case Const.LLOAD: + case Const.LSTORE: + case Const.RET: + if (wide) { + vindex = bytes.readUnsignedShort(); + wide = false; // Clear flag + } else { + vindex = bytes.readUnsignedByte(); + } + buf.append("\t\t%").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 Const.WIDE: + wide = true; + buf.append("\t(wide)"); + break; + /* Array of basic type. + */ + case Const.NEWARRAY: + buf.append("\t\t<").append(Const.getTypeName(bytes.readByte())).append(">"); + break; + /* Access object/class fields. + */ + case Const.GETFIELD: + case Const.GETSTATIC: + case Const.PUTFIELD: + case Const.PUTSTATIC: + index = bytes.readUnsignedShort(); + buf.append("\t\t").append( + constant_pool.constantToString(index, Const.CONSTANT_Fieldref)).append( + verbose ? " (" + index + ")" : ""); + break; + /* Operands are references to classes in constant pool + */ + case Const.NEW: + case Const.CHECKCAST: + buf.append("\t"); + //$FALL-THROUGH$ + case Const.INSTANCEOF: + index = bytes.readUnsignedShort(); + buf.append("\t<").append( + constant_pool.constantToString(index, Const.CONSTANT_Class)) + .append(">").append(verbose ? " (" + index + ")" : ""); + break; + /* Operands are references to methods in constant pool + */ + case Const.INVOKESPECIAL: + case Const.INVOKESTATIC: + index = bytes.readUnsignedShort(); + final Constant c = constant_pool.getConstant(index); + // With Java8 operand may be either a CONSTANT_Methodref + // or a CONSTANT_InterfaceMethodref. (markro) + buf.append("\t").append( + constant_pool.constantToString(index, c.getTag())) + .append(verbose ? " (" + index + ")" : ""); + break; + case Const.INVOKEVIRTUAL: + index = bytes.readUnsignedShort(); + buf.append("\t").append( + constant_pool.constantToString(index, Const.CONSTANT_Methodref)) + .append(verbose ? " (" + index + ")" : ""); + break; + case Const.INVOKEINTERFACE: + index = bytes.readUnsignedShort(); + final int nargs = bytes.readUnsignedByte(); // historical, redundant + buf.append("\t").append( + constant_pool + .constantToString(index, Const.CONSTANT_InterfaceMethodref)) + .append(verbose ? " (" + index + ")\t" : "").append(nargs).append("\t") + .append(bytes.readUnsignedByte()); // Last byte is a reserved space + break; + case Const.INVOKEDYNAMIC: + index = bytes.readUnsignedShort(); + buf.append("\t").append( + constant_pool + .constantToString(index, Const.CONSTANT_InvokeDynamic)) + .append(verbose ? " (" + index + ")\t" : "") + .append(bytes.readUnsignedByte()) // Thrid byte is a reserved space + .append(bytes.readUnsignedByte()); // Last byte is a reserved space + break; + /* Operands are references to items in constant pool + */ + case Const.LDC_W: + case Const.LDC2_W: + index = bytes.readUnsignedShort(); + buf.append("\t\t").append( + constant_pool.constantToString(index, constant_pool.getConstant(index) + .getTag())).append(verbose ? " (" + index + ")" : ""); + break; + case Const.LDC: + index = bytes.readUnsignedByte(); + buf.append("\t\t").append( + constant_pool.constantToString(index, constant_pool.getConstant(index) + .getTag())).append(verbose ? " (" + index + ")" : ""); + break; + /* Array of references. + */ + case Const.ANEWARRAY: + index = bytes.readUnsignedShort(); + buf.append("\t\t<").append( + compactClassName(constant_pool.getConstantString(index, + Const.CONSTANT_Class), false)).append(">").append( + verbose ? " (" + index + ")" : ""); + break; + /* Multidimensional array of references. + */ + case Const.MULTIANEWARRAY: { + index = bytes.readUnsignedShort(); + final int dimensions = bytes.readUnsignedByte(); + buf.append("\t<").append( + compactClassName(constant_pool.getConstantString(index, + Const.CONSTANT_Class), false)).append(">\t").append(dimensions) + .append(verbose ? " (" + index + ")" : ""); + } + break; + /* Increment local variable. + */ + case Const.IINC: + if (wide) { + vindex = bytes.readUnsignedShort(); + constant = bytes.readShort(); + wide = false; + } else { + vindex = bytes.readUnsignedByte(); + constant = bytes.readByte(); + } + buf.append("\t\t%").append(vindex).append("\t").append(constant); + break; + default: + if (Const.getNoOfOperands(opcode) > 0) { + for (int i = 0; i < Const.getOperandTypeCount(opcode); i++) { + buf.append("\t\t"); + switch (Const.getOperandType(opcode, i)) { + case Const.T_BYTE: + buf.append(bytes.readByte()); + break; + case Const.T_SHORT: + buf.append(bytes.readShort()); + break; + case Const.T_INT: + buf.append(bytes.readInt()); + break; + default: // Never reached + throw new IllegalStateException("Unreachable default case reached!"); + } + } + } + } + return buf.toString(); + } + + + public static String codeToString( final ByteSequence bytes, final ConstantPool constant_pool ) + throws IOException { + return codeToString(bytes, constant_pool, true); + } + + + /** + * Shorten long class names, java/lang/String becomes + * String. + * + * @param str The long class name + * @return Compacted class name + */ + public static String compactClassName( final String str ) { + return compactClassName(str, true); + } + + + /** + * Shorten long class name str, i.e., chop off the prefix, + * if the + * class name starts with this string and the flag chopit is true. + * Slashes / are converted to dots .. + * + * @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 String compactClassName( String str, final String prefix, final boolean chopit ) { + final 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, java/lang/String becomes + * java.lang.String, + * e.g.. If chopit is true the prefix java.lang + * 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 String compactClassName( final String str, final boolean chopit ) { + return compactClassName(str, "java.lang.", chopit); + } + + + /** + * @return `flag' with bit `i' set to 1 + */ + public static int setBit( final int flag, final int i ) { + return flag | pow2(i); + } + + + /** + * @return `flag' with bit `i' set to 0 + */ + public static int clearBit( final int flag, final int i ) { + final int bit = pow2(i); + return (flag & bit) == 0 ? flag : flag ^ bit; + } + + + /** + * @return true, if bit `i' in `flag' is set + */ + public static boolean isSet( final int flag, final 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 + * + * @throws ClassFormatException if the signature is for Void + */ + public static String methodTypeToSignature( final String ret, final String[] argv ) + throws ClassFormatException { + final StringBuilder buf = new StringBuilder("("); + String str; + if (argv != null) { + for (final String element : argv) { + str = getSignature(element); + if (str.endsWith("V")) { + throw new ClassFormatException("Invalid type: " + element); + } + buf.append(str); + } + } + str = getSignature(ret); + buf.append(")").append(str); + return buf.toString(); + } + + + /** + * @param signature Method signature + * @return Array of argument types + * @throws ClassFormatException + */ + public static String[] methodSignatureArgumentTypes( final String signature ) + throws ClassFormatException { + return methodSignatureArgumentTypes(signature, true); + } + + + /** + * @param signature Method signature + * @param chopit Shorten class names ? + * @return Array of argument types + * @throws ClassFormatException + */ + public static String[] methodSignatureArgumentTypes( final String signature, final boolean chopit ) + throws ClassFormatException { + final List vec = new ArrayList<>(); + int index; + try { // Read all declarations between for `(' and `)' + if (signature.charAt(0) != '(') { + throw new ClassFormatException("Invalid method signature: " + signature); + } + index = 1; // current string position + while (signature.charAt(index) != ')') { + vec.add(signatureToString(signature.substring(index), chopit)); + //corrected concurrent private static field acess + index += unwrap(consumed_chars); // update position + } + } catch (final StringIndexOutOfBoundsException e) { // Should never occur + throw new ClassFormatException("Invalid method signature: " + signature, e); + } + return vec.toArray(new String[vec.size()]); + } + + + /** + * @param signature Method signature + * @return return type of method + * @throws ClassFormatException + */ + public static String methodSignatureReturnType( final String signature ) throws ClassFormatException { + return methodSignatureReturnType(signature, true); + } + + + /** + * @param signature Method signature + * @param chopit Shorten class names ? + * @return return type of method + * @throws ClassFormatException + */ + public static String methodSignatureReturnType( final String signature, final boolean chopit ) throws ClassFormatException { + int index; + String type; + try { + // Read return type after `)' + index = signature.lastIndexOf(')') + 1; + type = signatureToString(signature.substring(index), chopit); + } catch (final StringIndexOutOfBoundsException e) { // Should never occur + throw new ClassFormatException("Invalid method signature: " + signature, e); + } + 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 String methodSignatureToString( final String signature, final String name, final String access ) { + return methodSignatureToString(signature, name, access, true); + } + + + public static String methodSignatureToString( final String signature, final String name, final String access, final boolean chopit ) { + return methodSignatureToString(signature, name, access, chopit, null); + } + + + /** + * A returntype 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 `ClassFormatException' when the parsed + * type is invalid. + * + * @param signature Method signature + * @param name Method name + * @param access Method access rights + * @param chopit + * @param vars + * @return Java type declaration + * @throws ClassFormatException + */ + public static String methodSignatureToString( final String signature, final String name, + final String access, final boolean chopit, final LocalVariableTable vars ) throws ClassFormatException { + final StringBuilder buf = new StringBuilder("("); + String type; + int index; + int var_index = access.contains("static") ? 0 : 1; + try { // Read all declarations between for `(' and `)' + if (signature.charAt(0) != '(') { + throw new ClassFormatException("Invalid method signature: " + signature); + } + index = 1; // current string position + while (signature.charAt(index) != ')') { + final String param_type = signatureToString(signature.substring(index), chopit); + buf.append(param_type); + if (vars != null) { + final LocalVariable l = vars.getLocalVariable(var_index, 0); + if (l != null) { + buf.append(" ").append(l.getName()); + } + } else { + buf.append(" arg").append(var_index); + } + if ("double".equals(param_type) || "long".equals(param_type)) { + var_index += 2; + } else { + var_index++; + } + buf.append(", "); + //corrected concurrent private static field acess + index += unwrap(consumed_chars); // update position + } + index++; // update position + // Read return type after `)' + type = signatureToString(signature.substring(index), chopit); + } catch (final StringIndexOutOfBoundsException e) { // Should never occur + throw new ClassFormatException("Invalid method signature: " + signature, e); + } + if (buf.length() > 1) { + 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 int pow2( final int n ) { + return 1 << n; + } + + + /** + * Replace all occurrences of old in str with new. + * + * @param str String to permute + * @param old String to be replaced + * @param new_ Replacement string + * @return new String object + */ + public static String replace( String str, final String old, final String new_ ) { + int index; + int old_index; + try { + if (str.contains(old)) { // `old' found in str + final StringBuilder buf = new StringBuilder(); + 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 (final 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 String signatureToString( final 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: + * + *
      +     * <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
      +     * 
      + * + * This method converts this string into a Java type declaration such as + * `String[]' and throws a `ClassFormatException' 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 ClassFormatException + */ + public static String signatureToString( final String signature, final boolean chopit ) { + //corrected concurrent private static field acess + wrap(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 'T': { // TypeVariableSignature + final int index = signature.indexOf(';'); // Look for closing `;' + if (index < 0) { + throw new ClassFormatException("Invalid signature: " + signature); + } + //corrected concurrent private static field acess + wrap(consumed_chars, index + 1); // "Tblabla;" `T' and `;' are removed + return compactClassName(signature.substring(1, index), chopit); + } + case 'L': { // Full class name + // should this be a while loop? can there be more than + // one generic clause? (markro) + int fromIndex = signature.indexOf('<'); // generic type? + if (fromIndex < 0) { + fromIndex = 0; + } else { + fromIndex = signature.indexOf('>', fromIndex); + if (fromIndex < 0) { + throw new ClassFormatException("Invalid signature: " + signature); + } + } + final int index = signature.indexOf(';', fromIndex); // Look for closing `;' + if (index < 0) { + throw new ClassFormatException("Invalid signature: " + signature); + } + + // check to see if there are any TypeArguments + final int bracketIndex = signature.substring(0, index).indexOf('<'); + if (bracketIndex < 0) { + // just a class identifier + wrap(consumed_chars, index + 1); // "Lblabla;" `L' and `;' are removed + return compactClassName(signature.substring(1, index), chopit); + } + // but make sure we are not looking past the end of the current item + fromIndex = signature.indexOf(';'); + if (fromIndex < 0) { + throw new ClassFormatException("Invalid signature: " + signature); + } + if (fromIndex < bracketIndex) { + // just a class identifier + wrap(consumed_chars, fromIndex + 1); // "Lblabla;" `L' and `;' are removed + return compactClassName(signature.substring(1, fromIndex), chopit); + } + + // we have TypeArguments; build up partial result + // as we recurse for each TypeArgument + final StringBuilder type = new StringBuilder(compactClassName(signature.substring(1, bracketIndex), chopit)).append("<"); + int consumed_chars = bracketIndex + 1; // Shadows global var + + // check for wildcards + if (signature.charAt(consumed_chars) == '+') { + type.append("? extends "); + consumed_chars++; + } else if (signature.charAt(consumed_chars) == '-') { + type.append("? super "); + consumed_chars++; + } + + // get the first TypeArgument + if (signature.charAt(consumed_chars) == '*') { + type.append("?"); + consumed_chars++; + } else { + type.append(signatureToString(signature.substring(consumed_chars), chopit)); + // update our consumed count by the number of characters the for type argument + consumed_chars = unwrap(Utility.consumed_chars) + consumed_chars; + wrap(Utility.consumed_chars, consumed_chars); + } + + // are there more TypeArguments? + while (signature.charAt(consumed_chars) != '>') { + type.append(", "); + // check for wildcards + if (signature.charAt(consumed_chars) == '+') { + type.append("? extends "); + consumed_chars++; + } else if (signature.charAt(consumed_chars) == '-') { + type.append("? super "); + consumed_chars++; + } + if (signature.charAt(consumed_chars) == '*') { + type.append("?"); + consumed_chars++; + } else { + type.append(signatureToString(signature.substring(consumed_chars), chopit)); + // update our consumed count by the number of characters the for type argument + consumed_chars = unwrap(Utility.consumed_chars) + consumed_chars; + wrap(Utility.consumed_chars, consumed_chars); + } + } + + // process the closing ">" + consumed_chars++; + type.append(">"); + + if (signature.charAt(consumed_chars) == '.') { + // we have a ClassTypeSignatureSuffix + type.append("."); + // convert SimpleClassTypeSignature to fake ClassTypeSignature + // and then recurse to parse it + type.append(signatureToString("L" + signature.substring(consumed_chars+1), chopit)); + // update our consumed count by the number of characters the for type argument + // note that this count includes the "L" we added, but that is ok + // as it accounts for the "." we didn't consume + consumed_chars = unwrap(Utility.consumed_chars) + consumed_chars; + wrap(Utility.consumed_chars, consumed_chars); + return type.toString(); + } + if (signature.charAt(consumed_chars) != ';') { + throw new ClassFormatException("Invalid signature: " + signature); + } + wrap(Utility.consumed_chars, consumed_chars + 1); // remove final ";" + return type.toString(); + } + case 'S': + return "short"; + case 'Z': + return "boolean"; + case '[': { // Array declaration + int n; + StringBuilder brackets; + String type; + int consumed_chars; // Shadows global var + brackets = new StringBuilder(); // 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 `' + type = signatureToString(signature.substring(n), chopit); + //corrected concurrent private static field acess + //Utility.consumed_chars += consumed_chars; is replaced by: + final int _temp = unwrap(Utility.consumed_chars) + consumed_chars; + wrap(Utility.consumed_chars, _temp); + return type + brackets.toString(); + } + case 'V': + return "void"; + default: + throw new ClassFormatException("Invalid signature: `" + signature + "'"); + } + } catch (final StringIndexOutOfBoundsException e) { // Should never occur + throw new ClassFormatException("Invalid signature: " + signature, e); + } + } + + + /** 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 ) { + final StringBuilder buf = new StringBuilder(); + final char[] chars = type.toCharArray(); + boolean char_found = false; + boolean 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 = Const.T_BOOLEAN; (i <= Const.T_VOID) && !found; i++) { + if (Const.getTypeName(i).equals(type)) { + found = true; + buf.append(Const.getShortTypeName(i)); + } + } + if (!found) { + buf.append('L').append(type.replace('.', '/')).append(';'); + } + return buf.toString(); + } + + + private static int countBrackets( final String brackets ) { + final char[] chars = brackets.toCharArray(); + int count = 0; + boolean open = false; + for (final char c : chars) { + switch (c) { + 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 + break; + } + } + if (open) { + throw new RuntimeException("Illegally nested brackets:" + brackets); + } + return count; + } + + + /** + * Return type of method signature as a byte value as defined in Constants + * + * @param signature in format described above + * @return type of method signature + * @see Const + * + * @throws ClassFormatException if signature is not a method signature + */ + public static byte typeOfMethodSignature( final String signature ) throws ClassFormatException { + int index; + try { + if (signature.charAt(0) != '(') { + throw new ClassFormatException("Invalid method signature: " + signature); + } + index = signature.lastIndexOf(')') + 1; + return typeOfSignature(signature.substring(index)); + } catch (final StringIndexOutOfBoundsException e) { + throw new ClassFormatException("Invalid method signature: " + signature, e); + } + } + + + /** + * Return type of signature as a byte value as defined in Constants + * + * @param signature in format described above + * @return type of signature + * @see Const + * + * @throws ClassFormatException if signature isn't a known type + */ + public static byte typeOfSignature( final String signature ) throws ClassFormatException { + try { + switch (signature.charAt(0)) { + case 'B': + return Const.T_BYTE; + case 'C': + return Const.T_CHAR; + case 'D': + return Const.T_DOUBLE; + case 'F': + return Const.T_FLOAT; + case 'I': + return Const.T_INT; + case 'J': + return Const.T_LONG; + case 'L': + case 'T': + return Const.T_REFERENCE; + case '[': + return Const.T_ARRAY; + case 'V': + return Const.T_VOID; + case 'Z': + return Const.T_BOOLEAN; + case 'S': + return Const.T_SHORT; + case '!': + case '+': + case '*': + return typeOfSignature(signature.substring(1)); + default: + throw new ClassFormatException("Invalid method signature: " + signature); + } + } catch (final StringIndexOutOfBoundsException e) { + throw new ClassFormatException("Invalid method signature: " + signature, e); + } + } + + + /** Map opcode names to opcode numbers. E.g., return Constants.ALOAD for "aload" + */ + public static short searchOpcode( String name ) { + name = name.toLowerCase(Locale.ENGLISH); + for (short i = 0; i < Const.OPCODE_NAMES_LENGTH; i++) { + if (Const.getOpcodeName(i).equals(name)) { + return i; + } + } + return -1; + } + + + /** + * Convert (signed) byte to (unsigned) short value, i.e., all negative + * values become positive. + */ + private static short byteToShort( final byte b ) { + return (b < 0) ? (short) (256 + b) : (short) b; + } + + + /** Convert bytes into hexadecimal string + * + * @param bytes an array of bytes to convert to hexadecimal + * + * @return bytes as hexadecimal string, e.g. 00 fa 12 ... + */ + public static String toHexString( final byte[] bytes ) { + final StringBuilder buf = new StringBuilder(); + for (int i = 0; i < bytes.length; i++) { + final short b = byteToShort(bytes[i]); + final String hex = Integer.toHexString(b); + if (b < 0x10) { + 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 String format( final int i, final int length, final boolean left_justify, final 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 String fillup( final String str, final int length, final boolean left_justify, final char fill ) { + final int len = length - str.length(); + final 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); + } + return new String(buf) + str; + } + + + static boolean equals( final byte[] a, final 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 void printArray( final PrintStream out, final Object[] obj ) { + out.println(printArray(obj, true)); + } + + + public static void printArray( final PrintWriter out, final Object[] obj ) { + out.println(printArray(obj, true)); + } + + + public static String printArray( final Object[] obj ) { + return printArray(obj, true); + } + + + public static String printArray( final Object[] obj, final boolean braces ) { + return printArray(obj, braces, false); + } + + + public static String printArray( final Object[] obj, final boolean braces, final boolean quote ) { + if (obj == null) { + return null; + } + final StringBuilder buf = new StringBuilder(); + if (braces) { + buf.append('{'); + } + for (int i = 0; i < obj.length; i++) { + if (obj[i] != null) { + buf.append(quote ? "\"" : "").append(obj[i]).append(quote ? "\"" : ""); + } else { + buf.append("null"); + } + if (i < obj.length - 1) { + buf.append(", "); + } + } + if (braces) { + buf.append('}'); + } + return buf.toString(); + } + + + /** + * @param ch the character to test if it's part of an identifier + * + * @return true, if character is one of (a, ... z, A, ... Z, 0, ... 9, _) + */ + public static boolean isJavaIdentifierPart( final 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: + * + *
        + *
      • the ASCII value as a hexadecimal string, if the value is not in the range 200..247
      • + *
      • a Java identifier char not used in a lowercase hexadecimal string, if the value is in the range 200..247
      • + *
      + * + *

      This operation inflates the original byte array by roughly 40-50%

      + * + * @param bytes the byte array to convert + * @param compress use gzip to minimize string + * + * @throws IOException if there's a gzip exception + */ + public static String encode(byte[] bytes, final boolean compress) throws IOException { + if (compress) { + try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); + GZIPOutputStream gos = new GZIPOutputStream(baos)) { + gos.write(bytes, 0, bytes.length); + bytes = baos.toByteArray(); + } + } + final CharArrayWriter caw = new CharArrayWriter(); + try (JavaWriter jw = new JavaWriter(caw)) { + for (final byte b : bytes) { + final int in = b & 0x000000ff; // Normalize to unsigned + jw.write(in); + } + } + return caw.toString(); + } + + + /** + * Decode a string back to a byte array. + * + * @param s the string to convert + * @param uncompress use gzip to uncompress the stream of bytes + * + * @throws IOException if there's a gzip exception + */ + public static byte[] decode(final String s, final boolean uncompress) throws IOException { + byte[] bytes; + try (JavaReader jr = new JavaReader(new CharArrayReader(s.toCharArray())); + ByteArrayOutputStream bos = new ByteArrayOutputStream()) { + int ch; + while ((ch = jr.read()) >= 0) { + bos.write(ch); + } + bytes = bos.toByteArray(); + } + if (uncompress) { + final GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(bytes)); + final 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; + 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 decode() + */ + private static class JavaReader extends FilterReader { + + public JavaReader(final Reader in) { + super(in); + } + + + @Override + public int read() throws IOException { + final int b = in.read(); + if (b != ESCAPE_CHAR) { + return b; + } + final int i = in.read(); + if (i < 0) { + return -1; + } + if (((i >= '0') && (i <= '9')) || ((i >= 'a') && (i <= 'f'))) { // Normal escape + final int j = in.read(); + if (j < 0) { + return -1; + } + final char[] tmp = { + (char) i, (char) j + }; + final int s = Integer.parseInt(new String(tmp), 16); + return s; + } + return MAP_CHAR[i]; + } + + + @Override + public int read( final char[] cbuf, final int off, final 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 encode() + */ + private static class JavaWriter extends FilterWriter { + + public JavaWriter(final Writer out) { + super(out); + } + + + @Override + public void write( final 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 + final 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]); + } + } + } + } + + + @Override + public void write( final char[] cbuf, final int off, final int len ) throws IOException { + for (int i = 0; i < len; i++) { + write(cbuf[off + i]); + } + } + + + @Override + public void write( final String str, final int off, final int len ) throws IOException { + write(str.toCharArray(), off, len); + } + } + + + /** + * Escape all occurences of newline chars '\n', quotes \", etc. + */ + public static String convertString( final String label ) { + final char[] ch = label.toCharArray(); + final StringBuilder buf = new StringBuilder(); + for (final char element : ch) { + switch (element) { + 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(element); + break; + } + } + return buf.toString(); + } + +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Visitor.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Visitor.java new file mode 100644 index 00000000..15004a5b --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Visitor.java @@ -0,0 +1,159 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.classfile; + +/** + * 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. + * + * @version $Id: Visitor.java 1782852 2017-02-13 20:19:41Z markt $ + */ +public interface Visitor +{ + void visitCode(Code obj); + + void visitCodeException(CodeException obj); + + void visitConstantClass(ConstantClass obj); + + void visitConstantDouble(ConstantDouble obj); + + void visitConstantFieldref(ConstantFieldref obj); + + void visitConstantFloat(ConstantFloat obj); + + void visitConstantInteger(ConstantInteger obj); + + void visitConstantInterfaceMethodref(ConstantInterfaceMethodref obj); + + void visitConstantInvokeDynamic(ConstantInvokeDynamic obj); + + void visitConstantLong(ConstantLong obj); + + void visitConstantMethodref(ConstantMethodref obj); + + void visitConstantNameAndType(ConstantNameAndType obj); + + void visitConstantPool(ConstantPool obj); + + void visitConstantString(ConstantString obj); + + void visitConstantUtf8(ConstantUtf8 obj); + + void visitConstantValue(ConstantValue obj); + + void visitDeprecated(Deprecated obj); + + void visitExceptionTable(ExceptionTable obj); + + void visitField(Field obj); + + void visitInnerClass(InnerClass obj); + + void visitInnerClasses(InnerClasses obj); + + void visitJavaClass(JavaClass obj); + + void visitLineNumber(LineNumber obj); + + void visitLineNumberTable(LineNumberTable obj); + + void visitLocalVariable(LocalVariable obj); + + void visitLocalVariableTable(LocalVariableTable obj); + + void visitMethod(Method obj); + + void visitSignature(Signature obj); + + void visitSourceFile(SourceFile obj); + + void visitSynthetic(Synthetic obj); + + void visitUnknown(Unknown obj); + + void visitStackMap(StackMap obj); + + void visitStackMapEntry(StackMapEntry obj); + + /** + * @since 6.0 + */ + void visitAnnotation(Annotations obj); + + /** + * @since 6.0 + */ + void visitParameterAnnotation(ParameterAnnotations obj); + + /** + * @since 6.0 + */ + void visitAnnotationEntry(AnnotationEntry obj); + + /** + * @since 6.0 + */ + void visitAnnotationDefault(AnnotationDefault obj); + + /** + * @since 6.0 + */ + void visitLocalVariableTypeTable(LocalVariableTypeTable obj); + + /** + * @since 6.0 + */ + void visitEnclosingMethod(EnclosingMethod obj); + + /** + * @since 6.0 + */ + void visitBootstrapMethods(BootstrapMethods obj); + + /** + * @since 6.0 + */ + void visitMethodParameters(MethodParameters obj); + + /** + * @since 6.0 + */ + void visitConstantMethodType(ConstantMethodType obj); + + /** + * @since 6.0 + */ + void visitConstantMethodHandle(ConstantMethodHandle obj); + + /** + * @since 6.0 + */ + void visitParameterAnnotationEntry(ParameterAnnotationEntry obj); + + /** + * @since 6.1 + */ + void visitConstantPackage(ConstantPackage constantPackage); + + /** + * @since 6.1 + */ + void visitConstantModule(ConstantModule constantModule); +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/package.html b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/package.html new file mode 100644 index 00000000..713a0bf2 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/package.html @@ -0,0 +1,30 @@ + + + + + + + +

      +This package contains the classes that describe the structure of a +Java class file and a class file parser. +

      + + diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/AALOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AALOAD.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/AALOAD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AALOAD.java index b3634ca9..55b791b4 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/AALOAD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AALOAD.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * AALOAD - Load reference from array - *
      Stack: ..., arrayref, index -> value
      - * - * @version $Id: AALOAD.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class AALOAD extends ArrayInstruction implements StackProducer { - - /** Load reference from array - */ - public AALOAD() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * AALOAD - Load reference from array + *
      Stack: ..., arrayref, index -> value
      + * + * @version $Id: AALOAD.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class AALOAD extends ArrayInstruction implements StackProducer { + + /** Load reference from array + */ + public AALOAD() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackProducer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitAALOAD(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/AASTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AASTORE.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/AASTORE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AASTORE.java index b2acbb05..5afe322c --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/AASTORE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AASTORE.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * AASTORE - Store into reference array - *
      Stack: ..., arrayref, index, value -> ...
      - * - * @version $Id: AASTORE.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class AASTORE extends ArrayInstruction implements StackConsumer { - - /** Store into reference array - */ - public AASTORE() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * AASTORE - Store into reference array + *
      Stack: ..., arrayref, index, value -> ...
      + * + * @version $Id: AASTORE.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class AASTORE extends ArrayInstruction implements StackConsumer { + + /** Store into reference array + */ + public AASTORE() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitAASTORE(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ACONST_NULL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ACONST_NULL.java old mode 100755 new mode 100644 similarity index 58% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ACONST_NULL.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ACONST_NULL.java index eff64a88..cabad429 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ACONST_NULL.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ACONST_NULL.java @@ -1,57 +1,59 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * ACONST_NULL - Push null reference - *
      Stack: ... -> ..., null
      - * - * @version $Id: ACONST_NULL.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class ACONST_NULL extends Instruction implements PushInstruction, TypedInstruction { - - /** - * Push null reference - */ - public ACONST_NULL() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * ACONST_NULL - Push null reference + *
      Stack: ... -> ..., null
      + * + * @version $Id: ACONST_NULL.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class ACONST_NULL extends Instruction implements PushInstruction, TypedInstruction { + + /** + * Push null reference + */ + public ACONST_NULL() { + super(org.apache.bcel.Const.ACONST_NULL, (short) 1); + } + + + /** @return Type.NULL + */ + @Override + public Type getType( final 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackProducer(this); + v.visitPushInstruction(this); + v.visitTypedInstruction(this); + v.visitACONST_NULL(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ALOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ALOAD.java old mode 100755 new mode 100644 similarity index 51% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ALOAD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ALOAD.java index ac937127..5971c0e1 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ALOAD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ALOAD.java @@ -1,57 +1,58 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * ALOAD - Load reference from local variable - *
      Stack: ... -> ..., objectref
      - * - * @version $Id: ALOAD.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.Constants.ALOAD, org.apache.bcel5_2_0.Constants.ALOAD_0); - } - - - /** Load reference from local variable - * @param n index of local variable - */ - public ALOAD(int n) { - super(org.apache.bcel5_2_0.Constants.ALOAD, org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * ALOAD - Load reference from local variable + *
      Stack: ... -> ..., objectref
      + * + * @version $Id: ALOAD.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class ALOAD extends LoadInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + ALOAD() { + super(org.apache.bcel.Const.ALOAD, org.apache.bcel.Const.ALOAD_0); + } + + + /** Load reference from local variable + * @param n index of local variable + */ + public ALOAD(final int n) { + super(org.apache.bcel.Const.ALOAD, org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + super.accept(v); + v.visitALOAD(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ANEWARRAY.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ANEWARRAY.java old mode 100755 new mode 100644 similarity index 53% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ANEWARRAY.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ANEWARRAY.java index 12701b68..3f91b8b6 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ANEWARRAY.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ANEWARRAY.java @@ -1,79 +1,79 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.ExceptionConstants; - -/** - * ANEWARRAY - Create new array of references - *
      Stack: ..., count -> ..., arrayref
      - * - * @version $Id: ANEWARRAY.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class ANEWARRAY extends CPInstruction implements LoadClass, AllocationInstruction, - ExceptionThrower, StackConsumer, 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.bcel5_2_0.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; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.ExceptionConst; + +/** + * ANEWARRAY - Create new array of references + *
      Stack: ..., count -> ..., arrayref
      + * + * @version $Id: ANEWARRAY.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class ANEWARRAY extends CPInstruction implements LoadClass, AllocationInstruction, + ExceptionThrower, StackConsumer, StackProducer { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + ANEWARRAY() { + } + + + public ANEWARRAY(final int index) { + super(org.apache.bcel.Const.ANEWARRAY, index); + } + + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_CLASS_AND_INTERFACE_RESOLUTION, + ExceptionConst.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitLoadClass(this); + v.visitAllocationInstruction(this); + v.visitExceptionThrower(this); + v.visitStackProducer(this); + v.visitTypedInstruction(this); + v.visitCPInstruction(this); + v.visitANEWARRAY(this); + } + + + @Override + public ObjectType getLoadClassType( final ConstantPoolGen cpg ) { + Type t = getType(cpg); + if (t instanceof ArrayType) { + t = ((ArrayType) t).getBasicType(); + } + return (t instanceof ObjectType) ? (ObjectType) t : null; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ARETURN.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ARETURN.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ARETURN.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ARETURN.java index a7d69069..bea418e3 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ARETURN.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ARETURN.java @@ -1,51 +1,52 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * ARETURN - Return reference from method - *
      Stack: ..., objectref -> <empty>
      - * - * @version $Id: ARETURN.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class ARETURN extends ReturnInstruction { - - /** - * Return reference from method - */ - public ARETURN() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * ARETURN - Return reference from method + *
      Stack: ..., objectref -> <empty>
      + * + * @version $Id: ARETURN.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class ARETURN extends ReturnInstruction { + + /** + * Return reference from method + */ + public ARETURN() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackConsumer(this); + v.visitReturnInstruction(this); + v.visitARETURN(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ARRAYLENGTH.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ARRAYLENGTH.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ARRAYLENGTH.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ARRAYLENGTH.java index e1dbd474..fb7f897f --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ARRAYLENGTH.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ARRAYLENGTH.java @@ -1,57 +1,61 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * ARRAYLENGTH - Get length of array - *
      Stack: ..., arrayref -> ..., length
      - * - * @version $Id: ARRAYLENGTH.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class ARRAYLENGTH extends Instruction implements ExceptionThrower, StackProducer { - - /** Get length of array - */ - public ARRAYLENGTH() { - super(org.apache.bcel5_2_0.Constants.ARRAYLENGTH, (short) 1); - } - - - /** @return exceptions this instruction may cause - */ - public Class[] getExceptions() { - return new Class[] { - org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.ExceptionConst; + +/** + * ARRAYLENGTH - Get length of array + *
      Stack: ..., arrayref -> ..., length
      + * + * @version $Id: ARRAYLENGTH.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class ARRAYLENGTH extends Instruction implements ExceptionThrower, StackProducer, StackConsumer /* since 6.0 */ { + + /** Get length of array + */ + public ARRAYLENGTH() { + super(org.apache.bcel.Const.ARRAYLENGTH, (short) 1); + } + + + /** @return exceptions this instruction may cause + */ + @Override + public Class[] getExceptions() { + return new Class[] { + ExceptionConst.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitExceptionThrower(this); + v.visitStackProducer(this); + v.visitARRAYLENGTH(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ASTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ASTORE.java old mode 100755 new mode 100644 similarity index 51% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ASTORE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ASTORE.java index ded7e342..546fe665 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ASTORE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ASTORE.java @@ -1,57 +1,58 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * ASTORE - Store reference into local variable - *
      Stack ..., objectref -> ... 
      - * - * @version $Id: ASTORE.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.Constants.ASTORE, org.apache.bcel5_2_0.Constants.ASTORE_0); - } - - - /** Store reference into local variable - * @param n index of local variable - */ - public ASTORE(int n) { - super(org.apache.bcel5_2_0.Constants.ASTORE, org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * ASTORE - Store reference into local variable + *
      Stack ..., objectref -> ... 
      + * + * @version $Id: ASTORE.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class ASTORE extends StoreInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + ASTORE() { + super(org.apache.bcel.Const.ASTORE, org.apache.bcel.Const.ASTORE_0); + } + + + /** Store reference into local variable + * @param n index of local variable + */ + public ASTORE(final int n) { + super(org.apache.bcel.Const.ASTORE, org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + super.accept(v); + v.visitASTORE(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ATHROW.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ATHROW.java old mode 100755 new mode 100644 similarity index 56% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ATHROW.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ATHROW.java index 4f42f6d7..8cf2b608 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ATHROW.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ATHROW.java @@ -1,58 +1,62 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * ATHROW - Throw exception - *
      Stack: ..., objectref -> objectref
      - * - * @version $Id: ATHROW.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class ATHROW extends Instruction implements UnconditionalBranch, ExceptionThrower { - - /** - * Throw exception - */ - public ATHROW() { - super(org.apache.bcel5_2_0.Constants.ATHROW, (short) 1); - } - - - /** @return exceptions this instruction may cause - */ - public Class[] getExceptions() { - return new Class[] { - org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.ExceptionConst; + +/** + * ATHROW - Throw exception + *
      Stack: ..., objectref -> objectref
      + * + * @version $Id: ATHROW.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class ATHROW extends Instruction implements UnconditionalBranch, ExceptionThrower { + + /** + * Throw exception + */ + public ATHROW() { + super(org.apache.bcel.Const.ATHROW, (short) 1); + } + + + /** @return exceptions this instruction may cause + */ + @Override + public Class[] getExceptions() { + return new Class[] { + ExceptionConst.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitUnconditionalBranch(this); + v.visitExceptionThrower(this); + v.visitATHROW(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AllocationInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AllocationInstruction.java new file mode 100644 index 00000000..09f2559c --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AllocationInstruction.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Denote family of instructions that allocates space in the heap. + * + * @version $Id: AllocationInstruction.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public interface AllocationInstruction { +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AnnotationElementValueGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AnnotationElementValueGen.java new file mode 100644 index 00000000..c5461bbb --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AnnotationElementValueGen.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.classfile.AnnotationElementValue; +import org.apache.bcel.classfile.ElementValue; + +/** + * @since 6.0 + */ +public class AnnotationElementValueGen extends ElementValueGen +{ + // For annotation element values, this is the annotation + private final AnnotationEntryGen a; + + public AnnotationElementValueGen(final AnnotationEntryGen a, final ConstantPoolGen cpool) + { + super(ANNOTATION, cpool); + this.a = a; + } + + public AnnotationElementValueGen(final int type, final AnnotationEntryGen annotation, + final ConstantPoolGen cpool) + { + super(type, cpool); + if (type != ANNOTATION) { + throw new RuntimeException( + "Only element values of type annotation can be built with this ctor - type specified: " + type); + } + this.a = annotation; + } + + public AnnotationElementValueGen(final AnnotationElementValue value, + final ConstantPoolGen cpool, final boolean copyPoolEntries) + { + super(ANNOTATION, cpool); + a = new AnnotationEntryGen(value.getAnnotationEntry(), cpool, copyPoolEntries); + } + + @Override + public void dump(final DataOutputStream dos) throws IOException + { + dos.writeByte(super.getElementValueType()); // u1 type of value (ANNOTATION == '@') + a.dump(dos); + } + + @Override + public String stringifyValue() + { + throw new RuntimeException("Not implemented yet"); + } + + /** + * Return immutable variant of this AnnotationElementValueGen + */ + @Override + public ElementValue getElementValue() + { + return new AnnotationElementValue(super.getElementValueType(), + a.getAnnotation(), + getConstantPool().getConstantPool()); + } + + public AnnotationEntryGen getAnnotation() + { + return a; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AnnotationEntryGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AnnotationEntryGen.java new file mode 100644 index 00000000..34e75626 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AnnotationEntryGen.java @@ -0,0 +1,355 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInput; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.apache.bcel.classfile.AnnotationEntry; +import org.apache.bcel.classfile.Attribute; +import org.apache.bcel.classfile.ConstantUtf8; +import org.apache.bcel.classfile.ElementValuePair; +import org.apache.bcel.classfile.RuntimeInvisibleAnnotations; +import org.apache.bcel.classfile.RuntimeInvisibleParameterAnnotations; +import org.apache.bcel.classfile.RuntimeVisibleAnnotations; +import org.apache.bcel.classfile.RuntimeVisibleParameterAnnotations; + +/** + * @since 6.0 + */ +public class AnnotationEntryGen { + private int typeIndex; + + private List evs; + + private final ConstantPoolGen cpool; + + private boolean isRuntimeVisible = false; + + /** + * Here we are taking a fixed annotation of type Annotation and building a + * modifiable AnnotationGen object. If the pool passed in is for a different + * class file, then copyPoolEntries should have been passed as true as that + * will force us to do a deep copy of the annotation and move the cpool + * entries across. We need to copy the type and the element name value pairs + * and the visibility. + */ + public AnnotationEntryGen(final AnnotationEntry a, final ConstantPoolGen cpool, + final boolean copyPoolEntries) { + this.cpool = cpool; + if (copyPoolEntries) { + typeIndex = cpool.addUtf8(a.getAnnotationType()); + } else { + typeIndex = a.getAnnotationTypeIndex(); + } + isRuntimeVisible = a.isRuntimeVisible(); + evs = copyValues(a.getElementValuePairs(), cpool, copyPoolEntries); + } + + private List copyValues(final ElementValuePair[] in, final ConstantPoolGen cpool, + final boolean copyPoolEntries) { + final List out = new ArrayList<>(); + for (final ElementValuePair nvp : in) { + out.add(new ElementValuePairGen(nvp, cpool, copyPoolEntries)); + } + return out; + } + + private AnnotationEntryGen(final ConstantPoolGen cpool) { + this.cpool = cpool; + } + + /** + * Retrieve an immutable version of this AnnotationGen + */ + public AnnotationEntry getAnnotation() { + final AnnotationEntry a = new AnnotationEntry(typeIndex, cpool.getConstantPool(), + isRuntimeVisible); + for (final ElementValuePairGen element : evs) { + a.addElementNameValuePair(element.getElementNameValuePair()); + } + return a; + } + + public AnnotationEntryGen(final ObjectType type, + final List elements, final boolean vis, + final ConstantPoolGen cpool) { + this.cpool = cpool; + this.typeIndex = cpool.addUtf8(type.getSignature()); + evs = elements; + isRuntimeVisible = vis; + } + + public static AnnotationEntryGen read(final DataInput dis, + final ConstantPoolGen cpool, final boolean b) throws IOException { + final AnnotationEntryGen a = new AnnotationEntryGen(cpool); + a.typeIndex = dis.readUnsignedShort(); + final int elemValuePairCount = dis.readUnsignedShort(); + for (int i = 0; i < elemValuePairCount; i++) { + final int nidx = dis.readUnsignedShort(); + a.addElementNameValuePair(new ElementValuePairGen(nidx, + ElementValueGen.readElementValue(dis, cpool), cpool)); + } + a.isRuntimeVisible(b); + return a; + } + + public void dump(final DataOutputStream dos) throws IOException { + dos.writeShort(typeIndex); // u2 index of type name in cpool + dos.writeShort(evs.size()); // u2 element_value pair count + for (final ElementValuePairGen envp : evs) { + envp.dump(dos); + } + } + + public void addElementNameValuePair(final ElementValuePairGen evp) { + if (evs == null) { + evs = new ArrayList<>(); + } + evs.add(evp); + } + + public int getTypeIndex() { + return typeIndex; + } + + public final String getTypeSignature() { + // ConstantClass c = (ConstantClass)cpool.getConstant(typeIndex); + final ConstantUtf8 utf8 = (ConstantUtf8) cpool + .getConstant(typeIndex/* c.getNameIndex() */); + return utf8.getBytes(); + } + + public final String getTypeName() { + return getTypeSignature();// BCELBUG: Should I use this instead? + // Utility.signatureToString(getTypeSignature()); + } + + /** + * Returns list of ElementNameValuePair objects + */ + public List getValues() { + return evs; + } + + @Override + public String toString() { + final StringBuilder s = new StringBuilder(32); // CHECKSTYLE IGNORE MagicNumber + s.append("AnnotationGen:[").append(getTypeName()).append(" #").append(evs.size()).append(" {"); + for (int i = 0; i < evs.size(); i++) { + s.append(evs.get(i)); + if (i + 1 < evs.size()) { + s.append(","); + } + } + s.append("}]"); + return s.toString(); + } + + public String toShortString() { + final StringBuilder s = new StringBuilder(); + s.append("@").append(getTypeName()).append("("); + for (int i = 0; i < evs.size(); i++) { + s.append(evs.get(i)); + if (i + 1 < evs.size()) { + s.append(","); + } + } + s.append(")"); + return s.toString(); + } + + private void isRuntimeVisible(final boolean b) { + isRuntimeVisible = b; + } + + public boolean isRuntimeVisible() { + return isRuntimeVisible; + } + + + /** + * Converts a list of AnnotationGen objects into a set of attributes + * that can be attached to the class file. + * + * @param cp The constant pool gen where we can create the necessary name refs + * @param annotationEntryGens An array of AnnotationGen objects + */ + static Attribute[] getAnnotationAttributes(final ConstantPoolGen cp, final AnnotationEntryGen[] annotationEntryGens) { + if (annotationEntryGens.length == 0) { + return new Attribute[0]; + } + + try { + int countVisible = 0; + int countInvisible = 0; + + // put the annotations in the right output stream + for (final AnnotationEntryGen a : annotationEntryGens) { + if (a.isRuntimeVisible()) { + countVisible++; + } else { + countInvisible++; + } + } + + final ByteArrayOutputStream rvaBytes = new ByteArrayOutputStream(); + final ByteArrayOutputStream riaBytes = new ByteArrayOutputStream(); + try (DataOutputStream rvaDos = new DataOutputStream(rvaBytes); + DataOutputStream riaDos = new DataOutputStream(riaBytes)) { + + rvaDos.writeShort(countVisible); + riaDos.writeShort(countInvisible); + + // put the annotations in the right output stream + for (final AnnotationEntryGen a : annotationEntryGens) { + if (a.isRuntimeVisible()) { + a.dump(rvaDos); + } else { + a.dump(riaDos); + } + } + } + + final byte[] rvaData = rvaBytes.toByteArray(); + final byte[] riaData = riaBytes.toByteArray(); + + int rvaIndex = -1; + int riaIndex = -1; + + if (rvaData.length > 2) { + rvaIndex = cp.addUtf8("RuntimeVisibleAnnotations"); + } + if (riaData.length > 2) { + riaIndex = cp.addUtf8("RuntimeInvisibleAnnotations"); + } + + final List newAttributes = new ArrayList<>(); + if (rvaData.length > 2) { + newAttributes.add( + new RuntimeVisibleAnnotations(rvaIndex, rvaData.length, + new DataInputStream(new ByteArrayInputStream(rvaData)), cp.getConstantPool())); + } + if (riaData.length > 2) { + newAttributes.add( + new RuntimeInvisibleAnnotations(riaIndex, riaData.length, + new DataInputStream(new ByteArrayInputStream(riaData)), cp.getConstantPool())); + } + + return newAttributes.toArray(new Attribute[newAttributes.size()]); + } catch (final IOException e) { + System.err.println("IOException whilst processing annotations"); + e.printStackTrace(); + } + return null; + } + + + /** + * Annotations against a class are stored in one of four attribute kinds: + * - RuntimeVisibleParameterAnnotations + * - RuntimeInvisibleParameterAnnotations + */ + static Attribute[] getParameterAnnotationAttributes( + final ConstantPoolGen cp, + final List[] /*Array of lists, array size depends on #params */vec) { + final int[] visCount = new int[vec.length]; + int totalVisCount = 0; + final int[] invisCount = new int[vec.length]; + int totalInvisCount = 0; + try { + for (int i = 0; i < vec.length; i++) { + if (vec[i] != null) { + for (final AnnotationEntryGen element : vec[i]) { + if (element.isRuntimeVisible()) { + visCount[i]++; + totalVisCount++; + } else { + invisCount[i]++; + totalInvisCount++; + } + } + } + } + // Lets do the visible ones + final ByteArrayOutputStream rvaBytes = new ByteArrayOutputStream(); + try (DataOutputStream rvaDos = new DataOutputStream(rvaBytes)) { + rvaDos.writeByte(vec.length); // First goes number of parameters + for (int i = 0; i < vec.length; i++) { + rvaDos.writeShort(visCount[i]); + if (visCount[i] > 0) { + for (final AnnotationEntryGen element : vec[i]) { + if (element.isRuntimeVisible()) { + element.dump(rvaDos); + } + } + } + } + } + // Lets do the invisible ones + final ByteArrayOutputStream riaBytes = new ByteArrayOutputStream(); + try (DataOutputStream riaDos = new DataOutputStream(riaBytes)) { + riaDos.writeByte(vec.length); // First goes number of parameters + for (int i = 0; i < vec.length; i++) { + riaDos.writeShort(invisCount[i]); + if (invisCount[i] > 0) { + for (final AnnotationEntryGen element : vec[i]) { + if (!element.isRuntimeVisible()) { + element.dump(riaDos); + } + } + } + } + } + final byte[] rvaData = rvaBytes.toByteArray(); + final byte[] riaData = riaBytes.toByteArray(); + int rvaIndex = -1; + int riaIndex = -1; + if (totalVisCount > 0) { + rvaIndex = cp.addUtf8("RuntimeVisibleParameterAnnotations"); + } + if (totalInvisCount > 0) { + riaIndex = cp.addUtf8("RuntimeInvisibleParameterAnnotations"); + } + final List newAttributes = new ArrayList<>(); + if (totalVisCount > 0) { + newAttributes + .add(new RuntimeVisibleParameterAnnotations(rvaIndex, + rvaData.length, new DataInputStream(new ByteArrayInputStream(rvaData)), cp.getConstantPool())); + } + if (totalInvisCount > 0) { + newAttributes + .add(new RuntimeInvisibleParameterAnnotations(riaIndex, + riaData.length, new DataInputStream(new ByteArrayInputStream(riaData)), cp.getConstantPool())); + } + return newAttributes.toArray(new Attribute[newAttributes.size()]); + } catch (final IOException e) { + System.err + .println("IOException whilst processing parameter annotations"); + e.printStackTrace(); + } + return null; + } + +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArithmeticInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArithmeticInstruction.java new file mode 100644 index 00000000..585b7dd4 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArithmeticInstruction.java @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.Const; + +/** + * Super class for the family of arithmetic instructions. + * + * @version $Id: ArithmeticInstruction.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public abstract class ArithmeticInstruction extends Instruction implements TypedInstruction, + StackProducer, StackConsumer { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + ArithmeticInstruction() { + } + + + /** + * @param opcode of instruction + */ + protected ArithmeticInstruction(final short opcode) { + super(opcode, (short) 1); + } + + + /** @return type associated with the instruction + */ + @Override + public Type getType( final ConstantPoolGen cp ) { + final short _opcode = super.getOpcode(); + switch (_opcode) { + case Const.DADD: + case Const.DDIV: + case Const.DMUL: + case Const.DNEG: + case Const.DREM: + case Const.DSUB: + return Type.DOUBLE; + case Const.FADD: + case Const.FDIV: + case Const.FMUL: + case Const.FNEG: + case Const.FREM: + case Const.FSUB: + return Type.FLOAT; + case Const.IADD: + case Const.IAND: + case Const.IDIV: + case Const.IMUL: + case Const.INEG: + case Const.IOR: + case Const.IREM: + case Const.ISHL: + case Const.ISHR: + case Const.ISUB: + case Const.IUSHR: + case Const.IXOR: + return Type.INT; + case Const.LADD: + case Const.LAND: + case Const.LDIV: + case Const.LMUL: + case Const.LNEG: + case Const.LOR: + case Const.LREM: + case Const.LSHL: + case Const.LSHR: + case Const.LSUB: + case Const.LUSHR: + case Const.LXOR: + return Type.LONG; + default: // Never reached + throw new ClassGenException("Unknown type " + _opcode); + } + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArrayElementValueGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArrayElementValueGen.java new file mode 100644 index 00000000..0ffd3ce9 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArrayElementValueGen.java @@ -0,0 +1,127 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.apache.bcel.classfile.ArrayElementValue; +import org.apache.bcel.classfile.ElementValue; + +/** + * @since 6.0 + */ +public class ArrayElementValueGen extends ElementValueGen +{ + // J5TODO: Should we make this an array or a list? A list would be easier to + // modify ... + private final List evalues; + + public ArrayElementValueGen(final ConstantPoolGen cp) + { + super(ARRAY, cp); + evalues = new ArrayList<>(); + } + + public ArrayElementValueGen(final int type, final ElementValue[] datums, + final ConstantPoolGen cpool) + { + super(type, cpool); + if (type != ARRAY) { + throw new RuntimeException( + "Only element values of type array can be built with this ctor - type specified: " + type); + } + this.evalues = new ArrayList<>(); + for (final ElementValue datum : datums) { + evalues.add(ElementValueGen.copy(datum, cpool, true)); + } + } + + /** + * Return immutable variant of this ArrayElementValueGen + */ + @Override + public ElementValue getElementValue() + { + final ElementValue[] immutableData = new ElementValue[evalues.size()]; + int i = 0; + for (final ElementValueGen element : evalues) { + immutableData[i++] = element.getElementValue(); + } + return new ArrayElementValue(super.getElementValueType(), + immutableData, + getConstantPool().getConstantPool()); + } + + /** + * @param value + * @param cpool + */ + public ArrayElementValueGen(final ArrayElementValue value, final ConstantPoolGen cpool, + final boolean copyPoolEntries) + { + super(ARRAY, cpool); + evalues = new ArrayList<>(); + final ElementValue[] in = value.getElementValuesArray(); + for (final ElementValue element : in) { + evalues.add(ElementValueGen.copy(element, cpool, copyPoolEntries)); + } + } + + @Override + public void dump(final DataOutputStream dos) throws IOException + { + dos.writeByte(super.getElementValueType()); // u1 type of value (ARRAY == '[') + dos.writeShort(evalues.size()); + for (final ElementValueGen element : evalues) { + element.dump(dos); + } + } + + @Override + public String stringifyValue() + { + final StringBuilder sb = new StringBuilder(); + sb.append("["); + String comma = ""; + for (final ElementValueGen element : evalues) { + sb.append(comma); + comma = ","; + sb.append(element.stringifyValue()); + } + sb.append("]"); + return sb.toString(); + } + + public List getElementValues() + { + return evalues; + } + + public int getElementValuesSize() + { + return evalues.size(); + } + + public void addElement(final ElementValueGen gen) + { + evalues.add(gen); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArrayInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArrayInstruction.java new file mode 100644 index 00000000..a5becc55 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArrayInstruction.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.ExceptionConst; + +/** + * Super class for instructions dealing with array access such as IALOAD. + * + * @version $Id: ArrayInstruction.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public abstract class ArrayInstruction extends Instruction implements ExceptionThrower, + TypedInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + ArrayInstruction() { + } + + + /** + * @param opcode of instruction + */ + protected ArrayInstruction(final short opcode) { + super(opcode, (short) 1); + } + + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_ARRAY_EXCEPTION); + } + + + /** @return type associated with the instruction + */ + @Override + public Type getType( final ConstantPoolGen cp ) { + final short _opcode = super.getOpcode(); + switch (_opcode) { + case org.apache.bcel.Const.IALOAD: + case org.apache.bcel.Const.IASTORE: + return Type.INT; + case org.apache.bcel.Const.CALOAD: + case org.apache.bcel.Const.CASTORE: + return Type.CHAR; + case org.apache.bcel.Const.BALOAD: + case org.apache.bcel.Const.BASTORE: + return Type.BYTE; + case org.apache.bcel.Const.SALOAD: + case org.apache.bcel.Const.SASTORE: + return Type.SHORT; + case org.apache.bcel.Const.LALOAD: + case org.apache.bcel.Const.LASTORE: + return Type.LONG; + case org.apache.bcel.Const.DALOAD: + case org.apache.bcel.Const.DASTORE: + return Type.DOUBLE; + case org.apache.bcel.Const.FALOAD: + case org.apache.bcel.Const.FASTORE: + return Type.FLOAT; + case org.apache.bcel.Const.AALOAD: + case org.apache.bcel.Const.AASTORE: + return Type.OBJECT; + default: + throw new ClassGenException("Oops: unknown case in switch" + _opcode); + } + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ArrayType.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArrayType.java old mode 100755 new mode 100644 similarity index 64% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ArrayType.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArrayType.java index f368a3d1..54dad25b --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ArrayType.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArrayType.java @@ -1,127 +1,129 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.Constants; - -/** - * Denotes array type, such as int[][] - * - * @version $Id: ArrayType.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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, ""); - 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; - } - StringBuilder buf = new StringBuilder(); - 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; - } - 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); - } - return false; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.Const; + +/** + * Denotes array type, such as int[][] + * + * @version $Id: ArrayType.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +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(final byte type, final 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(final String class_name, final int dimensions) { + this(ObjectType.getInstance(class_name), dimensions); + } + + + /** + * Constructor for array of given type + * + * @param type type of array (may be an array itself) + */ + public ArrayType(final Type type, final int dimensions) { + super(Const.T_ARRAY, ""); + if ((dimensions < 1) || (dimensions > Const.MAX_BYTE)) { + throw new ClassGenException("Invalid number of dimensions: " + dimensions); + } + switch (type.getType()) { + case Const.T_ARRAY: + final ArrayType array = (ArrayType) type; + this.dimensions = dimensions + array.dimensions; + basic_type = array.basic_type; + break; + case Const.T_VOID: + throw new ClassGenException("Invalid type: void[]"); + default: // Basic type or reference + this.dimensions = dimensions; + basic_type = type; + break; + } + final StringBuilder buf = new StringBuilder(); + for (int i = 0; i < this.dimensions; i++) { + buf.append('['); + } + buf.append(basic_type.getSignature()); + super.setSignature(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; + } + 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. + */ + @Override + public int hashCode() { + return basic_type.hashCode() ^ dimensions; + } + + + /** @return true if both type objects refer to the same array type. + */ + @Override + public boolean equals( final Object _type ) { + if (_type instanceof ArrayType) { + final ArrayType array = (ArrayType) _type; + return (array.dimensions == dimensions) && array.basic_type.equals(basic_type); + } + return false; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/BALOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BALOAD.java old mode 100755 new mode 100644 similarity index 61% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/BALOAD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BALOAD.java index 7bc9c794..6dbac273 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/BALOAD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BALOAD.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * BALOAD - Load byte or boolean from array - *
      Stack: ..., arrayref, index -> ..., value
      - * - * @version $Id: BALOAD.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class BALOAD extends ArrayInstruction implements StackProducer { - - /** Load byte or boolean from array - */ - public BALOAD() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * BALOAD - Load byte or boolean from array + *
      Stack: ..., arrayref, index -> ..., value
      + * + * @version $Id: BALOAD.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class BALOAD extends ArrayInstruction implements StackProducer { + + /** Load byte or boolean from array + */ + public BALOAD() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackProducer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitBALOAD(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/BASTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BASTORE.java old mode 100755 new mode 100644 similarity index 61% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/BASTORE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BASTORE.java index 0e42aac7..16d63632 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/BASTORE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BASTORE.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * BASTORE - Store into byte or boolean array - *
      Stack: ..., arrayref, index, value -> ...
      - * - * @version $Id: BASTORE.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class BASTORE extends ArrayInstruction implements StackConsumer { - - /** Store byte or boolean into array - */ - public BASTORE() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * BASTORE - Store into byte or boolean array + *
      Stack: ..., arrayref, index, value -> ...
      + * + * @version $Id: BASTORE.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class BASTORE extends ArrayInstruction implements StackConsumer { + + /** Store byte or boolean into array + */ + public BASTORE() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitBASTORE(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/BIPUSH.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BIPUSH.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/BIPUSH.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BIPUSH.java index a3f18f35..859fa442 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/BIPUSH.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BIPUSH.java @@ -1,106 +1,112 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.util.ByteSequence; - -/** - * BIPUSH - Push byte on stack - * - *
      Stack: ... -> ..., value
      - * - * @version $Id: BIPUSH.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.util.ByteSequence; + +/** + * BIPUSH - Push byte on stack + * + *
      Stack: ... -> ..., value
      + * + * @version $Id: BIPUSH.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class BIPUSH extends Instruction implements ConstantPushInstruction { + + private byte b; + + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + BIPUSH() { + } + + + /** Push byte on stack + */ + public BIPUSH(final byte b) { + super(org.apache.bcel.Const.BIPUSH, (short) 2); + this.b = b; + } + + + /** + * Dump instruction as byte code to stream out. + */ + @Override + public void dump( final DataOutputStream out ) throws IOException { + super.dump(out); + out.writeByte(b); + } + + + /** + * @return mnemonic for instruction + */ + @Override + public String toString( final boolean verbose ) { + return super.toString(verbose) + " " + b; + } + + + /** + * Read needed data (e.g. index) from file. + */ + @Override + protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException { + super.setLength(2); + b = bytes.readByte(); + } + + + @Override + public Number getValue() { + return Integer.valueOf(b); + } + + + /** @return Type.BYTE + */ + @Override + public Type getType( final 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitPushInstruction(this); + v.visitStackProducer(this); + v.visitTypedInstruction(this); + v.visitConstantPushInstruction(this); + v.visitBIPUSH(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/BREAKPOINT.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BREAKPOINT.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/BREAKPOINT.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BREAKPOINT.java index 4029192f..7ffb1faf --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/BREAKPOINT.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BREAKPOINT.java @@ -1,43 +1,44 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * BREAKPOINT, JVM dependent, ignored by default - * - * @version $Id: BREAKPOINT.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class BREAKPOINT extends Instruction { - - public BREAKPOINT() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * BREAKPOINT, JVM dependent, ignored by default + * + * @version $Id: BREAKPOINT.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public class BREAKPOINT extends Instruction { + + public BREAKPOINT() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitBREAKPOINT(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BasicType.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BasicType.java new file mode 100644 index 00000000..8afc6f8b --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BasicType.java @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.Const; + +/** + * Denotes basic type such as int. + * + * @version $Id: BasicType.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +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 Const + */ + BasicType(final byte type) { + super(type, Const.getShortTypeName(type)); + if ((type < Const.T_BOOLEAN) || (type > Const.T_VOID)) { + throw new ClassGenException("Invalid type: " + type); + } + } + + + // @since 6.0 no longer final + public static BasicType getType( final byte type ) { + switch (type) { + case Const.T_VOID: + return VOID; + case Const.T_BOOLEAN: + return BOOLEAN; + case Const.T_BYTE: + return BYTE; + case Const.T_SHORT: + return SHORT; + case Const.T_CHAR: + return CHAR; + case Const.T_INT: + return INT; + case Const.T_LONG: + return LONG; + case Const.T_DOUBLE: + return DOUBLE; + case Const.T_FLOAT: + return FLOAT; + default: + throw new ClassGenException("Invalid type: " + type); + } + } + + + /** @return a hash code value for the object. + */ + @Override + public int hashCode() { + return super.getType(); + } + + + /** @return true if both type objects refer to the same type + */ + @Override + public boolean equals( final Object _type ) { + return (_type instanceof BasicType) ? ((BasicType) _type).getType() == this.getType() : false; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/BranchHandle.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BranchHandle.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/BranchHandle.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BranchHandle.java index 04e4de55..a6a06890 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/BranchHandle.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BranchHandle.java @@ -1,121 +1,130 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * 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: BranchHandle.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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); - } - 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; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * 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: BranchHandle.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public final class BranchHandle extends InstructionHandle { + + // This is also a cache in case the InstructionHandle#swapInstruction() method is used + // See BCEL-273 + private BranchInstruction bi; // An alias in fact, but saves lots of casts + + + private BranchHandle(final BranchInstruction i) { + super(i); + bi = i; + } + + /** Factory methods. + */ + private static BranchHandle bh_list = null; // List of reusable handles + + + static BranchHandle getBranchHandle( final BranchInstruction i ) { + if (bh_list == null) { + return new BranchHandle(i); + } + final BranchHandle bh = bh_list; + bh_list = (BranchHandle) bh.getNext(); + bh.setInstruction(i); + return bh; + } + + + /** Handle adds itself to the list of resuable handles. + */ + @Override + protected void addHandle() { + super.setNext(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. + */ + @Override + public int getPosition() { + return bi.getPosition(); + } + + + @Override + void setPosition( final int pos ) { + // Original code: i_position = bi.position = pos; + bi.setPosition(pos); + super.setPosition(pos); + } + + + @Override + protected int updatePosition( final int offset, final int max_offset ) { + final int x = bi.updatePosition(offset, max_offset); + super.setPosition(bi.getPosition()); + return x; + } + + + /** + * Pass new target to instruction. + */ + public void setTarget( final InstructionHandle ih ) { + bi.setTarget(ih); + } + + + /** + * Update target of instruction. + */ + public void updateTarget( final InstructionHandle old_ih, final 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. + */ + @Override // This is only done in order to apply the additional type check; could be merged with super impl. + public void setInstruction( final Instruction i ) { // TODO could be package-protected? + 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/BranchInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BranchInstruction.java old mode 100755 new mode 100644 similarity index 58% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/BranchInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BranchInstruction.java index 2da2ac4c..0f64be16 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/BranchInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BranchInstruction.java @@ -1,231 +1,284 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.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: BranchInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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 opcode 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) { - 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: - * - * <position in byte code> - * <name of opcode> "["<opcode number>"]" - * "("<length of instruction>")" - * "<"<target instruction>">" "@"<branch target offset> - * - * @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 = ""; - } else if (target.getInstruction() == null) { - t = ""; - } 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; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +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: BranchInstruction.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public abstract class BranchInstruction extends Instruction implements InstructionTargeter { + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected int index; // Branch target relative to this instruction + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected InstructionHandle target; // Target object in instruction list + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected int position; // Byte code offset + + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + BranchInstruction() { + } + + + /** Common super constructor + * @param opcode Instruction opcode + * @param target instruction to branch to + */ + protected BranchInstruction(final short opcode, final InstructionHandle target) { + super(opcode, (short) 3); + setTarget(target); + } + + + /** + * Dump instruction as byte code to stream out. + * @param out Output stream + */ + @Override + public void dump( final DataOutputStream out ) throws IOException { + out.writeByte(super.getOpcode()); + index = getTargetOffset(); + if (!isValidShort(index)) { + throw new ClassGenException("Branch target offset too large for short: " + index); + } + 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( final InstructionHandle _target ) { + if (_target == null) { + throw new ClassGenException("Target of " + super.toString(true) + + " is invalid null handle"); + } + final 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( final int offset, final int max_offset ) { + position += offset; + return 0; + } + + + /** + * Long output format: + * + * <position in byte code> + * <name of opcode> "["<opcode number>"]" + * "("<length of instruction>")" + * "<"<target instruction>">" "@"<branch target offset> + * + * @param verbose long/short format switch + * @return mnemonic for instruction + */ + @Override + public String toString( final boolean verbose ) { + final String s = super.toString(verbose); + String t = "null"; + if (verbose) { + if (target != null) { + if (target.getInstruction() == this) { + t = ""; + } else if (target.getInstruction() == null) { + t = ""; + } else { + // I'm more interested in the address of the target then + // the instruction located there. + //t = target.getInstruction().toString(false); // Avoid circles + t = "" + target.getPosition(); + } + } + } else { + if (target != null) { + index = target.getPosition(); + // index = getTargetOffset(); crashes if positions haven't been set + // t = "" + (index + position); + t = "" + index; + } + } + 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 + */ + @Override + protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException { + super.setLength(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( final InstructionHandle target ) { + notifyTarget(this.target, target, this); + this.target = target; + } + + + /** + * Used by BranchInstruction, LocalVariableGen, CodeExceptionGen, LineNumberGen + */ + static void notifyTarget( final InstructionHandle old_ih, final InstructionHandle new_ih, + final 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 + */ + @Override + public void updateTarget( final InstructionHandle old_ih, final 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 + */ + @Override + public boolean containsTarget( final InstructionHandle ih ) { + return target == ih; + } + + + /** + * Inform target that it's not targeted anymore. + */ + @Override + void dispose() { + setTarget(null); + index = -1; + position = -1; + } + + + /** + * @return the position + * @since 6.0 + */ + protected int getPosition() { + return position; + } + + + /** + * @param position the position to set + * @since 6.0 + */ + protected void setPosition(final int position) { + this.position = position; + } + + + /** + * @param index the index to set + * @since 6.0 + */ + protected void setIndex(final int index) { + this.index = index; + } + +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/CALOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CALOAD.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/CALOAD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CALOAD.java index c9b9cc7b..97ca1931 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/CALOAD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CALOAD.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * CALOAD - Load char from array - *
      Stack: ..., arrayref, index -> ..., value
      - * - * @version $Id: CALOAD.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class CALOAD extends ArrayInstruction implements StackProducer { - - /** Load char from array - */ - public CALOAD() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * CALOAD - Load char from array + *
      Stack: ..., arrayref, index -> ..., value
      + * + * @version $Id: CALOAD.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class CALOAD extends ArrayInstruction implements StackProducer { + + /** Load char from array + */ + public CALOAD() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackProducer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitCALOAD(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/CASTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CASTORE.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/CASTORE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CASTORE.java index 4713588f..91a4600d --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/CASTORE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CASTORE.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * CASTORE - Store into char array - *
      Stack: ..., arrayref, index, value -> ...
      - * - * @version $Id: CASTORE.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class CASTORE extends ArrayInstruction implements StackConsumer { - - /** Store char into array - */ - public CASTORE() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * CASTORE - Store into char array + *
      Stack: ..., arrayref, index, value -> ...
      + * + * @version $Id: CASTORE.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class CASTORE extends ArrayInstruction implements StackConsumer { + + /** Store char into array + */ + public CASTORE() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitCASTORE(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/CHECKCAST.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CHECKCAST.java old mode 100755 new mode 100644 similarity index 55% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/CHECKCAST.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CHECKCAST.java index bc2983ee..142adcd5 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/CHECKCAST.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CHECKCAST.java @@ -1,84 +1,84 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.ExceptionConstants; - -/** - * CHECKCAST - Check whether object is of given type - *
      Stack: ..., objectref -> ..., objectref
      - * - * @version $Id: CHECKCAST.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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 index index to class in constant pool - */ - public CHECKCAST(int index) { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.ExceptionConst; + +/** + * CHECKCAST - Check whether object is of given type + *
      Stack: ..., objectref -> ..., objectref
      + * + * @version $Id: CHECKCAST.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class CHECKCAST extends CPInstruction implements LoadClass, ExceptionThrower, StackProducer, + StackConsumer { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + CHECKCAST() { + } + + + /** Check whether object is of given type + * @param index index to class in constant pool + */ + public CHECKCAST(final int index) { + super(org.apache.bcel.Const.CHECKCAST, index); + } + + + /** @return exceptions this instruction may cause + */ + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_CLASS_AND_INTERFACE_RESOLUTION, + ExceptionConst.CLASS_CAST_EXCEPTION); + } + + + @Override + public ObjectType getLoadClassType( final 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 + */ + @Override + public void accept( final 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/CPInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CPInstruction.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/CPInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CPInstruction.java index e70a27e9..df789e8f --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/CPInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CPInstruction.java @@ -1,139 +1,150 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.classfile.Constant; -import org.apache.bcel5_2_0.classfile.ConstantClass; -import org.apache.bcel5_2_0.classfile.ConstantPool; -import org.apache.bcel5_2_0.util.ByteSequence; - -/** - * 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: CPInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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: - * - * <name of opcode> "["<opcode number>"]" - * "("<length of instruction>")" "<"< constant pool index>">" - * - * @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.bcel5_2_0.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.bcel5_2_0.Constants.CONSTANT_Class); - if (!name.startsWith("[")) { - name = "L" + name + ";"; - } - return Type.getType(name); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.classfile.Constant; +import org.apache.bcel.classfile.ConstantClass; +import org.apache.bcel.classfile.ConstantPool; +import org.apache.bcel.util.ByteSequence; + +/** + * 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: CPInstruction.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public abstract class CPInstruction extends Instruction implements TypedInstruction, + IndexedInstruction { + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected int index; // index to constant pool + + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + CPInstruction() { + } + + + /** + * @param index to constant pool + */ + protected CPInstruction(final short opcode, final int index) { + super(opcode, (short) 3); + setIndex(index); + } + + + /** + * Dump instruction as byte code to stream out. + * @param out Output stream + */ + @Override + public void dump( final DataOutputStream out ) throws IOException { + out.writeByte(super.getOpcode()); + out.writeShort(index); + } + + + /** + * Long output format: + * + * <name of opcode> "["<opcode number>"]" + * "("<length of instruction>")" "<"< constant pool index>">" + * + * @param verbose long/short format switch + * @return mnemonic for instruction + */ + @Override + public String toString( final boolean verbose ) { + return super.toString(verbose) + " " + index; + } + + + /** + * @return mnemonic for instruction with symbolic references resolved + */ + @Override + public String toString( final ConstantPool cp ) { + final Constant c = cp.getConstant(index); + String str = cp.constantToString(c); + if (c instanceof ConstantClass) { + str = str.replace('.', '/'); + } + return org.apache.bcel.Const.getOpcodeName(super.getOpcode()) + " " + str; + } + + + /** + * Read needed data (i.e., index) from file. + * @param bytes input stream + * @param wide wide prefix? + */ + @Override + protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException { + setIndex(bytes.readUnsignedShort()); + super.setLength(3); + } + + + /** + * @return index in constant pool referred by this instruction. + */ + @Override + public final int getIndex() { + return index; + } + + + /** + * Set the index to constant pool. + * @param index in constant pool. + */ + @Override + public void setIndex( final int index ) { // TODO could be package-protected? + if (index < 0) { + throw new ClassGenException("Negative index value: " + index); + } + this.index = index; + } + + + /** @return type related with this instruction. + */ + @Override + public Type getType( final ConstantPoolGen cpg ) { + final ConstantPool cp = cpg.getConstantPool(); + String name = cp.getConstantString(index, org.apache.bcel.Const.CONSTANT_Class); + if (!name.startsWith("[")) { + name = "L" + name + ";"; + } + return Type.getType(name); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassElementValueGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassElementValueGen.java new file mode 100644 index 00000000..7317150e --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassElementValueGen.java @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.classfile.ClassElementValue; +import org.apache.bcel.classfile.ConstantUtf8; +import org.apache.bcel.classfile.ElementValue; + +/** + * @since 6.0 + */ +public class ClassElementValueGen extends ElementValueGen +{ + // For primitive types and string type, this points to the value entry in + // the cpool + // For 'class' this points to the class entry in the cpool + private int idx; + + protected ClassElementValueGen(final int typeIdx, final ConstantPoolGen cpool) + { + super(ElementValueGen.CLASS, cpool); + this.idx = typeIdx; + } + + public ClassElementValueGen(final ObjectType t, final ConstantPoolGen cpool) + { + super(ElementValueGen.CLASS, cpool); + // this.idx = cpool.addClass(t); + idx = cpool.addUtf8(t.getSignature()); + } + + /** + * Return immutable variant of this ClassElementValueGen + */ + @Override + public ElementValue getElementValue() + { + return new ClassElementValue(super.getElementValueType(), + idx, + getConstantPool().getConstantPool()); + } + + public ClassElementValueGen(final ClassElementValue value, final ConstantPoolGen cpool, + final boolean copyPoolEntries) + { + super(CLASS, cpool); + if (copyPoolEntries) + { + // idx = cpool.addClass(value.getClassString()); + idx = cpool.addUtf8(value.getClassString()); + } + else + { + idx = value.getIndex(); + } + } + + public int getIndex() + { + return idx; + } + + public String getClassString() + { + final ConstantUtf8 cu8 = (ConstantUtf8) getConstantPool().getConstant(idx); + return cu8.getBytes(); + // ConstantClass c = (ConstantClass)getConstantPool().getConstant(idx); + // ConstantUtf8 utf8 = + // (ConstantUtf8)getConstantPool().getConstant(c.getNameIndex()); + // return utf8.getBytes(); + } + + @Override + public String stringifyValue() + { + return getClassString(); + } + + @Override + public void dump(final DataOutputStream dos) throws IOException + { + dos.writeByte(super.getElementValueType()); // u1 kind of value + dos.writeShort(idx); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassGen.java new file mode 100644 index 00000000..8cc378fc --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassGen.java @@ -0,0 +1,607 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.bcel.Const; +import org.apache.bcel.classfile.AccessFlags; +import org.apache.bcel.classfile.AnnotationEntry; +import org.apache.bcel.classfile.Annotations; +import org.apache.bcel.classfile.Attribute; +import org.apache.bcel.classfile.ConstantPool; +import org.apache.bcel.classfile.Field; +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.Method; +import org.apache.bcel.classfile.RuntimeInvisibleAnnotations; +import org.apache.bcel.classfile.RuntimeVisibleAnnotations; +import org.apache.bcel.classfile.SourceFile; +import org.apache.bcel.util.BCELComparator; + +/** + * Template class for building up a java class. May be initialized with an + * existing java class (file). + * + * @see JavaClass + * @version $Id: ClassGen.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class ClassGen extends AccessFlags implements Cloneable { + + /* Corresponds to the fields found in a JavaClass object. + */ + private String class_name; + private String super_class_name; + private final String file_name; + private int class_name_index = -1; + private int superclass_name_index = -1; + private int major = Const.MAJOR_1_1; + private int minor = Const.MINOR_1_1; + private ConstantPoolGen cp; // Template for building up constant pool + // ArrayLists instead of arrays to gather fields, methods, etc. + private final List field_vec = new ArrayList<>(); + private final List method_vec = new ArrayList<>(); + private final List attribute_vec = new ArrayList<>(); + private final List interface_vec = new ArrayList<>(); + private final List annotation_vec = new ArrayList<>(); + + private static BCELComparator _cmp = new BCELComparator() { + + @Override + public boolean equals( final Object o1, final Object o2 ) { + final ClassGen THIS = (ClassGen) o1; + final ClassGen THAT = (ClassGen) o2; + return THIS.getClassName().equals(THAT.getClassName()); + } + + + @Override + public int hashCode( final Object o ) { + final ClassGen THIS = (ClassGen) o; + return THIS.getClassName().hashCode(); + } + }; + + + /** 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 + * @param cp constant pool to use + */ + public ClassGen(final String class_name, final String super_class_name, final String file_name, final int access_flags, + final String[] interfaces, final ConstantPoolGen cp) { + super(access_flags); + this.class_name = class_name; + this.super_class_name = super_class_name; + this.file_name = file_name; + this.cp = cp; + // Put everything needed by default into the constant pool and the vectors + if (file_name != null) { + 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 (final String interface1 : interfaces) { + addInterface(interface1); + } + } + } + + + /** 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(final String class_name, final String super_class_name, final String file_name, final int access_flags, + final String[] interfaces) { + this(class_name, super_class_name, file_name, access_flags, interfaces, + new ConstantPoolGen()); + } + + + /** + * Initialize with existing class. + * @param clazz JavaClass object (e.g. read from file) + */ + public ClassGen(final JavaClass clazz) { + super(clazz.getAccessFlags()); + class_name_index = clazz.getClassNameIndex(); + superclass_name_index = clazz.getSuperclassNameIndex(); + class_name = clazz.getClassName(); + super_class_name = clazz.getSuperclassName(); + file_name = clazz.getSourceFileName(); + cp = new ConstantPoolGen(clazz.getConstantPool()); + major = clazz.getMajor(); + minor = clazz.getMinor(); + final Attribute[] attributes = clazz.getAttributes(); + // J5TODO: Could make unpacking lazy, done on first reference + final AnnotationEntryGen[] annotations = unpackAnnotations(attributes); + final Method[] methods = clazz.getMethods(); + final Field[] fields = clazz.getFields(); + final String[] interfaces = clazz.getInterfaceNames(); + for (final String interface1 : interfaces) { + addInterface(interface1); + } + for (final Attribute attribute : attributes) { + if (!(attribute instanceof Annotations)) { + addAttribute(attribute); + } + } + for (final AnnotationEntryGen annotation : annotations) { + addAnnotationEntry(annotation); + } + for (final Method method : methods) { + addMethod(method); + } + for (final Field field : fields) { + addField(field); + } + } + + /** + * Look for attributes representing annotations and unpack them. + */ + private AnnotationEntryGen[] unpackAnnotations(final Attribute[] attrs) + { + final List annotationGenObjs = new ArrayList<>(); + for (final Attribute attr : attrs) { + if (attr instanceof RuntimeVisibleAnnotations) + { + final RuntimeVisibleAnnotations rva = (RuntimeVisibleAnnotations) attr; + final AnnotationEntry[] annos = rva.getAnnotationEntries(); + for (final AnnotationEntry a : annos) { + annotationGenObjs.add(new AnnotationEntryGen(a, + getConstantPool(), false)); + } + } + else + if (attr instanceof RuntimeInvisibleAnnotations) + { + final RuntimeInvisibleAnnotations ria = (RuntimeInvisibleAnnotations) attr; + final AnnotationEntry[] annos = ria.getAnnotationEntries(); + for (final AnnotationEntry a : annos) { + annotationGenObjs.add(new AnnotationEntryGen(a, + getConstantPool(), false)); + } + } + } + return annotationGenObjs.toArray(new AnnotationEntryGen[annotationGenObjs.size()]); + } + + + /** + * @return the (finally) built up Java class object. + */ + public JavaClass getJavaClass() { + final int[] interfaces = getInterfaces(); + final Field[] fields = getFields(); + final Method[] methods = getMethods(); + Attribute[] attributes = null; + if (annotation_vec.isEmpty()) { + attributes = getAttributes(); + } else { + // TODO: Sometime later, trash any attributes called 'RuntimeVisibleAnnotations' or 'RuntimeInvisibleAnnotations' + final Attribute[] annAttributes = AnnotationEntryGen.getAnnotationAttributes(cp, getAnnotationEntries()); + attributes = new Attribute[attribute_vec.size()+annAttributes.length]; + attribute_vec.toArray(attributes); + System.arraycopy(annAttributes,0,attributes,attribute_vec.size(),annAttributes.length); + } + // Must be last since the above calls may still add something to it + final ConstantPool _cp = this.cp.getFinalConstantPool(); + return new JavaClass(class_name_index, superclass_name_index, file_name, major, minor, + super.getAccessFlags(), _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( final String name ) { + interface_vec.add(name); + } + + + /** + * Remove an interface from this class. + * @param name interface to remove (fully qualified name) + */ + public void removeInterface( final 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( final int major ) { // TODO could be package-protected - only called by test code + 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( final int minor ) { // TODO could be package-protected - only called by test code + 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( final Attribute a ) { + attribute_vec.add(a); + } + + public void addAnnotationEntry(final AnnotationEntryGen a) { + annotation_vec.add(a); + } + + + /** + * Add a method to this class. + * @param m method to add + */ + public void addMethod( final Method m ) { + method_vec.add(m); + } + + + /** + * Convenience method. + * + * Add an empty constructor to this class that does nothing but calling super(). + * @param access_flags rights for constructor + */ + public void addEmptyConstructor( final int access_flags ) { + final InstructionList il = new InstructionList(); + il.append(InstructionConst.THIS); // Push `this' + il.append(new INVOKESPECIAL(cp.addMethodref(super_class_name, "", "()V"))); + il.append(InstructionConst.RETURN); + final MethodGen mg = new MethodGen(access_flags, Type.VOID, Type.NO_ARGS, null, "", + class_name, il, cp); + mg.setMaxStack(1); + addMethod(mg.getMethod()); + } + + + /** + * Add a field to this class. + * @param f field to add + */ + public void addField( final Field f ) { + field_vec.add(f); + } + + + public boolean containsField( final Field f ) { + return field_vec.contains(f); + } + + + /** @return field object with given name, or null + */ + public Field containsField( final String name ) { + for (final Field f : field_vec) { + if (f.getName().equals(name)) { + return f; + } + } + return null; + } + + + /** @return method object with given name and signature, or null + */ + public Method containsMethod( final String name, final String signature ) { + for (final Method m : method_vec) { + 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( final Attribute a ) { + attribute_vec.remove(a); + } + + + /** + * Remove a method from this class. + * @param m method to remove + */ + public void removeMethod( final 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( final Method old, final Method new_ ) { + if (new_ == null) { + throw new ClassGenException("Replacement method must not be null"); + } + final 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( final Field old, final Field new_ ) { + if (new_ == null) { + throw new ClassGenException("Replacement method must not be null"); + } + final 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( final 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( final String name ) { + class_name = name.replace('/', '.'); + class_name_index = cp.addClass(name); + } + + + public void setSuperclassName( final String name ) { + super_class_name = name.replace('/', '.'); + superclass_name_index = cp.addClass(name); + } + + + public Method[] getMethods() { + return method_vec.toArray(new Method[method_vec.size()]); + } + + + public void setMethods( final Method[] methods ) { + method_vec.clear(); + for (final Method method : methods) { + addMethod(method); + } + } + + + public void setMethodAt( final Method method, final int pos ) { + method_vec.set(pos, method); + } + + + public Method getMethodAt( final int pos ) { + return method_vec.get(pos); + } + + + public String[] getInterfaceNames() { + final int size = interface_vec.size(); + final String[] interfaces = new String[size]; + interface_vec.toArray(interfaces); + return interfaces; + } + + + public int[] getInterfaces() { + final int size = interface_vec.size(); + final int[] interfaces = new int[size]; + for (int i = 0; i < size; i++) { + interfaces[i] = cp.addClass(interface_vec.get(i)); + } + return interfaces; + } + + + public Field[] getFields() { + return field_vec.toArray(new Field[field_vec.size()]); + } + + + public Attribute[] getAttributes() { + return attribute_vec.toArray(new Attribute[attribute_vec.size()]); + } + + // J5TODO: Should we make calling unpackAnnotations() lazy and put it in here? + public AnnotationEntryGen[] getAnnotationEntries() { + return annotation_vec.toArray(new AnnotationEntryGen[annotation_vec.size()]); + } + + + public ConstantPoolGen getConstantPool() { + return cp; + } + + + public void setConstantPool( final ConstantPoolGen constant_pool ) { + cp = constant_pool; + } + + + public void setClassNameIndex( final int class_name_index ) { + this.class_name_index = class_name_index; + class_name = cp.getConstantPool().getConstantString(class_name_index, + Const.CONSTANT_Class).replace('/', '.'); + } + + + public void setSuperclassNameIndex( final int superclass_name_index ) { + this.superclass_name_index = superclass_name_index; + super_class_name = cp.getConstantPool().getConstantString(superclass_name_index, + Const.CONSTANT_Class).replace('/', '.'); + } + + + public int getSuperclassNameIndex() { + return superclass_name_index; + } + + + public int getClassNameIndex() { + return class_name_index; + } + + private List observers; + + + /** Add observer for this object. + */ + public void addObserver( final ClassObserver o ) { + if (observers == null) { + observers = new ArrayList<>(); + } + observers.add(o); + } + + + /** Remove observer for this object. + */ + public void removeObserver( final 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 (final ClassObserver observer : observers) { + observer.notify(this); + } + } + } + + + @Override + public Object clone() { + try { + return super.clone(); + } catch (final CloneNotSupportedException e) { + throw new Error("Clone Not Supported"); // never happens + } + } + + + /** + * @return Comparison strategy object + */ + public static BCELComparator getComparator() { + return _cmp; + } + + + /** + * @param comparator Comparison strategy object + */ + public static void setComparator( final BCELComparator comparator ) { + _cmp = comparator; + } + + + /** + * Return value as defined by given BCELComparator strategy. + * By default two ClassGen objects are said to be equal when + * their class names are equal. + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals( final Object obj ) { + return _cmp.equals(this, obj); + } + + + /** + * Return value as defined by given BCELComparator strategy. + * By default return the hashcode of the class name. + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return _cmp.hashCode(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassGenException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassGenException.java new file mode 100644 index 00000000..55fb2147 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassGenException.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Thrown on internal errors. Extends RuntimeException so it hasn't to be declared + * in the throws clause every time. + * + * @version $Id: ClassGenException.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class ClassGenException extends RuntimeException { + + private static final long serialVersionUID = 7247369755051242791L; + + public ClassGenException() { + super(); + } + + + public ClassGenException(final String s) { + super(s); + } + + public ClassGenException(final String s, final Throwable initCause) { + super(s, initCause); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassObserver.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassObserver.java new file mode 100644 index 00000000..cddb9f6b --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassObserver.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Implement this interface if you're interested in changes to a ClassGen object + * and register yourself with addObserver(). + * + * @version $Id: ClassObserver.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public interface ClassObserver { + + void notify( ClassGen clazz ); +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/CodeExceptionGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CodeExceptionGen.java old mode 100755 new mode 100644 similarity index 70% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/CodeExceptionGen.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CodeExceptionGen.java index 070be6a1..dc7a9c6c --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/CodeExceptionGen.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CodeExceptionGen.java @@ -1,184 +1,187 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.classfile.CodeException; - -/** - * 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: CodeExceptionGen.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @see MethodGen - * @see CodeException - * @see InstructionHandle - */ -public final class CodeExceptionGen implements InstructionTargeter, Cloneable, java.io.Serializable { - - 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.
      - * - * 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; - } - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.classfile.CodeException; + +/** + * 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: CodeExceptionGen.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @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(final InstructionHandle start_pc, final InstructionHandle end_pc, + final InstructionHandle handler_pc, final ObjectType catch_type) { + setStartPC(start_pc); + setEndPC(end_pc); + setHandlerPC(handler_pc); + this.catch_type = catch_type; + } + + + /** + * Get CodeException 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 cp constant pool + */ + public CodeException getCodeException( final 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( final InstructionHandle start_pc ) { // TODO could be package-protected? + 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( final InstructionHandle end_pc ) { // TODO could be package-protected? + 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( final InstructionHandle handler_pc ) { // TODO could be package-protected? + 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 + */ + @Override + public void updateTarget( final InstructionHandle old_ih, final 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 + */ + @Override + public boolean containsTarget( final 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( final 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; + } + + + @Override + public String toString() { + return "CodeExceptionGen(" + start_pc + ", " + end_pc + ", " + handler_pc + ")"; + } + + + @Override + public Object clone() { + try { + return super.clone(); + } catch (final CloneNotSupportedException e) { + throw new Error("Clone Not Supported"); // never happens + } + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/CompoundInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CompoundInstruction.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/CompoundInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CompoundInstruction.java index 4116cc0a..4e3a55e5 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/CompoundInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CompoundInstruction.java @@ -1,38 +1,38 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * 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: CompoundInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @see PUSH - * @see SWITCH - */ -public interface CompoundInstruction { - - public InstructionList getInstructionList(); -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * 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: CompoundInstruction.java 1747278 2016-06-07 17:28:43Z britter $ + * @see PUSH + * @see SWITCH + */ +public interface CompoundInstruction { + + InstructionList getInstructionList(); +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ConstantPoolGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ConstantPoolGen.java old mode 100755 new mode 100644 similarity index 57% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ConstantPoolGen.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ConstantPoolGen.java index 5ae20528..afc106c5 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ConstantPoolGen.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ConstantPoolGen.java @@ -1,765 +1,836 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.classfile.Constant; -import org.apache.bcel5_2_0.classfile.ConstantCP; -import org.apache.bcel5_2_0.classfile.ConstantClass; -import org.apache.bcel5_2_0.classfile.ConstantDouble; -import org.apache.bcel5_2_0.classfile.ConstantFieldref; -import org.apache.bcel5_2_0.classfile.ConstantFloat; -import org.apache.bcel5_2_0.classfile.ConstantInteger; -import org.apache.bcel5_2_0.classfile.ConstantInterfaceMethodref; -import org.apache.bcel5_2_0.classfile.ConstantLong; -import org.apache.bcel5_2_0.classfile.ConstantMethodref; -import org.apache.bcel5_2_0.classfile.ConstantNameAndType; -import org.apache.bcel5_2_0.classfile.ConstantPool; -import org.apache.bcel5_2_0.classfile.ConstantString; -import org.apache.bcel5_2_0.classfile.ConstantUtf8; - -/** - * 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: ConstantPoolGen.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @see Constant - */ -public class ConstantPoolGen implements java.io.Serializable { - - 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 implements java.io.Serializable { - - int index; - - - Index(int i) { - index = i; - } - } - - - /** - * Initialize with given array of constants. - * - * @param cs 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 key = u8.getBytes(); - if (!string_table.containsKey(key)) { - string_table.put(key, new Index(i)); - } - } else if (c instanceof ConstantClass) { - ConstantClass s = (ConstantClass) c; - ConstantUtf8 u8 = (ConstantUtf8) constants[s.getNameIndex()]; - String key = u8.getBytes(); - if (!class_table.containsKey(key)) { - class_table.put(key, 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()]; - String key = u8.getBytes() + NAT_DELIM + u8_2.getBytes(); - if (!n_a_t_table.containsKey(key)) { - n_a_t_table.put(key, new Index(i)); - } - } else if (c instanceof ConstantUtf8) { - ConstantUtf8 u = (ConstantUtf8) c; - String key = u.getBytes(); - if (!utf8_table.containsKey(key)) { - utf8_table.put(key, 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; - } - String key = class_name + delim + method_name + delim + signature; - if (!cp_table.containsKey(key)) { - cp_table.put(key, 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 Map 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 - } - int utf8 = addUtf8(str); - adjustSize(); - ConstantString s = new ConstantString(utf8); - ret = index; - constants[index++] = s; - if (!string_table.containsKey(str)) { - string_table.put(str, new Index(ret)); - } - return ret; - } - - private Map 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; - if (!class_table.containsKey(clazz)) { - 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 type 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 ) { - int bits = Float.floatToIntBits(n); - for (int i = 1; i < index; i++) { - if (constants[i] instanceof ConstantFloat) { - ConstantFloat c = (ConstantFloat) constants[i]; - if (Float.floatToIntBits(c.getBytes()) == bits) { - 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 Map 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); - if (!utf8_table.containsKey(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 ) { - long bits = Double.doubleToLongBits(n); - for (int i = 1; i < index; i++) { - if (constants[i] instanceof ConstantDouble) { - ConstantDouble c = (ConstantDouble) constants[i]; - if (Double.doubleToLongBits(c.getBytes()) == bits) { - 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 Map 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 name Name string to add - * @param signature signature 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); - String key = name + NAT_DELIM + signature; - if (!n_a_t_table.containsKey(key)) { - n_a_t_table.put(key, new Index(ret)); - } - return ret; - } - - private Map 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 class_name class name string to add - * @param method_name method name string to add - * @param signature method signature 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); - String key = class_name + METHODREF_DELIM + method_name + METHODREF_DELIM + signature; - if (!cp_table.containsKey(key)) { - cp_table.put(key, 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 class_name class name string to add - * @param method_name method name string to add - * @param signature signature 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); - String key = class_name + IMETHODREF_DELIM + method_name + IMETHODREF_DELIM + signature; - if (!cp_table.containsKey(key)) { - cp_table.put(key, 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 class_name class name string to add - * @param field_name field name string to add - * @param signature signature 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); - String key = class_name + FIELDREF_DELIM + field_name + FIELDREF_DELIM + signature; - if (!cp_table.containsKey(key)) { - cp_table.put(key, 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() { - StringBuilder buf = new StringBuilder(); - for (int i = 1; i < index; i++) { - buf.append(i).append(")").append(constants[i]).append("\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); - } - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.bcel.Const; +import org.apache.bcel.classfile.Constant; +import org.apache.bcel.classfile.ConstantCP; +import org.apache.bcel.classfile.ConstantClass; +import org.apache.bcel.classfile.ConstantDouble; +import org.apache.bcel.classfile.ConstantFieldref; +import org.apache.bcel.classfile.ConstantFloat; +import org.apache.bcel.classfile.ConstantInteger; +import org.apache.bcel.classfile.ConstantInterfaceMethodref; +import org.apache.bcel.classfile.ConstantInvokeDynamic; +import org.apache.bcel.classfile.ConstantLong; +import org.apache.bcel.classfile.ConstantMethodref; +import org.apache.bcel.classfile.ConstantNameAndType; +import org.apache.bcel.classfile.ConstantPool; +import org.apache.bcel.classfile.ConstantString; +import org.apache.bcel.classfile.ConstantUtf8; + +/** + * 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: ConstantPoolGen.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see Constant + */ +public class ConstantPoolGen { + + private static final int DEFAULT_BUFFER_SIZE = 256; + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected int size; + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected Constant[] constants; + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getSize() + */ + @Deprecated + 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 = "%"; // Name and Type + + private static class Index { + + final int index; + + + Index(final int i) { + index = i; + } + } + + + /** + * Initialize with given array of constants. + * + * @param cs array of given constants, new ones will be appended + */ + public ConstantPoolGen(final Constant[] cs) { + final StringBuilder sb = new StringBuilder(DEFAULT_BUFFER_SIZE); + + size = Math.max(DEFAULT_BUFFER_SIZE, cs.length + 64); + 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++) { + final Constant c = constants[i]; + if (c instanceof ConstantString) { + final ConstantString s = (ConstantString) c; + final ConstantUtf8 u8 = (ConstantUtf8) constants[s.getStringIndex()]; + final String key = u8.getBytes(); + if (!string_table.containsKey(key)) { + string_table.put(key, new Index(i)); + } + } else if (c instanceof ConstantClass) { + final ConstantClass s = (ConstantClass) c; + final ConstantUtf8 u8 = (ConstantUtf8) constants[s.getNameIndex()]; + final String key = u8.getBytes(); + if (!class_table.containsKey(key)) { + class_table.put(key, new Index(i)); + } + } else if (c instanceof ConstantNameAndType) { + final ConstantNameAndType n = (ConstantNameAndType) c; + final ConstantUtf8 u8 = (ConstantUtf8) constants[n.getNameIndex()]; + final ConstantUtf8 u8_2 = (ConstantUtf8) constants[n.getSignatureIndex()]; + + sb.append(u8.getBytes()); + sb.append(NAT_DELIM); + sb.append(u8_2.getBytes()); + final String key = sb.toString(); + sb.delete(0, sb.length()); + + if (!n_a_t_table.containsKey(key)) { + n_a_t_table.put(key, new Index(i)); + } + } else if (c instanceof ConstantUtf8) { + final ConstantUtf8 u = (ConstantUtf8) c; + final String key = u.getBytes(); + if (!utf8_table.containsKey(key)) { + utf8_table.put(key, new Index(i)); + } + } else if (c instanceof ConstantCP) { + final ConstantCP m = (ConstantCP) c; + String class_name; + ConstantUtf8 u8; + + if (c instanceof ConstantInvokeDynamic) { + class_name = Integer.toString(((ConstantInvokeDynamic) m).getBootstrapMethodAttrIndex()); + // since name can't begin with digit, can use + // METHODREF_DELIM with out fear of duplicates. + } else { + final ConstantClass clazz = (ConstantClass) constants[m.getClassIndex()]; + u8 = (ConstantUtf8) constants[clazz.getNameIndex()]; + class_name = u8.getBytes().replace('/', '.'); + } + + final ConstantNameAndType n = (ConstantNameAndType) constants[m.getNameAndTypeIndex()]; + u8 = (ConstantUtf8) constants[n.getNameIndex()]; + final String method_name = u8.getBytes(); + u8 = (ConstantUtf8) constants[n.getSignatureIndex()]; + final String signature = u8.getBytes(); + + String delim = METHODREF_DELIM; + if (c instanceof ConstantInterfaceMethodref) { + delim = IMETHODREF_DELIM; + } else if (c instanceof ConstantFieldref) { + delim = FIELDREF_DELIM; + } + + sb.append(class_name); + sb.append(delim); + sb.append(method_name); + sb.append(delim); + sb.append(signature); + final String key = sb.toString(); + sb.delete(0, sb.length()); + + if (!cp_table.containsKey(key)) { + cp_table.put(key, new Index(i)); + } + } else if (c == null) { // entries may be null + // nothing to do + } else if (c instanceof ConstantInteger) { + // nothing to do + } else if (c instanceof ConstantLong) { + // nothing to do + } else if (c instanceof ConstantFloat) { + // nothing to do + } else if (c instanceof ConstantDouble) { + // nothing to do + } else if (c instanceof org.apache.bcel.classfile.ConstantMethodType) { + // TODO should this be handled somehow? + } else if (c instanceof org.apache.bcel.classfile.ConstantMethodHandle) { + // TODO should this be handled somehow? + } else { + assert false : "Unexpected constant type: " + c.getClass().getName(); + } + } + } + + + /** + * Initialize with given constant pool. + */ + public ConstantPoolGen(final ConstantPool cp) { + this(cp.getConstantPool()); + } + + + /** + * Create empty constant pool. + */ + public ConstantPoolGen() { + size = DEFAULT_BUFFER_SIZE; + constants = new Constant[size]; + } + + + /** Resize internal array of constants. + */ + protected void adjustSize() { + if (index + 3 >= size) { + final Constant[] cs = constants; + size *= 2; + constants = new Constant[size]; + System.arraycopy(cs, 0, constants, 0, index); + } + } + + private final Map 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( final String str ) { + final 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( final String str ) { + int ret; + if ((ret = lookupString(str)) != -1) { + return ret; // Already in CP + } + final int utf8 = addUtf8(str); + adjustSize(); + final ConstantString s = new ConstantString(utf8); + ret = index; + constants[index++] = s; + if (!string_table.containsKey(str)) { + string_table.put(str, new Index(ret)); + } + return ret; + } + + private final Map 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( final String str ) { + final Index index = class_table.get(str.replace('.', '/')); + return (index != null) ? index.index : -1; + } + + + private int addClass_( final String clazz ) { + int ret; + if ((ret = lookupClass(clazz)) != -1) { + return ret; // Already in CP + } + adjustSize(); + final ConstantClass c = new ConstantClass(addUtf8(clazz)); + ret = index; + constants[index++] = c; + if (!class_table.containsKey(clazz)) { + 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( final String str ) { + return addClass_(str.replace('.', '/')); + } + + + /** + * Add a new Class reference to the ConstantPool for a given type. + * + * @param type Class to add + * @return index of entry + */ + public int addClass( final 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( final 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( final int n ) { + for (int i = 1; i < index; i++) { + if (constants[i] instanceof ConstantInteger) { + final 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( final 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( final float n ) { + final int bits = Float.floatToIntBits(n); + for (int i = 1; i < index; i++) { + if (constants[i] instanceof ConstantFloat) { + final ConstantFloat c = (ConstantFloat) constants[i]; + if (Float.floatToIntBits(c.getBytes()) == bits) { + 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( final 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 final Map 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( final String n ) { + final 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( final String n ) { + int ret; + if ((ret = lookupUtf8(n)) != -1) { + return ret; // Already in CP + } + adjustSize(); + ret = index; + constants[index++] = new ConstantUtf8(n); + if (!utf8_table.containsKey(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( final long n ) { + for (int i = 1; i < index; i++) { + if (constants[i] instanceof ConstantLong) { + final 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( final 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( final double n ) { + final long bits = Double.doubleToLongBits(n); + for (int i = 1; i < index; i++) { + if (constants[i] instanceof ConstantDouble) { + final ConstantDouble c = (ConstantDouble) constants[i]; + if (Double.doubleToLongBits(c.getBytes()) == bits) { + 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( final 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 final Map 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( final String name, final String signature ) { + final 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 name Name string to add + * @param signature signature string to add + * @return index of entry + */ + public int addNameAndType( final String name, final String signature ) { + int ret; + int name_index; + int 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); + final String key = name + NAT_DELIM + signature; + if (!n_a_t_table.containsKey(key)) { + n_a_t_table.put(key, new Index(ret)); + } + return ret; + } + + private final Map 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( final String class_name, final String method_name, final String signature ) { + final Index index = cp_table.get(class_name + METHODREF_DELIM + method_name + + METHODREF_DELIM + signature); + return (index != null) ? index.index : -1; + } + + + public int lookupMethodref( final 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 class_name class name string to add + * @param method_name method name string to add + * @param signature method signature string to add + * @return index of entry + */ + public int addMethodref( final String class_name, final String method_name, final String signature ) { + int ret; + int class_index; + int 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); + final String key = class_name + METHODREF_DELIM + method_name + METHODREF_DELIM + signature; + if (!cp_table.containsKey(key)) { + cp_table.put(key, new Index(ret)); + } + return ret; + } + + + public int addMethodref( final 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( final String class_name, final String method_name, final String signature ) { + final Index index = cp_table.get(class_name + IMETHODREF_DELIM + method_name + + IMETHODREF_DELIM + signature); + return (index != null) ? index.index : -1; + } + + + public int lookupInterfaceMethodref( final 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 class_name class name string to add + * @param method_name method name string to add + * @param signature signature string to add + * @return index of entry + */ + public int addInterfaceMethodref( final String class_name, final String method_name, final String signature ) { + int ret; + int class_index; + int 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); + final String key = class_name + IMETHODREF_DELIM + method_name + IMETHODREF_DELIM + signature; + if (!cp_table.containsKey(key)) { + cp_table.put(key, new Index(ret)); + } + return ret; + } + + + public int addInterfaceMethodref( final 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( final String class_name, final String field_name, final String signature ) { + final 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 class_name class name string to add + * @param field_name field name string to add + * @param signature signature string to add + * @return index of entry + */ + public int addFieldref( final String class_name, final String field_name, final String signature ) { + int ret; + int class_index; + int 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); + final String key = class_name + FIELDREF_DELIM + field_name + FIELDREF_DELIM + signature; + if (!cp_table.containsKey(key)) { + cp_table.put(key, new Index(ret)); + } + return ret; + } + + + /** + * @param i index in constant pool + * @return constant pool entry at index i + */ + public Constant getConstant( final 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( final int i, final 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() { + final Constant[] cs = new Constant[index]; + System.arraycopy(constants, 0, cs, 0, index); + return new ConstantPool(cs); + } + + + /** + * @return String representation. + */ + @Override + public String toString() { + final StringBuilder buf = new StringBuilder(); + for (int i = 1; i < index; i++) { + buf.append(i).append(")").append(constants[i]).append("\n"); + } + return buf.toString(); + } + + + /** Import constant from another ConstantPool and return new index. + */ + public int addConstant( final Constant c, final ConstantPoolGen cp ) { + final Constant[] constants = cp.getConstantPool().getConstantPool(); + switch (c.getTag()) { + case Const.CONSTANT_String: { + final ConstantString s = (ConstantString) c; + final ConstantUtf8 u8 = (ConstantUtf8) constants[s.getStringIndex()]; + return addString(u8.getBytes()); + } + case Const.CONSTANT_Class: { + final ConstantClass s = (ConstantClass) c; + final ConstantUtf8 u8 = (ConstantUtf8) constants[s.getNameIndex()]; + return addClass(u8.getBytes()); + } + case Const.CONSTANT_NameAndType: { + final ConstantNameAndType n = (ConstantNameAndType) c; + final ConstantUtf8 u8 = (ConstantUtf8) constants[n.getNameIndex()]; + final ConstantUtf8 u8_2 = (ConstantUtf8) constants[n.getSignatureIndex()]; + return addNameAndType(u8.getBytes(), u8_2.getBytes()); + } + case Const.CONSTANT_Utf8: + return addUtf8(((ConstantUtf8) c).getBytes()); + case Const.CONSTANT_Double: + return addDouble(((ConstantDouble) c).getBytes()); + case Const.CONSTANT_Float: + return addFloat(((ConstantFloat) c).getBytes()); + case Const.CONSTANT_Long: + return addLong(((ConstantLong) c).getBytes()); + case Const.CONSTANT_Integer: + return addInteger(((ConstantInteger) c).getBytes()); + case Const.CONSTANT_InterfaceMethodref: + case Const.CONSTANT_Methodref: + case Const.CONSTANT_Fieldref: { + final ConstantCP m = (ConstantCP) c; + final ConstantClass clazz = (ConstantClass) constants[m.getClassIndex()]; + final ConstantNameAndType n = (ConstantNameAndType) constants[m.getNameAndTypeIndex()]; + ConstantUtf8 u8 = (ConstantUtf8) constants[clazz.getNameIndex()]; + final String class_name = u8.getBytes().replace('/', '.'); + u8 = (ConstantUtf8) constants[n.getNameIndex()]; + final String name = u8.getBytes(); + u8 = (ConstantUtf8) constants[n.getSignatureIndex()]; + final String signature = u8.getBytes(); + switch (c.getTag()) { + case Const.CONSTANT_InterfaceMethodref: + return addInterfaceMethodref(class_name, name, signature); + case Const.CONSTANT_Methodref: + return addMethodref(class_name, name, signature); + case Const.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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ConstantPushInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ConstantPushInstruction.java new file mode 100644 index 00000000..bcfd8402 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ConstantPushInstruction.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Denotes a push instruction that produces a literal on the stack + * such as SIPUSH, BIPUSH, ICONST, etc. + * + * @version $Id: ConstantPushInstruction.java 1747278 2016-06-07 17:28:43Z britter $ + + * @see ICONST + * @see SIPUSH + */ +public interface ConstantPushInstruction extends PushInstruction, TypedInstruction { + + Number getValue(); +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ConversionInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ConversionInstruction.java new file mode 100644 index 00000000..febbc906 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ConversionInstruction.java @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.Const; + +/** + * Super class for the x2y family of instructions. + * + * @version $Id: ConversionInstruction.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public abstract class ConversionInstruction extends Instruction implements TypedInstruction, + StackProducer, StackConsumer { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + ConversionInstruction() { + } + + + /** + * @param opcode opcode of instruction + */ + protected ConversionInstruction(final short opcode) { + super(opcode, (short) 1); + } + + + /** @return type associated with the instruction + */ + @Override + public Type getType( final ConstantPoolGen cp ) { + final short _opcode = super.getOpcode(); + switch (_opcode) { + case Const.D2I: + case Const.F2I: + case Const.L2I: + return Type.INT; + case Const.D2F: + case Const.I2F: + case Const.L2F: + return Type.FLOAT; + case Const.D2L: + case Const.F2L: + case Const.I2L: + return Type.LONG; + case Const.F2D: + case Const.I2D: + case Const.L2D: + return Type.DOUBLE; + case Const.I2B: + return Type.BYTE; + case Const.I2C: + return Type.CHAR; + case Const.I2S: + return Type.SHORT; + default: // Never reached + throw new ClassGenException("Unknown type " + _opcode); + } + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/D2F.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/D2F.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/D2F.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/D2F.java index 363ebd10..6726669a --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/D2F.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/D2F.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * D2F - Convert double to float - *
      Stack: ..., value.word1, value.word2 -> ..., result
      - * - * @version $Id: D2F.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class D2F extends ConversionInstruction { - - /** Convert double to float - */ - public D2F() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * D2F - Convert double to float + *
      Stack: ..., value.word1, value.word2 -> ..., result
      + * + * @version $Id: D2F.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class D2F extends ConversionInstruction { + + /** Convert double to float + */ + public D2F() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitD2F(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/D2I.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/D2I.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/D2I.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/D2I.java index 12f4ef2a..1f96d874 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/D2I.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/D2I.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * D2I - Convert double to int - *
      Stack: ..., value.word1, value.word2 -> ..., result
      - * - * @version $Id: D2I.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class D2I extends ConversionInstruction { - - /** Convert double to int - */ - public D2I() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * D2I - Convert double to int + *
      Stack: ..., value.word1, value.word2 -> ..., result
      + * + * @version $Id: D2I.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class D2I extends ConversionInstruction { + + /** Convert double to int + */ + public D2I() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitD2I(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/D2L.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/D2L.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/D2L.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/D2L.java index cee5473d..213949b0 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/D2L.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/D2L.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * D2L - Convert double to long - *
      Stack: ..., value.word1, value.word2 -> ..., result.word1, result.word2
      - * - * @version $Id: D2L.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class D2L extends ConversionInstruction { - - /** Convert double to long - */ - public D2L() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * D2L - Convert double to long + *
      Stack: ..., value.word1, value.word2 -> ..., result.word1, result.word2
      + * + * @version $Id: D2L.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class D2L extends ConversionInstruction { + + /** Convert double to long + */ + public D2L() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitD2L(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DADD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DADD.java old mode 100755 new mode 100644 similarity index 61% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DADD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DADD.java index 518d16ef..fcbab2d7 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DADD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DADD.java @@ -1,51 +1,52 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * DADD - Add doubles - *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
      - * ..., result.word1, result1.word2 - * - * @version $Id: DADD.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class DADD extends ArithmeticInstruction { - - /** Add doubles - */ - public DADD() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * DADD - Add doubles + *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
      + * ..., result.word1, result1.word2 + * + * @version $Id: DADD.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class DADD extends ArithmeticInstruction { + + /** Add doubles + */ + public DADD() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitDADD(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DALOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DALOAD.java old mode 100755 new mode 100644 similarity index 61% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DALOAD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DALOAD.java index b789be53..1668d9cd --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DALOAD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DALOAD.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * DALOAD - Load double from array - *
      Stack: ..., arrayref, index -> ..., result.word1, result.word2
      - * - * @version $Id: DALOAD.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class DALOAD extends ArrayInstruction implements StackProducer { - - /** Load double from array - */ - public DALOAD() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * DALOAD - Load double from array + *
      Stack: ..., arrayref, index -> ..., result.word1, result.word2
      + * + * @version $Id: DALOAD.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class DALOAD extends ArrayInstruction implements StackProducer { + + /** Load double from array + */ + public DALOAD() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackProducer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitDALOAD(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DASTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DASTORE.java old mode 100755 new mode 100644 similarity index 61% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DASTORE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DASTORE.java index 7464b6ed..d87db262 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DASTORE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DASTORE.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * DASTORE - Store into double array - *
      Stack: ..., arrayref, index, value.word1, value.word2 -> ...
      - * - * @version $Id: DASTORE.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class DASTORE extends ArrayInstruction implements StackConsumer { - - /** Store double into array - */ - public DASTORE() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * DASTORE - Store into double array + *
      Stack: ..., arrayref, index, value.word1, value.word2 -> ...
      + * + * @version $Id: DASTORE.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class DASTORE extends ArrayInstruction implements StackConsumer { + + /** Store double into array + */ + public DASTORE() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitDASTORE(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DCMPG.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DCMPG.java old mode 100755 new mode 100644 similarity index 55% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DCMPG.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DCMPG.java index 90132254..53baea63 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DCMPG.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DCMPG.java @@ -1,55 +1,54 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * DCMPG - Compare doubles: value1 > value2 - *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
      - * ..., result - * - * @version $Id: DCMPG.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class DCMPG extends Instruction implements TypedInstruction, StackProducer, StackConsumer { - - public DCMPG() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * DCMPG - Compare doubles: value1 > value2 + *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -> ..., result
      + * + * @version $Id: DCMPG.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class DCMPG extends Instruction implements TypedInstruction, StackProducer, StackConsumer { + + public DCMPG() { + super(org.apache.bcel.Const.DCMPG, (short) 1); + } + + /** @return Type.DOUBLE + */ + @Override + public Type getType( final 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitDCMPG(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DCMPL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DCMPL.java old mode 100755 new mode 100644 similarity index 55% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DCMPL.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DCMPL.java index c3cbb6a7..26c32804 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DCMPL.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DCMPL.java @@ -1,55 +1,54 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * DCMPL - Compare doubles: value1 < value2 - *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
      - * ..., result - * - * @version $Id: DCMPL.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class DCMPL extends Instruction implements TypedInstruction, StackProducer, StackConsumer { - - public DCMPL() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * DCMPL - Compare doubles: value1 < value2 + *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -> ..., result
      + * + * @version $Id: DCMPL.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class DCMPL extends Instruction implements TypedInstruction, StackProducer, StackConsumer { + + public DCMPL() { + super(org.apache.bcel.Const.DCMPL, (short) 1); + } + + /** @return Type.DOUBLE + */ + @Override + public Type getType( final 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitDCMPL(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DCONST.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DCONST.java old mode 100755 new mode 100644 similarity index 56% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DCONST.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DCONST.java index 71fba77f..6a8dda30 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DCONST.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DCONST.java @@ -1,80 +1,83 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * DCONST - Push 0.0 or 1.0, other values cause an exception - * - *
      Stack: ... -> ..., 
      - * - * @version $Id: DCONST.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.Constants.DCONST_0, (short) 1); - if (f == 0.0) { - opcode = org.apache.bcel5_2_0.Constants.DCONST_0; - } else if (f == 1.0) { - opcode = org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * DCONST - Push 0.0 or 1.0, other values cause an exception + * + *
      Stack: ... -> ..., 
      + * + * @version $Id: DCONST.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class DCONST extends Instruction implements ConstantPushInstruction { + + private double value; + + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + DCONST() { + } + + + public DCONST(final double f) { + super(org.apache.bcel.Const.DCONST_0, (short) 1); + if (f == 0.0) { + super.setOpcode(org.apache.bcel.Const.DCONST_0); + } else if (f == 1.0) { + super.setOpcode(org.apache.bcel.Const.DCONST_1); + } else { + throw new ClassGenException("DCONST can be used only for 0.0 and 1.0: " + f); + } + value = f; + } + + + @Override + public Number getValue() { + return new Double(value); + } + + + /** @return Type.DOUBLE + */ + @Override + public Type getType( final 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitPushInstruction(this); + v.visitStackProducer(this); + v.visitTypedInstruction(this); + v.visitConstantPushInstruction(this); + v.visitDCONST(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DDIV.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DDIV.java old mode 100755 new mode 100644 similarity index 61% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DDIV.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DDIV.java index 402408d5..68c3cca2 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DDIV.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DDIV.java @@ -1,51 +1,52 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * DDIV - Divide doubles - *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
      - * ..., result.word1, result.word2 - * - * @version $Id: DDIV.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class DDIV extends ArithmeticInstruction { - - /** Divide doubles - */ - public DDIV() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * DDIV - Divide doubles + *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
      + * ..., result.word1, result.word2 + * + * @version $Id: DDIV.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class DDIV extends ArithmeticInstruction { + + /** Divide doubles + */ + public DDIV() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitDDIV(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DLOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DLOAD.java old mode 100755 new mode 100644 similarity index 51% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DLOAD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DLOAD.java index 47609f74..dc9aad54 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DLOAD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DLOAD.java @@ -1,57 +1,58 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * DLOAD - Load double from local variable - *
      Stack ... -> ..., result.word1, result.word2
      - * - * @version $Id: DLOAD.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.Constants.DLOAD, org.apache.bcel5_2_0.Constants.DLOAD_0); - } - - - /** Load double from local variable - * @param n index of local variable - */ - public DLOAD(int n) { - super(org.apache.bcel5_2_0.Constants.DLOAD, org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * DLOAD - Load double from local variable + *
      Stack ... -> ..., result.word1, result.word2
      + * + * @version $Id: DLOAD.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class DLOAD extends LoadInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + DLOAD() { + super(org.apache.bcel.Const.DLOAD, org.apache.bcel.Const.DLOAD_0); + } + + + /** Load double from local variable + * @param n index of local variable + */ + public DLOAD(final int n) { + super(org.apache.bcel.Const.DLOAD, org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + super.accept(v); + v.visitDLOAD(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DMUL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DMUL.java old mode 100755 new mode 100644 similarity index 61% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DMUL.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DMUL.java index 6aba328f..8b4edd65 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DMUL.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DMUL.java @@ -1,51 +1,52 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * DMUL - Multiply doubles - *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
      - * ..., result.word1, result.word2 - * - * @version $Id: DMUL.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class DMUL extends ArithmeticInstruction { - - /** Multiply doubles - */ - public DMUL() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * DMUL - Multiply doubles + *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
      + * ..., result.word1, result.word2 + * + * @version $Id: DMUL.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class DMUL extends ArithmeticInstruction { + + /** Multiply doubles + */ + public DMUL() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitDMUL(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DNEG.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DNEG.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DNEG.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DNEG.java index 639ac38d..566b6aba --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DNEG.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DNEG.java @@ -1,48 +1,49 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * DNEG - Negate double - *
      Stack: ..., value.word1, value.word2 -> ..., result.word1, result.word2
      - * - * @version $Id: DNEG.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class DNEG extends ArithmeticInstruction { - - public DNEG() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * DNEG - Negate double + *
      Stack: ..., value.word1, value.word2 -> ..., result.word1, result.word2
      + * + * @version $Id: DNEG.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class DNEG extends ArithmeticInstruction { + + public DNEG() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitDNEG(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DREM.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DREM.java old mode 100755 new mode 100644 similarity index 61% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DREM.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DREM.java index 909f06eb..37fcfdd1 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DREM.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DREM.java @@ -1,51 +1,52 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * DREM - Remainder of doubles - *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
      - * ..., result.word1, result.word2 - * - * @version $Id: DREM.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class DREM extends ArithmeticInstruction { - - /** Remainder of doubles - */ - public DREM() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * DREM - Remainder of doubles + *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
      + * ..., result.word1, result.word2 + * + * @version $Id: DREM.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class DREM extends ArithmeticInstruction { + + /** Remainder of doubles + */ + public DREM() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitDREM(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DRETURN.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DRETURN.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DRETURN.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DRETURN.java index 3f76bff1..ff87dd27 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DRETURN.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DRETURN.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * DRETURN - Return double from method - *
      Stack: ..., value.word1, value.word2 -> <empty>
      - * - * @version $Id: DRETURN.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class DRETURN extends ReturnInstruction { - - /** Return double from method - */ - public DRETURN() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * DRETURN - Return double from method + *
      Stack: ..., value.word1, value.word2 -> <empty>
      + * + * @version $Id: DRETURN.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class DRETURN extends ReturnInstruction { + + /** Return double from method + */ + public DRETURN() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackConsumer(this); + v.visitReturnInstruction(this); + v.visitDRETURN(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DSTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DSTORE.java old mode 100755 new mode 100644 similarity index 51% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DSTORE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DSTORE.java index fe25a259..77d0f879 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DSTORE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DSTORE.java @@ -1,57 +1,58 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * DSTORE - Store double into local variable - *
      Stack: ..., value.word1, value.word2 -> ... 
      - * - * @version $Id: DSTORE.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.Constants.DSTORE, org.apache.bcel5_2_0.Constants.DSTORE_0); - } - - - /** Store double into local variable - * @param n index of local variable - */ - public DSTORE(int n) { - super(org.apache.bcel5_2_0.Constants.DSTORE, org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * DSTORE - Store double into local variable + *
      Stack: ..., value.word1, value.word2 -> ... 
      + * + * @version $Id: DSTORE.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class DSTORE extends StoreInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + DSTORE() { + super(org.apache.bcel.Const.DSTORE, org.apache.bcel.Const.DSTORE_0); + } + + + /** Store double into local variable + * @param n index of local variable + */ + public DSTORE(final int n) { + super(org.apache.bcel.Const.DSTORE, org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + super.accept(v); + v.visitDSTORE(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DSUB.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DSUB.java old mode 100755 new mode 100644 similarity index 61% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DSUB.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DSUB.java index 4d56b1ba..04445c9d --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DSUB.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DSUB.java @@ -1,51 +1,52 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * DSUB - Substract doubles - *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
      - * ..., result.word1, result.word2 - * - * @version $Id: DSUB.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class DSUB extends ArithmeticInstruction { - - /** Substract doubles - */ - public DSUB() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * DSUB - Substract doubles + *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
      + * ..., result.word1, result.word2 + * + * @version $Id: DSUB.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class DSUB extends ArithmeticInstruction { + + /** Substract doubles + */ + public DSUB() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitDSUB(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DUP.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DUP.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP.java index d9ef76b1..8061764e --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DUP.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP.java @@ -1,47 +1,48 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * DUP - Duplicate top operand stack word - *
      Stack: ..., word -> ..., word, word
      - * - * @version $Id: DUP.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class DUP extends StackInstruction implements PushInstruction { - - public DUP() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * DUP - Duplicate top operand stack word + *
      Stack: ..., word -> ..., word, word
      + * + * @version $Id: DUP.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class DUP extends StackInstruction implements PushInstruction { + + public DUP() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackProducer(this); + v.visitPushInstruction(this); + v.visitStackInstruction(this); + v.visitDUP(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DUP2.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP2.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DUP2.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP2.java index 6f1076be..4fb58329 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DUP2.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP2.java @@ -1,47 +1,48 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * DUP2 - Duplicate two top operand stack words - *
      Stack: ..., word2, word1 -> ..., word2, word1, word2, word1
      - * - * @version $Id: DUP2.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class DUP2 extends StackInstruction implements PushInstruction { - - public DUP2() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * DUP2 - Duplicate two top operand stack words + *
      Stack: ..., word2, word1 -> ..., word2, word1, word2, word1
      + * + * @version $Id: DUP2.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class DUP2 extends StackInstruction implements PushInstruction { + + public DUP2() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackProducer(this); + v.visitPushInstruction(this); + v.visitStackInstruction(this); + v.visitDUP2(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DUP2_X1.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP2_X1.java old mode 100755 new mode 100644 similarity index 58% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DUP2_X1.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP2_X1.java index c8a2e1d3..75488539 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DUP2_X1.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP2_X1.java @@ -1,45 +1,46 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * DUP2_X1 - Duplicate two top operand stack words and put three down - *
      Stack: ..., word3, word2, word1 -> ..., word2, word1, word3, word2, word1
      - * - * @version $Id: DUP2_X1.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class DUP2_X1 extends StackInstruction { - - public DUP2_X1() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * DUP2_X1 - Duplicate two top operand stack words and put three down + *
      Stack: ..., word3, word2, word1 -> ..., word2, word1, word3, word2, word1
      + * + * @version $Id: DUP2_X1.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class DUP2_X1 extends StackInstruction { + + public DUP2_X1() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackInstruction(this); + v.visitDUP2_X1(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DUP2_X2.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP2_X2.java old mode 100755 new mode 100644 similarity index 58% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DUP2_X2.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP2_X2.java index 4dfc8026..0ebb2075 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DUP2_X2.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP2_X2.java @@ -1,45 +1,46 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * DUP2_X2 - Duplicate two top operand stack words and put four down - *
      Stack: ..., word4, word3, word2, word1 -> ..., word2, word1, word4, word3, word2, word1
      - * - * @version $Id: DUP2_X2.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class DUP2_X2 extends StackInstruction { - - public DUP2_X2() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * DUP2_X2 - Duplicate two top operand stack words and put four down + *
      Stack: ..., word4, word3, word2, word1 -> ..., word2, word1, word4, word3, word2, word1
      + * + * @version $Id: DUP2_X2.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class DUP2_X2 extends StackInstruction { + + public DUP2_X2() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackInstruction(this); + v.visitDUP2_X2(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DUP_X1.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP_X1.java old mode 100755 new mode 100644 similarity index 57% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DUP_X1.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP_X1.java index 9afc3e87..b3bab424 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DUP_X1.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP_X1.java @@ -1,45 +1,46 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * DUP_X1 - Duplicate top operand stack word and put two down - *
      Stack: ..., word2, word1 -> ..., word1, word2, word1
      - * - * @version $Id: DUP_X1.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class DUP_X1 extends StackInstruction { - - public DUP_X1() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * DUP_X1 - Duplicate top operand stack word and put two down + *
      Stack: ..., word2, word1 -> ..., word1, word2, word1
      + * + * @version $Id: DUP_X1.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class DUP_X1 extends StackInstruction { + + public DUP_X1() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackInstruction(this); + v.visitDUP_X1(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DUP_X2.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP_X2.java old mode 100755 new mode 100644 similarity index 58% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DUP_X2.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP_X2.java index 9b66559f..e33d95d5 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/DUP_X2.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP_X2.java @@ -1,45 +1,46 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * DUP_X2 - Duplicate top operand stack word and put three down - *
      Stack: ..., word3, word2, word1 -> ..., word1, word3, word2, word1
      - * - * @version $Id: DUP_X2.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class DUP_X2 extends StackInstruction { - - public DUP_X2() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * DUP_X2 - Duplicate top operand stack word and put three down + *
      Stack: ..., word3, word2, word1 -> ..., word1, word3, word2, word1
      + * + * @version $Id: DUP_X2.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class DUP_X2 extends StackInstruction { + + public DUP_X2() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackInstruction(this); + v.visitDUP_X2(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ElementValueGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ElementValueGen.java new file mode 100644 index 00000000..e357b3eb --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ElementValueGen.java @@ -0,0 +1,194 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataInput; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.classfile.AnnotationElementValue; +import org.apache.bcel.classfile.AnnotationEntry; +import org.apache.bcel.classfile.ArrayElementValue; +import org.apache.bcel.classfile.ClassElementValue; +import org.apache.bcel.classfile.ElementValue; +import org.apache.bcel.classfile.EnumElementValue; +import org.apache.bcel.classfile.SimpleElementValue; + +/** + * @since 6.0 + */ +public abstract class ElementValueGen +{ + /** + * @deprecated (since 6.0) will be made private and final; do not access directly, use getter + */ + @Deprecated + protected int type; + + /** + * @deprecated (since 6.0) will be made private and final; do not access directly, use getter + */ + @Deprecated + protected ConstantPoolGen cpGen; + + protected ElementValueGen(final int type, final ConstantPoolGen cpGen) + { + this.type = type; + this.cpGen = cpGen; + } + + /** + * Subtypes return an immutable variant of the ElementValueGen + */ + public abstract ElementValue getElementValue(); + + public int getElementValueType() + { + return type; + } + + public abstract String stringifyValue(); + + public abstract void dump(DataOutputStream dos) throws IOException; + + public static final int STRING = 's'; + + public static final int ENUM_CONSTANT = 'e'; + + public static final int CLASS = 'c'; + + public static final int ANNOTATION = '@'; + + public static final int ARRAY = '['; + + public static final int PRIMITIVE_INT = 'I'; + + public static final int PRIMITIVE_BYTE = 'B'; + + public static final int PRIMITIVE_CHAR = 'C'; + + public static final int PRIMITIVE_DOUBLE = 'D'; + + public static final int PRIMITIVE_FLOAT = 'F'; + + public static final int PRIMITIVE_LONG = 'J'; + + public static final int PRIMITIVE_SHORT = 'S'; + + public static final int PRIMITIVE_BOOLEAN = 'Z'; + + public static ElementValueGen readElementValue(final DataInput dis, + final ConstantPoolGen cpGen) throws IOException + { + final int type = dis.readUnsignedByte(); + switch (type) + { + case 'B': // byte + return new SimpleElementValueGen(PRIMITIVE_BYTE, dis + .readUnsignedShort(), cpGen); + case 'C': // char + return new SimpleElementValueGen(PRIMITIVE_CHAR, dis + .readUnsignedShort(), cpGen); + case 'D': // double + return new SimpleElementValueGen(PRIMITIVE_DOUBLE, dis + .readUnsignedShort(), cpGen); + case 'F': // float + return new SimpleElementValueGen(PRIMITIVE_FLOAT, dis + .readUnsignedShort(), cpGen); + case 'I': // int + return new SimpleElementValueGen(PRIMITIVE_INT, dis + .readUnsignedShort(), cpGen); + case 'J': // long + return new SimpleElementValueGen(PRIMITIVE_LONG, dis + .readUnsignedShort(), cpGen); + case 'S': // short + return new SimpleElementValueGen(PRIMITIVE_SHORT, dis + .readUnsignedShort(), cpGen); + case 'Z': // boolean + return new SimpleElementValueGen(PRIMITIVE_BOOLEAN, dis + .readUnsignedShort(), cpGen); + case 's': // String + return new SimpleElementValueGen(STRING, dis.readUnsignedShort(), + cpGen); + case 'e': // Enum constant + return new EnumElementValueGen(dis.readUnsignedShort(), dis + .readUnsignedShort(), cpGen); + case 'c': // Class + return new ClassElementValueGen(dis.readUnsignedShort(), cpGen); + case '@': // Annotation + // TODO: isRuntimeVisible ?????????? + // FIXME + return new AnnotationElementValueGen(ANNOTATION, + new AnnotationEntryGen(AnnotationEntry.read(dis, cpGen + .getConstantPool(), true), cpGen, false), cpGen); + case '[': // Array + final int numArrayVals = dis.readUnsignedShort(); + final ElementValue[] evalues = new ElementValue[numArrayVals]; + for (int j = 0; j < numArrayVals; j++) + { + evalues[j] = ElementValue.readElementValue(dis, cpGen + .getConstantPool()); + } + return new ArrayElementValueGen(ARRAY, evalues, cpGen); + default: + throw new RuntimeException("Unexpected element value kind in annotation: " + type); + } + } + + protected ConstantPoolGen getConstantPool() + { + return cpGen; + } + + /** + * Creates an (modifiable) ElementValueGen copy of an (immutable) + * ElementValue - constant pool is assumed correct. + */ + public static ElementValueGen copy(final ElementValue value, + final ConstantPoolGen cpool, final boolean copyPoolEntries) + { + switch (value.getElementValueType()) + { + case 'B': // byte + case 'C': // char + case 'D': // double + case 'F': // float + case 'I': // int + case 'J': // long + case 'S': // short + case 'Z': // boolean + case 's': // String + return new SimpleElementValueGen((SimpleElementValue) value, cpool, + copyPoolEntries); + case 'e': // Enum constant + return new EnumElementValueGen((EnumElementValue) value, cpool, + copyPoolEntries); + case '@': // Annotation + return new AnnotationElementValueGen( + (AnnotationElementValue) value, cpool, copyPoolEntries); + case '[': // Array + return new ArrayElementValueGen((ArrayElementValue) value, cpool, + copyPoolEntries); + case 'c': // Class + return new ClassElementValueGen((ClassElementValue) value, cpool, + copyPoolEntries); + default: + throw new RuntimeException("Not implemented yet! (" + value.getElementValueType() + ")"); + } + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ElementValuePairGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ElementValuePairGen.java new file mode 100644 index 00000000..7fcb0c8e --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ElementValuePairGen.java @@ -0,0 +1,115 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.classfile.ConstantUtf8; +import org.apache.bcel.classfile.ElementValue; +import org.apache.bcel.classfile.ElementValuePair; + +/** + * @since 6.0 + */ +public class ElementValuePairGen +{ + private int nameIdx; + + private final ElementValueGen value; + + private final ConstantPoolGen cpool; + + public ElementValuePairGen(final ElementValuePair nvp, final ConstantPoolGen cpool, + final boolean copyPoolEntries) + { + this.cpool = cpool; + // J5ASSERT: + // Could assert nvp.getNameString() points to the same thing as + // cpool.getConstant(nvp.getNameIndex()) + // if + // (!nvp.getNameString().equals(((ConstantUtf8)cpool.getConstant(nvp.getNameIndex())).getBytes())) + // { + // throw new RuntimeException("envp buggered"); + // } + if (copyPoolEntries) + { + nameIdx = cpool.addUtf8(nvp.getNameString()); + } + else + { + nameIdx = nvp.getNameIndex(); + } + value = ElementValueGen.copy(nvp.getValue(), cpool, copyPoolEntries); + } + + /** + * Retrieve an immutable version of this ElementNameValuePairGen + */ + public ElementValuePair getElementNameValuePair() + { + final ElementValue immutableValue = value.getElementValue(); + return new ElementValuePair(nameIdx, immutableValue, cpool + .getConstantPool()); + } + + protected ElementValuePairGen(final int idx, final ElementValueGen value, + final ConstantPoolGen cpool) + { + this.nameIdx = idx; + this.value = value; + this.cpool = cpool; + } + + public ElementValuePairGen(final String name, final ElementValueGen value, + final ConstantPoolGen cpool) + { + this.nameIdx = cpool.addUtf8(name); + this.value = value; + this.cpool = cpool; + } + + protected void dump(final DataOutputStream dos) throws IOException + { + dos.writeShort(nameIdx); // u2 name of the element + value.dump(dos); + } + + public int getNameIndex() + { + return nameIdx; + } + + public final String getNameString() + { + // ConstantString cu8 = (ConstantString)cpool.getConstant(nameIdx); + return ((ConstantUtf8) cpool.getConstant(nameIdx)).getBytes(); + } + + public final ElementValueGen getValue() + { + return value; + } + + @Override + public String toString() + { + return "ElementValuePair:[" + getNameString() + "=" + + value.stringifyValue() + "]"; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/EmptyVisitor.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/EmptyVisitor.java new file mode 100644 index 00000000..49ebebdb --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/EmptyVisitor.java @@ -0,0 +1,932 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Supplies empty method bodies to be overridden by subclasses. + * + * @version $Id: EmptyVisitor.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public abstract class EmptyVisitor implements Visitor { + + @Override + public void visitStackInstruction( final StackInstruction obj ) { + } + + + @Override + public void visitLocalVariableInstruction( final LocalVariableInstruction obj ) { + } + + + @Override + public void visitBranchInstruction( final BranchInstruction obj ) { + } + + + @Override + public void visitLoadClass( final LoadClass obj ) { + } + + + @Override + public void visitFieldInstruction( final FieldInstruction obj ) { + } + + + @Override + public void visitIfInstruction( final IfInstruction obj ) { + } + + + @Override + public void visitConversionInstruction( final ConversionInstruction obj ) { + } + + + @Override + public void visitPopInstruction( final PopInstruction obj ) { + } + + + @Override + public void visitJsrInstruction( final JsrInstruction obj ) { + } + + + @Override + public void visitGotoInstruction( final GotoInstruction obj ) { + } + + + @Override + public void visitStoreInstruction( final StoreInstruction obj ) { + } + + + @Override + public void visitTypedInstruction( final TypedInstruction obj ) { + } + + + @Override + public void visitSelect( final Select obj ) { + } + + + @Override + public void visitUnconditionalBranch( final UnconditionalBranch obj ) { + } + + + @Override + public void visitPushInstruction( final PushInstruction obj ) { + } + + + @Override + public void visitArithmeticInstruction( final ArithmeticInstruction obj ) { + } + + + @Override + public void visitCPInstruction( final CPInstruction obj ) { + } + + + @Override + public void visitInvokeInstruction( final InvokeInstruction obj ) { + } + + + @Override + public void visitArrayInstruction( final ArrayInstruction obj ) { + } + + + @Override + public void visitAllocationInstruction( final AllocationInstruction obj ) { + } + + + @Override + public void visitReturnInstruction( final ReturnInstruction obj ) { + } + + + @Override + public void visitFieldOrMethod( final FieldOrMethod obj ) { + } + + + @Override + public void visitConstantPushInstruction( final ConstantPushInstruction obj ) { + } + + + @Override + public void visitExceptionThrower( final ExceptionThrower obj ) { + } + + + @Override + public void visitLoadInstruction( final LoadInstruction obj ) { + } + + + @Override + public void visitVariableLengthInstruction( final VariableLengthInstruction obj ) { + } + + + @Override + public void visitStackProducer( final StackProducer obj ) { + } + + + @Override + public void visitStackConsumer( final StackConsumer obj ) { + } + + + @Override + public void visitACONST_NULL( final ACONST_NULL obj ) { + } + + + @Override + public void visitGETSTATIC( final GETSTATIC obj ) { + } + + + @Override + public void visitIF_ICMPLT( final IF_ICMPLT obj ) { + } + + + @Override + public void visitMONITOREXIT( final MONITOREXIT obj ) { + } + + + @Override + public void visitIFLT( final IFLT obj ) { + } + + + @Override + public void visitLSTORE( final LSTORE obj ) { + } + + + @Override + public void visitPOP2( final POP2 obj ) { + } + + + @Override + public void visitBASTORE( final BASTORE obj ) { + } + + + @Override + public void visitISTORE( final ISTORE obj ) { + } + + + @Override + public void visitCHECKCAST( final CHECKCAST obj ) { + } + + + @Override + public void visitFCMPG( final FCMPG obj ) { + } + + + @Override + public void visitI2F( final I2F obj ) { + } + + + @Override + public void visitATHROW( final ATHROW obj ) { + } + + + @Override + public void visitDCMPL( final DCMPL obj ) { + } + + + @Override + public void visitARRAYLENGTH( final ARRAYLENGTH obj ) { + } + + + @Override + public void visitDUP( final DUP obj ) { + } + + + @Override + public void visitINVOKESTATIC( final INVOKESTATIC obj ) { + } + + + @Override + public void visitLCONST( final LCONST obj ) { + } + + + @Override + public void visitDREM( final DREM obj ) { + } + + + @Override + public void visitIFGE( final IFGE obj ) { + } + + + @Override + public void visitCALOAD( final CALOAD obj ) { + } + + + @Override + public void visitLASTORE( final LASTORE obj ) { + } + + + @Override + public void visitI2D( final I2D obj ) { + } + + + @Override + public void visitDADD( final DADD obj ) { + } + + + @Override + public void visitINVOKESPECIAL( final INVOKESPECIAL obj ) { + } + + + @Override + public void visitIAND( final IAND obj ) { + } + + + @Override + public void visitPUTFIELD( final PUTFIELD obj ) { + } + + + @Override + public void visitILOAD( final ILOAD obj ) { + } + + + @Override + public void visitDLOAD( final DLOAD obj ) { + } + + + @Override + public void visitDCONST( final DCONST obj ) { + } + + + @Override + public void visitNEW( final NEW obj ) { + } + + + @Override + public void visitIFNULL( final IFNULL obj ) { + } + + + @Override + public void visitLSUB( final LSUB obj ) { + } + + + @Override + public void visitL2I( final L2I obj ) { + } + + + @Override + public void visitISHR( final ISHR obj ) { + } + + + @Override + public void visitTABLESWITCH( final TABLESWITCH obj ) { + } + + + @Override + public void visitIINC( final IINC obj ) { + } + + + @Override + public void visitDRETURN( final DRETURN obj ) { + } + + + @Override + public void visitFSTORE( final FSTORE obj ) { + } + + + @Override + public void visitDASTORE( final DASTORE obj ) { + } + + + @Override + public void visitIALOAD( final IALOAD obj ) { + } + + + @Override + public void visitDDIV( final DDIV obj ) { + } + + + @Override + public void visitIF_ICMPGE( final IF_ICMPGE obj ) { + } + + + @Override + public void visitLAND( final LAND obj ) { + } + + + @Override + public void visitIDIV( final IDIV obj ) { + } + + + @Override + public void visitLOR( final LOR obj ) { + } + + + @Override + public void visitCASTORE( final CASTORE obj ) { + } + + + @Override + public void visitFREM( final FREM obj ) { + } + + + @Override + public void visitLDC( final LDC obj ) { + } + + + @Override + public void visitBIPUSH( final BIPUSH obj ) { + } + + + @Override + public void visitDSTORE( final DSTORE obj ) { + } + + + @Override + public void visitF2L( final F2L obj ) { + } + + + @Override + public void visitFMUL( final FMUL obj ) { + } + + + @Override + public void visitLLOAD( final LLOAD obj ) { + } + + + @Override + public void visitJSR( final JSR obj ) { + } + + + @Override + public void visitFSUB( final FSUB obj ) { + } + + + @Override + public void visitSASTORE( final SASTORE obj ) { + } + + + @Override + public void visitALOAD( final ALOAD obj ) { + } + + + @Override + public void visitDUP2_X2( final DUP2_X2 obj ) { + } + + + @Override + public void visitRETURN( final RETURN obj ) { + } + + + @Override + public void visitDALOAD( final DALOAD obj ) { + } + + + @Override + public void visitSIPUSH( final SIPUSH obj ) { + } + + + @Override + public void visitDSUB( final DSUB obj ) { + } + + + @Override + public void visitL2F( final L2F obj ) { + } + + + @Override + public void visitIF_ICMPGT( final IF_ICMPGT obj ) { + } + + + @Override + public void visitF2D( final F2D obj ) { + } + + + @Override + public void visitI2L( final I2L obj ) { + } + + + @Override + public void visitIF_ACMPNE( final IF_ACMPNE obj ) { + } + + + @Override + public void visitPOP( final POP obj ) { + } + + + @Override + public void visitI2S( final I2S obj ) { + } + + + @Override + public void visitIFEQ( final IFEQ obj ) { + } + + + @Override + public void visitSWAP( final SWAP obj ) { + } + + + @Override + public void visitIOR( final IOR obj ) { + } + + + @Override + public void visitIREM( final IREM obj ) { + } + + + @Override + public void visitIASTORE( final IASTORE obj ) { + } + + + @Override + public void visitNEWARRAY( final NEWARRAY obj ) { + } + + + @Override + public void visitINVOKEINTERFACE( final INVOKEINTERFACE obj ) { + } + + + @Override + public void visitINEG( final INEG obj ) { + } + + + @Override + public void visitLCMP( final LCMP obj ) { + } + + + @Override + public void visitJSR_W( final JSR_W obj ) { + } + + + @Override + public void visitMULTIANEWARRAY( final MULTIANEWARRAY obj ) { + } + + + @Override + public void visitDUP_X2( final DUP_X2 obj ) { + } + + + @Override + public void visitSALOAD( final SALOAD obj ) { + } + + + @Override + public void visitIFNONNULL( final IFNONNULL obj ) { + } + + + @Override + public void visitDMUL( final DMUL obj ) { + } + + + @Override + public void visitIFNE( final IFNE obj ) { + } + + + @Override + public void visitIF_ICMPLE( final IF_ICMPLE obj ) { + } + + + @Override + public void visitLDC2_W( final LDC2_W obj ) { + } + + + @Override + public void visitGETFIELD( final GETFIELD obj ) { + } + + + @Override + public void visitLADD( final LADD obj ) { + } + + + @Override + public void visitNOP( final NOP obj ) { + } + + + @Override + public void visitFALOAD( final FALOAD obj ) { + } + + + @Override + public void visitINSTANCEOF( final INSTANCEOF obj ) { + } + + + @Override + public void visitIFLE( final IFLE obj ) { + } + + + @Override + public void visitLXOR( final LXOR obj ) { + } + + + @Override + public void visitLRETURN( final LRETURN obj ) { + } + + + @Override + public void visitFCONST( final FCONST obj ) { + } + + + @Override + public void visitIUSHR( final IUSHR obj ) { + } + + + @Override + public void visitBALOAD( final BALOAD obj ) { + } + + + @Override + public void visitDUP2( final DUP2 obj ) { + } + + + @Override + public void visitIF_ACMPEQ( final IF_ACMPEQ obj ) { + } + + + @Override + public void visitIMPDEP1( final IMPDEP1 obj ) { + } + + + @Override + public void visitMONITORENTER( final MONITORENTER obj ) { + } + + + @Override + public void visitLSHL( final LSHL obj ) { + } + + + @Override + public void visitDCMPG( final DCMPG obj ) { + } + + + @Override + public void visitD2L( final D2L obj ) { + } + + + @Override + public void visitIMPDEP2( final IMPDEP2 obj ) { + } + + + @Override + public void visitL2D( final L2D obj ) { + } + + + @Override + public void visitRET( final RET obj ) { + } + + + @Override + public void visitIFGT( final IFGT obj ) { + } + + + @Override + public void visitIXOR( final IXOR obj ) { + } + + + @Override + public void visitINVOKEVIRTUAL( final INVOKEVIRTUAL obj ) { + } + + + @Override + public void visitFASTORE( final FASTORE obj ) { + } + + + @Override + public void visitIRETURN( final IRETURN obj ) { + } + + + @Override + public void visitIF_ICMPNE( final IF_ICMPNE obj ) { + } + + + @Override + public void visitFLOAD( final FLOAD obj ) { + } + + + @Override + public void visitLDIV( final LDIV obj ) { + } + + + @Override + public void visitPUTSTATIC( final PUTSTATIC obj ) { + } + + + @Override + public void visitAALOAD( final AALOAD obj ) { + } + + + @Override + public void visitD2I( final D2I obj ) { + } + + + @Override + public void visitIF_ICMPEQ( final IF_ICMPEQ obj ) { + } + + + @Override + public void visitAASTORE( final AASTORE obj ) { + } + + + @Override + public void visitARETURN( final ARETURN obj ) { + } + + + @Override + public void visitDUP2_X1( final DUP2_X1 obj ) { + } + + + @Override + public void visitFNEG( final FNEG obj ) { + } + + + @Override + public void visitGOTO_W( final GOTO_W obj ) { + } + + + @Override + public void visitD2F( final D2F obj ) { + } + + + @Override + public void visitGOTO( final GOTO obj ) { + } + + + @Override + public void visitISUB( final ISUB obj ) { + } + + + @Override + public void visitF2I( final F2I obj ) { + } + + + @Override + public void visitDNEG( final DNEG obj ) { + } + + + @Override + public void visitICONST( final ICONST obj ) { + } + + + @Override + public void visitFDIV( final FDIV obj ) { + } + + + @Override + public void visitI2B( final I2B obj ) { + } + + + @Override + public void visitLNEG( final LNEG obj ) { + } + + + @Override + public void visitLREM( final LREM obj ) { + } + + + @Override + public void visitIMUL( final IMUL obj ) { + } + + + @Override + public void visitIADD( final IADD obj ) { + } + + + @Override + public void visitLSHR( final LSHR obj ) { + } + + + @Override + public void visitLOOKUPSWITCH( final LOOKUPSWITCH obj ) { + } + + + @Override + public void visitDUP_X1( final DUP_X1 obj ) { + } + + + @Override + public void visitFCMPL( final FCMPL obj ) { + } + + + @Override + public void visitI2C( final I2C obj ) { + } + + + @Override + public void visitLMUL( final LMUL obj ) { + } + + + @Override + public void visitLUSHR( final LUSHR obj ) { + } + + + @Override + public void visitISHL( final ISHL obj ) { + } + + + @Override + public void visitLALOAD( final LALOAD obj ) { + } + + + @Override + public void visitASTORE( final ASTORE obj ) { + } + + + @Override + public void visitANEWARRAY( final ANEWARRAY obj ) { + } + + + @Override + public void visitFRETURN( final FRETURN obj ) { + } + + + @Override + public void visitFADD( final FADD obj ) { + } + + + @Override + public void visitBREAKPOINT( final BREAKPOINT obj ) { + } + + /** + * @since 6.0 + */ + @Override + public void visitINVOKEDYNAMIC(final INVOKEDYNAMIC obj) { + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/EnumElementValueGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/EnumElementValueGen.java new file mode 100644 index 00000000..2d390bfa --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/EnumElementValueGen.java @@ -0,0 +1,142 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.classfile.ConstantUtf8; +import org.apache.bcel.classfile.ElementValue; +import org.apache.bcel.classfile.EnumElementValue; + +/** + * @since 6.0 + */ +public class EnumElementValueGen extends ElementValueGen +{ + // For enum types, these two indices point to the type and value + private int typeIdx; + + private int valueIdx; + + /** + * This ctor assumes the constant pool already contains the right type and + * value - as indicated by typeIdx and valueIdx. This ctor is used for + * deserialization + */ + protected EnumElementValueGen(final int typeIdx, final int valueIdx, + final ConstantPoolGen cpool) + { + super(ElementValueGen.ENUM_CONSTANT, cpool); + if (super.getElementValueType() != ENUM_CONSTANT) { + throw new RuntimeException( + "Only element values of type enum can be built with this ctor - type specified: " + super.getElementValueType()); + } + this.typeIdx = typeIdx; + this.valueIdx = valueIdx; + } + + /** + * Return immutable variant of this EnumElementValue + */ + @Override + public ElementValue getElementValue() + { + System.err.println("Duplicating value: " + getEnumTypeString() + ":" + + getEnumValueString()); + return new EnumElementValue(super.getElementValueType(), typeIdx, valueIdx, + getConstantPool().getConstantPool()); + } + + public EnumElementValueGen(final ObjectType t, final String value, final ConstantPoolGen cpool) + { + super(ElementValueGen.ENUM_CONSTANT, cpool); + typeIdx = cpool.addUtf8(t.getSignature());// was addClass(t); + valueIdx = cpool.addUtf8(value);// was addString(value); + } + + public EnumElementValueGen(final EnumElementValue value, final ConstantPoolGen cpool, + final boolean copyPoolEntries) + { + super(ENUM_CONSTANT, cpool); + if (copyPoolEntries) + { + typeIdx = cpool.addUtf8(value.getEnumTypeString());// was + // addClass(value.getEnumTypeString()); + valueIdx = cpool.addUtf8(value.getEnumValueString()); // was + // addString(value.getEnumValueString()); + } + else + { + typeIdx = value.getTypeIndex(); + valueIdx = value.getValueIndex(); + } + } + + @Override + public void dump(final DataOutputStream dos) throws IOException + { + dos.writeByte(super.getElementValueType()); // u1 type of value (ENUM_CONSTANT == 'e') + dos.writeShort(typeIdx); // u2 + dos.writeShort(valueIdx); // u2 + } + + @Override + public String stringifyValue() + { + final ConstantUtf8 cu8 = (ConstantUtf8) getConstantPool().getConstant(valueIdx); + return cu8.getBytes(); + // ConstantString cu8 = + // (ConstantString)getConstantPool().getConstant(valueIdx); + // return + // ((ConstantUtf8)getConstantPool().getConstant(cu8.getStringIndex())).getBytes(); + } + + // BCELBUG: Should we need to call utility.signatureToString() on the output + // here? + public String getEnumTypeString() + { + // Constant cc = getConstantPool().getConstant(typeIdx); + // ConstantClass cu8 = + // (ConstantClass)getConstantPool().getConstant(typeIdx); + // return + // ((ConstantUtf8)getConstantPool().getConstant(cu8.getNameIndex())).getBytes(); + return ((ConstantUtf8) getConstantPool().getConstant(typeIdx)) + .getBytes(); + // return Utility.signatureToString(cu8.getBytes()); + } + + public String getEnumValueString() + { + return ((ConstantUtf8) getConstantPool().getConstant(valueIdx)).getBytes(); + // ConstantString cu8 = + // (ConstantString)getConstantPool().getConstant(valueIdx); + // return + // ((ConstantUtf8)getConstantPool().getConstant(cu8.getStringIndex())).getBytes(); + } + + public int getValueIndex() + { + return valueIdx; + } + + public int getTypeIndex() + { + return typeIdx; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ExceptionThrower.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ExceptionThrower.java old mode 100755 new mode 100644 similarity index 64% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ExceptionThrower.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ExceptionThrower.java index 6a3f92c3..8dfcb5d3 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ExceptionThrower.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ExceptionThrower.java @@ -1,42 +1,42 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * 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 - * RUN-TIME and which LINKING 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: ExceptionThrower.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author Enver Haase - */ -public interface ExceptionThrower { - - public java.lang.Class[] getExceptions(); -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * 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 + * RUN-TIME and which LINKING 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: ExceptionThrower.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public interface ExceptionThrower { + + java.lang.Class[] getExceptions(); +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/F2D.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/F2D.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/F2D.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/F2D.java index 8bd545ee..430e30d9 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/F2D.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/F2D.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * F2D - Convert float to double - *
      Stack: ..., value -> ..., result.word1, result.word2
      - * - * @version $Id: F2D.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class F2D extends ConversionInstruction { - - /** Convert float to double - */ - public F2D() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * F2D - Convert float to double + *
      Stack: ..., value -> ..., result.word1, result.word2
      + * + * @version $Id: F2D.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class F2D extends ConversionInstruction { + + /** Convert float to double + */ + public F2D() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitF2D(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/F2I.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/F2I.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/F2I.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/F2I.java index 863b2750..8b0dbe50 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/F2I.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/F2I.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * F2I - Convert float to int - *
      Stack: ..., value -> ..., result
      - * - * @version $Id: F2I.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class F2I extends ConversionInstruction { - - /** Convert float to int - */ - public F2I() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * F2I - Convert float to int + *
      Stack: ..., value -> ..., result
      + * + * @version $Id: F2I.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class F2I extends ConversionInstruction { + + /** Convert float to int + */ + public F2I() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitF2I(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/F2L.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/F2L.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/F2L.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/F2L.java index baa1ed67..fb749419 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/F2L.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/F2L.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * F2L - Convert float to long - *
      Stack: ..., value -> ..., result.word1, result.word2
      - * - * @version $Id: F2L.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class F2L extends ConversionInstruction { - - /** Convert float to long - */ - public F2L() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * F2L - Convert float to long + *
      Stack: ..., value -> ..., result.word1, result.word2
      + * + * @version $Id: F2L.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class F2L extends ConversionInstruction { + + /** Convert float to long + */ + public F2L() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitF2L(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FADD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FADD.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FADD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FADD.java index 394dc524..44a10c8b --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FADD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FADD.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * FADD - Add floats - *
      Stack: ..., value1, value2 -> result
      - * - * @version $Id: FADD.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class FADD extends ArithmeticInstruction { - - /** Add floats - */ - public FADD() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * FADD - Add floats + *
      Stack: ..., value1, value2 -> result
      + * + * @version $Id: FADD.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class FADD extends ArithmeticInstruction { + + /** Add floats + */ + public FADD() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitFADD(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FALOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FALOAD.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FALOAD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FALOAD.java index 42e77efa..4f8d0add --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FALOAD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FALOAD.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * FALOAD - Load float from array - *
      Stack: ..., arrayref, index -> ..., value
      - * - * @version $Id: FALOAD.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class FALOAD extends ArrayInstruction implements StackProducer { - - /** Load float from array - */ - public FALOAD() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * FALOAD - Load float from array + *
      Stack: ..., arrayref, index -> ..., value
      + * + * @version $Id: FALOAD.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class FALOAD extends ArrayInstruction implements StackProducer { + + /** Load float from array + */ + public FALOAD() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackProducer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitFALOAD(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FASTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FASTORE.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FASTORE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FASTORE.java index f0c3b544..1d19b20f --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FASTORE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FASTORE.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * FASTORE - Store into float array - *
      Stack: ..., arrayref, index, value -> ...
      - * - * @version $Id: FASTORE.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class FASTORE extends ArrayInstruction implements StackConsumer { - - /** Store float into array - */ - public FASTORE() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * FASTORE - Store into float array + *
      Stack: ..., arrayref, index, value -> ...
      + * + * @version $Id: FASTORE.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class FASTORE extends ArrayInstruction implements StackConsumer { + + /** Store float into array + */ + public FASTORE() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitFASTORE(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FCMPG.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FCMPG.java old mode 100755 new mode 100644 similarity index 56% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FCMPG.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FCMPG.java index ee4c4d03..c660f867 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FCMPG.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FCMPG.java @@ -1,54 +1,56 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * FCMPG - Compare floats: value1 > value2 - *
      Stack: ..., value1, value2 -> ..., result
      - * - * @version $Id: FCMPG.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class FCMPG extends Instruction implements TypedInstruction, StackProducer, StackConsumer { - - public FCMPG() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * FCMPG - Compare floats: value1 > value2 + *
      Stack: ..., value1, value2 -> ..., result
      + * + * @version $Id: FCMPG.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class FCMPG extends Instruction implements TypedInstruction, StackProducer, StackConsumer { + + public FCMPG() { + super(org.apache.bcel.Const.FCMPG, (short) 1); + } + + + /** @return Type.FLOAT + */ + @Override + public Type getType( final 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitFCMPG(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FCMPL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FCMPL.java old mode 100755 new mode 100644 similarity index 56% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FCMPL.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FCMPL.java index 35d93891..19212643 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FCMPL.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FCMPL.java @@ -1,54 +1,56 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * FCMPL - Compare floats: value1 < value2 - *
      Stack: ..., value1, value2 -> ..., result
      - * - * @version $Id: FCMPL.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class FCMPL extends Instruction implements TypedInstruction, StackProducer, StackConsumer { - - public FCMPL() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * FCMPL - Compare floats: value1 < value2 + *
      Stack: ..., value1, value2 -> ..., result
      + * + * @version $Id: FCMPL.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class FCMPL extends Instruction implements TypedInstruction, StackProducer, StackConsumer { + + public FCMPL() { + super(org.apache.bcel.Const.FCMPL, (short) 1); + } + + + /** @return Type.FLOAT + */ + @Override + public Type getType( final 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitFCMPL(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FCONST.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FCONST.java old mode 100755 new mode 100644 similarity index 55% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FCONST.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FCONST.java index e339dcec..d4537dfe --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FCONST.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FCONST.java @@ -1,82 +1,85 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * FCONST - Push 0.0, 1.0 or 2.0, other values cause an exception - * - *
      Stack: ... -> ..., 
      - * - * @version $Id: FCONST.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.Constants.FCONST_0, (short) 1); - if (f == 0.0) { - opcode = org.apache.bcel5_2_0.Constants.FCONST_0; - } else if (f == 1.0) { - opcode = org.apache.bcel5_2_0.Constants.FCONST_1; - } else if (f == 2.0) { - opcode = org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * FCONST - Push 0.0, 1.0 or 2.0, other values cause an exception + * + *
      Stack: ... -> ..., 
      + * + * @version $Id: FCONST.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class FCONST extends Instruction implements ConstantPushInstruction { + + private float value; + + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + FCONST() { + } + + + public FCONST(final float f) { + super(org.apache.bcel.Const.FCONST_0, (short) 1); + if (f == 0.0) { + super.setOpcode(org.apache.bcel.Const.FCONST_0); + } else if (f == 1.0) { + super.setOpcode(org.apache.bcel.Const.FCONST_1); + } else if (f == 2.0) { + super.setOpcode(org.apache.bcel.Const.FCONST_2); + } else { + throw new ClassGenException("FCONST can be used only for 0.0, 1.0 and 2.0: " + f); + } + value = f; + } + + + @Override + public Number getValue() { + return new Float(value); + } + + + /** @return Type.FLOAT + */ + @Override + public Type getType( final 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitPushInstruction(this); + v.visitStackProducer(this); + v.visitTypedInstruction(this); + v.visitConstantPushInstruction(this); + v.visitFCONST(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FDIV.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FDIV.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FDIV.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FDIV.java index d28ef766..db716f92 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FDIV.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FDIV.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * FDIV - Divide floats - *
      Stack: ..., value1, value2 -> result
      - * - * @version $Id: FDIV.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class FDIV extends ArithmeticInstruction { - - /** Divide floats - */ - public FDIV() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * FDIV - Divide floats + *
      Stack: ..., value1, value2 -> result
      + * + * @version $Id: FDIV.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public class FDIV extends ArithmeticInstruction { + + /** Divide floats + */ + public FDIV() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitFDIV(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FLOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FLOAD.java old mode 100755 new mode 100644 similarity index 51% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FLOAD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FLOAD.java index 75099cc0..2f249afb --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FLOAD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FLOAD.java @@ -1,57 +1,58 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * FLOAD - Load float from local variable - *
      Stack ... -> ..., result
      - * - * @version $Id: FLOAD.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.Constants.FLOAD, org.apache.bcel5_2_0.Constants.FLOAD_0); - } - - - /** Load float from local variable - * @param n index of local variable - */ - public FLOAD(int n) { - super(org.apache.bcel5_2_0.Constants.FLOAD, org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * FLOAD - Load float from local variable + *
      Stack ... -> ..., result
      + * + * @version $Id: FLOAD.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class FLOAD extends LoadInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + FLOAD() { + super(org.apache.bcel.Const.FLOAD, org.apache.bcel.Const.FLOAD_0); + } + + + /** Load float from local variable + * @param n index of local variable + */ + public FLOAD(final int n) { + super(org.apache.bcel.Const.FLOAD, org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + super.accept(v); + v.visitFLOAD(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FMUL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FMUL.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FMUL.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FMUL.java index 5c8d382c..526f3091 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FMUL.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FMUL.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * FMUL - Multiply floats - *
      Stack: ..., value1, value2 -> result
      - * - * @version $Id: FMUL.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class FMUL extends ArithmeticInstruction { - - /** Multiply floats - */ - public FMUL() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * FMUL - Multiply floats + *
      Stack: ..., value1, value2 -> result
      + * + * @version $Id: FMUL.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public class FMUL extends ArithmeticInstruction { + + /** Multiply floats + */ + public FMUL() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitFMUL(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FNEG.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FNEG.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FNEG.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FNEG.java index d7f8e012..db1dc36a --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FNEG.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FNEG.java @@ -1,48 +1,49 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * FNEG - Negate float - *
      Stack: ..., value -> ..., result
      - * - * @version $Id: FNEG.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class FNEG extends ArithmeticInstruction { - - public FNEG() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * FNEG - Negate float + *
      Stack: ..., value -> ..., result
      + * + * @version $Id: FNEG.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class FNEG extends ArithmeticInstruction { + + public FNEG() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitFNEG(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FREM.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FREM.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FREM.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FREM.java index 35f57da3..38e0609e --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FREM.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FREM.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * FREM - Remainder of floats - *
      Stack: ..., value1, value2 -> result
      - * - * @version $Id: FREM.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class FREM extends ArithmeticInstruction { - - /** Remainder of floats - */ - public FREM() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * FREM - Remainder of floats + *
      Stack: ..., value1, value2 -> result
      + * + * @version $Id: FREM.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public class FREM extends ArithmeticInstruction { + + /** Remainder of floats + */ + public FREM() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitFREM(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FRETURN.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FRETURN.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FRETURN.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FRETURN.java index e487c498..5fde2263 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FRETURN.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FRETURN.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * FRETURN - Return float from method - *
      Stack: ..., value -> <empty>
      - * - * @version $Id: FRETURN.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class FRETURN extends ReturnInstruction { - - /** Return float from method - */ - public FRETURN() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * FRETURN - Return float from method + *
      Stack: ..., value -> <empty>
      + * + * @version $Id: FRETURN.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class FRETURN extends ReturnInstruction { + + /** Return float from method + */ + public FRETURN() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackConsumer(this); + v.visitReturnInstruction(this); + v.visitFRETURN(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FSTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FSTORE.java old mode 100755 new mode 100644 similarity index 51% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FSTORE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FSTORE.java index e34af929..d5878c6d --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FSTORE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FSTORE.java @@ -1,57 +1,58 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * FSTORE - Store float into local variable - *
      Stack: ..., value -> ... 
      - * - * @version $Id: FSTORE.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.Constants.FSTORE, org.apache.bcel5_2_0.Constants.FSTORE_0); - } - - - /** Store float into local variable - * @param n index of local variable - */ - public FSTORE(int n) { - super(org.apache.bcel5_2_0.Constants.FSTORE, org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * FSTORE - Store float into local variable + *
      Stack: ..., value -> ... 
      + * + * @version $Id: FSTORE.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class FSTORE extends StoreInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + FSTORE() { + super(org.apache.bcel.Const.FSTORE, org.apache.bcel.Const.FSTORE_0); + } + + + /** Store float into local variable + * @param n index of local variable + */ + public FSTORE(final int n) { + super(org.apache.bcel.Const.FSTORE, org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + super.accept(v); + v.visitFSTORE(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FSUB.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FSUB.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FSUB.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FSUB.java index 431f9064..a0de0109 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FSUB.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FSUB.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * FSUB - Substract floats - *
      Stack: ..., value1, value2 -> result
      - * - * @version $Id: FSUB.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class FSUB extends ArithmeticInstruction { - - /** Substract floats - */ - public FSUB() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * FSUB - Substract floats + *
      Stack: ..., value1, value2 -> result
      + * + * @version $Id: FSUB.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public class FSUB extends ArithmeticInstruction { + + /** Substract floats + */ + public FSUB() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitFSUB(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldGen.java new file mode 100644 index 00000000..263abdad --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldGen.java @@ -0,0 +1,381 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.bcel.Const; +import org.apache.bcel.classfile.AnnotationEntry; +import org.apache.bcel.classfile.Annotations; +import org.apache.bcel.classfile.Attribute; +import org.apache.bcel.classfile.Constant; +import org.apache.bcel.classfile.ConstantObject; +import org.apache.bcel.classfile.ConstantPool; +import org.apache.bcel.classfile.ConstantValue; +import org.apache.bcel.classfile.Field; +import org.apache.bcel.classfile.Utility; +import org.apache.bcel.util.BCELComparator; + +/** + * 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: FieldGen.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see Field + */ +public class FieldGen extends FieldGenOrMethodGen { + + private Object value = null; + private static BCELComparator bcelComparator = new BCELComparator() { + + @Override + public boolean equals( final Object o1, final Object o2 ) { + final FieldGen THIS = (FieldGen) o1; + final FieldGen THAT = (FieldGen) o2; + return THIS.getName().equals(THAT.getName()) + && THIS.getSignature().equals(THAT.getSignature()); + } + + + @Override + public int hashCode( final Object o ) { + final FieldGen THIS = (FieldGen) o; + return THIS.getSignature().hashCode() ^ THIS.getName().hashCode(); + } + }; + + + /** + * 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(final int access_flags, final Type type, final String name, final ConstantPoolGen cp) { + super(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(final Field field, final ConstantPoolGen cp) { + this(field.getAccessFlags(), Type.getType(field.getSignature()), field.getName(), cp); + final Attribute[] attrs = field.getAttributes(); + for (final Attribute attr : attrs) { + if (attr instanceof ConstantValue) { + setValue(((ConstantValue) attr).getConstantValueIndex()); + } else if (attr instanceof Annotations) { + final Annotations runtimeAnnotations = (Annotations)attr; + final AnnotationEntry[] annotationEntries = runtimeAnnotations.getAnnotationEntries(); + for (final AnnotationEntry element : annotationEntries) { + addAnnotationEntry(new AnnotationEntryGen(element,cp,false)); + } + } else { + addAttribute(attr); + } + } + } + + + private void setValue( final int index ) { + final ConstantPool cp = super.getConstantPool().getConstantPool(); + final 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( final String str ) { + checkType( ObjectType.getInstance("java.lang.String")); + if (str != null) { + value = str; + } + } + + + public void setInitValue( final long l ) { + checkType(Type.LONG); + if (l != 0L) { + value = Long.valueOf(l); + } + } + + + public void setInitValue( final int i ) { + checkType(Type.INT); + if (i != 0) { + value = Integer.valueOf(i); + } + } + + + public void setInitValue( final short s ) { + checkType(Type.SHORT); + if (s != 0) { + value = Integer.valueOf(s); + } + } + + + public void setInitValue( final char c ) { + checkType(Type.CHAR); + if (c != 0) { + value = Integer.valueOf(c); + } + } + + + public void setInitValue( final byte b ) { + checkType(Type.BYTE); + if (b != 0) { + value = Integer.valueOf(b); + } + } + + + public void setInitValue( final boolean b ) { + checkType(Type.BOOLEAN); + if (b) { + value = Integer.valueOf(1); + } + } + + + public void setInitValue( final float f ) { + checkType(Type.FLOAT); + if (f != 0.0) { + value = new Float(f); + } + } + + + public void setInitValue( final 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( final Type atype ) { + final Type superType = super.getType(); + if (superType == 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 (!superType.equals(atype)) { + throw new ClassGenException("Types are not compatible: " + superType + " vs. " + atype); + } + } + + + /** + * Get field object after having set up all necessary values. + */ + public Field getField() { + final String signature = getSignature(); + final int name_index = super.getConstantPool().addUtf8(super.getName()); + final int signature_index = super.getConstantPool().addUtf8(signature); + if (value != null) { + checkType(super.getType()); + final int index = addConstant(); + addAttribute(new ConstantValue(super.getConstantPool().addUtf8("ConstantValue"), 2, index, + super.getConstantPool().getConstantPool())); // sic + } + addAnnotationsAsAttribute(super.getConstantPool()); + return new Field(super.getAccessFlags(), name_index, signature_index, getAttributes(), + super.getConstantPool().getConstantPool()); // sic + } + + private void addAnnotationsAsAttribute(final ConstantPoolGen cp) { + final Attribute[] attrs = AnnotationEntryGen.getAnnotationAttributes(cp, super.getAnnotationEntries()); + for (final Attribute attr : attrs) { + addAttribute(attr); + } + } + + + private int addConstant() { + switch (super.getType().getType()) { // sic + case Const.T_INT: + case Const.T_CHAR: + case Const.T_BYTE: + case Const.T_BOOLEAN: + case Const.T_SHORT: + return super.getConstantPool().addInteger(((Integer) value).intValue()); + case Const.T_FLOAT: + return super.getConstantPool().addFloat(((Float) value).floatValue()); + case Const.T_DOUBLE: + return super.getConstantPool().addDouble(((Double) value).doubleValue()); + case Const.T_LONG: + return super.getConstantPool().addLong(((Long) value).longValue()); + case Const.T_REFERENCE: + return super.getConstantPool().addString((String) value); + default: + throw new RuntimeException("Oops: Unhandled : " + super.getType().getType()); // sic + } + } + + + @Override + public String getSignature() { + return super.getType().getSignature(); + } + + private List observers; + + + /** Add observer for this object. + */ + public void addObserver( final FieldObserver o ) { + if (observers == null) { + observers = new ArrayList<>(); + } + observers.add(o); + } + + + /** Remove observer for this object. + */ + public void removeObserver( final 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 (final FieldObserver observer : observers ) { + observer.notify(this); + } + } + } + + + public String getInitValue() { + if (value != null) { + return value.toString(); + } + return null; + } + + + /** + * Return string representation close to declaration format, + * `public static final short MAX = 100', e.g.. + * + * @return String representation of field + */ + @Override + public final String toString() { + String name; + String signature; + String access; // Short cuts to constant pool + access = Utility.accessToString(super.getAccessFlags()); + access = access.isEmpty() ? "" : (access + " "); + signature = super.getType().toString(); + name = getName(); + final StringBuilder buf = new StringBuilder(32); // CHECKSTYLE IGNORE MagicNumber + buf.append(access).append(signature).append(" ").append(name); + final String value = getInitValue(); + if (value != null) { + buf.append(" = ").append(value); + } + return buf.toString(); + } + + + /** @return deep copy of this field + */ + public FieldGen copy( final ConstantPoolGen cp ) { + final FieldGen fg = (FieldGen) clone(); + fg.setConstantPool(cp); + return fg; + } + + + /** + * @return Comparison strategy object + */ + public static BCELComparator getComparator() { + return bcelComparator; + } + + + /** + * @param comparator Comparison strategy object + */ + public static void setComparator( final BCELComparator comparator ) { + bcelComparator = comparator; + } + + + /** + * Return value as defined by given BCELComparator strategy. + * By default two FieldGen objects are said to be equal when + * their names and signatures are equal. + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals( final Object obj ) { + return bcelComparator.equals(this, obj); + } + + + /** + * Return value as defined by given BCELComparator strategy. + * By default return the hashcode of the field's name XOR signature. + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return bcelComparator.hashCode(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldGenOrMethodGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldGenOrMethodGen.java new file mode 100644 index 00000000..7e9a0d42 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldGenOrMethodGen.java @@ -0,0 +1,191 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.bcel.Const; +import org.apache.bcel.classfile.AccessFlags; +import org.apache.bcel.classfile.Attribute; + +/** + * Super class for FieldGen and MethodGen objects, since they have + * some methods in common! + * + * @version $Id: FieldGenOrMethodGen.java 1749603 2016-06-21 20:50:19Z ggregory $ + */ +public abstract class FieldGenOrMethodGen extends AccessFlags implements NamedAndTyped, Cloneable { + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected String name; + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected Type type; + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected ConstantPoolGen cp; + + private final List attribute_vec = new ArrayList<>(); + + // @since 6.0 + private final List annotation_vec= new ArrayList<>(); + + + protected FieldGenOrMethodGen() { + } + + + /** + * @since 6.0 + */ + protected FieldGenOrMethodGen(final int access_flags) { // TODO could this be package protected? + super(access_flags); + } + + @Override + public void setType( final Type type ) { // TODO could be package-protected? + if (type.getType() == Const.T_ADDRESS) { + throw new IllegalArgumentException("Type can not be " + type); + } + this.type = type; + } + + + @Override + public Type getType() { + return type; + } + + + /** @return name of method/field. + */ + @Override + public String getName() { + return name; + } + + + @Override + public void setName( final String name ) { // TODO could be package-protected? + this.name = name; + } + + + public ConstantPoolGen getConstantPool() { + return cp; + } + + + public void setConstantPool( final ConstantPoolGen cp ) { // TODO could be package-protected? + 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( final Attribute a ) { + attribute_vec.add(a); + } + + /** + * @since 6.0 + */ + protected void addAnnotationEntry(final AnnotationEntryGen ag) // TODO could this be package protected? + { + annotation_vec.add(ag); + } + + + /** + * Remove an attribute. + */ + public void removeAttribute( final Attribute a ) { + attribute_vec.remove(a); + } + + /** + * @since 6.0 + */ + protected void removeAnnotationEntry(final AnnotationEntryGen ag) // TODO could this be package protected? + { + annotation_vec.remove(ag); + } + + + /** + * Remove all attributes. + */ + public void removeAttributes() { + attribute_vec.clear(); + } + + /** + * @since 6.0 + */ + protected void removeAnnotationEntries() // TODO could this be package protected? + { + annotation_vec.clear(); + } + + + /** + * @return all attributes of this method. + */ + public Attribute[] getAttributes() { + final Attribute[] attributes = new Attribute[attribute_vec.size()]; + attribute_vec.toArray(attributes); + return attributes; + } + + public AnnotationEntryGen[] getAnnotationEntries() { + final AnnotationEntryGen[] annotations = new AnnotationEntryGen[annotation_vec.size()]; + annotation_vec.toArray(annotations); + return annotations; + } + + + /** @return signature of method/field. + */ + public abstract String getSignature(); + + + @Override + public Object clone() { + try { + return super.clone(); + } catch (final CloneNotSupportedException e) { + throw new Error("Clone Not Supported"); // never happens + } + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldInstruction.java new file mode 100644 index 00000000..a61a679f --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldInstruction.java @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.classfile.ConstantPool; + +/** + * Super class for the GET/PUTxxx family of instructions. + * + * @version $Id: FieldInstruction.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public abstract class FieldInstruction extends FieldOrMethod { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + FieldInstruction() { + } + + + /** + * @param index to constant pool + */ + protected FieldInstruction(final short opcode, final int index) { + super(opcode, index); + } + + + /** + * @return mnemonic for instruction with symbolic references resolved + */ + @Override + public String toString( final ConstantPool cp ) { + return org.apache.bcel.Const.getOpcodeName(super.getOpcode()) + " " + + cp.constantToString(super.getIndex(), org.apache.bcel.Const.CONSTANT_Fieldref); + } + + + /** @return size of field (1 or 2) + */ + protected int getFieldSize( final ConstantPoolGen cpg ) { + return Type.size(Type.getTypeSize(getSignature(cpg))); + } + + + /** @return return type of referenced field + */ + @Override + public Type getType( final ConstantPoolGen cpg ) { + return getFieldType(cpg); + } + + + /** @return type of field + */ + public Type getFieldType( final ConstantPoolGen cpg ) { + return Type.getType(getSignature(cpg)); + } + + + /** @return name of referenced field. + */ + public String getFieldName( final ConstantPoolGen cpg ) { + return getName(cpg); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldObserver.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldObserver.java new file mode 100644 index 00000000..c82c3c91 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldObserver.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Imnplement this interface if you're interested in changes to a FieldGen object + * and register yourself with addObserver(). + * + * @version $Id: FieldObserver.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public interface FieldObserver { + + void notify( FieldGen field ); +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldOrMethod.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldOrMethod.java new file mode 100644 index 00000000..0a952b00 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldOrMethod.java @@ -0,0 +1,139 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.Const; +import org.apache.bcel.classfile.ConstantCP; +import org.apache.bcel.classfile.ConstantNameAndType; +import org.apache.bcel.classfile.ConstantPool; +import org.apache.bcel.classfile.ConstantUtf8; + +/** + * Super class for InvokeInstruction and FieldInstruction, since they have + * some methods in common! + * + * @version $Id: FieldOrMethod.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public abstract class FieldOrMethod extends CPInstruction implements LoadClass { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + FieldOrMethod() { + } + + + /** + * @param index to constant pool + */ + protected FieldOrMethod(final short opcode, final int index) { + super(opcode, index); + } + + + /** @return signature of referenced method/field. + */ + public String getSignature( final ConstantPoolGen cpg ) { + final ConstantPool cp = cpg.getConstantPool(); + final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex()); + final ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex()); + return ((ConstantUtf8) cp.getConstant(cnat.getSignatureIndex())).getBytes(); + } + + + /** @return name of referenced method/field. + */ + public String getName( final ConstantPoolGen cpg ) { + final ConstantPool cp = cpg.getConstantPool(); + final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex()); + final ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex()); + return ((ConstantUtf8) cp.getConstant(cnat.getNameIndex())).getBytes(); + } + + + /** + * @return name of the referenced class/interface + * @deprecated If the instruction references an array class, + * this method will return "java.lang.Object". + * For code generated by Java 1.5, this answer is + * sometimes wrong (e.g., if the "clone()" method is + * called on an array). A better idea is to use + * the {@link #getReferenceType(ConstantPoolGen)} method, which correctly distinguishes + * between class types and array types. + * + */ + @Deprecated + public String getClassName( final ConstantPoolGen cpg ) { + final ConstantPool cp = cpg.getConstantPool(); + final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex()); + final String className = cp.getConstantString(cmr.getClassIndex(), Const.CONSTANT_Class); + if (className.startsWith("[")) { + // Turn array classes into java.lang.Object. + return "java.lang.Object"; + } + return className.replace('/', '.'); + } + + + /** @return type of the referenced class/interface + * @deprecated If the instruction references an array class, + * the ObjectType returned will be invalid. Use + * getReferenceType() instead. + */ + @Deprecated + public ObjectType getClassType( final ConstantPoolGen cpg ) { + return ObjectType.getInstance(getClassName(cpg)); + } + + + /** + * Return the reference type representing the class, interface, + * or array class referenced by the instruction. + * @param cpg the ConstantPoolGen used to create the instruction + * @return an ObjectType (if the referenced class type is a class + * or interface), or an ArrayType (if the referenced class + * type is an array class) + */ + public ReferenceType getReferenceType( final ConstantPoolGen cpg ) { + final ConstantPool cp = cpg.getConstantPool(); + final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex()); + String className = cp.getConstantString(cmr.getClassIndex(), Const.CONSTANT_Class); + if (className.startsWith("[")) { + return (ArrayType) Type.getType(className); + } + className = className.replace('/', '.'); + return ObjectType.getInstance(className); + } + + + /** + * Get the ObjectType of the method return or field. + * + * @return type of the referenced class/interface + * @throws ClassGenException when the field is (or method returns) an array, + */ + @Override + public ObjectType getLoadClassType( final ConstantPoolGen cpg ) { + final ReferenceType rt = getReferenceType(cpg); + if(rt instanceof ObjectType) { + return (ObjectType)rt; + } + throw new ClassGenException(rt.getSignature() + " does not represent an ObjectType"); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/GETFIELD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GETFIELD.java old mode 100755 new mode 100644 similarity index 50% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/GETFIELD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GETFIELD.java index 42d9cef1..c6136430 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/GETFIELD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GETFIELD.java @@ -1,81 +1,81 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.ExceptionConstants; - -/** - * GETFIELD - Fetch field from object - *
      Stack: ..., objectref -> ..., value
      - * OR - *
      Stack: ..., objectref -> ..., value.word1, value.word2
      - * - * @version $Id: GETFIELD.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.Const; +import org.apache.bcel.ExceptionConst; + +/** + * GETFIELD - Fetch field from object + *
      Stack: ..., objectref -> ..., value
      + * OR + *
      Stack: ..., objectref -> ..., value.word1, value.word2
      + * + * @version $Id: GETFIELD.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class GETFIELD extends FieldInstruction implements ExceptionThrower, StackConsumer, + StackProducer { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + GETFIELD() { + } + + + public GETFIELD(final int index) { + super(Const.GETFIELD, index); + } + + + @Override + public int produceStack( final ConstantPoolGen cpg ) { + return getFieldSize(cpg); + } + + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, + ExceptionConst.NULL_POINTER_EXCEPTION, + ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR); + } + + + /** + * 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 + */ + @Override + public void accept( final 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/GETSTATIC.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GETSTATIC.java old mode 100755 new mode 100644 similarity index 51% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/GETSTATIC.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GETSTATIC.java index 60e435ce..7323fc04 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/GETSTATIC.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GETSTATIC.java @@ -1,79 +1,79 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.ExceptionConstants; - -/** - * GETSTATIC - Fetch static field from class - *
      Stack: ..., -> ..., value
      - * OR - *
      Stack: ..., -> ..., value.word1, value.word2
      - * - * @version $Id: GETSTATIC.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.Const; +import org.apache.bcel.ExceptionConst; + +/** + * GETSTATIC - Fetch static field from class + *
      Stack: ..., -> ..., value
      + * OR + *
      Stack: ..., -> ..., value.word1, value.word2
      + * + * @version $Id: GETSTATIC.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class GETSTATIC extends FieldInstruction implements PushInstruction, ExceptionThrower { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + GETSTATIC() { + } + + + public GETSTATIC(final int index) { + super(Const.GETSTATIC, index); + } + + + @Override + public int produceStack( final ConstantPoolGen cpg ) { + return getFieldSize(cpg); + } + + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, + ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR); + } + + + /** + * 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 + */ + @Override + public void accept( final 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GOTO.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GOTO.java new file mode 100644 index 00000000..15ded296 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GOTO.java @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * GOTO - Branch always (to relative offset, not absolute address) + * + * @version $Id: GOTO.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class GOTO extends GotoInstruction implements VariableLengthInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + GOTO() { + } + + + public GOTO(final InstructionHandle target) { + super(org.apache.bcel.Const.GOTO, target); + } + + + /** + * Dump instruction as byte code to stream out. + * @param out Output stream + */ + @Override + public void dump( final DataOutputStream out ) throws IOException { + super.setIndex(getTargetOffset()); + final short _opcode = getOpcode(); + if (_opcode == org.apache.bcel.Const.GOTO) { + super.dump(out); + } else { // GOTO_W + super.setIndex(getTargetOffset()); + out.writeByte(_opcode); + out.writeInt(super.getIndex()); + } + } + + + /** + * Called in pass 2 of InstructionList.setPositions() in order to update + * the branch target, that may shift due to variable length instructions. + * + * @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 + */ + @Override + protected int updatePosition( final int offset, final int max_offset ) { + final int i = getTargetOffset(); // Depending on old position value + setPosition(getPosition() + offset); // Position may be shifted by preceding expansions + if (Math.abs(i) >= (Short.MAX_VALUE - max_offset)) { // to large for short (estimate) + super.setOpcode(org.apache.bcel.Const.GOTO_W); + final short old_length = (short) super.getLength(); + super.setLength(5); + return super.getLength() - old_length; + } + 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitVariableLengthInstruction(this); + v.visitUnconditionalBranch(this); + v.visitBranchInstruction(this); + v.visitGotoInstruction(this); + v.visitGOTO(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GOTO_W.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GOTO_W.java new file mode 100644 index 00000000..9955e9d1 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GOTO_W.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.util.ByteSequence; + +/** + * GOTO_W - Branch always (to relative offset, not absolute address) + * + * @version $Id: GOTO_W.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class GOTO_W extends GotoInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + GOTO_W() { + } + + + public GOTO_W(final InstructionHandle target) { + super(org.apache.bcel.Const.GOTO_W, target); + super.setLength(5); + } + + + /** + * Dump instruction as byte code to stream out. + * @param out Output stream + */ + @Override + public void dump( final DataOutputStream out ) throws IOException { + super.setIndex(getTargetOffset()); + out.writeByte(super.getOpcode()); + out.writeInt(super.getIndex()); + } + + + /** + * Read needed data (e.g. index) from file. + */ + @Override + protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException { + super.setIndex(bytes.readInt()); + super.setLength(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 + */ + @Override + public void accept( final Visitor v ) { + v.visitUnconditionalBranch(this); + v.visitBranchInstruction(this); + v.visitGotoInstruction(this); + v.visitGOTO_W(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GotoInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GotoInstruction.java new file mode 100644 index 00000000..1a5afa65 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GotoInstruction.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Super class for GOTO + * + * @version $Id: GotoInstruction.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public abstract class GotoInstruction extends BranchInstruction implements UnconditionalBranch { + + GotoInstruction(final short opcode, final InstructionHandle target) { + super(opcode, target); + } + + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + GotoInstruction() { + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/I2B.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2B.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/I2B.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2B.java index baafe8bb..5a027644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/I2B.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2B.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * I2B - Convert int to byte - *
      Stack: ..., value -> ..., result
      - * - * @version $Id: I2B.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class I2B extends ConversionInstruction { - - /** Convert int to byte - */ - public I2B() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * I2B - Convert int to byte + *
      Stack: ..., value -> ..., result
      + * + * @version $Id: I2B.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class I2B extends ConversionInstruction { + + /** Convert int to byte + */ + public I2B() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitI2B(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/I2C.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2C.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/I2C.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2C.java index 9c22b6b2..df97da64 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/I2C.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2C.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * I2C - Convert int to char - *
      Stack: ..., value -> ..., result
      - * - * @version $Id: I2C.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class I2C extends ConversionInstruction { - - /** Convert int to char - */ - public I2C() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * I2C - Convert int to char + *
      Stack: ..., value -> ..., result
      + * + * @version $Id: I2C.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class I2C extends ConversionInstruction { + + /** Convert int to char + */ + public I2C() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitI2C(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/I2D.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2D.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/I2D.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2D.java index 116f15e6..7d12f659 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/I2D.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2D.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * I2D - Convert int to double - *
      Stack: ..., value -> ..., result.word1, result.word2
      - * - * @version $Id: I2D.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class I2D extends ConversionInstruction { - - /** Convert int to double - */ - public I2D() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * I2D - Convert int to double + *
      Stack: ..., value -> ..., result.word1, result.word2
      + * + * @version $Id: I2D.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public class I2D extends ConversionInstruction { + + /** Convert int to double + */ + public I2D() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitI2D(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/I2F.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2F.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/I2F.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2F.java index 4920cca9..730dbb80 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/I2F.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2F.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * I2F - Convert int to float - *
      Stack: ..., value -> ..., result
      - * - * @version $Id: I2F.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class I2F extends ConversionInstruction { - - /** Convert int to float - */ - public I2F() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * I2F - Convert int to float + *
      Stack: ..., value -> ..., result
      + * + * @version $Id: I2F.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class I2F extends ConversionInstruction { + + /** Convert int to float + */ + public I2F() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitI2F(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/I2L.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2L.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/I2L.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2L.java index 987bb494..70997c13 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/I2L.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2L.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * I2L - Convert int to long - *
      Stack: ..., value -> ..., result.word1, result.word2
      - * - * @version $Id: I2L.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class I2L extends ConversionInstruction { - - /** Convert int to long - */ - public I2L() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * I2L - Convert int to long + *
      Stack: ..., value -> ..., result.word1, result.word2
      + * + * @version $Id: I2L.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public class I2L extends ConversionInstruction { + + /** Convert int to long + */ + public I2L() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitI2L(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/I2S.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2S.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/I2S.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2S.java index d25dc6c2..c2952a17 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/I2S.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2S.java @@ -1,48 +1,49 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * I2S - Convert int to short - *
      Stack: ..., value -> ..., result
      - * - * @version $Id: I2S.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class I2S extends ConversionInstruction { - - public I2S() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * I2S - Convert int to short + *
      Stack: ..., value -> ..., result
      + * + * @version $Id: I2S.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public class I2S extends ConversionInstruction { + + public I2S() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitI2S(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IADD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IADD.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IADD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IADD.java index c1923921..d8d1e07d --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IADD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IADD.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IADD - Add ints - *
      Stack: ..., value1, value2 -> result
      - * - * @version $Id: IADD.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class IADD extends ArithmeticInstruction { - - /** Add ints - */ - public IADD() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IADD - Add ints + *
      Stack: ..., value1, value2 -> result
      + * + * @version $Id: IADD.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class IADD extends ArithmeticInstruction { + + /** Add ints + */ + public IADD() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitIADD(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IALOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IALOAD.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IALOAD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IALOAD.java index 02b9f5f6..ceab7fcd --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IALOAD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IALOAD.java @@ -1,51 +1,52 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IALOAD - Load int from array - *
      Stack: ..., arrayref, index -> ..., value
      - * - * @version $Id: IALOAD.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class IALOAD extends ArrayInstruction implements StackProducer { - - /** - * Load int from array - */ - public IALOAD() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IALOAD - Load int from array + *
      Stack: ..., arrayref, index -> ..., value
      + * + * @version $Id: IALOAD.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class IALOAD extends ArrayInstruction implements StackProducer { + + /** + * Load int from array + */ + public IALOAD() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackProducer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitIALOAD(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IAND.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IAND.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IAND.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IAND.java index 89b0121d..e2f4a2d1 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IAND.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IAND.java @@ -1,48 +1,49 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IAND - Bitwise AND int - *
      Stack: ..., value1, value2 -> ..., result
      - * - * @version $Id: IAND.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class IAND extends ArithmeticInstruction { - - public IAND() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IAND - Bitwise AND int + *
      Stack: ..., value1, value2 -> ..., result
      + * + * @version $Id: IAND.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class IAND extends ArithmeticInstruction { + + public IAND() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitIAND(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IASTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IASTORE.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IASTORE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IASTORE.java index 065e544e..97695196 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IASTORE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IASTORE.java @@ -1,51 +1,52 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IASTORE - Store into int array - *
      Stack: ..., arrayref, index, value -> ...
      - * - * @version $Id: IASTORE.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class IASTORE extends ArrayInstruction implements StackConsumer { - - /** - * Store into int array - */ - public IASTORE() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IASTORE - Store into int array + *
      Stack: ..., arrayref, index, value -> ...
      + * + * @version $Id: IASTORE.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class IASTORE extends ArrayInstruction implements StackConsumer { + + /** + * Store into int array + */ + public IASTORE() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitIASTORE(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ICONST.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ICONST.java old mode 100755 new mode 100644 similarity index 55% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ICONST.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ICONST.java index efe7d25f..cc602854 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ICONST.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ICONST.java @@ -1,78 +1,81 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * ICONST - Push value between -1, ..., 5, other values cause an exception - * - *
      Stack: ... -> ..., 
      - * - * @version $Id: ICONST.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.Constants.ICONST_0, (short) 1); - if ((i >= -1) && (i <= 5)) { - opcode = (short) (org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * ICONST - Push value between -1, ..., 5, other values cause an exception + * + *
      Stack: ... -> ..., 
      + * + * @version $Id: ICONST.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class ICONST extends Instruction implements ConstantPushInstruction { + + private int value; + + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + ICONST() { + } + + + public ICONST(final int i) { + super(org.apache.bcel.Const.ICONST_0, (short) 1); + if ((i >= -1) && (i <= 5)) { + super.setOpcode((short) (org.apache.bcel.Const.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; + } + + + @Override + public Number getValue() { + return Integer.valueOf(value); + } + + + /** @return Type.INT + */ + @Override + public Type getType( final 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitPushInstruction(this); + v.visitStackProducer(this); + v.visitTypedInstruction(this); + v.visitConstantPushInstruction(this); + v.visitICONST(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IDIV.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IDIV.java old mode 100755 new mode 100644 similarity index 58% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IDIV.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IDIV.java index 5182cb1c..8c169e24 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IDIV.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IDIV.java @@ -1,60 +1,64 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IDIV - Divide ints - *
      Stack: ..., value1, value2 -> result
      - * - * @version $Id: IDIV.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class IDIV extends ArithmeticInstruction implements ExceptionThrower { - - /** Divide ints - */ - public IDIV() { - super(org.apache.bcel5_2_0.Constants.IDIV); - } - - - /** @return exceptions this instruction may cause - */ - public Class[] getExceptions() { - return new Class[] { - org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.ExceptionConst; + +/** + * IDIV - Divide ints + *
      Stack: ..., value1, value2 -> result
      + * + * @version $Id: IDIV.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public class IDIV extends ArithmeticInstruction implements ExceptionThrower { + + /** Divide ints + */ + public IDIV() { + super(org.apache.bcel.Const.IDIV); + } + + + /** @return exceptions this instruction may cause + */ + @Override + public Class[] getExceptions() { + return new Class[] { + ExceptionConst.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitIDIV(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IFEQ.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFEQ.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IFEQ.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFEQ.java index eda70a65..e6f1378b --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IFEQ.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFEQ.java @@ -1,64 +1,66 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IFEQ - Branch if int comparison with zero succeeds - * - *
      Stack: ..., value -> ...
      - * - * @version $Id: IFEQ.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IFEQ - Branch if int comparison with zero succeeds + * + *
      Stack: ..., value -> ...
      + * + * @version $Id: IFEQ.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class IFEQ extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + IFEQ() { + } + + + public IFEQ(final InstructionHandle target) { + super(org.apache.bcel.Const.IFEQ, target); + } + + + /** + * @return negation of instruction, e.g. IFEQ.negate() == IFNE + */ + @Override + public IfInstruction negate() { + return new IFNE(super.getTarget()); + } + + + /** + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIFEQ(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IFGE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFGE.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IFGE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFGE.java index ff392234..edd6a6a7 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IFGE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFGE.java @@ -1,64 +1,66 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IFGE - Branch if int comparison with zero succeeds - * - *
      Stack: ..., value -> ...
      - * - * @version $Id: IFGE.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IFGE - Branch if int comparison with zero succeeds + * + *
      Stack: ..., value -> ...
      + * + * @version $Id: IFGE.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class IFGE extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + IFGE() { + } + + + public IFGE(final InstructionHandle target) { + super(org.apache.bcel.Const.IFGE, target); + } + + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IFLT(super.getTarget()); + } + + + /** + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIFGE(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IFGT.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFGT.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IFGT.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFGT.java index 9762316c..0e37a531 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IFGT.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFGT.java @@ -1,64 +1,66 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IFGT - Branch if int comparison with zero succeeds - * - *
      Stack: ..., value -> ...
      - * - * @version $Id: IFGT.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IFGT - Branch if int comparison with zero succeeds + * + *
      Stack: ..., value -> ...
      + * + * @version $Id: IFGT.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class IFGT extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + IFGT() { + } + + + public IFGT(final InstructionHandle target) { + super(org.apache.bcel.Const.IFGT, target); + } + + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IFLE(super.getTarget()); + } + + + /** + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIFGT(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IFLE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFLE.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IFLE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFLE.java index bf97deac..7b696e20 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IFLE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFLE.java @@ -1,64 +1,66 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IFLE - Branch if int comparison with zero succeeds - * - *
      Stack: ..., value -> ...
      - * - * @version $Id: IFLE.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IFLE - Branch if int comparison with zero succeeds + * + *
      Stack: ..., value -> ...
      + * + * @version $Id: IFLE.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class IFLE extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + IFLE() { + } + + + public IFLE(final InstructionHandle target) { + super(org.apache.bcel.Const.IFLE, target); + } + + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IFGT(super.getTarget()); + } + + + /** + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIFLE(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IFLT.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFLT.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IFLT.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFLT.java index a8a98bd3..520b67e1 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IFLT.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFLT.java @@ -1,64 +1,66 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IFLT - Branch if int comparison with zero succeeds - * - *
      Stack: ..., value -> ...
      - * - * @version $Id: IFLT.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IFLT - Branch if int comparison with zero succeeds + * + *
      Stack: ..., value -> ...
      + * + * @version $Id: IFLT.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class IFLT extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + IFLT() { + } + + + public IFLT(final InstructionHandle target) { + super(org.apache.bcel.Const.IFLT, target); + } + + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IFGE(super.getTarget()); + } + + + /** + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIFLT(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IFNE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFNE.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IFNE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFNE.java index 4b480086..7b4d536e --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IFNE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFNE.java @@ -1,64 +1,66 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IFNE - Branch if int comparison with zero succeeds - * - *
      Stack: ..., value -> ...
      - * - * @version $Id: IFNE.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IFNE - Branch if int comparison with zero succeeds + * + *
      Stack: ..., value -> ...
      + * + * @version $Id: IFNE.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class IFNE extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + IFNE() { + } + + + public IFNE(final InstructionHandle target) { + super(org.apache.bcel.Const.IFNE, target); + } + + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IFEQ(super.getTarget()); + } + + + /** + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIFNE(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IFNONNULL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFNONNULL.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IFNONNULL.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFNONNULL.java index 9cc2ba44..25e62b50 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IFNONNULL.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFNONNULL.java @@ -1,64 +1,66 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IFNONNULL - Branch if reference is not null - * - *
      Stack: ..., reference -> ...
      - * - * @version $Id: IFNONNULL.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IFNONNULL - Branch if reference is not null + * + *
      Stack: ..., reference -> ...
      + * + * @version $Id: IFNONNULL.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class IFNONNULL extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + IFNONNULL() { + } + + + public IFNONNULL(final InstructionHandle target) { + super(org.apache.bcel.Const.IFNONNULL, target); + } + + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IFNULL(super.getTarget()); + } + + + /** + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIFNONNULL(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IFNULL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFNULL.java old mode 100755 new mode 100644 similarity index 53% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IFNULL.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFNULL.java index 4e3bd88d..702d469a --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IFNULL.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFNULL.java @@ -1,64 +1,66 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IFNULL - Branch if reference is not null - * - *
      Stack: ..., reference -> ...
      - * - * @version $Id: IFNULL.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IFNULL - Branch if reference is not null + * + *
      Stack: ..., reference -> ...
      + * + * @version $Id: IFNULL.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class IFNULL extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + IFNULL() { + } + + + public IFNULL(final InstructionHandle target) { + super(org.apache.bcel.Const.IFNULL, target); + } + + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IFNONNULL(super.getTarget()); + } + + + /** + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIFNULL(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IF_ACMPEQ.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ACMPEQ.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IF_ACMPEQ.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ACMPEQ.java index 9977b477..ce5a8594 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IF_ACMPEQ.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ACMPEQ.java @@ -1,64 +1,66 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IF_ACMPEQ - Branch if reference comparison succeeds - * - *
      Stack: ..., value1, value2 -> ...
      - * - * @version $Id: IF_ACMPEQ.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IF_ACMPEQ - Branch if reference comparison succeeds + * + *
      Stack: ..., value1, value2 -> ...
      + * + * @version $Id: IF_ACMPEQ.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class IF_ACMPEQ extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + IF_ACMPEQ() { + } + + + public IF_ACMPEQ(final InstructionHandle target) { + super(org.apache.bcel.Const.IF_ACMPEQ, target); + } + + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IF_ACMPNE(super.getTarget()); + } + + + /** + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIF_ACMPEQ(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IF_ACMPNE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ACMPNE.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IF_ACMPNE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ACMPNE.java index 3ec803fb..1ad7c2f5 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IF_ACMPNE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ACMPNE.java @@ -1,64 +1,66 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IF_ACMPNE - Branch if reference comparison doesn't succeed - * - *
      Stack: ..., value1, value2 -> ...
      - * - * @version $Id: IF_ACMPNE.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IF_ACMPNE - Branch if reference comparison doesn't succeed + * + *
      Stack: ..., value1, value2 -> ...
      + * + * @version $Id: IF_ACMPNE.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class IF_ACMPNE extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + IF_ACMPNE() { + } + + + public IF_ACMPNE(final InstructionHandle target) { + super(org.apache.bcel.Const.IF_ACMPNE, target); + } + + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IF_ACMPEQ(super.getTarget()); + } + + + /** + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIF_ACMPNE(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IF_ICMPEQ.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPEQ.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IF_ICMPEQ.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPEQ.java index 73a7d6f9..f1018140 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IF_ICMPEQ.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPEQ.java @@ -1,64 +1,66 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IF_ICMPEQ - Branch if int comparison succeeds - * - *
      Stack: ..., value1, value2 -> ...
      - * - * @version $Id: IF_ICMPEQ.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IF_ICMPEQ - Branch if int comparison succeeds + * + *
      Stack: ..., value1, value2 -> ...
      + * + * @version $Id: IF_ICMPEQ.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class IF_ICMPEQ extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + IF_ICMPEQ() { + } + + + public IF_ICMPEQ(final InstructionHandle target) { + super(org.apache.bcel.Const.IF_ICMPEQ, target); + } + + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IF_ICMPNE(super.getTarget()); + } + + + /** + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIF_ICMPEQ(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IF_ICMPGE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPGE.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IF_ICMPGE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPGE.java index 96034c2e..a31dda68 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IF_ICMPGE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPGE.java @@ -1,64 +1,66 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IF_ICMPGE - Branch if int comparison succeeds - * - *
      Stack: ..., value1, value2 -> ...
      - * - * @version $Id: IF_ICMPGE.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IF_ICMPGE - Branch if int comparison succeeds + * + *
      Stack: ..., value1, value2 -> ...
      + * + * @version $Id: IF_ICMPGE.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class IF_ICMPGE extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + IF_ICMPGE() { + } + + + public IF_ICMPGE(final InstructionHandle target) { + super(org.apache.bcel.Const.IF_ICMPGE, target); + } + + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IF_ICMPLT(super.getTarget()); + } + + + /** + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIF_ICMPGE(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IF_ICMPGT.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPGT.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IF_ICMPGT.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPGT.java index 3ea29a5a..64af7dbc --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IF_ICMPGT.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPGT.java @@ -1,64 +1,66 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IF_ICMPGT - Branch if int comparison succeeds - * - *
      Stack: ..., value1, value2 -> ...
      - * - * @version $Id: IF_ICMPGT.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IF_ICMPGT - Branch if int comparison succeeds + * + *
      Stack: ..., value1, value2 -> ...
      + * + * @version $Id: IF_ICMPGT.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class IF_ICMPGT extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + IF_ICMPGT() { + } + + + public IF_ICMPGT(final InstructionHandle target) { + super(org.apache.bcel.Const.IF_ICMPGT, target); + } + + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IF_ICMPLE(super.getTarget()); + } + + + /** + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIF_ICMPGT(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IF_ICMPLE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPLE.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IF_ICMPLE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPLE.java index 08e803f9..0cd2db5e --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IF_ICMPLE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPLE.java @@ -1,64 +1,66 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IF_ICMPLE - Branch if int comparison succeeds - * - *
      Stack: ..., value1, value2 -> ...
      - * - * @version $Id: IF_ICMPLE.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IF_ICMPLE - Branch if int comparison succeeds + * + *
      Stack: ..., value1, value2 -> ...
      + * + * @version $Id: IF_ICMPLE.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class IF_ICMPLE extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + IF_ICMPLE() { + } + + + public IF_ICMPLE(final InstructionHandle target) { + super(org.apache.bcel.Const.IF_ICMPLE, target); + } + + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IF_ICMPGT(super.getTarget()); + } + + + /** + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIF_ICMPLE(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IF_ICMPLT.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPLT.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IF_ICMPLT.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPLT.java index 14374d95..ce5cec1b --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IF_ICMPLT.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPLT.java @@ -1,64 +1,66 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IF_ICMPLT - Branch if int comparison succeeds - * - *
      Stack: ..., value1, value2 -> ...
      - * - * @version $Id: IF_ICMPLT.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IF_ICMPLT - Branch if int comparison succeeds + * + *
      Stack: ..., value1, value2 -> ...
      + * + * @version $Id: IF_ICMPLT.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class IF_ICMPLT extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + IF_ICMPLT() { + } + + + public IF_ICMPLT(final InstructionHandle target) { + super(org.apache.bcel.Const.IF_ICMPLT, target); + } + + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IF_ICMPGE(super.getTarget()); + } + + + /** + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIF_ICMPLT(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IF_ICMPNE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPNE.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IF_ICMPNE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPNE.java index d8c407f3..e9e139b4 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IF_ICMPNE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPNE.java @@ -1,64 +1,66 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IF_ICMPNE - Branch if int comparison doesn't succeed - * - *
      Stack: ..., value1, value2 -> ...
      - * - * @version $Id: IF_ICMPNE.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IF_ICMPNE - Branch if int comparison doesn't succeed + * + *
      Stack: ..., value1, value2 -> ...
      + * + * @version $Id: IF_ICMPNE.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class IF_ICMPNE extends IfInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + IF_ICMPNE() { + } + + + public IF_ICMPNE(final InstructionHandle target) { + super(org.apache.bcel.Const.IF_ICMPNE, target); + } + + + /** + * @return negation of instruction + */ + @Override + public IfInstruction negate() { + return new IF_ICMPEQ(super.getTarget()); + } + + + /** + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitIfInstruction(this); + v.visitIF_ICMPNE(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IINC.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IINC.java old mode 100755 new mode 100644 similarity index 51% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IINC.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IINC.java index 22669130..bc4411e8 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IINC.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IINC.java @@ -1,159 +1,170 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.util.ByteSequence; - -/** - * IINC - Increment local variable by constant - * - * @version $Id: IINC.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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() { - } - - - /** - * @param n index of local variable - * @param c increment factor - */ - public IINC(int n, int c) { - super(); // Default behaviour of LocalVariableInstruction causes error - this.opcode = org.apache.bcel5_2_0.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) { - out.writeByte(org.apache.bcel5_2_0.Constants.WIDE); - } - out.writeByte(opcode); - if (wide) { - out.writeShort(n); - out.writeShort(c); - } else { - out.writeByte(n); - out.writeByte(c); - } - } - - - private final void setWide() { - wide = (n > org.apache.bcel5_2_0.Constants.MAX_BYTE) || (Math.abs(c) > Byte.MAX_VALUE); - if (wide) { - 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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.util.ByteSequence; + +/** + * IINC - Increment local variable by constant + * + * @version $Id: IINC.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class IINC extends LocalVariableInstruction { + + private boolean wide; + private int c; + + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + IINC() { + } + + + /** + * @param n index of local variable + * @param c increment factor + */ + public IINC(final int n, final int c) { + super(); // Default behaviour of LocalVariableInstruction causes error + super.setOpcode(org.apache.bcel.Const.IINC); + super.setLength((short) 3); + setIndex(n); // May set wide as side effect + setIncrement(c); + } + + + /** + * Dump instruction as byte code to stream out. + * @param out Output stream + */ + @Override + public void dump( final DataOutputStream out ) throws IOException { + if (wide) { + out.writeByte(org.apache.bcel.Const.WIDE); + } + out.writeByte(super.getOpcode()); + if (wide) { + out.writeShort(super.getIndex()); + out.writeShort(c); + } else { + out.writeByte(super.getIndex()); + out.writeByte(c); + } + } + + + private void setWide() { + wide = super.getIndex() > org.apache.bcel.Const.MAX_BYTE; + if (c > 0) { + wide = wide || (c > Byte.MAX_VALUE); + } else { + wide = wide || (c < Byte.MIN_VALUE); + } + if (wide) { + super.setLength(6); // wide byte included + } else { + super.setLength(3); + } + } + + + /** + * Read needed data (e.g. index) from file. + */ + @Override + protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException { + this.wide = wide; + if (wide) { + super.setLength(6); + super.setIndexOnly(bytes.readUnsignedShort()); + c = bytes.readShort(); + } else { + super.setLength(3); + super.setIndexOnly(bytes.readUnsignedByte()); + c = bytes.readByte(); + } + } + + + /** + * @return mnemonic for instruction + */ + @Override + public String toString( final boolean verbose ) { + return super.toString(verbose) + " " + c; + } + + + /** + * Set index of local variable. + */ + @Override + public final void setIndex( final int n ) { + if (n < 0) { + throw new ClassGenException("Negative index value: " + n); + } + super.setIndexOnly(n); + setWide(); + } + + + /** + * @return increment factor + */ + public final int getIncrement() { + return c; + } + + + /** + * Set increment factor. + */ + public final void setIncrement( final int c ) { + this.c = c; + setWide(); + } + + + /** @return int type + */ + @Override + public Type getType( final 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitLocalVariableInstruction(this); + v.visitIINC(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ILOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ILOAD.java old mode 100755 new mode 100644 similarity index 51% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ILOAD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ILOAD.java index 2430ed11..44c3391b --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ILOAD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ILOAD.java @@ -1,57 +1,58 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * ILOAD - Load int from local variable onto stack - *
      Stack: ... -> ..., result
      - * - * @version $Id: ILOAD.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.Constants.ILOAD, org.apache.bcel5_2_0.Constants.ILOAD_0); - } - - - /** Load int from local variable - * @param n index of local variable - */ - public ILOAD(int n) { - super(org.apache.bcel5_2_0.Constants.ILOAD, org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * ILOAD - Load int from local variable onto stack + *
      Stack: ... -> ..., result
      + * + * @version $Id: ILOAD.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class ILOAD extends LoadInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + ILOAD() { + super(org.apache.bcel.Const.ILOAD, org.apache.bcel.Const.ILOAD_0); + } + + + /** Load int from local variable + * @param n index of local variable + */ + public ILOAD(final int n) { + super(org.apache.bcel.Const.ILOAD, org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + super.accept(v); + v.visitILOAD(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IMPDEP1.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IMPDEP1.java old mode 100755 new mode 100644 similarity index 53% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IMPDEP1.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IMPDEP1.java index 88b3a021..05241539 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IMPDEP1.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IMPDEP1.java @@ -1,43 +1,44 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IMPDEP1 - Implementation dependent - * - * @version $Id: IMPDEP1.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class IMPDEP1 extends Instruction { - - public IMPDEP1() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IMPDEP1 - Implementation dependent + * + * @version $Id: IMPDEP1.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public class IMPDEP1 extends Instruction { + + public IMPDEP1() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitIMPDEP1(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IMPDEP2.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IMPDEP2.java old mode 100755 new mode 100644 similarity index 53% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IMPDEP2.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IMPDEP2.java index 16cf3b4c..dbf9402a --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IMPDEP2.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IMPDEP2.java @@ -1,43 +1,44 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IMPDEP2 - Implementation dependent - * - * @version $Id: IMPDEP2.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class IMPDEP2 extends Instruction { - - public IMPDEP2() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IMPDEP2 - Implementation dependent + * + * @version $Id: IMPDEP2.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public class IMPDEP2 extends Instruction { + + public IMPDEP2() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitIMPDEP2(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IMUL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IMUL.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IMUL.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IMUL.java index f9ae5876..29699a61 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IMUL.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IMUL.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IMUL - Multiply ints - *
      Stack: ..., value1, value2 -> result
      - * - * @version $Id: IMUL.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class IMUL extends ArithmeticInstruction { - - /** Multiply ints - */ - public IMUL() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IMUL - Multiply ints + *
      Stack: ..., value1, value2 -> result
      + * + * @version $Id: IMUL.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class IMUL extends ArithmeticInstruction { + + /** Multiply ints + */ + public IMUL() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitIMUL(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/INEG.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INEG.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/INEG.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INEG.java index 5d839665..e2c71717 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/INEG.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INEG.java @@ -1,48 +1,49 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * INEG - Negate int - *
      Stack: ..., value -> ..., result
      - * - * @version $Id: INEG.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class INEG extends ArithmeticInstruction { - - public INEG() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * INEG - Negate int + *
      Stack: ..., value -> ..., result
      + * + * @version $Id: INEG.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class INEG extends ArithmeticInstruction { + + public INEG() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitINEG(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/INSTANCEOF.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INSTANCEOF.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/INSTANCEOF.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INSTANCEOF.java index c1ef93dc..19f42b88 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/INSTANCEOF.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INSTANCEOF.java @@ -1,73 +1,78 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * INSTANCEOF - Determine if object is of given type - *
      Stack: ..., objectref -> ..., result
      - * - * @version $Id: INSTANCEOF.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.Constants.INSTANCEOF, index); - } - - - public Class[] getExceptions() { - return org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.ExceptionConst; + +/** + * INSTANCEOF - Determine if object is of given type + *
      Stack: ..., objectref -> ..., result
      + * + * @version $Id: INSTANCEOF.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class INSTANCEOF extends CPInstruction implements LoadClass, ExceptionThrower, + StackProducer, StackConsumer { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + INSTANCEOF() { + } + + + public INSTANCEOF(final int index) { + super(org.apache.bcel.Const.INSTANCEOF, index); + } + + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_CLASS_AND_INTERFACE_RESOLUTION); + } + + + @Override + public ObjectType getLoadClassType( final 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 + */ + @Override + public void accept( final 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKEDYNAMIC.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKEDYNAMIC.java new file mode 100644 index 00000000..d512574e --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKEDYNAMIC.java @@ -0,0 +1,145 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; +import org.apache.bcel.ExceptionConst; +import org.apache.bcel.classfile.ConstantInvokeDynamic; +import org.apache.bcel.classfile.ConstantNameAndType; +import org.apache.bcel.classfile.ConstantPool; +import org.apache.bcel.util.ByteSequence; + +/** + * Class for INVOKEDYNAMIC. Not an instance of InvokeInstruction, since that class + * expects to be able to get the class of the method. Ignores the bootstrap + * mechanism entirely. + * + * @version $Id: InvokeInstruction.java 1152072 2011-07-29 01:54:05Z dbrosius $ + * @see + * + * The invokedynamic instruction in The Java Virtual Machine Specification + * @since 6.0 + */ +public class INVOKEDYNAMIC extends InvokeInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + INVOKEDYNAMIC() { + } + + + public INVOKEDYNAMIC(final int index) { + super(Const.INVOKEDYNAMIC, index); + } + + + /** + * Dump instruction as byte code to stream out. + * @param out Output stream + */ + @Override + public void dump( final DataOutputStream out ) throws IOException { + out.writeByte(super.getOpcode()); + out.writeShort(super.getIndex()); + out.writeByte(0); + out.writeByte(0); + } + + + /** + * Read needed data (i.e., index) from file. + */ + @Override + protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException { + super.initFromFile(bytes, wide); + super.setLength(5); + bytes.readByte(); // Skip 0 byte + bytes.readByte(); // Skip 0 byte + } + + + /** + * @return mnemonic for instruction with symbolic references resolved + */ + @Override + public String toString( final ConstantPool cp ) { + return super.toString(cp); + } + + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_INTERFACE_METHOD_RESOLUTION, + ExceptionConst.UNSATISFIED_LINK_ERROR, + ExceptionConst.ABSTRACT_METHOD_ERROR, + ExceptionConst.ILLEGAL_ACCESS_ERROR, + ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR); + } + + + /** + * 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 + */ + @Override + public void accept( final 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.visitINVOKEDYNAMIC(this); + } + + /** + * Override the parent method because our classname is held elsewhere. + */ + @Override + public String getClassName( final ConstantPoolGen cpg ) { + final ConstantPool cp = cpg.getConstantPool(); + final ConstantInvokeDynamic cid = (ConstantInvokeDynamic) cp.getConstant(super.getIndex(), Const.CONSTANT_InvokeDynamic); + return ((ConstantNameAndType) cp.getConstant(cid.getNameAndTypeIndex())).getName(cp); + } + + + /** + * Since InvokeDynamic doesn't refer to a reference type, just return java.lang.Object, + * as that is the only type we can say for sure the reference will be. + * + * @param cpg + * the ConstantPoolGen used to create the instruction + * @return an ObjectType for java.lang.Object + * @since 6.1 + */ + @Override + public ReferenceType getReferenceType(final ConstantPoolGen cpg) { + return new ObjectType(Object.class.getName()); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/INVOKEINTERFACE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKEINTERFACE.java old mode 100755 new mode 100644 similarity index 51% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/INVOKEINTERFACE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKEINTERFACE.java index 72d9959c..f2660704 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/INVOKEINTERFACE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKEINTERFACE.java @@ -1,133 +1,139 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.ExceptionConstants; -import org.apache.bcel5_2_0.classfile.ConstantPool; -import org.apache.bcel5_2_0.util.ByteSequence; - -/** - * INVOKEINTERFACE - Invoke interface method - *
      Stack: ..., objectref, [arg1, [arg2 ...]] -> ...
      - * - * @version $Id: INVOKEINTERFACE.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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 count 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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; +import org.apache.bcel.ExceptionConst; +import org.apache.bcel.classfile.ConstantPool; +import org.apache.bcel.util.ByteSequence; + +/** + * INVOKEINTERFACE - Invoke interface method + *
      Stack: ..., objectref, [arg1, [arg2 ...]] -> ...
      + * + * @version $Id: INVOKEINTERFACE.java 1812166 2017-10-13 23:48:11Z ggregory $ + * @see + * + * The invokeinterface instruction in The Java Virtual Machine Specification + */ +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 Instruction.readInstruction. + * Not to be used otherwise. + */ + INVOKEINTERFACE() { + } + + + public INVOKEINTERFACE(final int index, final int nargs) { + super(Const.INVOKEINTERFACE, index); + super.setLength(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 + */ + @Override + public void dump( final DataOutputStream out ) throws IOException { + out.writeByte(super.getOpcode()); + out.writeShort(super.getIndex()); + out.writeByte(nargs); + out.writeByte(0); + } + + + /** + * The count argument according to the Java Language Specification, + * Second Edition. + */ + public int getCount() { + return nargs; + } + + + /** + * Read needed data (i.e., index) from file. + */ + @Override + protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException { + super.initFromFile(bytes, wide); + super.setLength(5); + nargs = bytes.readUnsignedByte(); + bytes.readByte(); // Skip 0 byte + } + + + /** + * @return mnemonic for instruction with symbolic references resolved + */ + @Override + public String toString( final ConstantPool cp ) { + return super.toString(cp) + " " + nargs; + } + + + @Override + public int consumeStack( final ConstantPoolGen cpg ) { // nargs is given in byte-code + return nargs; // nargs includes this reference + } + + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_INTERFACE_METHOD_RESOLUTION, + ExceptionConst.UNSATISFIED_LINK_ERROR, + ExceptionConst.ABSTRACT_METHOD_ERROR, + ExceptionConst.ILLEGAL_ACCESS_ERROR, + ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR); + } + + + /** + * 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 + */ + @Override + public void accept( final 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKESPECIAL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKESPECIAL.java new file mode 100644 index 00000000..9fe379bc --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKESPECIAL.java @@ -0,0 +1,92 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; +import org.apache.bcel.ExceptionConst; + +/** + * INVOKESPECIAL - Invoke instance method; special handling for superclass, private + * and instance initialization method invocations + * + *
      Stack: ..., objectref, [arg1, [arg2 ...]] -> ...
      + * + * @version $Id: INVOKESPECIAL.java 1812166 2017-10-13 23:48:11Z ggregory $ + * @see + * + * The invokespecial instruction in The Java Virtual Machine Specification + */ +public class INVOKESPECIAL extends InvokeInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + INVOKESPECIAL() { + } + + + public INVOKESPECIAL(final int index) { + super(Const.INVOKESPECIAL, index); + } + + + /** + * Dump instruction as byte code to stream out. + * @param out Output stream + */ + @Override + public void dump( final DataOutputStream out ) throws IOException { + out.writeByte(super.getOpcode()); + out.writeShort(super.getIndex()); + } + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, + ExceptionConst.NULL_POINTER_EXCEPTION, + ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR, + ExceptionConst.ABSTRACT_METHOD_ERROR, + ExceptionConst.UNSATISFIED_LINK_ERROR); + } + + + /** + * 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 + */ + @Override + public void accept( final 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKESTATIC.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKESTATIC.java new file mode 100644 index 00000000..bdeb328b --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKESTATIC.java @@ -0,0 +1,89 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; +import org.apache.bcel.ExceptionConst; + +/** + * INVOKESTATIC - Invoke a class (static) method + * + *
      Stack: ..., [arg1, [arg2 ...]] -> ...
      + * + * @version $Id: INVOKESTATIC.java 1812166 2017-10-13 23:48:11Z ggregory $ + * @see + * + * The invokestatic instruction in The Java Virtual Machine Specification + */ +public class INVOKESTATIC extends InvokeInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + INVOKESTATIC() { + } + + + public INVOKESTATIC(final int index) { + super(Const.INVOKESTATIC, index); + } + + + /** + * Dump instruction as byte code to stream out. + * @param out Output stream + */ + @Override + public void dump( final DataOutputStream out ) throws IOException { + out.writeByte(super.getOpcode()); + out.writeShort(super.getIndex()); + } + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, + ExceptionConst.UNSATISFIED_LINK_ERROR, + ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR); + } + + + /** + * 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 + */ + @Override + public void accept( final 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKEVIRTUAL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKEVIRTUAL.java new file mode 100644 index 00000000..f6b0d905 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKEVIRTUAL.java @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; +import org.apache.bcel.ExceptionConst; + +/** + * INVOKEVIRTUAL - Invoke instance method; dispatch based on class + * + *
      Stack: ..., objectref, [arg1, [arg2 ...]] -> ...
      + * + * @version $Id: INVOKEVIRTUAL.java 1812166 2017-10-13 23:48:11Z ggregory $ + * @see + * + * The invokevirtual instruction in The Java Virtual Machine Specification + */ +public class INVOKEVIRTUAL extends InvokeInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + INVOKEVIRTUAL() { + } + + + public INVOKEVIRTUAL(final int index) { + super(Const.INVOKEVIRTUAL, index); + } + + + /** + * Dump instruction as byte code to stream out. + * @param out Output stream + */ + @Override + public void dump( final DataOutputStream out ) throws IOException { + out.writeByte(super.getOpcode()); + out.writeShort(super.getIndex()); + } + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, + ExceptionConst.NULL_POINTER_EXCEPTION, + ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR, + ExceptionConst.ABSTRACT_METHOD_ERROR, + ExceptionConst.UNSATISFIED_LINK_ERROR); + } + + + /** + * 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 + */ + @Override + public void accept( final 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IOR.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IOR.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IOR.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IOR.java index 8ba8dd68..9ec1f823 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IOR.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IOR.java @@ -1,48 +1,49 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IOR - Bitwise OR int - *
      Stack: ..., value1, value2 -> ..., result
      - * - * @version $Id: IOR.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class IOR extends ArithmeticInstruction { - - public IOR() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IOR - Bitwise OR int + *
      Stack: ..., value1, value2 -> ..., result
      + * + * @version $Id: IOR.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class IOR extends ArithmeticInstruction { + + public IOR() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitIOR(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IREM.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IREM.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IREM.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IREM.java index b89cf797..9c71111a --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IREM.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IREM.java @@ -1,60 +1,64 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IREM - Remainder of int - *
      Stack: ..., value1, value2 -> result
      - * - * @version $Id: IREM.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class IREM extends ArithmeticInstruction implements ExceptionThrower { - - /** Remainder of ints - */ - public IREM() { - super(org.apache.bcel5_2_0.Constants.IREM); - } - - - /** @return exceptions this instruction may cause - */ - public Class[] getExceptions() { - return new Class[] { - org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.ExceptionConst; + +/** + * IREM - Remainder of int + *
      Stack: ..., value1, value2 -> result
      + * + * @version $Id: IREM.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public class IREM extends ArithmeticInstruction implements ExceptionThrower { + + /** Remainder of ints + */ + public IREM() { + super(org.apache.bcel.Const.IREM); + } + + + /** @return exceptions this instruction may cause + */ + @Override + public Class[] getExceptions() { + return new Class[] { + ExceptionConst.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitIREM(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IRETURN.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IRETURN.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IRETURN.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IRETURN.java index edba9ad9..8bea094f --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IRETURN.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IRETURN.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IRETURN - Return int from method - *
      Stack: ..., value -> <empty>
      - * - * @version $Id: IRETURN.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class IRETURN extends ReturnInstruction { - - /** Return int from method - */ - public IRETURN() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IRETURN - Return int from method + *
      Stack: ..., value -> <empty>
      + * + * @version $Id: IRETURN.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class IRETURN extends ReturnInstruction { + + /** Return int from method + */ + public IRETURN() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackConsumer(this); + v.visitReturnInstruction(this); + v.visitIRETURN(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ISHL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ISHL.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ISHL.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ISHL.java index 6a4f3804..1060c188 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ISHL.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ISHL.java @@ -1,48 +1,49 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * ISHL - Arithmetic shift left int - *
      Stack: ..., value1, value2 -> ..., result
      - * - * @version $Id: ISHL.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class ISHL extends ArithmeticInstruction { - - public ISHL() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * ISHL - Arithmetic shift left int + *
      Stack: ..., value1, value2 -> ..., result
      + * + * @version $Id: ISHL.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public class ISHL extends ArithmeticInstruction { + + public ISHL() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitISHL(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ISHR.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ISHR.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ISHR.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ISHR.java index 2e479317..00f17eee --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ISHR.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ISHR.java @@ -1,48 +1,49 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * ISHR - Arithmetic shift right int - *
      Stack: ..., value1, value2 -> ..., result
      - * - * @version $Id: ISHR.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class ISHR extends ArithmeticInstruction { - - public ISHR() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * ISHR - Arithmetic shift right int + *
      Stack: ..., value1, value2 -> ..., result
      + * + * @version $Id: ISHR.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public class ISHR extends ArithmeticInstruction { + + public ISHR() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitISHR(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ISTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ISTORE.java old mode 100755 new mode 100644 similarity index 51% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ISTORE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ISTORE.java index f1e345e7..289fc405 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ISTORE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ISTORE.java @@ -1,57 +1,58 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * ISTORE - Store int from stack into local variable - *
      Stack: ..., value -> ... 
      - * - * @version $Id: ISTORE.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.Constants.ISTORE, org.apache.bcel5_2_0.Constants.ISTORE_0); - } - - - /** Store int into local variable - * @param n index of local variable - */ - public ISTORE(int n) { - super(org.apache.bcel5_2_0.Constants.ISTORE, org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * ISTORE - Store int from stack into local variable + *
      Stack: ..., value -> ... 
      + * + * @version $Id: ISTORE.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class ISTORE extends StoreInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + ISTORE() { + super(org.apache.bcel.Const.ISTORE, org.apache.bcel.Const.ISTORE_0); + } + + + /** Store int into local variable + * @param n index of local variable + */ + public ISTORE(final int n) { + super(org.apache.bcel.Const.ISTORE, org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + super.accept(v); + v.visitISTORE(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ISUB.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ISUB.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ISUB.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ISUB.java index 88adf19b..537bc22b --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ISUB.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ISUB.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * ISUB - Substract ints - *
      Stack: ..., value1, value2 -> result
      - * - * @version $Id: ISUB.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class ISUB extends ArithmeticInstruction { - - /** Substract ints - */ - public ISUB() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * ISUB - Substract ints + *
      Stack: ..., value1, value2 -> result
      + * + * @version $Id: ISUB.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class ISUB extends ArithmeticInstruction { + + /** Substract ints + */ + public ISUB() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitISUB(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IUSHR.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IUSHR.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IUSHR.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IUSHR.java index 54409be9..2d134769 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IUSHR.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IUSHR.java @@ -1,48 +1,49 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IUSHR - Logical shift right int - *
      Stack: ..., value1, value2 -> ..., result
      - * - * @version $Id: IUSHR.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class IUSHR extends ArithmeticInstruction { - - public IUSHR() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IUSHR - Logical shift right int + *
      Stack: ..., value1, value2 -> ..., result
      + * + * @version $Id: IUSHR.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class IUSHR extends ArithmeticInstruction { + + public IUSHR() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitIUSHR(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IXOR.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IXOR.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IXOR.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IXOR.java index 9e5491ce..8b83c13b --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IXOR.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IXOR.java @@ -1,48 +1,49 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * IXOR - Bitwise XOR int - *
      Stack: ..., value1, value2 -> ..., result
      - * - * @version $Id: IXOR.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class IXOR extends ArithmeticInstruction { - - public IXOR() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * IXOR - Bitwise XOR int + *
      Stack: ..., value1, value2 -> ..., result
      + * + * @version $Id: IXOR.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class IXOR extends ArithmeticInstruction { + + public IXOR() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitIXOR(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IfInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IfInstruction.java old mode 100755 new mode 100644 similarity index 51% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IfInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IfInstruction.java index acd5317b..bab15627 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IfInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IfInstruction.java @@ -1,48 +1,48 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Super class for the IFxxx family of instructions. - * - * @version $Id: IfInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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 opcode opcode of instruction - * @param target 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(); -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Super class for the IFxxx family of instructions. + * + * @version $Id: IfInstruction.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public abstract class IfInstruction extends BranchInstruction implements StackConsumer { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + IfInstruction() { + } + + + /** + * @param opcode opcode of instruction + * @param target Target instruction to branch to + */ + protected IfInstruction(final short opcode, final InstructionHandle target) { + super(opcode, target); + } + + + /** + * @return negation of instruction, e.g. IFEQ.negate() == IFNE + */ + public abstract IfInstruction negate(); +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IndexedInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IndexedInstruction.java new file mode 100644 index 00000000..2a40694d --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IndexedInstruction.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Denote entity that refers to an index, e.g. local variable instructions, + * RET, CPInstruction, etc. + * + * @version $Id: IndexedInstruction.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public interface IndexedInstruction { + + int getIndex(); + + + void setIndex( int index ); +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Instruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Instruction.java new file mode 100644 index 00000000..2fe0f407 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Instruction.java @@ -0,0 +1,609 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; +import org.apache.bcel.classfile.ConstantPool; +import org.apache.bcel.util.ByteSequence; + +/** + * Abstract super class for all Java byte codes. + * + * @version $Id: Instruction.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public abstract class Instruction implements Cloneable { + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected short length = 1; // Length of instruction in bytes + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected short opcode = -1; // Opcode number + + private static InstructionComparator cmp = InstructionComparator.DEFAULT; + + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + Instruction() { + } + + + public Instruction(final short opcode, final short length) { + this.length = length; + this.opcode = opcode; + } + + + /** + * Dump instruction as byte code to stream out. + * @param out Output stream + */ + public void dump( final DataOutputStream out ) throws IOException { + out.writeByte(opcode); // Common for all instructions + } + + + /** @return name of instruction, i.e., opcode name + */ + public String getName() { + return Const.getOpcodeName(opcode); + } + + + /** + * Long output format: + * + * <name of opcode> "["<opcode number>"]" + * "("<length of instruction>")" + * + * @param verbose long/short format switch + * @return mnemonic for instruction + */ + public String toString( final boolean verbose ) { + if (verbose) { + return getName() + "[" + opcode + "](" + length + ")"; + } + return getName(); + } + + + /** + * @return mnemonic for instruction in verbose format + */ + @Override + public String toString() { + return toString(true); + } + + + /** + * @return mnemonic for instruction with sumbolic references resolved + */ + public String toString( final 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 (InstructionConst.getInstruction(this.getOpcode()) != null) { + i = this; + } else { + try { + i = (Instruction) clone(); + } catch (final 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 + * @throws IOException may be thrown if the implementation needs to read data from the file + */ + protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException { + } + + + /** + * Read an instruction from (byte code) input stream and return the + * appropiate object. + *

      + * If the Instruction is defined in {@link InstructionConst}, then the + * singleton instance is returned. + * @param bytes input stream bytes + * @return instruction object being read + * @see InstructionConst#getInstruction(int) + */ + // @since 6.0 no longer final + public static Instruction readInstruction( final ByteSequence bytes ) throws IOException { + boolean wide = false; + short opcode = (short) bytes.readUnsignedByte(); + Instruction obj = null; + if (opcode == Const.WIDE) { // Read next opcode after wide byte + wide = true; + opcode = (short) bytes.readUnsignedByte(); + } + final Instruction instruction = InstructionConst.getInstruction(opcode); + if (instruction != null) { + return instruction; // Used predefined immutable object, if available + } + + switch (opcode) { + case Const.BIPUSH: + obj = new BIPUSH(); + break; + case Const.SIPUSH: + obj = new SIPUSH(); + break; + case Const.LDC: + obj = new LDC(); + break; + case Const.LDC_W: + obj = new LDC_W(); + break; + case Const.LDC2_W: + obj = new LDC2_W(); + break; + case Const.ILOAD: + obj = new ILOAD(); + break; + case Const.LLOAD: + obj = new LLOAD(); + break; + case Const.FLOAD: + obj = new FLOAD(); + break; + case Const.DLOAD: + obj = new DLOAD(); + break; + case Const.ALOAD: + obj = new ALOAD(); + break; + case Const.ILOAD_0: + obj = new ILOAD(0); + break; + case Const.ILOAD_1: + obj = new ILOAD(1); + break; + case Const.ILOAD_2: + obj = new ILOAD(2); + break; + case Const.ILOAD_3: + obj = new ILOAD(3); + break; + case Const.LLOAD_0: + obj = new LLOAD(0); + break; + case Const.LLOAD_1: + obj = new LLOAD(1); + break; + case Const.LLOAD_2: + obj = new LLOAD(2); + break; + case Const.LLOAD_3: + obj = new LLOAD(3); + break; + case Const.FLOAD_0: + obj = new FLOAD(0); + break; + case Const.FLOAD_1: + obj = new FLOAD(1); + break; + case Const.FLOAD_2: + obj = new FLOAD(2); + break; + case Const.FLOAD_3: + obj = new FLOAD(3); + break; + case Const.DLOAD_0: + obj = new DLOAD(0); + break; + case Const.DLOAD_1: + obj = new DLOAD(1); + break; + case Const.DLOAD_2: + obj = new DLOAD(2); + break; + case Const.DLOAD_3: + obj = new DLOAD(3); + break; + case Const.ALOAD_0: + obj = new ALOAD(0); + break; + case Const.ALOAD_1: + obj = new ALOAD(1); + break; + case Const.ALOAD_2: + obj = new ALOAD(2); + break; + case Const.ALOAD_3: + obj = new ALOAD(3); + break; + case Const.ISTORE: + obj = new ISTORE(); + break; + case Const.LSTORE: + obj = new LSTORE(); + break; + case Const.FSTORE: + obj = new FSTORE(); + break; + case Const.DSTORE: + obj = new DSTORE(); + break; + case Const.ASTORE: + obj = new ASTORE(); + break; + case Const.ISTORE_0: + obj = new ISTORE(0); + break; + case Const.ISTORE_1: + obj = new ISTORE(1); + break; + case Const.ISTORE_2: + obj = new ISTORE(2); + break; + case Const.ISTORE_3: + obj = new ISTORE(3); + break; + case Const.LSTORE_0: + obj = new LSTORE(0); + break; + case Const.LSTORE_1: + obj = new LSTORE(1); + break; + case Const.LSTORE_2: + obj = new LSTORE(2); + break; + case Const.LSTORE_3: + obj = new LSTORE(3); + break; + case Const.FSTORE_0: + obj = new FSTORE(0); + break; + case Const.FSTORE_1: + obj = new FSTORE(1); + break; + case Const.FSTORE_2: + obj = new FSTORE(2); + break; + case Const.FSTORE_3: + obj = new FSTORE(3); + break; + case Const.DSTORE_0: + obj = new DSTORE(0); + break; + case Const.DSTORE_1: + obj = new DSTORE(1); + break; + case Const.DSTORE_2: + obj = new DSTORE(2); + break; + case Const.DSTORE_3: + obj = new DSTORE(3); + break; + case Const.ASTORE_0: + obj = new ASTORE(0); + break; + case Const.ASTORE_1: + obj = new ASTORE(1); + break; + case Const.ASTORE_2: + obj = new ASTORE(2); + break; + case Const.ASTORE_3: + obj = new ASTORE(3); + break; + case Const.IINC: + obj = new IINC(); + break; + case Const.IFEQ: + obj = new IFEQ(); + break; + case Const.IFNE: + obj = new IFNE(); + break; + case Const.IFLT: + obj = new IFLT(); + break; + case Const.IFGE: + obj = new IFGE(); + break; + case Const.IFGT: + obj = new IFGT(); + break; + case Const.IFLE: + obj = new IFLE(); + break; + case Const.IF_ICMPEQ: + obj = new IF_ICMPEQ(); + break; + case Const.IF_ICMPNE: + obj = new IF_ICMPNE(); + break; + case Const.IF_ICMPLT: + obj = new IF_ICMPLT(); + break; + case Const.IF_ICMPGE: + obj = new IF_ICMPGE(); + break; + case Const.IF_ICMPGT: + obj = new IF_ICMPGT(); + break; + case Const.IF_ICMPLE: + obj = new IF_ICMPLE(); + break; + case Const.IF_ACMPEQ: + obj = new IF_ACMPEQ(); + break; + case Const.IF_ACMPNE: + obj = new IF_ACMPNE(); + break; + case Const.GOTO: + obj = new GOTO(); + break; + case Const.JSR: + obj = new JSR(); + break; + case Const.RET: + obj = new RET(); + break; + case Const.TABLESWITCH: + obj = new TABLESWITCH(); + break; + case Const.LOOKUPSWITCH: + obj = new LOOKUPSWITCH(); + break; + case Const.GETSTATIC: + obj = new GETSTATIC(); + break; + case Const.PUTSTATIC: + obj = new PUTSTATIC(); + break; + case Const.GETFIELD: + obj = new GETFIELD(); + break; + case Const.PUTFIELD: + obj = new PUTFIELD(); + break; + case Const.INVOKEVIRTUAL: + obj = new INVOKEVIRTUAL(); + break; + case Const.INVOKESPECIAL: + obj = new INVOKESPECIAL(); + break; + case Const.INVOKESTATIC: + obj = new INVOKESTATIC(); + break; + case Const.INVOKEINTERFACE: + obj = new INVOKEINTERFACE(); + break; + case Const.INVOKEDYNAMIC: + obj = new INVOKEDYNAMIC(); + break; + case Const.NEW: + obj = new NEW(); + break; + case Const.NEWARRAY: + obj = new NEWARRAY(); + break; + case Const.ANEWARRAY: + obj = new ANEWARRAY(); + break; + case Const.CHECKCAST: + obj = new CHECKCAST(); + break; + case Const.INSTANCEOF: + obj = new INSTANCEOF(); + break; + case Const.MULTIANEWARRAY: + obj = new MULTIANEWARRAY(); + break; + case Const.IFNULL: + obj = new IFNULL(); + break; + case Const.IFNONNULL: + obj = new IFNONNULL(); + break; + case Const.GOTO_W: + obj = new GOTO_W(); + break; + case Const.JSR_W: + obj = new JSR_W(); + break; + case Const.BREAKPOINT: + obj = new BREAKPOINT(); + break; + case Const.IMPDEP1: + obj = new IMPDEP1(); + break; + case Const.IMPDEP2: + obj = new IMPDEP2(); + break; + default: + throw new ClassGenException("Illegal opcode detected: " + opcode); + + } + + if (wide + && !((obj instanceof LocalVariableInstruction) || (obj instanceof IINC) || (obj instanceof RET))) { + throw new ClassGenException("Illegal opcode after wide: " + opcode); + } + obj.setOpcode(opcode); + obj.initFromFile(bytes, wide); // Do further initializations, if any + return obj; + } + + /** + * 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( final ConstantPoolGen cpg ) { + return Const.getConsumeStack(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( final ConstantPoolGen cpg ) { + return Const.getProduceStack(opcode); + } + + + /** + * @return this instructions opcode + */ + public short getOpcode() { + return opcode; + } + + + /** + * @return length (in bytes) of instruction + */ + public int getLength() { + return length; + } + + + /** + * Needed in readInstruction and subclasses in this package + */ + final void setOpcode( final short opcode ) { + this.opcode = opcode; + } + + + /** + * Needed in readInstruction and subclasses in this package + * @since 6.0 + */ + final void setLength( final int length ) { + this.length = (short) length; // TODO check range? + } + + + /** 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 ); + + + /** Get Comparator object used in the equals() method to determine + * equality of instructions. + * + * @return currently used comparator for equals() + * @deprecated (6.0) use the built in comparator, or wrap this class in another object that implements these methods + */ + @Deprecated + public static InstructionComparator getComparator() { + return cmp; + } + + + /** Set comparator to be used for equals(). + * @deprecated (6.0) use the built in comparator, or wrap this class in another object that implements these methods + */ + @Deprecated + public static void setComparator( final InstructionComparator c ) { + cmp = c; + } + + + /** Check for equality, delegated to comparator + * @return true if that is an Instruction and has the same opcode + */ + @Override + public boolean equals( final Object that ) { + return (that instanceof Instruction) ? cmp.equals(this, (Instruction) that) : false; + } + + /** calculate the hashCode of this object + * @return the hashCode + * @since 6.0 + */ + @Override + public int hashCode() { + return opcode; + } + + /** + * Check if the value can fit in a byte (signed) + * @param value the value to check + * @return true if the value is in range + * @since 6.0 + */ + public static boolean isValidByte(final int value) { + return value >= Byte.MIN_VALUE && value <= Byte.MAX_VALUE; + } + + /** + * Check if the value can fit in a short (signed) + * @param value the value to check + * @return true if the value is in range + * @since 6.0 + */ + public static boolean isValidShort(final int value) { + return value >= Short.MIN_VALUE && value <= Short.MAX_VALUE; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InstructionComparator.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionComparator.java old mode 100755 new mode 100644 similarity index 53% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InstructionComparator.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionComparator.java index 886eb3e1..65efe70e --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InstructionComparator.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionComparator.java @@ -1,69 +1,62 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Equality of instructions isn't clearly to be defined. You might - * wish, for example, to compare whether instructions have the same - * meaning. E.g., whether two INVOKEVIRTUALs describe the same - * call.
      The DEFAULT comparator however, considers two instructions - * to be equal if they have same opcode and point to the same indexes - * (if any) in the constant pool or the same local variable index. Branch - * instructions must have the same target. - * - * @see Instruction - * @version $Id: InstructionComparator.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public interface InstructionComparator { - - public static final InstructionComparator DEFAULT = new InstructionComparator() { - - public boolean equals( Instruction i1, Instruction i2 ) { - if (i1.opcode == i2.opcode) { - if (i1 instanceof Select) { - InstructionHandle[] t1 = ((Select) i1).getTargets(); - InstructionHandle[] t2 = ((Select) i2).getTargets(); - if (t1.length == t2.length) { - for (int i = 0; i < t1.length; i++) { - if (t1[i] != t2[i]) { - return false; - } - } - return true; - } - } else if (i1 instanceof BranchInstruction) { - return ((BranchInstruction) i1).target == ((BranchInstruction) i2).target; - } else if (i1 instanceof ConstantPushInstruction) { - return ((ConstantPushInstruction) i1).getValue().equals( - ((ConstantPushInstruction) i2).getValue()); - } else if (i1 instanceof IndexedInstruction) { - return ((IndexedInstruction) i1).getIndex() == ((IndexedInstruction) i2) - .getIndex(); - } else if (i1 instanceof NEWARRAY) { - return ((NEWARRAY) i1).getTypecode() == ((NEWARRAY) i2).getTypecode(); - } else { - return true; - } - } - return false; - } - }; - - - public boolean equals( Instruction i1, Instruction i2 ); -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Equality of instructions isn't clearly to be defined. You might + * wish, for example, to compare whether instructions have the same + * meaning. E.g., whether two INVOKEVIRTUALs describe the same + * call.
      The DEFAULT comparator however, considers two instructions + * to be equal if they have same opcode and point to the same indexes + * (if any) in the constant pool or the same local variable index. Branch + * instructions must have the same target. + * + * @see Instruction + * @version $Id: InstructionComparator.java 1749597 2016-06-21 20:28:51Z ggregory $ + */ +public interface InstructionComparator { + + InstructionComparator DEFAULT = new InstructionComparator() { + + @Override + public boolean equals( final Instruction i1, final Instruction i2 ) { + if (i1.getOpcode() == i2.getOpcode()) { + if (i1 instanceof BranchInstruction) { + // BIs are never equal to make targeters work correctly (BCEL-195) + return false; +// } else if (i1 == i2) { TODO consider adding this shortcut +// return true; // this must be AFTER the BI test + } else if (i1 instanceof ConstantPushInstruction) { + return ((ConstantPushInstruction) i1).getValue().equals( + ((ConstantPushInstruction) i2).getValue()); + } else if (i1 instanceof IndexedInstruction) { + return ((IndexedInstruction) i1).getIndex() == ((IndexedInstruction) i2) + .getIndex(); + } else if (i1 instanceof NEWARRAY) { + return ((NEWARRAY) i1).getTypecode() == ((NEWARRAY) i2).getTypecode(); + } else { + return true; + } + } + return false; + } + }; + + + boolean equals( Instruction i1, Instruction i2 ); +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InstructionConstants.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionConst.java old mode 100755 new mode 100644 similarity index 58% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InstructionConstants.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionConst.java index a33534f8..df198194 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InstructionConstants.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionConst.java @@ -1,286 +1,297 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.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: InstructionConstants.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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; - } - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.Const; + +/** + * 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: InstructionConstants.java 1695415 2015-08-12 01:02:39Z chas $ + */ +public final class InstructionConst { + + /** + * Predefined instruction objects + */ + /* + * NOTE these are not currently immutable, because Instruction + * has mutable protected fields opcode and length. + */ + 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. + */ + private static final Instruction[] INSTRUCTIONS = new Instruction[256]; + + static { + INSTRUCTIONS[Const.NOP] = NOP; + INSTRUCTIONS[Const.ACONST_NULL] = ACONST_NULL; + INSTRUCTIONS[Const.ICONST_M1] = ICONST_M1; + INSTRUCTIONS[Const.ICONST_0] = ICONST_0; + INSTRUCTIONS[Const.ICONST_1] = ICONST_1; + INSTRUCTIONS[Const.ICONST_2] = ICONST_2; + INSTRUCTIONS[Const.ICONST_3] = ICONST_3; + INSTRUCTIONS[Const.ICONST_4] = ICONST_4; + INSTRUCTIONS[Const.ICONST_5] = ICONST_5; + INSTRUCTIONS[Const.LCONST_0] = LCONST_0; + INSTRUCTIONS[Const.LCONST_1] = LCONST_1; + INSTRUCTIONS[Const.FCONST_0] = FCONST_0; + INSTRUCTIONS[Const.FCONST_1] = FCONST_1; + INSTRUCTIONS[Const.FCONST_2] = FCONST_2; + INSTRUCTIONS[Const.DCONST_0] = DCONST_0; + INSTRUCTIONS[Const.DCONST_1] = DCONST_1; + INSTRUCTIONS[Const.IALOAD] = IALOAD; + INSTRUCTIONS[Const.LALOAD] = LALOAD; + INSTRUCTIONS[Const.FALOAD] = FALOAD; + INSTRUCTIONS[Const.DALOAD] = DALOAD; + INSTRUCTIONS[Const.AALOAD] = AALOAD; + INSTRUCTIONS[Const.BALOAD] = BALOAD; + INSTRUCTIONS[Const.CALOAD] = CALOAD; + INSTRUCTIONS[Const.SALOAD] = SALOAD; + INSTRUCTIONS[Const.IASTORE] = IASTORE; + INSTRUCTIONS[Const.LASTORE] = LASTORE; + INSTRUCTIONS[Const.FASTORE] = FASTORE; + INSTRUCTIONS[Const.DASTORE] = DASTORE; + INSTRUCTIONS[Const.AASTORE] = AASTORE; + INSTRUCTIONS[Const.BASTORE] = BASTORE; + INSTRUCTIONS[Const.CASTORE] = CASTORE; + INSTRUCTIONS[Const.SASTORE] = SASTORE; + INSTRUCTIONS[Const.POP] = POP; + INSTRUCTIONS[Const.POP2] = POP2; + INSTRUCTIONS[Const.DUP] = DUP; + INSTRUCTIONS[Const.DUP_X1] = DUP_X1; + INSTRUCTIONS[Const.DUP_X2] = DUP_X2; + INSTRUCTIONS[Const.DUP2] = DUP2; + INSTRUCTIONS[Const.DUP2_X1] = DUP2_X1; + INSTRUCTIONS[Const.DUP2_X2] = DUP2_X2; + INSTRUCTIONS[Const.SWAP] = SWAP; + INSTRUCTIONS[Const.IADD] = IADD; + INSTRUCTIONS[Const.LADD] = LADD; + INSTRUCTIONS[Const.FADD] = FADD; + INSTRUCTIONS[Const.DADD] = DADD; + INSTRUCTIONS[Const.ISUB] = ISUB; + INSTRUCTIONS[Const.LSUB] = LSUB; + INSTRUCTIONS[Const.FSUB] = FSUB; + INSTRUCTIONS[Const.DSUB] = DSUB; + INSTRUCTIONS[Const.IMUL] = IMUL; + INSTRUCTIONS[Const.LMUL] = LMUL; + INSTRUCTIONS[Const.FMUL] = FMUL; + INSTRUCTIONS[Const.DMUL] = DMUL; + INSTRUCTIONS[Const.IDIV] = IDIV; + INSTRUCTIONS[Const.LDIV] = LDIV; + INSTRUCTIONS[Const.FDIV] = FDIV; + INSTRUCTIONS[Const.DDIV] = DDIV; + INSTRUCTIONS[Const.IREM] = IREM; + INSTRUCTIONS[Const.LREM] = LREM; + INSTRUCTIONS[Const.FREM] = FREM; + INSTRUCTIONS[Const.DREM] = DREM; + INSTRUCTIONS[Const.INEG] = INEG; + INSTRUCTIONS[Const.LNEG] = LNEG; + INSTRUCTIONS[Const.FNEG] = FNEG; + INSTRUCTIONS[Const.DNEG] = DNEG; + INSTRUCTIONS[Const.ISHL] = ISHL; + INSTRUCTIONS[Const.LSHL] = LSHL; + INSTRUCTIONS[Const.ISHR] = ISHR; + INSTRUCTIONS[Const.LSHR] = LSHR; + INSTRUCTIONS[Const.IUSHR] = IUSHR; + INSTRUCTIONS[Const.LUSHR] = LUSHR; + INSTRUCTIONS[Const.IAND] = IAND; + INSTRUCTIONS[Const.LAND] = LAND; + INSTRUCTIONS[Const.IOR] = IOR; + INSTRUCTIONS[Const.LOR] = LOR; + INSTRUCTIONS[Const.IXOR] = IXOR; + INSTRUCTIONS[Const.LXOR] = LXOR; + INSTRUCTIONS[Const.I2L] = I2L; + INSTRUCTIONS[Const.I2F] = I2F; + INSTRUCTIONS[Const.I2D] = I2D; + INSTRUCTIONS[Const.L2I] = L2I; + INSTRUCTIONS[Const.L2F] = L2F; + INSTRUCTIONS[Const.L2D] = L2D; + INSTRUCTIONS[Const.F2I] = F2I; + INSTRUCTIONS[Const.F2L] = F2L; + INSTRUCTIONS[Const.F2D] = F2D; + INSTRUCTIONS[Const.D2I] = D2I; + INSTRUCTIONS[Const.D2L] = D2L; + INSTRUCTIONS[Const.D2F] = D2F; + INSTRUCTIONS[Const.I2B] = I2B; + INSTRUCTIONS[Const.I2C] = I2C; + INSTRUCTIONS[Const.I2S] = I2S; + INSTRUCTIONS[Const.LCMP] = LCMP; + INSTRUCTIONS[Const.FCMPL] = FCMPL; + INSTRUCTIONS[Const.FCMPG] = FCMPG; + INSTRUCTIONS[Const.DCMPL] = DCMPL; + INSTRUCTIONS[Const.DCMPG] = DCMPG; + INSTRUCTIONS[Const.IRETURN] = IRETURN; + INSTRUCTIONS[Const.LRETURN] = LRETURN; + INSTRUCTIONS[Const.FRETURN] = FRETURN; + INSTRUCTIONS[Const.DRETURN] = DRETURN; + INSTRUCTIONS[Const.ARETURN] = ARETURN; + INSTRUCTIONS[Const.RETURN] = RETURN; + INSTRUCTIONS[Const.ARRAYLENGTH] = ARRAYLENGTH; + INSTRUCTIONS[Const.ATHROW] = ATHROW; + INSTRUCTIONS[Const.MONITORENTER] = MONITORENTER; + INSTRUCTIONS[Const.MONITOREXIT] = MONITOREXIT; + } + + private InstructionConst() { } // non-instantiable + + /** + * Gets the Instruction. + * @param index the index, e.g. {@link Const#RETURN} + * @return the entry from the private INSTRUCTIONS table + */ + public static Instruction getInstruction(final int index) { + return INSTRUCTIONS[index]; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionConstants.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionConstants.java new file mode 100644 index 00000000..2fb0521f --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionConstants.java @@ -0,0 +1,292 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.Const; + +/** + * 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: InstructionConstants.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @deprecated (since 6.0) Do not use. Use InstructionConst instead. + */ +@Deprecated +public interface InstructionConstants { + + /** Predefined instruction objects + */ + /* + * NOTE these are not currently immutable, because Instruction + * has mutable protected fields opcode and length. + */ + Instruction NOP = new NOP(); + Instruction ACONST_NULL = new ACONST_NULL(); + Instruction ICONST_M1 = new ICONST(-1); + Instruction ICONST_0 = new ICONST(0); + Instruction ICONST_1 = new ICONST(1); + Instruction ICONST_2 = new ICONST(2); + Instruction ICONST_3 = new ICONST(3); + Instruction ICONST_4 = new ICONST(4); + Instruction ICONST_5 = new ICONST(5); + Instruction LCONST_0 = new LCONST(0); + Instruction LCONST_1 = new LCONST(1); + Instruction FCONST_0 = new FCONST(0); + Instruction FCONST_1 = new FCONST(1); + Instruction FCONST_2 = new FCONST(2); + Instruction DCONST_0 = new DCONST(0); + Instruction DCONST_1 = new DCONST(1); + ArrayInstruction IALOAD = new IALOAD(); + ArrayInstruction LALOAD = new LALOAD(); + ArrayInstruction FALOAD = new FALOAD(); + ArrayInstruction DALOAD = new DALOAD(); + ArrayInstruction AALOAD = new AALOAD(); + ArrayInstruction BALOAD = new BALOAD(); + ArrayInstruction CALOAD = new CALOAD(); + ArrayInstruction SALOAD = new SALOAD(); + ArrayInstruction IASTORE = new IASTORE(); + ArrayInstruction LASTORE = new LASTORE(); + ArrayInstruction FASTORE = new FASTORE(); + ArrayInstruction DASTORE = new DASTORE(); + ArrayInstruction AASTORE = new AASTORE(); + ArrayInstruction BASTORE = new BASTORE(); + ArrayInstruction CASTORE = new CASTORE(); + ArrayInstruction SASTORE = new SASTORE(); + StackInstruction POP = new POP(); + StackInstruction POP2 = new POP2(); + StackInstruction DUP = new DUP(); + StackInstruction DUP_X1 = new DUP_X1(); + StackInstruction DUP_X2 = new DUP_X2(); + StackInstruction DUP2 = new DUP2(); + StackInstruction DUP2_X1 = new DUP2_X1(); + StackInstruction DUP2_X2 = new DUP2_X2(); + StackInstruction SWAP = new SWAP(); + ArithmeticInstruction IADD = new IADD(); + ArithmeticInstruction LADD = new LADD(); + ArithmeticInstruction FADD = new FADD(); + ArithmeticInstruction DADD = new DADD(); + ArithmeticInstruction ISUB = new ISUB(); + ArithmeticInstruction LSUB = new LSUB(); + ArithmeticInstruction FSUB = new FSUB(); + ArithmeticInstruction DSUB = new DSUB(); + ArithmeticInstruction IMUL = new IMUL(); + ArithmeticInstruction LMUL = new LMUL(); + ArithmeticInstruction FMUL = new FMUL(); + ArithmeticInstruction DMUL = new DMUL(); + ArithmeticInstruction IDIV = new IDIV(); + ArithmeticInstruction LDIV = new LDIV(); + ArithmeticInstruction FDIV = new FDIV(); + ArithmeticInstruction DDIV = new DDIV(); + ArithmeticInstruction IREM = new IREM(); + ArithmeticInstruction LREM = new LREM(); + ArithmeticInstruction FREM = new FREM(); + ArithmeticInstruction DREM = new DREM(); + ArithmeticInstruction INEG = new INEG(); + ArithmeticInstruction LNEG = new LNEG(); + ArithmeticInstruction FNEG = new FNEG(); + ArithmeticInstruction DNEG = new DNEG(); + ArithmeticInstruction ISHL = new ISHL(); + ArithmeticInstruction LSHL = new LSHL(); + ArithmeticInstruction ISHR = new ISHR(); + ArithmeticInstruction LSHR = new LSHR(); + ArithmeticInstruction IUSHR = new IUSHR(); + ArithmeticInstruction LUSHR = new LUSHR(); + ArithmeticInstruction IAND = new IAND(); + ArithmeticInstruction LAND = new LAND(); + ArithmeticInstruction IOR = new IOR(); + ArithmeticInstruction LOR = new LOR(); + ArithmeticInstruction IXOR = new IXOR(); + ArithmeticInstruction LXOR = new LXOR(); + ConversionInstruction I2L = new I2L(); + ConversionInstruction I2F = new I2F(); + ConversionInstruction I2D = new I2D(); + ConversionInstruction L2I = new L2I(); + ConversionInstruction L2F = new L2F(); + ConversionInstruction L2D = new L2D(); + ConversionInstruction F2I = new F2I(); + ConversionInstruction F2L = new F2L(); + ConversionInstruction F2D = new F2D(); + ConversionInstruction D2I = new D2I(); + ConversionInstruction D2L = new D2L(); + ConversionInstruction D2F = new D2F(); + ConversionInstruction I2B = new I2B(); + ConversionInstruction I2C = new I2C(); + ConversionInstruction I2S = new I2S(); + Instruction LCMP = new LCMP(); + Instruction FCMPL = new FCMPL(); + Instruction FCMPG = new FCMPG(); + Instruction DCMPL = new DCMPL(); + Instruction DCMPG = new DCMPG(); + ReturnInstruction IRETURN = new IRETURN(); + ReturnInstruction LRETURN = new LRETURN(); + ReturnInstruction FRETURN = new FRETURN(); + ReturnInstruction DRETURN = new DRETURN(); + ReturnInstruction ARETURN = new ARETURN(); + ReturnInstruction RETURN = new RETURN(); + Instruction ARRAYLENGTH = new ARRAYLENGTH(); + Instruction ATHROW = new ATHROW(); + Instruction MONITORENTER = new MONITORENTER(); + 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(). + */ + LocalVariableInstruction THIS = new ALOAD(0); + LocalVariableInstruction ALOAD_0 = THIS; + LocalVariableInstruction ALOAD_1 = new ALOAD(1); + LocalVariableInstruction ALOAD_2 = new ALOAD(2); + LocalVariableInstruction ILOAD_0 = new ILOAD(0); + LocalVariableInstruction ILOAD_1 = new ILOAD(1); + LocalVariableInstruction ILOAD_2 = new ILOAD(2); + LocalVariableInstruction ASTORE_0 = new ASTORE(0); + LocalVariableInstruction ASTORE_1 = new ASTORE(1); + LocalVariableInstruction ASTORE_2 = new ASTORE(2); + LocalVariableInstruction ISTORE_0 = new ISTORE(0); + LocalVariableInstruction ISTORE_1 = new ISTORE(1); + LocalVariableInstruction ISTORE_2 = new ISTORE(2); + /** Get object via its opcode, for immutable instructions like + * branch instructions entries are set to null. + */ + Instruction[] INSTRUCTIONS = new Instruction[256]; + /** Interfaces may have no static initializers, so we simulate this + * with an inner class. + */ + Clinit bla = new Clinit(); + + class Clinit { + + Clinit() { + INSTRUCTIONS[Const.NOP] = NOP; + INSTRUCTIONS[Const.ACONST_NULL] = ACONST_NULL; + INSTRUCTIONS[Const.ICONST_M1] = ICONST_M1; + INSTRUCTIONS[Const.ICONST_0] = ICONST_0; + INSTRUCTIONS[Const.ICONST_1] = ICONST_1; + INSTRUCTIONS[Const.ICONST_2] = ICONST_2; + INSTRUCTIONS[Const.ICONST_3] = ICONST_3; + INSTRUCTIONS[Const.ICONST_4] = ICONST_4; + INSTRUCTIONS[Const.ICONST_5] = ICONST_5; + INSTRUCTIONS[Const.LCONST_0] = LCONST_0; + INSTRUCTIONS[Const.LCONST_1] = LCONST_1; + INSTRUCTIONS[Const.FCONST_0] = FCONST_0; + INSTRUCTIONS[Const.FCONST_1] = FCONST_1; + INSTRUCTIONS[Const.FCONST_2] = FCONST_2; + INSTRUCTIONS[Const.DCONST_0] = DCONST_0; + INSTRUCTIONS[Const.DCONST_1] = DCONST_1; + INSTRUCTIONS[Const.IALOAD] = IALOAD; + INSTRUCTIONS[Const.LALOAD] = LALOAD; + INSTRUCTIONS[Const.FALOAD] = FALOAD; + INSTRUCTIONS[Const.DALOAD] = DALOAD; + INSTRUCTIONS[Const.AALOAD] = AALOAD; + INSTRUCTIONS[Const.BALOAD] = BALOAD; + INSTRUCTIONS[Const.CALOAD] = CALOAD; + INSTRUCTIONS[Const.SALOAD] = SALOAD; + INSTRUCTIONS[Const.IASTORE] = IASTORE; + INSTRUCTIONS[Const.LASTORE] = LASTORE; + INSTRUCTIONS[Const.FASTORE] = FASTORE; + INSTRUCTIONS[Const.DASTORE] = DASTORE; + INSTRUCTIONS[Const.AASTORE] = AASTORE; + INSTRUCTIONS[Const.BASTORE] = BASTORE; + INSTRUCTIONS[Const.CASTORE] = CASTORE; + INSTRUCTIONS[Const.SASTORE] = SASTORE; + INSTRUCTIONS[Const.POP] = POP; + INSTRUCTIONS[Const.POP2] = POP2; + INSTRUCTIONS[Const.DUP] = DUP; + INSTRUCTIONS[Const.DUP_X1] = DUP_X1; + INSTRUCTIONS[Const.DUP_X2] = DUP_X2; + INSTRUCTIONS[Const.DUP2] = DUP2; + INSTRUCTIONS[Const.DUP2_X1] = DUP2_X1; + INSTRUCTIONS[Const.DUP2_X2] = DUP2_X2; + INSTRUCTIONS[Const.SWAP] = SWAP; + INSTRUCTIONS[Const.IADD] = IADD; + INSTRUCTIONS[Const.LADD] = LADD; + INSTRUCTIONS[Const.FADD] = FADD; + INSTRUCTIONS[Const.DADD] = DADD; + INSTRUCTIONS[Const.ISUB] = ISUB; + INSTRUCTIONS[Const.LSUB] = LSUB; + INSTRUCTIONS[Const.FSUB] = FSUB; + INSTRUCTIONS[Const.DSUB] = DSUB; + INSTRUCTIONS[Const.IMUL] = IMUL; + INSTRUCTIONS[Const.LMUL] = LMUL; + INSTRUCTIONS[Const.FMUL] = FMUL; + INSTRUCTIONS[Const.DMUL] = DMUL; + INSTRUCTIONS[Const.IDIV] = IDIV; + INSTRUCTIONS[Const.LDIV] = LDIV; + INSTRUCTIONS[Const.FDIV] = FDIV; + INSTRUCTIONS[Const.DDIV] = DDIV; + INSTRUCTIONS[Const.IREM] = IREM; + INSTRUCTIONS[Const.LREM] = LREM; + INSTRUCTIONS[Const.FREM] = FREM; + INSTRUCTIONS[Const.DREM] = DREM; + INSTRUCTIONS[Const.INEG] = INEG; + INSTRUCTIONS[Const.LNEG] = LNEG; + INSTRUCTIONS[Const.FNEG] = FNEG; + INSTRUCTIONS[Const.DNEG] = DNEG; + INSTRUCTIONS[Const.ISHL] = ISHL; + INSTRUCTIONS[Const.LSHL] = LSHL; + INSTRUCTIONS[Const.ISHR] = ISHR; + INSTRUCTIONS[Const.LSHR] = LSHR; + INSTRUCTIONS[Const.IUSHR] = IUSHR; + INSTRUCTIONS[Const.LUSHR] = LUSHR; + INSTRUCTIONS[Const.IAND] = IAND; + INSTRUCTIONS[Const.LAND] = LAND; + INSTRUCTIONS[Const.IOR] = IOR; + INSTRUCTIONS[Const.LOR] = LOR; + INSTRUCTIONS[Const.IXOR] = IXOR; + INSTRUCTIONS[Const.LXOR] = LXOR; + INSTRUCTIONS[Const.I2L] = I2L; + INSTRUCTIONS[Const.I2F] = I2F; + INSTRUCTIONS[Const.I2D] = I2D; + INSTRUCTIONS[Const.L2I] = L2I; + INSTRUCTIONS[Const.L2F] = L2F; + INSTRUCTIONS[Const.L2D] = L2D; + INSTRUCTIONS[Const.F2I] = F2I; + INSTRUCTIONS[Const.F2L] = F2L; + INSTRUCTIONS[Const.F2D] = F2D; + INSTRUCTIONS[Const.D2I] = D2I; + INSTRUCTIONS[Const.D2L] = D2L; + INSTRUCTIONS[Const.D2F] = D2F; + INSTRUCTIONS[Const.I2B] = I2B; + INSTRUCTIONS[Const.I2C] = I2C; + INSTRUCTIONS[Const.I2S] = I2S; + INSTRUCTIONS[Const.LCMP] = LCMP; + INSTRUCTIONS[Const.FCMPL] = FCMPL; + INSTRUCTIONS[Const.FCMPG] = FCMPG; + INSTRUCTIONS[Const.DCMPL] = DCMPL; + INSTRUCTIONS[Const.DCMPG] = DCMPG; + INSTRUCTIONS[Const.IRETURN] = IRETURN; + INSTRUCTIONS[Const.LRETURN] = LRETURN; + INSTRUCTIONS[Const.FRETURN] = FRETURN; + INSTRUCTIONS[Const.DRETURN] = DRETURN; + INSTRUCTIONS[Const.ARETURN] = ARETURN; + INSTRUCTIONS[Const.RETURN] = RETURN; + INSTRUCTIONS[Const.ARRAYLENGTH] = ARRAYLENGTH; + INSTRUCTIONS[Const.ATHROW] = ATHROW; + INSTRUCTIONS[Const.MONITORENTER] = MONITORENTER; + INSTRUCTIONS[Const.MONITOREXIT] = MONITOREXIT; + } + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionFactory.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionFactory.java new file mode 100644 index 00000000..f53d1df1 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionFactory.java @@ -0,0 +1,780 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.Const; + +/** + * 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. + *

      + * Note: The static createXXX methods return singleton instances + * from the {@link InstructionConst} class. + * + * @version $Id: InstructionFactory.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see Const + * @see InstructionConst + */ +public class InstructionFactory implements InstructionConstants { + + // N.N. These must agree with the order of Constants.T_CHAR through T_LONG + private static final String[] short_names = { + "C", "F", "D", "B", "S", "I", "L" + }; + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected ClassGen cg; + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected ConstantPoolGen cp; + + + public InstructionFactory(final ClassGen cg, final ConstantPoolGen cp) { + this.cg = cg; + this.cp = cp; + } + + + /** Initialize with ClassGen object + */ + public InstructionFactory(final ClassGen cg) { + this(cg, cg.getConstantPool()); + } + + + /** Initialize just with ConstantPoolGen object + */ + public InstructionFactory(final ConstantPoolGen cp) { + this(null, cp); + } + + + /** Create an invoke instruction. (Except for invokedynamic.) + * + * @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 Const + */ + public InvokeInstruction createInvoke( final String class_name, final String name, final Type ret_type, + final Type[] arg_types, final short kind ) { + int index; + int nargs = 0; + final String signature = Type.getMethodSignature(ret_type, arg_types); + for (final Type arg_type : arg_types) { + nargs += arg_type.getSize(); + } + if (kind == Const.INVOKEINTERFACE) { + index = cp.addInterfaceMethodref(class_name, name, signature); + } else { + index = cp.addMethodref(class_name, name, signature); + } + switch (kind) { + case Const.INVOKESPECIAL: + return new INVOKESPECIAL(index); + case Const.INVOKEVIRTUAL: + return new INVOKEVIRTUAL(index); + case Const.INVOKESTATIC: + return new INVOKESTATIC(index); + case Const.INVOKEINTERFACE: + return new INVOKEINTERFACE(index, nargs + 1); + case Const.INVOKEDYNAMIC: + return new INVOKEDYNAMIC(index); + default: + throw new RuntimeException("Oops: Unknown invoke kind: " + kind); + } + } + + /** Create an invokedynamic instruction. + * + * @param bootstrap_index index into the bootstrap_methods array + * @param name name of the called method + * @param ret_type return type of method + * @param arg_types argument types of method + * @see Constants + */ +/* + * createInvokeDynamic only needed if instrumention code wants to generate + * a new invokedynamic instruction. I don't think we need. (markro) + * + public InvokeInstruction createInvokeDynamic( int bootstrap_index, String name, Type ret_type, + Type[] arg_types) { + int index; + int nargs = 0; + String signature = Type.getMethodSignature(ret_type, arg_types); + for (int i = 0; i < arg_types.length; i++) { + nargs += arg_types[i].getSize(); + } + // UNDONE - needs to be added to ConstantPoolGen + //index = cp.addInvokeDynamic(bootstrap_index, name, signature); + index = 0; + return new INVOKEDYNAMIC(index); + } + */ + + /** Create a call to the most popular System.out.println() method. + * + * @param s the string to print + */ + public InstructionList createPrintln( final String s ) { + final InstructionList il = new InstructionList(); + final int out = cp.addFieldref("java.lang.System", "out", "Ljava/io/PrintStream;"); + final 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; + } + + + /** Uses PUSH to push a constant value onto the stack. + * @param value must be of type Number, Boolean, Character or String + */ + public Instruction createConstant( final Object value ) { + PUSH push; + if (value instanceof Number) { + push = new PUSH(cp, (Number) value); + } else if (value instanceof String) { + push = new PUSH(cp, (String) value); + } else if (value instanceof Boolean) { + push = new PUSH(cp, (Boolean) value); + } else if (value instanceof Character) { + push = new PUSH(cp, (Character) value); + } else { + throw new ClassGenException("Illegal type: " + value.getClass()); + } + return push.getInstruction(); + } + + private static class MethodObject { + + final Type[] arg_types; + final Type result_type; + final String class_name; + final String name; + + + MethodObject(final String c, final String n, final Type r, final Type[] a) { + class_name = c; + name = n; + result_type = r; + arg_types = a; + } + } + + + private InvokeInstruction createInvoke( final MethodObject m, final short kind ) { + return createInvoke(m.class_name, m.name, m.result_type, m.arg_types, kind); + } + + private static final MethodObject[] append_mos = { + new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, new Type[] { + Type.STRING + }), + new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, new Type[] { + Type.OBJECT + }), + null, + null, // indices 2, 3 + new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, new Type[] { + Type.BOOLEAN + }), + new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, new Type[] { + Type.CHAR + }), + new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, new Type[] { + Type.FLOAT + }), + new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, new Type[] { + Type.DOUBLE + }), + new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, new Type[] { + Type.INT + }), + new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, // No append(byte) + new Type[] { + Type.INT + }), + new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, // No append(short) + new Type[] { + Type.INT + }), + new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, new Type[] { + Type.LONG + }) + }; + + + private static boolean isString( final Type type ) { + return (type instanceof ObjectType) && + ((ObjectType) type).getClassName().equals("java.lang.String"); + } + + + public Instruction createAppend( final Type type ) { + final byte t = type.getType(); + if (isString(type)) { + return createInvoke(append_mos[0], Const.INVOKEVIRTUAL); + } + switch (t) { + case Const.T_BOOLEAN: + case Const.T_CHAR: + case Const.T_FLOAT: + case Const.T_DOUBLE: + case Const.T_BYTE: + case Const.T_SHORT: + case Const.T_INT: + case Const.T_LONG: + return createInvoke(append_mos[t], Const.INVOKEVIRTUAL); + case Const.T_ARRAY: + case Const.T_OBJECT: + return createInvoke(append_mos[1], Const.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 Const + */ + public FieldInstruction createFieldAccess( final String class_name, final String name, final Type type, final short kind ) { + int index; + final String signature = type.getSignature(); + index = cp.addFieldref(class_name, name, signature); + switch (kind) { + case Const.GETFIELD: + return new GETFIELD(index); + case Const.PUTFIELD: + return new PUTFIELD(index); + case Const.GETSTATIC: + return new GETSTATIC(index); + case Const.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( final Type type ) { + switch (type.getType()) { + case Const.T_ARRAY: + case Const.T_OBJECT: + return InstructionConst.ARETURN; + case Const.T_INT: + case Const.T_SHORT: + case Const.T_BOOLEAN: + case Const.T_CHAR: + case Const.T_BYTE: + return InstructionConst.IRETURN; + case Const.T_FLOAT: + return InstructionConst.FRETURN; + case Const.T_DOUBLE: + return InstructionConst.DRETURN; + case Const.T_LONG: + return InstructionConst.LRETURN; + case Const.T_VOID: + return InstructionConst.RETURN; + default: + throw new RuntimeException("Invalid type: " + type); + } + } + + + private static ArithmeticInstruction createBinaryIntOp( final char first, final String op ) { + switch (first) { + case '-': + return InstructionConst.ISUB; + case '+': + return InstructionConst.IADD; + case '%': + return InstructionConst.IREM; + case '*': + return InstructionConst.IMUL; + case '/': + return InstructionConst.IDIV; + case '&': + return InstructionConst.IAND; + case '|': + return InstructionConst.IOR; + case '^': + return InstructionConst.IXOR; + case '<': + return InstructionConst.ISHL; + case '>': + return op.equals(">>>") ? InstructionConst.IUSHR : InstructionConst.ISHR; + default: + throw new RuntimeException("Invalid operand " + op); + } + } + + + private static ArithmeticInstruction createBinaryLongOp( final char first, final String op ) { + switch (first) { + case '-': + return InstructionConst.LSUB; + case '+': + return InstructionConst.LADD; + case '%': + return InstructionConst.LREM; + case '*': + return InstructionConst.LMUL; + case '/': + return InstructionConst.LDIV; + case '&': + return InstructionConst.LAND; + case '|': + return InstructionConst.LOR; + case '^': + return InstructionConst.LXOR; + case '<': + return InstructionConst.LSHL; + case '>': + return op.equals(">>>") ? InstructionConst.LUSHR : InstructionConst.LSHR; + default: + throw new RuntimeException("Invalid operand " + op); + } + } + + + private static ArithmeticInstruction createBinaryFloatOp( final char op ) { + switch (op) { + case '-': + return InstructionConst.FSUB; + case '+': + return InstructionConst.FADD; + case '*': + return InstructionConst.FMUL; + case '/': + return InstructionConst.FDIV; + case '%': + return InstructionConst.FREM; + default: + throw new RuntimeException("Invalid operand " + op); + } + } + + + private static ArithmeticInstruction createBinaryDoubleOp( final char op ) { + switch (op) { + case '-': + return InstructionConst.DSUB; + case '+': + return InstructionConst.DADD; + case '*': + return InstructionConst.DMUL; + case '/': + return InstructionConst.DDIV; + case '%': + return InstructionConst.DREM; + 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( final String op, final Type type ) { + final char first = op.charAt(0); + switch (type.getType()) { + case Const.T_BYTE: + case Const.T_SHORT: + case Const.T_INT: + case Const.T_CHAR: + return createBinaryIntOp(first, op); + case Const.T_LONG: + return createBinaryLongOp(first, op); + case Const.T_FLOAT: + return createBinaryFloatOp(first); + case Const.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( final int size ) { + return (size == 2) ? InstructionConst.POP2 : InstructionConst.POP; + } + + + /** + * @param size size of operand, either 1 (int, e.g.) or 2 (double) + */ + public static StackInstruction createDup( final int size ) { + return (size == 2) ? InstructionConst.DUP2 : InstructionConst.DUP; + } + + + /** + * @param size size of operand, either 1 (int, e.g.) or 2 (double) + */ + public static StackInstruction createDup_2( final int size ) { + return (size == 2) ? InstructionConst.DUP2_X2 : InstructionConst.DUP_X2; + } + + + /** + * @param size size of operand, either 1 (int, e.g.) or 2 (double) + */ + public static StackInstruction createDup_1( final int size ) { + return (size == 2) ? InstructionConst.DUP2_X1 : InstructionConst.DUP_X1; + } + + + /** + * @param index index of local variable + */ + public static LocalVariableInstruction createStore( final Type type, final int index ) { + switch (type.getType()) { + case Const.T_BOOLEAN: + case Const.T_CHAR: + case Const.T_BYTE: + case Const.T_SHORT: + case Const.T_INT: + return new ISTORE(index); + case Const.T_FLOAT: + return new FSTORE(index); + case Const.T_DOUBLE: + return new DSTORE(index); + case Const.T_LONG: + return new LSTORE(index); + case Const.T_ARRAY: + case Const.T_OBJECT: + return new ASTORE(index); + default: + throw new RuntimeException("Invalid type " + type); + } + } + + + /** + * @param index index of local variable + */ + public static LocalVariableInstruction createLoad( final Type type, final int index ) { + switch (type.getType()) { + case Const.T_BOOLEAN: + case Const.T_CHAR: + case Const.T_BYTE: + case Const.T_SHORT: + case Const.T_INT: + return new ILOAD(index); + case Const.T_FLOAT: + return new FLOAD(index); + case Const.T_DOUBLE: + return new DLOAD(index); + case Const.T_LONG: + return new LLOAD(index); + case Const.T_ARRAY: + case Const.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( final Type type ) { + switch (type.getType()) { + case Const.T_BOOLEAN: + case Const.T_BYTE: + return InstructionConst.BALOAD; + case Const.T_CHAR: + return InstructionConst.CALOAD; + case Const.T_SHORT: + return InstructionConst.SALOAD; + case Const.T_INT: + return InstructionConst.IALOAD; + case Const.T_FLOAT: + return InstructionConst.FALOAD; + case Const.T_DOUBLE: + return InstructionConst.DALOAD; + case Const.T_LONG: + return InstructionConst.LALOAD; + case Const.T_ARRAY: + case Const.T_OBJECT: + return InstructionConst.AALOAD; + default: + throw new RuntimeException("Invalid type " + type); + } + } + + + /** + * @param type type of elements of array, i.e., array.getElementType() + */ + public static ArrayInstruction createArrayStore( final Type type ) { + switch (type.getType()) { + case Const.T_BOOLEAN: + case Const.T_BYTE: + return InstructionConst.BASTORE; + case Const.T_CHAR: + return InstructionConst.CASTORE; + case Const.T_SHORT: + return InstructionConst.SASTORE; + case Const.T_INT: + return InstructionConst.IASTORE; + case Const.T_FLOAT: + return InstructionConst.FASTORE; + case Const.T_DOUBLE: + return InstructionConst.DASTORE; + case Const.T_LONG: + return InstructionConst.LASTORE; + case Const.T_ARRAY: + case Const.T_OBJECT: + return InstructionConst.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( final Type src_type, final Type dest_type ) { + if ((src_type instanceof BasicType) && (dest_type instanceof BasicType)) { + final byte dest = dest_type.getType(); + byte src = src_type.getType(); + if (dest == Const.T_LONG + && (src == Const.T_CHAR || src == Const.T_BYTE || src == Const.T_SHORT)) { + src = Const.T_INT; + } + final String name = "org.apache.bcel.generic." + short_names[src - Const.T_CHAR] + "2" + + short_names[dest - Const.T_CHAR]; + Instruction i = null; + try { + i = (Instruction) java.lang.Class.forName(name).newInstance(); + } catch (final Exception e) { + throw new RuntimeException("Could not find instruction: " + name, e); + } + 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)); + } + return new CHECKCAST(cp.addClass(((ObjectType) dest_type).getClassName())); + } else { + throw new RuntimeException("Can not cast " + src_type + " to " + dest_type); + } + } + + + public GETFIELD createGetField( final String class_name, final String name, final Type t ) { + return new GETFIELD(cp.addFieldref(class_name, name, t.getSignature())); + } + + + public GETSTATIC createGetStatic( final String class_name, final String name, final Type t ) { + return new GETSTATIC(cp.addFieldref(class_name, name, t.getSignature())); + } + + + public PUTFIELD createPutField( final String class_name, final String name, final Type t ) { + return new PUTFIELD(cp.addFieldref(class_name, name, t.getSignature())); + } + + + public PUTSTATIC createPutStatic( final String class_name, final String name, final Type t ) { + return new PUTSTATIC(cp.addFieldref(class_name, name, t.getSignature())); + } + + + public CHECKCAST createCheckCast( final ReferenceType t ) { + if (t instanceof ArrayType) { + return new CHECKCAST(cp.addArrayClass((ArrayType) t)); + } + return new CHECKCAST(cp.addClass((ObjectType) t)); + } + + + public INSTANCEOF createInstanceOf( final ReferenceType t ) { + if (t instanceof ArrayType) { + return new INSTANCEOF(cp.addArrayClass((ArrayType) t)); + } + return new INSTANCEOF(cp.addClass((ObjectType) t)); + } + + + public NEW createNew( final ObjectType t ) { + return new NEW(cp.addClass(t)); + } + + + public NEW createNew( final String s ) { + return createNew(ObjectType.getInstance(s)); + } + + + /** Create new array of given size and type. + * @return an instruction that creates the corresponding array at runtime, i.e. is an AllocationInstruction + */ + public Instruction createNewArray( final Type t, final 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(t.getType()); + } + } + 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( final Type type ) { + switch (type.getType()) { + case Const.T_ARRAY: + case Const.T_OBJECT: + return InstructionConst.ACONST_NULL; + case Const.T_INT: + case Const.T_SHORT: + case Const.T_BOOLEAN: + case Const.T_CHAR: + case Const.T_BYTE: + return InstructionConst.ICONST_0; + case Const.T_FLOAT: + return InstructionConst.FCONST_0; + case Const.T_DOUBLE: + return InstructionConst.DCONST_0; + case Const.T_LONG: + return InstructionConst.LCONST_0; + case Const.T_VOID: + return InstructionConst.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 compound instruction. + */ + public static BranchInstruction createBranchInstruction( final short opcode, final InstructionHandle target ) { + switch (opcode) { + case Const.IFEQ: + return new IFEQ(target); + case Const.IFNE: + return new IFNE(target); + case Const.IFLT: + return new IFLT(target); + case Const.IFGE: + return new IFGE(target); + case Const.IFGT: + return new IFGT(target); + case Const.IFLE: + return new IFLE(target); + case Const.IF_ICMPEQ: + return new IF_ICMPEQ(target); + case Const.IF_ICMPNE: + return new IF_ICMPNE(target); + case Const.IF_ICMPLT: + return new IF_ICMPLT(target); + case Const.IF_ICMPGE: + return new IF_ICMPGE(target); + case Const.IF_ICMPGT: + return new IF_ICMPGT(target); + case Const.IF_ICMPLE: + return new IF_ICMPLE(target); + case Const.IF_ACMPEQ: + return new IF_ACMPEQ(target); + case Const.IF_ACMPNE: + return new IF_ACMPNE(target); + case Const.GOTO: + return new GOTO(target); + case Const.JSR: + return new JSR(target); + case Const.IFNULL: + return new IFNULL(target); + case Const.IFNONNULL: + return new IFNONNULL(target); + case Const.GOTO_W: + return new GOTO_W(target); + case Const.JSR_W: + return new JSR_W(target); + default: + throw new RuntimeException("Invalid opcode: " + opcode); + } + } + + + public void setClassGen( final ClassGen c ) { + cg = c; + } + + + public ClassGen getClassGen() { + return cg; + } + + + public void setConstantPool( final ConstantPoolGen c ) { + cp = c; + } + + + public ConstantPoolGen getConstantPool() { + return cp; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InstructionHandle.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionHandle.java old mode 100755 new mode 100644 similarity index 64% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InstructionHandle.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionHandle.java index 8e5db5c1..457fe4c4 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InstructionHandle.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionHandle.java @@ -1,291 +1,324 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.bcel5_2_0.classfile.Utility; - -/** - * 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: InstructionHandle.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 Set targeters; - private Map 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 ) { - if (targeters != null) { - 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() { - if (attributes == null) { - attributes = new HashMap(3); - } - return attributes.values(); - } - - - /** Convenience method, simply calls accept() on the contained instruction. - * - * @param v Visitor object - */ - public void accept( Visitor v ) { - instruction.accept(v); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.bcel.classfile.Utility; + +/** + * 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: InstructionHandle.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see Instruction + * @see BranchHandle + * @see InstructionList + */ +public class InstructionHandle { + + private InstructionHandle next; + private InstructionHandle prev; + private Instruction instruction; + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected int i_position = -1; // byte code offset of instruction + + private Set targeters; + private Map 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( final Instruction i ) { // Overridden in BranchHandle TODO could be package-protected? + 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. + *

      + * Warning: if this is used on a BranchHandle then some methods such as + * getPosition() will still refer to the original cached instruction, whereas + * other BH methods may affect the cache and the replacement instruction. + */ + // See BCEL-273 + // TODO remove this method in any redesign of BCEL + public Instruction swapInstruction( final Instruction i ) { + final Instruction oldInstruction = instruction; + instruction = i; + return oldInstruction; + } + + + /*private*/protected InstructionHandle(final Instruction i) { + setInstruction(i); + } + + private static InstructionHandle ih_list = null; // List of reusable handles + + + /** Factory method. + */ + static InstructionHandle getInstructionHandle( final Instruction i ) { + if (ih_list == null) { + return new InstructionHandle(i); + } + final 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( final int offset, final 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( final 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( final InstructionTargeter t ) { + if (targeters != null) { + targeters.remove(t); + } + } + + + /** + * Denote this handle is being referenced by t. + */ + public void addTargeter( final 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 new InstructionTargeter[0]; + } + final InstructionTargeter[] t = new InstructionTargeter[targeters.size()]; + targeters.toArray(t); + return t; + } + + + /** @return a (verbose) string representation of the contained instruction. + */ + public String toString( final boolean verbose ) { + return Utility.format(i_position, 4, false, ' ') + ": " + instruction.toString(verbose); + } + + + /** @return a string representation of the contained instruction. + */ + @Override + 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( final Object key, final 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( final 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( final Object key ) { + if (attributes != null) { + return attributes.get(key); + } + return null; + } + + + /** @return all attributes associated with this handle + */ + public Collection getAttributes() { + if (attributes == null) { + attributes = new HashMap<>(3); + } + return attributes.values(); + } + + + /** Convenience method, simply calls accept() on the contained instruction. + * + * @param v Visitor object + */ + public void accept( final Visitor v ) { + instruction.accept(v); + } + + + /** + * @param next the next to set + * @ since 6.0 + */ + final InstructionHandle setNext(final InstructionHandle next) { + this.next = next; + return next; + } + + + /** + * @param prev the prev to set + * @ since 6.0 + */ + final InstructionHandle setPrev(final InstructionHandle prev) { + this.prev = prev; + return prev; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionList.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionList.java new file mode 100644 index 00000000..cfee431c --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionList.java @@ -0,0 +1,1257 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; + +import org.apache.bcel.Const; +import org.apache.bcel.classfile.Constant; +import org.apache.bcel.util.ByteSequence; + +/** + * This class is a container for a list of Instruction objects. Instructions can be appended, inserted, moved, deleted, etc.. + * Instructions are being wrapped into InstructionHandles 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 getByteCode. + * + * @version $Id: InstructionList.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see Instruction + * @see InstructionHandle + * @see BranchHandle + */ +public class InstructionList implements Iterable { + + private InstructionHandle start = null; + private InstructionHandle 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(final Instruction i) { + append(i); + } + + /** + * Create instruction list containing one instruction. + * + * @param i + * initial instruction + */ + public InstructionList(final 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(final 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(final InstructionHandle[] ihs, final int[] pos, final int count, final int target) { + int l = 0; + int r = count - 1; + /* + * Do a binary search since the pos array is orderd. + */ + do { + final int i = (l + r) / 2; + final int j = pos[i]; + if (j == target) { + return ihs[i]; + } else if (target < j) { + r = i - 1; + } else { + 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(final int pos) { + final int[] positions = byte_positions; + InstructionHandle ih = start; + for (int i = 0; i < length; i++) { + if (positions[i] == pos) { + return ih; + } + ih = ih.getNext(); + } + return null; + } + + /** + * Initialize instruction list from byte array. + * + * @param code + * byte array containing the instructions + */ + public InstructionList(final byte[] code) { + int count = 0; // Contains actual length + int[] pos; + InstructionHandle[] ihs; + try (ByteSequence bytes = new ByteSequence(code)) { + ihs = new InstructionHandle[code.length]; + pos = new int[code.length]; // Can't be more than that + /* + * Pass 1: Create an object for each byte code and append them to the list. + */ + while (bytes.available() > 0) { + // Remember byte offset and associate it with the instruction + final int off = bytes.getIndex(); + pos[count] = off; + /* + * Read one instruction from the byte stream, the byte position is set accordingly. + */ + final Instruction i = Instruction.readInstruction(bytes); + InstructionHandle ih; + if (i instanceof BranchInstruction) { + ih = append((BranchInstruction) i); + } else { + ih = append(i); + } + ih.setPosition(off); + ihs[count] = ih; + count++; + } + } catch (final IOException e) { + throw new ClassGenException(e.toString(), e); + } + 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) { + final BranchInstruction bi = (BranchInstruction) ihs[i].getInstruction(); + int target = bi.getPosition() + bi.getIndex(); /* + * Byte code position: relative -> absolute. + */ + // Search for target position + InstructionHandle ih = findHandle(ihs, pos, count, target); + if (ih == null) { + 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 + final Select s = (Select) bi; + final int[] indices = s.getIndices(); + for (int j = 0; j < indices.length; j++) { + target = bi.getPosition() + indices[j]; + ih = findHandle(ihs, pos, count, target); + if (ih == null) { + 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 first appended instruction + */ + public InstructionHandle append(final InstructionHandle ih, final InstructionList il) { + if (il == null) { + throw new ClassGenException("Appending null InstructionList"); + } + if (il.isEmpty()) { + return ih; + } + final InstructionHandle next = ih.getNext(); + final InstructionHandle ret = il.start; + ih.setNext(il.start); + il.start.setPrev(ih); + il.end.setNext(next); + if (next != null) { + next.setPrev(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 first appended instruction + */ + public InstructionHandle append(final Instruction i, final InstructionList il) { + InstructionHandle ih; + if ((ih = findInstruction2(i)) == null) { + 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 first appended instruction + */ + public InstructionHandle append(final InstructionList il) { + if (il == null) { + throw new ClassGenException("Appending null InstructionList"); + } + if (il.isEmpty()) { + return null; + } + if (isEmpty()) { + start = il.start; + end = il.end; + length = il.length; + il.clear(); + return start; + } + return append(end, il); // was end.instruction + } + + /** + * Append an instruction to the end of this list. + * + * @param ih + * instruction to append + */ + private void append(final InstructionHandle ih) { + if (isEmpty()) { + start = end = ih; + ih.setNext(ih.setPrev(null)); + } else { + end.setNext(ih); + ih.setPrev(end); + ih.setNext(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(final Instruction i) { + final 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(final BranchInstruction i) { + final 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(final Instruction i, final 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(final Instruction i, final 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(final 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(final InstructionHandle ih, final 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 first appended instruction + */ + public InstructionHandle append(final InstructionHandle ih, final 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 first appended instruction + */ + public BranchHandle append(final InstructionHandle ih, final BranchInstruction i) { + final BranchHandle bh = BranchHandle.getBranchHandle(i); + final 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 ih + * where to append the instruction list + * @param il + * Instruction list to insert + * @return instruction handle of the first inserted instruction + */ + public InstructionHandle insert(final InstructionHandle ih, final InstructionList il) { + if (il == null) { + throw new ClassGenException("Inserting null InstructionList"); + } + if (il.isEmpty()) { + return ih; + } + final InstructionHandle prev = ih.getPrev(); + final InstructionHandle ret = il.start; + ih.setPrev(il.end); + il.end.setNext(ih); + il.start.setPrev(prev); + if (prev != null) { + prev.setNext(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(final InstructionList il) { + if (isEmpty()) { + append(il); // Code is identical for this case + return start; + } + return insert(start, il); + } + + /** + * Insert an instruction at start of this list. + * + * @param ih + * instruction to insert + */ + private void insert(final InstructionHandle ih) { + if (isEmpty()) { + start = end = ih; + ih.setNext(ih.setPrev(null)); + } else { + start.setPrev(ih); + ih.setNext(start); + ih.setPrev(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(final Instruction i, final 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(final Instruction i) { + final 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(final BranchInstruction i) { + final 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(final Instruction i, final 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(final Instruction i, final 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(final 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(final InstructionHandle ih, final 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(final InstructionHandle ih, final 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(final InstructionHandle ih, final BranchInstruction i) { + final BranchHandle bh = BranchHandle.getBranchHandle(i); + final 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.
      + * 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(final InstructionHandle start, final InstructionHandle end, final 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.getNext(); ih = ih.getNext()) { + if (ih == null) { + throw new ClassGenException("Invalid range: From " + start + " to " + end); + } else if (ih == target) { + throw new ClassGenException("Invalid range: From " + start + " to " + end + " contains target " + target); + } + } + // Step 2: Temporarily remove the given instructions from the list + final InstructionHandle prev = start.getPrev(); + InstructionHandle next = end.getNext(); + if (prev != null) { + prev.setNext(next); + } else { + this.start = next; + } + if (next != null) { + next.setPrev(prev); + } else { + this.end = prev; + } + start.setPrev(end.setNext(null)); + // Step 3: append after target + if (target == null) { // append to start of list + if (this.start != null) { + this.start.setPrev(end); + } + end.setNext(this.start); + this.start = start; + } else { + next = target.getNext(); + target.setNext(start); + start.setPrev(target); + end.setNext(next); + if (next != null) { + next.setPrev(end); + } else { + this.end = end; + } + } + } + + /** + * Move a single instruction (handle) to a new location. + * + * @param ih + * moved instruction + * @param target + * new location of moved instruction + */ + public void move(final InstructionHandle ih, final 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(final InstructionHandle prev, InstructionHandle next) throws TargetLostException { + InstructionHandle first; + InstructionHandle last; // First and last deleted instruction + if ((prev == null) && (next == null)) { + first = start; + last = end; + start = end = null; + } else { + if (prev == null) { // At start of list + first = start; + start = next; + } else { + first = prev.getNext(); + prev.setNext(next); + } + if (next == null) { // At end of list + last = end; + end = prev; + } else { + last = next.getPrev(); + next.setPrev(prev); + } + } + first.setPrev(null); // Completely separated from rest of list + last.setNext(null); + final List target_vec = new ArrayList<>(); + for (InstructionHandle ih = first; ih != null; ih = ih.getNext()) { + ih.getInstruction().dispose(); // e.g. BranchInstructions release their targets + } + final StringBuilder buf = new StringBuilder("{ "); + for (InstructionHandle ih = first; ih != null; ih = next) { + next = ih.getNext(); + length--; + if (ih.hasTargeters()) { // Still got targeters? + target_vec.add(ih); + buf.append(ih.toString(true)).append(" "); + ih.setNext(ih.setPrev(null)); + } else { + ih.dispose(); + } + } + buf.append("}"); + if (!target_vec.isEmpty()) { + final 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(final InstructionHandle ih) throws TargetLostException { + remove(ih.getPrev(), ih.getNext()); + } + + /** + * Remove instruction from this list. The corresponding Instruction handles must not be reused! + * + * @param i + * instruction to remove + */ + public void delete(final 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(final InstructionHandle from, final InstructionHandle to) throws TargetLostException { + remove(from.getPrev(), to.getNext()); + } + + /** + * 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(final Instruction from, final Instruction to) throws TargetLostException { + InstructionHandle from_ih; + InstructionHandle 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(final Instruction i) { + for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { + if (ih.getInstruction() == 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(final Instruction i) { + for (InstructionHandle ih = end; ih != null; ih = ih.getPrev()) { + if (ih.getInstruction() == i) { + return ih; + } + } + return null; + } + + public boolean contains(final InstructionHandle i) { + if (i == null) { + return false; + } + for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { + if (ih == i) { + return true; + } + } + return false; + } + + public boolean contains(final Instruction i) { + return findInstruction1(i) != null; + } + + public void setPositions() { // TODO could be package-protected? (some test code would need to be repackaged) + 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(final boolean check) { // called by code in other packages + int max_additional_bytes = 0; + int additional_bytes = 0; + int index = 0; + int count = 0; + final int[] pos = new int[length]; + /* + * Pass 0: Sanity checks + */ + if (check) { + for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { + final Instruction i = ih.getInstruction(); + if (i instanceof BranchInstruction) { // target instruction within list? + Instruction inst = ((BranchInstruction) i).getTarget().getInstruction(); + if (!contains(inst)) { + throw new ClassGenException("Branch target of " + Const.getOpcodeName(i.getOpcode()) + ":" + inst + " not in instruction list"); + } + if (i instanceof Select) { + final InstructionHandle[] targets = ((Select) i).getTargets(); + for (final InstructionHandle target : targets) { + inst = target.getInstruction(); + if (!contains(inst)) { + throw new ClassGenException("Branch target of " + Const.getOpcodeName(i.getOpcode()) + ":" + inst + " not in instruction list"); + } + } + } + if (!(ih instanceof BranchHandle)) { + throw new ClassGenException( + "Branch instruction " + Const.getOpcodeName(i.getOpcode()) + ":" + 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.getNext()) { + final Instruction i = ih.getInstruction(); + 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 Const.JSR: + case Const.GOTO: + max_additional_bytes += 2; + break; + case Const.TABLESWITCH: + case Const.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.getNext()) { + 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.getNext()) { + final Instruction i = ih.getInstruction(); + 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(); + final ByteArrayOutputStream b = new ByteArrayOutputStream(); + final DataOutputStream out = new DataOutputStream(b); + try { + for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { + final Instruction i = ih.getInstruction(); + i.dump(out); // Traverse list + } + out.flush(); + } catch (final IOException e) { + System.err.println(e); + return new byte[0]; + } + return b.toByteArray(); + } + + /** + * @return an array of instructions without target information for branch instructions. + */ + public Instruction[] getInstructions() { + final List instructions = new ArrayList<>(); + try (ByteSequence bytes = new ByteSequence(getByteCode())) { + while (bytes.available() > 0) { + instructions.add(Instruction.readInstruction(bytes)); + } + } catch (final IOException e) { + throw new ClassGenException(e.toString(), e); + } + return instructions.toArray(new Instruction[instructions.size()]); + } + + @Override + public String toString() { + return toString(true); + } + + /** + * @param verbose + * toggle output format + * @return String containing all instructions in this list. + */ + public String toString(final boolean verbose) { + final StringBuilder buf = new StringBuilder(); + for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { + buf.append(ih.toString(verbose)).append("\n"); + } + return buf.toString(); + } + + /** + * @return iterator that lists all instructions (handles) + */ + @Override + public Iterator iterator() { + return new Iterator() { + + private InstructionHandle ih = start; + + @Override + public InstructionHandle next() throws NoSuchElementException { + if (ih == null) { + throw new NoSuchElementException(); + } + final InstructionHandle i = ih; + ih = ih.getNext(); + return i; + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + + @Override + public boolean hasNext() { + return ih != null; + } + }; + } + + /** + * @return array containing all instructions (handles) + */ + public InstructionHandle[] getInstructionHandles() { + final InstructionHandle[] ihs = new InstructionHandle[length]; + InstructionHandle ih = start; + for (int i = 0; i < length; i++) { + ihs[i] = ih; + ih = ih.getNext(); + } + 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() { + final Map map = new HashMap<>(); + final 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.getNext()) { + final Instruction i = ih.getInstruction(); + final 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) { + final Instruction i = ih.getInstruction(); + final Instruction c = ch.getInstruction(); + if (i instanceof BranchInstruction) { + final BranchInstruction bi = (BranchInstruction) i; + final BranchInstruction bc = (BranchInstruction) c; + final InstructionHandle itarget = bi.getTarget(); // old target + // New target is in hash map + bc.setTarget(map.get(itarget)); + if (bi instanceof Select) { // Either LOOKUPSWITCH or TABLESWITCH + final InstructionHandle[] itargets = ((Select) bi).getTargets(); + final InstructionHandle[] ctargets = ((Select) bc).getTargets(); + for (int j = 0; j < itargets.length; j++) { // Update all targets + ctargets[j] = map.get(itargets[j]); + } + } + } + ih = ih.getNext(); + ch = ch.getNext(); + } + return il; + } + + /** + * Replace all references to the old constant pool with references to the new constant pool + */ + public void replaceConstantPool(final ConstantPoolGen old_cp, final ConstantPoolGen new_cp) { + for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { + final Instruction i = ih.getInstruction(); + if (i instanceof CPInstruction) { + final CPInstruction ci = (CPInstruction) i; + final 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 better memory utilization, because the system then may reuse the instruction handles. This method is typically called + * right after {@link MethodGen#getMethod()}. + */ + public void dispose() { + // Traverse in reverse order, because ih.next is overwritten + for (InstructionHandle ih = end; ih != null; ih = ih.getPrev()) { + /* + * 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(final InstructionHandle old_target, final InstructionHandle new_target) { + for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { + final Instruction i = ih.getInstruction(); + if (i instanceof BranchInstruction) { + final BranchInstruction b = (BranchInstruction) i; + final InstructionHandle target = b.getTarget(); + if (target == old_target) { + b.setTarget(new_target); + } + if (b instanceof Select) { // Either LOOKUPSWITCH or TABLESWITCH + final InstructionHandle[] targets = ((Select) b).getTargets(); + for (int j = 0; j < targets.length; j++) { + 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(final LocalVariableGen[] lg, final InstructionHandle old_target, final InstructionHandle new_target) { + for (final LocalVariableGen element : lg) { + final InstructionHandle start = element.getStart(); + final InstructionHandle end = element.getEnd(); + if (start == old_target) { + element.setStart(new_target); + } + if (end == old_target) { + element.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(final CodeExceptionGen[] exceptions, final InstructionHandle old_target, final InstructionHandle new_target) { + for (final CodeExceptionGen exception : exceptions) { + if (exception.getStartPC() == old_target) { + exception.setStartPC(new_target); + } + if (exception.getEndPC() == old_target) { + exception.setEndPC(new_target); + } + if (exception.getHandlerPC() == old_target) { + exception.setHandlerPC(new_target); + } + } + } + + private List observers; + + /** + * Add observer for this object. + */ + public void addObserver(final InstructionListObserver o) { + if (observers == null) { + observers = new ArrayList<>(); + } + observers.add(o); + } + + /** + * Remove observer for this object. + */ + public void removeObserver(final 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 (final InstructionListObserver observer : observers) { + observer.notify(this); + } + } + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionListObserver.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionListObserver.java new file mode 100644 index 00000000..32e00628 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionListObserver.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Implement this interface if you're interested in changes to an InstructionList object + * and register yourself with addObserver(). + * + * @version $Id: InstructionListObserver.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public interface InstructionListObserver { + + void notify( InstructionList list ); +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionTargeter.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionTargeter.java new file mode 100644 index 00000000..9a487f65 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionTargeter.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.bcel.generic; + +/** + * Denote that a class targets InstructionHandles within an InstructionList. Namely + * the following implementers: + * + * @see BranchHandle + * @see LocalVariableGen + * @see CodeExceptionGen + * @version $Id: InstructionTargeter.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public interface InstructionTargeter { + + /** + * Checks whether this targeter targets the specified instruction handle. + */ + boolean containsTarget(InstructionHandle ih); + + /** + * Replaces the target of this targeter from this old handle to the new handle. + * + * @param old_ih the old handle + * @param new_ih the new handle + * @throws ClassGenException if old_ih is not targeted by this object + */ + void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) throws ClassGenException; +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InvokeInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InvokeInstruction.java new file mode 100644 index 00000000..6f835e8f --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InvokeInstruction.java @@ -0,0 +1,137 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.util.StringTokenizer; + +import org.apache.bcel.Const; +import org.apache.bcel.classfile.Constant; +import org.apache.bcel.classfile.ConstantCP; +import org.apache.bcel.classfile.ConstantPool; + +/** + * Super class for the INVOKExxx family of instructions. + * + * @version $Id: InvokeInstruction.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public abstract class InvokeInstruction extends FieldOrMethod implements ExceptionThrower, + StackConsumer, StackProducer { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + InvokeInstruction() { + } + + + /** + * @param index to constant pool + */ + protected InvokeInstruction(final short opcode, final int index) { + super(opcode, index); + } + + + /** + * @return mnemonic for instruction with symbolic references resolved + */ + @Override + public String toString( final ConstantPool cp ) { + final Constant c = cp.getConstant(super.getIndex()); + final StringTokenizer tok = new StringTokenizer(cp.constantToString(c)); + return Const.getOpcodeName(super.getOpcode()) + " " + 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 + */ + @Override + public int consumeStack( final ConstantPoolGen cpg ) { + int sum; + if ((super.getOpcode() == Const.INVOKESTATIC) || (super.getOpcode() == Const.INVOKEDYNAMIC)) { + sum = 0; + } else { + sum = 1; // this reference + } + + final String signature = getSignature(cpg); + sum += Type.getArgumentTypesSize(signature); + 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 + */ + @Override + public int produceStack( final ConstantPoolGen cpg ) { + final String signature = getSignature(cpg); + return Type.getReturnTypeSize(signature); + } + + /** + * This overrides the deprecated version as we know here that the referenced class + * may legally be an array. + * + * @return name of the referenced class/interface + * @throws IllegalArgumentException if the referenced class is an array (this should not happen) + */ + @Override + public String getClassName( final ConstantPoolGen cpg ) { + final ConstantPool cp = cpg.getConstantPool(); + final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex()); + final String className = cp.getConstantString(cmr.getClassIndex(), Const.CONSTANT_Class); + return className.replace('/', '.'); + } + + /** @return return type of referenced method. + */ + @Override + public Type getType( final ConstantPoolGen cpg ) { + return getReturnType(cpg); + } + + + /** @return name of referenced method. + */ + public String getMethodName( final ConstantPoolGen cpg ) { + return getName(cpg); + } + + + /** @return return type of referenced method. + */ + public Type getReturnType( final ConstantPoolGen cpg ) { + return Type.getReturnType(getSignature(cpg)); + } + + + /** @return argument types of referenced method. + */ + public Type[] getArgumentTypes( final ConstantPoolGen cpg ) { + return Type.getArgumentTypes(getSignature(cpg)); + } + +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/JSR.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/JSR.java new file mode 100644 index 00000000..d1e83430 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/JSR.java @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * JSR - Jump to subroutine + * + * @version $Id: JSR.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class JSR extends JsrInstruction implements VariableLengthInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + JSR() { + } + + + public JSR(final InstructionHandle target) { + super(org.apache.bcel.Const.JSR, target); + } + + + /** + * Dump instruction as byte code to stream out. + * @param out Output stream + */ + @Override + public void dump( final DataOutputStream out ) throws IOException { + super.setIndex(getTargetOffset()); + if (super.getOpcode() == org.apache.bcel.Const.JSR) { + super.dump(out); + } else { // JSR_W + super.setIndex(getTargetOffset()); + out.writeByte(super.getOpcode()); + out.writeInt(super.getIndex()); + } + } + + + @Override + protected int updatePosition( final int offset, final int max_offset ) { + final int i = getTargetOffset(); // Depending on old position value + setPosition(getPosition() + offset); // Position may be shifted by preceding expansions + if (Math.abs(i) >= (Short.MAX_VALUE - max_offset)) { // to large for short (estimate) + super.setOpcode(org.apache.bcel.Const.JSR_W); + final short old_length = (short) super.getLength(); + super.setLength(5); + return super.getLength() - old_length; + } + 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackProducer(this); + v.visitVariableLengthInstruction(this); + v.visitBranchInstruction(this); + v.visitJsrInstruction(this); + v.visitJSR(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/JSR_W.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/JSR_W.java new file mode 100644 index 00000000..954d7c7f --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/JSR_W.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.util.ByteSequence; + +/** + * JSR_W - Jump to subroutine + * + * @version $Id: JSR_W.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class JSR_W extends JsrInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + JSR_W() { + } + + + public JSR_W(final InstructionHandle target) { + super(org.apache.bcel.Const.JSR_W, target); + super.setLength(5); + } + + + /** + * Dump instruction as byte code to stream out. + * @param out Output stream + */ + @Override + public void dump( final DataOutputStream out ) throws IOException { + super.setIndex(getTargetOffset()); + out.writeByte(super.getOpcode()); + out.writeInt(super.getIndex()); + } + + + /** + * Read needed data (e.g. index) from file. + */ + @Override + protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException { + super.setIndex(bytes.readInt()); + super.setLength(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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackProducer(this); + v.visitBranchInstruction(this); + v.visitJsrInstruction(this); + v.visitJSR_W(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/JsrInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/JsrInstruction.java old mode 100755 new mode 100644 similarity index 64% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/JsrInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/JsrInstruction.java index 56aea6be..409971f8 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/JsrInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/JsrInstruction.java @@ -1,79 +1,80 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Super class for JSR - Jump to subroutine - * - * @version $Id: JsrInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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. For this method to work, - * this JsrInstruction object must not be shared between - * multiple InstructionHandle objects! - * 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(); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Super class for JSR - Jump to subroutine + * + * @version $Id: JsrInstruction.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public abstract class JsrInstruction extends BranchInstruction implements UnconditionalBranch, + TypedInstruction, StackProducer { + + JsrInstruction(final short opcode, final InstructionHandle target) { + super(opcode, target); + } + + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + JsrInstruction() { + } + + + /** @return return address type + */ + @Override + public Type getType( final ConstantPoolGen cp ) { + return new ReturnaddressType(physicalSuccessor()); + } + + + /** + * Returns an InstructionHandle to the physical successor + * of this JsrInstruction. For this method to work, + * this JsrInstruction object must not be shared between + * multiple InstructionHandle objects! + * 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 = super.getTarget(); + // Rewind! + while (ih.getPrev() != null) { + ih = ih.getPrev(); + } + // Find the handle for "this" JsrInstruction object. + while (ih.getInstruction() != this) { + ih = ih.getNext(); + } + final 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/L2D.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/L2D.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/L2D.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/L2D.java index 9d1898ea..2b91cf23 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/L2D.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/L2D.java @@ -1,48 +1,49 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * L2D - Convert long to double - *
      Stack: ..., value.word1, value.word2 -> ..., result.word1, result.word2
      - * - * @version $Id: L2D.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class L2D extends ConversionInstruction { - - public L2D() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * L2D - Convert long to double + *
      Stack: ..., value.word1, value.word2 -> ..., result.word1, result.word2
      + * + * @version $Id: L2D.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class L2D extends ConversionInstruction { + + public L2D() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitL2D(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/L2F.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/L2F.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/L2F.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/L2F.java index 1a9c693e..b44f542c --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/L2F.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/L2F.java @@ -1,48 +1,49 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * L2F - Convert long to float - *
      Stack: ..., value.word1, value.word2 -> ..., result
      - * - * @version $Id: L2F.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class L2F extends ConversionInstruction { - - public L2F() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * L2F - Convert long to float + *
      Stack: ..., value.word1, value.word2 -> ..., result
      + * + * @version $Id: L2F.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public class L2F extends ConversionInstruction { + + public L2F() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitL2F(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/L2I.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/L2I.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/L2I.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/L2I.java index 5348c3c7..e1223b5b --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/L2I.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/L2I.java @@ -1,48 +1,49 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * L2I - Convert long to int - *
      Stack: ..., value.word1, value.word2 -> ..., result
      - * - * @version $Id: L2I.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class L2I extends ConversionInstruction { - - public L2I() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * L2I - Convert long to int + *
      Stack: ..., value.word1, value.word2 -> ..., result
      + * + * @version $Id: L2I.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public class L2I extends ConversionInstruction { + + public L2I() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitConversionInstruction(this); + v.visitL2I(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LADD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LADD.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LADD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LADD.java index 8dd94e22..d3dc450a --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LADD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LADD.java @@ -1,49 +1,50 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * LADD - Add longs - *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
      - * ..., result.word1, result.word2 - * - * @version $Id: LADD.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class LADD extends ArithmeticInstruction { - - public LADD() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * LADD - Add longs + *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
      + * ..., result.word1, result.word2 + * + * @version $Id: LADD.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class LADD extends ArithmeticInstruction { + + public LADD() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitLADD(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LALOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LALOAD.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LALOAD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LALOAD.java index a8b0b5ce..24a4e48c --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LALOAD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LALOAD.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * LALOAD - Load long from array - *
      Stack: ..., arrayref, index -> ..., value1, value2
      - * - * @version $Id: LALOAD.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class LALOAD extends ArrayInstruction implements StackProducer { - - /** Load long from array - */ - public LALOAD() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * LALOAD - Load long from array + *
      Stack: ..., arrayref, index -> ..., value1, value2
      + * + * @version $Id: LALOAD.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class LALOAD extends ArrayInstruction implements StackProducer { + + /** Load long from array + */ + public LALOAD() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackProducer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitLALOAD(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LAND.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LAND.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LAND.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LAND.java index 4ad83ee7..38183598 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LAND.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LAND.java @@ -1,49 +1,50 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * LAND - Bitwise AND longs - *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
      - * ..., result.word1, result.word2 - * - * @version $Id: LAND.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class LAND extends ArithmeticInstruction { - - public LAND() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * LAND - Bitwise AND longs + *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
      + * ..., result.word1, result.word2 + * + * @version $Id: LAND.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class LAND extends ArithmeticInstruction { + + public LAND() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitLAND(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LASTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LASTORE.java old mode 100755 new mode 100644 similarity index 61% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LASTORE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LASTORE.java index b1846f0b..821c71c4 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LASTORE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LASTORE.java @@ -1,50 +1,51 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * LASTORE - Store into long array - *
      Stack: ..., arrayref, index, value.word1, value.word2 -> ...
      - * - * @version $Id: LASTORE.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class LASTORE extends ArrayInstruction implements StackConsumer { - - /** Store long into array - */ - public LASTORE() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * LASTORE - Store into long array + *
      Stack: ..., arrayref, index, value.word1, value.word2 -> ...
      + * + * @version $Id: LASTORE.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class LASTORE extends ArrayInstruction implements StackConsumer { + + /** Store long into array + */ + public LASTORE() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitLASTORE(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LCMP.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LCMP.java old mode 100755 new mode 100644 similarity index 56% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LCMP.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LCMP.java index b63770b6..b8563695 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LCMP.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LCMP.java @@ -1,55 +1,57 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * LCMP - Compare longs: - *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
      - * ..., result <= -1, 0, 1> - * - * @version $Id: LCMP.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class LCMP extends Instruction implements TypedInstruction, StackProducer, StackConsumer { - - public LCMP() { - super(org.apache.bcel5_2_0.Constants.LCMP, (short) 1); - } - - - /** @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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitLCMP(this); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * LCMP - Compare longs: + *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -> ..., result <= -1, 0, 1>
      + * + * + * @version $Id: LCMP.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class LCMP extends Instruction implements TypedInstruction, StackProducer, StackConsumer { + + public LCMP() { + super(org.apache.bcel.Const.LCMP, (short) 1); + } + + + /** @return Type.LONG + */ + @Override + public Type getType( final 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitLCMP(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LCONST.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LCONST.java old mode 100755 new mode 100644 similarity index 55% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LCONST.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LCONST.java index e108c939..c2b5d2fa --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LCONST.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LCONST.java @@ -1,80 +1,83 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * LCONST - Push 0 or 1, other values cause an exception - * - *
      Stack: ... -> ..., 
      - * - * @version $Id: LCONST.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.Constants.LCONST_0, (short) 1); - if (l == 0) { - opcode = org.apache.bcel5_2_0.Constants.LCONST_0; - } else if (l == 1) { - opcode = org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * LCONST - Push 0 or 1, other values cause an exception + * + *
      Stack: ... -> ..., 
      + * + * @version $Id: LCONST.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class LCONST extends Instruction implements ConstantPushInstruction { + + private long value; + + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + LCONST() { + } + + + public LCONST(final long l) { + super(org.apache.bcel.Const.LCONST_0, (short) 1); + if (l == 0) { + super.setOpcode(org.apache.bcel.Const.LCONST_0); + } else if (l == 1) { + super.setOpcode(org.apache.bcel.Const.LCONST_1); + } else { + throw new ClassGenException("LCONST can be used only for 0 and 1: " + l); + } + value = l; + } + + + @Override + public Number getValue() { + return Long.valueOf(value); + } + + + /** @return Type.LONG + */ + @Override + public Type getType( final 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitPushInstruction(this); + v.visitStackProducer(this); + v.visitTypedInstruction(this); + v.visitConstantPushInstruction(this); + v.visitLCONST(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDC.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDC.java new file mode 100644 index 00000000..df574300 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDC.java @@ -0,0 +1,157 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.ExceptionConst; +import org.apache.bcel.util.ByteSequence; + +/** + * LDC - Push item from constant pool. + * + *
      Stack: ... -> ..., item
      + * + * @version $Id: LDC.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class LDC extends CPInstruction implements PushInstruction, ExceptionThrower { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + LDC() { + } + + + public LDC(final int index) { + super(org.apache.bcel.Const.LDC_W, index); + setSize(); + } + + + // Adjust to proper size + protected final void setSize() { + if (super.getIndex() <= org.apache.bcel.Const.MAX_BYTE) { // Fits in one byte? + super.setOpcode(org.apache.bcel.Const.LDC); + super.setLength(2); + } else { + super.setOpcode(org.apache.bcel.Const.LDC_W); + super.setLength(3); + } + } + + + /** + * Dump instruction as byte code to stream out. + * @param out Output stream + */ + @Override + public void dump( final DataOutputStream out ) throws IOException { + out.writeByte(super.getOpcode()); + if (super.getLength() == 2) { // TODO useless check? + out.writeByte(super.getIndex()); + } else { + out.writeShort(super.getIndex()); + } + } + + + /** + * Set the index to constant pool and adjust size. + */ + @Override + public final void setIndex( final int index ) { + super.setIndex(index); + setSize(); + } + + + /** + * Read needed data (e.g. index) from file. + */ + @Override + protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException { + super.setLength(2); + super.setIndex(bytes.readUnsignedByte()); + } + + + public Object getValue( final ConstantPoolGen cpg ) { + org.apache.bcel.classfile.Constant c = cpg.getConstantPool().getConstant(super.getIndex()); + switch (c.getTag()) { + case org.apache.bcel.Const.CONSTANT_String: + final 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.Const.CONSTANT_Float: + return new Float(((org.apache.bcel.classfile.ConstantFloat) c).getBytes()); + case org.apache.bcel.Const.CONSTANT_Integer: + return Integer.valueOf(((org.apache.bcel.classfile.ConstantInteger) c).getBytes()); + case org.apache.bcel.Const.CONSTANT_Class: + final int nameIndex = ((org.apache.bcel.classfile.ConstantClass) c).getNameIndex(); + c = cpg.getConstantPool().getConstant(nameIndex); + return new ObjectType(((org.apache.bcel.classfile.ConstantUtf8) c).getBytes()); + default: // Never reached + throw new RuntimeException("Unknown or invalid constant type at " + super.getIndex()); + } + } + + + @Override + public Type getType( final ConstantPoolGen cpg ) { + switch (cpg.getConstantPool().getConstant(super.getIndex()).getTag()) { + case org.apache.bcel.Const.CONSTANT_String: + return Type.STRING; + case org.apache.bcel.Const.CONSTANT_Float: + return Type.FLOAT; + case org.apache.bcel.Const.CONSTANT_Integer: + return Type.INT; + case org.apache.bcel.Const.CONSTANT_Class: + return Type.CLASS; + default: // Never reached + throw new RuntimeException("Unknown or invalid constant type at " + super.getIndex()); + } + } + + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackProducer(this); + v.visitPushInstruction(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitCPInstruction(this); + v.visitLDC(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDC2_W.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDC2_W.java new file mode 100644 index 00000000..f020ff32 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDC2_W.java @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * LDC2_W - Push long or double from constant pool + * + *
      Stack: ... -> ..., item.word1, item.word2
      + * + * @version $Id: LDC2_W.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class LDC2_W extends CPInstruction implements PushInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + LDC2_W() { + } + + + public LDC2_W(final int index) { + super(org.apache.bcel.Const.LDC2_W, index); + } + + + @Override + public Type getType( final ConstantPoolGen cpg ) { + switch (cpg.getConstantPool().getConstant(super.getIndex()).getTag()) { + case org.apache.bcel.Const.CONSTANT_Long: + return Type.LONG; + case org.apache.bcel.Const.CONSTANT_Double: + return Type.DOUBLE; + default: // Never reached + throw new RuntimeException("Unknown constant type " + super.getOpcode()); + } + } + + + public Number getValue( final ConstantPoolGen cpg ) { + final org.apache.bcel.classfile.Constant c = cpg.getConstantPool().getConstant(super.getIndex()); + switch (c.getTag()) { + case org.apache.bcel.Const.CONSTANT_Long: + return Long.valueOf(((org.apache.bcel.classfile.ConstantLong) c).getBytes()); + case org.apache.bcel.Const.CONSTANT_Double: + return new Double(((org.apache.bcel.classfile.ConstantDouble) c).getBytes()); + default: // Never reached + throw new RuntimeException("Unknown or invalid constant type at " + super.getIndex()); + } + } + + + /** + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackProducer(this); + v.visitPushInstruction(this); + v.visitTypedInstruction(this); + v.visitCPInstruction(this); + v.visitLDC2_W(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDC_W.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDC_W.java new file mode 100644 index 00000000..f0c0a836 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDC_W.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.IOException; + +import org.apache.bcel.util.ByteSequence; + +/** + * LDC_W - Push item from constant pool (wide index) + * + *
      Stack: ... -> ..., item.word1, item.word2
      + * + * @version $Id: LDC_W.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class LDC_W extends LDC { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + LDC_W() { + } + + + public LDC_W(final int index) { + super(index); + } + + + /** + * Read needed data (i.e., index) from file. + */ + @Override + protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException { + setIndex(bytes.readUnsignedShort()); + // Override just in case it has been changed + super.setOpcode(org.apache.bcel.Const.LDC_W); + super.setLength(3); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LDIV.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDIV.java old mode 100755 new mode 100644 similarity index 58% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LDIV.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDIV.java index 764fafd3..eddd4340 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LDIV.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDIV.java @@ -1,57 +1,61 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * LDIV - Divide longs - *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
      - * ..., result.word1, result.word2 - * - * @version $Id: LDIV.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class LDIV extends ArithmeticInstruction implements ExceptionThrower { - - public LDIV() { - super(org.apache.bcel5_2_0.Constants.LDIV); - } - - - public Class[] getExceptions() { - return new Class[] { - org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.ExceptionConst; + +/** + * LDIV - Divide longs + *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
      + * ..., result.word1, result.word2 + * + * @version $Id: LDIV.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public class LDIV extends ArithmeticInstruction implements ExceptionThrower { + + public LDIV() { + super(org.apache.bcel.Const.LDIV); + } + + + @Override + public Class[] getExceptions() { + return new Class[] { + ExceptionConst.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitLDIV(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LLOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LLOAD.java new file mode 100644 index 00000000..a84aaeaa --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LLOAD.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * LLOAD - Load long from local variable + *
      Stack ... -> ..., result.word1, result.word2
      + * + * @version $Id: LLOAD.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class LLOAD extends LoadInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + LLOAD() { + super(org.apache.bcel.Const.LLOAD, org.apache.bcel.Const.LLOAD_0); + } + + + public LLOAD(final int n) { + super(org.apache.bcel.Const.LLOAD, org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + super.accept(v); + v.visitLLOAD(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LMUL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LMUL.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LMUL.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LMUL.java index f596d9e4..6a642a89 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LMUL.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LMUL.java @@ -1,49 +1,50 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * LMUL - Multiply longs - *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
      - * ..., result.word1, result.word2 - * - * @version $Id: LMUL.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class LMUL extends ArithmeticInstruction { - - public LMUL() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * LMUL - Multiply longs + *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
      + * ..., result.word1, result.word2 + * + * @version $Id: LMUL.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class LMUL extends ArithmeticInstruction { + + public LMUL() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitLMUL(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LNEG.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LNEG.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LNEG.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LNEG.java index 280ef8e2..03327603 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LNEG.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LNEG.java @@ -1,48 +1,49 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * LNEG - Negate long - *
      Stack: ..., value.word1, value.word2 -> ..., result.word1, result.word2
      - * - * @version $Id: LNEG.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class LNEG extends ArithmeticInstruction { - - public LNEG() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * LNEG - Negate long + *
      Stack: ..., value.word1, value.word2 -> ..., result.word1, result.word2
      + * + * @version $Id: LNEG.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class LNEG extends ArithmeticInstruction { + + public LNEG() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitLNEG(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LOOKUPSWITCH.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LOOKUPSWITCH.java new file mode 100644 index 00000000..b34db911 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LOOKUPSWITCH.java @@ -0,0 +1,104 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.util.ByteSequence; + +/** + * LOOKUPSWITCH - Switch with unordered set of values + * + * @version $Id: LOOKUPSWITCH.java 1812166 2017-10-13 23:48:11Z ggregory $ + * @see SWITCH + */ +public class LOOKUPSWITCH extends Select { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + LOOKUPSWITCH() { + } + + + public LOOKUPSWITCH(final int[] match, final InstructionHandle[] targets, final InstructionHandle defaultTarget) { + super(org.apache.bcel.Const.LOOKUPSWITCH, match, targets, defaultTarget); + /* alignment remainder assumed 0 here, until dump time. */ + final short _length = (short) (9 + getMatch_length() * 8); + super.setLength(_length); + setFixed_length(_length); + } + + + /** + * Dump instruction as byte code to stream out. + * @param out Output stream + */ + @Override + public void dump( final DataOutputStream out ) throws IOException { + super.dump(out); + final int _match_length = getMatch_length(); + out.writeInt(_match_length); // npairs + for (int i = 0; i < _match_length; i++) { + out.writeInt(super.getMatch(i)); // match-offset pairs + out.writeInt(setIndices(i, getTargetOffset(super.getTarget(i)))); + } + } + + + /** + * Read needed data (e.g. index) from file. + */ + @Override + protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException { + super.initFromFile(bytes, wide); // reads padding + final int _match_length = bytes.readInt(); + setMatch_length(_match_length); + final short _fixed_length = (short) (9 + _match_length * 8); + setFixed_length(_fixed_length); + final short _length = (short) (_match_length + super.getPadding()); + super.setLength(_length); + super.setMatches(new int[_match_length]); + super.setIndices(new int[_match_length]); + super.setTargets(new InstructionHandle[_match_length]); + for (int i = 0; i < _match_length; i++) { + super.setMatch(i, bytes.readInt()); + super.setIndices(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 + */ + @Override + public void accept( final Visitor v ) { + v.visitVariableLengthInstruction(this); + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitSelect(this); + v.visitLOOKUPSWITCH(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LOR.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LOR.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LOR.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LOR.java index e0210b68..876aa4b6 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LOR.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LOR.java @@ -1,48 +1,49 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * LOR - Bitwise OR long - *
      Stack: ..., value1, value2 -> ..., result
      - * - * @version $Id: LOR.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class LOR extends ArithmeticInstruction { - - public LOR() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * LOR - Bitwise OR long + *
      Stack: ..., value1, value2 -> ..., result
      + * + * @version $Id: LOR.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class LOR extends ArithmeticInstruction { + + public LOR() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitLOR(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LREM.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LREM.java old mode 100755 new mode 100644 similarity index 57% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LREM.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LREM.java index fd332d64..513d120c --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LREM.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LREM.java @@ -1,56 +1,60 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * LREM - Remainder of long - *
      Stack: ..., value1, value2 -> result
      - * - * @version $Id: LREM.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class LREM extends ArithmeticInstruction implements ExceptionThrower { - - public LREM() { - super(org.apache.bcel5_2_0.Constants.LREM); - } - - - public Class[] getExceptions() { - return new Class[] { - org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.ExceptionConst; + +/** + * LREM - Remainder of long + *
      Stack: ..., value1, value2 -> result
      + * + * @version $Id: LREM.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public class LREM extends ArithmeticInstruction implements ExceptionThrower { + + public LREM() { + super(org.apache.bcel.Const.LREM); + } + + + @Override + public Class[] getExceptions() { + return new Class[] { + ExceptionConst.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitLREM(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LRETURN.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LRETURN.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LRETURN.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LRETURN.java index 97a4787c..1708c5dd --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LRETURN.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LRETURN.java @@ -1,48 +1,49 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * LRETURN - Return long from method - *
      Stack: ..., value.word1, value.word2 -> <empty>
      - * - * @version $Id: LRETURN.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class LRETURN extends ReturnInstruction { - - public LRETURN() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * LRETURN - Return long from method + *
      Stack: ..., value.word1, value.word2 -> <empty>
      + * + * @version $Id: LRETURN.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class LRETURN extends ReturnInstruction { + + public LRETURN() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackConsumer(this); + v.visitReturnInstruction(this); + v.visitLRETURN(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LSHL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LSHL.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LSHL.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LSHL.java index cd684fe2..5a853a3d --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LSHL.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LSHL.java @@ -1,48 +1,49 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * LSHL - Arithmetic shift left long - *
      Stack: ..., value1.word1, value1.word2, value2 -> ..., result.word1, result.word2
      - * - * @version $Id: LSHL.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class LSHL extends ArithmeticInstruction { - - public LSHL() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * LSHL - Arithmetic shift left long + *
      Stack: ..., value1.word1, value1.word2, value2 -> ..., result.word1, result.word2
      + * + * @version $Id: LSHL.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class LSHL extends ArithmeticInstruction { + + public LSHL() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitLSHL(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LSHR.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LSHR.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LSHR.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LSHR.java index 406d57cc..035136eb --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LSHR.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LSHR.java @@ -1,48 +1,49 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * LSHR - Arithmetic shift right long - *
      Stack: ..., value1.word1, value1.word2, value2 -> ..., result.word1, result.word2
      - * - * @version $Id: LSHR.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class LSHR extends ArithmeticInstruction { - - public LSHR() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * LSHR - Arithmetic shift right long + *
      Stack: ..., value1.word1, value1.word2, value2 -> ..., result.word1, result.word2
      + * + * @version $Id: LSHR.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class LSHR extends ArithmeticInstruction { + + public LSHR() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitLSHR(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LSTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LSTORE.java new file mode 100644 index 00000000..03844774 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LSTORE.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * LSTORE - Store long into local variable + *
      Stack: ..., value.word1, value.word2 -> ... 
      + * + * @version $Id: LSTORE.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class LSTORE extends StoreInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + LSTORE() { + super(org.apache.bcel.Const.LSTORE, org.apache.bcel.Const.LSTORE_0); + } + + + public LSTORE(final int n) { + super(org.apache.bcel.Const.LSTORE, org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + super.accept(v); + v.visitLSTORE(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LSUB.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LSUB.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LSUB.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LSUB.java index ee622bcc..9303cfc3 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LSUB.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LSUB.java @@ -1,49 +1,50 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * LSUB - Substract longs - *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
      - * ..., result.word1, result.word2 - * - * @version $Id: LSUB.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class LSUB extends ArithmeticInstruction { - - public LSUB() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * LSUB - Substract longs + *
      Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
      + * ..., result.word1, result.word2 + * + * @version $Id: LSUB.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class LSUB extends ArithmeticInstruction { + + public LSUB() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitLSUB(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LUSHR.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LUSHR.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LUSHR.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LUSHR.java index e8332b1c..bc33a52b --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LUSHR.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LUSHR.java @@ -1,48 +1,49 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * LUSHR - Logical shift right long - *
      Stack: ..., value1, value2 -> ..., result
      - * - * @version $Id: LUSHR.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class LUSHR extends ArithmeticInstruction { - - public LUSHR() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * LUSHR - Logical shift right long + *
      Stack: ..., value1, value2 -> ..., result
      + * + * @version $Id: LUSHR.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class LUSHR extends ArithmeticInstruction { + + public LUSHR() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitLUSHR(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LXOR.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LXOR.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LXOR.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LXOR.java index ca30a032..a614d300 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LXOR.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LXOR.java @@ -1,48 +1,49 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * LXOR - Bitwise XOR long - *
      Stack: ..., value1, value2 -> ..., result
      - * - * @version $Id: LXOR.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class LXOR extends ArithmeticInstruction { - - public LXOR() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * LXOR - Bitwise XOR long + *
      Stack: ..., value1, value2 -> ..., result
      + * + * @version $Id: LXOR.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class LXOR extends ArithmeticInstruction { + + public LXOR() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitArithmeticInstruction(this); + v.visitLXOR(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LineNumberGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LineNumberGen.java old mode 100755 new mode 100644 similarity index 56% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LineNumberGen.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LineNumberGen.java index 0acd7516..e9c325c7 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LineNumberGen.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LineNumberGen.java @@ -1,108 +1,112 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.classfile.LineNumber; - -/** - * 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: LineNumberGen.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @see LineNumber - * @see MethodGen - */ -public class LineNumberGen implements InstructionTargeter, Cloneable, java.io.Serializable { - - private InstructionHandle ih; - private int src_line; - - - /** - * Create a line number. - * - * @param ih instruction handle to reference - */ - 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; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.classfile.LineNumber; + +/** + * 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: LineNumberGen.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @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 + */ + public LineNumberGen(final InstructionHandle ih, final int src_line) { + setInstruction(ih); + setSourceLine(src_line); + } + + + /** + * @return true, if ih is target of this line number + */ + @Override + public boolean containsTarget( final InstructionHandle ih ) { + return this.ih == ih; + } + + + /** + * @param old_ih old target + * @param new_ih new target + */ + @Override + public void updateTarget( final InstructionHandle old_ih, final InstructionHandle new_ih ) { + if (old_ih != ih) { + throw new ClassGenException("Not targeting " + old_ih + ", but " + ih + "}"); + } + 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( final InstructionHandle ih ) { // TODO could be package-protected? + if (ih == null) { + throw new NullPointerException("InstructionHandle may not be null"); + } + BranchInstruction.notifyTarget(this.ih, ih, this); + this.ih = ih; + } + + + @Override + public Object clone() { + try { + return super.clone(); + } catch (final CloneNotSupportedException e) { + throw new Error("Clone Not Supported"); // never happens + } + } + + + public InstructionHandle getInstruction() { + return ih; + } + + + public void setSourceLine( final int src_line ) { // TODO could be package-protected? + this.src_line = src_line; + } + + + public int getSourceLine() { + return src_line; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LoadClass.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LoadClass.java old mode 100755 new mode 100644 similarity index 64% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LoadClass.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LoadClass.java index b483a4a0..a034be26 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LoadClass.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LoadClass.java @@ -1,50 +1,50 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Denotes that an instruction may start the process of loading and resolving - * the referenced class in the Virtual Machine. - * - * @version $Id: LoadClass.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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, null is returned. - * An example for this is an ANEWARRAY instruction that creates - * an int[][]. - * @see #getLoadClassType(ConstantPoolGen) - */ - public Type getType( ConstantPoolGen cpg ); -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Denotes that an instruction may start the process of loading and resolving + * the referenced class in the Virtual Machine. + * + * @version $Id: LoadClass.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +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 + */ + 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, null is returned. + * An example for this is an ANEWARRAY instruction that creates + * an int[][]. + * @see #getLoadClassType(ConstantPoolGen) + */ + Type getType( ConstantPoolGen cpg ); +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LoadInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LoadInstruction.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LoadInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LoadInstruction.java index ffa11303..aaf5a2f6 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LoadInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LoadInstruction.java @@ -1,63 +1,64 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Denotes an unparameterized instruction to load a value from a local - * variable, e.g. ILOAD. - * - * @version $Id: LoadInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Denotes an unparameterized instruction to load a value from a local + * variable, e.g. ILOAD. + * + * @version $Id: LoadInstruction.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public abstract class LoadInstruction extends LocalVariableInstruction implements PushInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + * tag and length are defined in readInstruction and initFromFile, respectively. + */ + LoadInstruction(final short canon_tag, final 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(final short opcode, final short c_tag, final 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackProducer(this); + v.visitPushInstruction(this); + v.visitTypedInstruction(this); + v.visitLocalVariableInstruction(this); + v.visitLoadInstruction(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LocalVariableGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LocalVariableGen.java new file mode 100644 index 00000000..8b15eb59 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LocalVariableGen.java @@ -0,0 +1,263 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.Const; +import org.apache.bcel.classfile.LocalVariable; + +/** + * 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: LocalVariableGen.java 1812325 2017-10-16 20:34:31Z ggregory $ + * @see LocalVariable + * @see MethodGen + */ +public class LocalVariableGen implements InstructionTargeter, NamedAndTyped, Cloneable { + + private int index; + private String name; + private Type type; + private InstructionHandle start; + private InstructionHandle end; + private int orig_index; // never changes; used to match up with LocalVariableTypeTable entries + private boolean live_to_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(final int index, final String name, final Type type, final InstructionHandle start, + final InstructionHandle end) { + if ((index < 0) || (index > Const.MAX_SHORT)) { + throw new ClassGenException("Invalid index index: " + index); + } + this.name = name; + this.type = type; + this.index = index; + setStart(start); + setEnd(end); + this.orig_index = index; + this.live_to_end = end == null; + } + + + /** + * 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) + * @param orig_index index of local variable prior to any changes to index + */ + public LocalVariableGen(final int index, final String name, final Type type, final InstructionHandle start, + final InstructionHandle end, final int orig_index) { + this(index, name, type, start, end); + this.orig_index = orig_index; + } + + + /** + * 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. + * + * Note that due to the conversion from byte code offset to InstructionHandle, + * it is impossible to tell the difference between a live range that ends BEFORE + * the last insturction of the method or a live range that ends AFTER the last + * instruction of the method. Hence the live_to_end flag to differentiate + * between these two cases. + * + * @param cp constant pool + */ + public LocalVariable getLocalVariable( final ConstantPoolGen cp ) { + int start_pc = 0; + int length = 0; + if ((start != null) && (end != null)) { + start_pc = start.getPosition(); + length = end.getPosition() - start_pc; + if ((end.getNext() == null) && live_to_end) { + length += end.getInstruction().getLength(); + } + } + final int name_index = cp.addUtf8(name); + final int signature_index = cp.addUtf8(type.getSignature()); + return new LocalVariable(start_pc, length, name_index, signature_index, index, cp + .getConstantPool(), orig_index); + } + + + public void setIndex( final int index ) { + this.index = index; + } + + + public int getIndex() { + return index; + } + + + public int getOrigIndex() { + return orig_index; + } + + + public void setLiveToEnd( final boolean live_to_end) { + this.live_to_end = live_to_end; + } + + + public boolean getLiveToEnd() { + return live_to_end; + } + + + @Override + public void setName( final String name ) { + this.name = name; + } + + + @Override + public String getName() { + return name; + } + + + @Override + public void setType( final Type type ) { + this.type = type; + } + + + @Override + public Type getType() { + return type; + } + + + public InstructionHandle getStart() { + return start; + } + + + public InstructionHandle getEnd() { + return end; + } + + + public void setStart( final InstructionHandle start ) { // TODO could be package-protected? + BranchInstruction.notifyTarget(this.start, start, this); + this.start = start; + } + + + public void setEnd( final InstructionHandle end ) { // TODO could be package-protected? + BranchInstruction.notifyTarget(this.end, end, this); + this.end = end; + } + + + /** + * @param old_ih old target, either start or end + * @param new_ih new target + */ + @Override + public void updateTarget( final InstructionHandle old_ih, final 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 + + "}"); + } + } + + /** + * Clear the references from and to this variable when it's removed. + */ + void dispose() { + setStart(null); + setEnd(null); + } + + /** + * @return true, if ih is target of this variable + */ + @Override + public boolean containsTarget( final InstructionHandle ih ) { + return (start == ih) || (end == ih); + } + + + @Override + public int hashCode() { + // If the user changes the name or type, problems with the targeter hashmap will occur. + // Note: index cannot be part of hash as it may be changed by the user. + return name.hashCode() ^ type.hashCode(); + } + + + /** + * We consider to local variables to be equal, if the use the same index and + * are valid in the same range. + */ + @Override + public boolean equals( final Object o ) { + if (!(o instanceof LocalVariableGen)) { + return false; + } + final LocalVariableGen l = (LocalVariableGen) o; + return (l.index == index) && (l.start == start) && (l.end == end); + } + + + @Override + public String toString() { + return "LocalVariableGen(" + name + ", " + type + ", " + start + ", " + end + ")"; + } + + + @Override + public Object clone() { + try { + return super.clone(); + } catch (final CloneNotSupportedException e) { + throw new Error("Clone Not Supported"); // never happens + } + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LocalVariableInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LocalVariableInstruction.java new file mode 100644 index 00000000..4f407f79 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LocalVariableInstruction.java @@ -0,0 +1,232 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.Const; +import org.apache.bcel.util.ByteSequence; + +/** + * Abstract super class for instructions dealing with local variables. + * + * @version $Id: LocalVariableInstruction.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public abstract class LocalVariableInstruction extends Instruction implements TypedInstruction, + IndexedInstruction { + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + 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 boolean wide() { + return n > Const.MAX_BYTE; + } + + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + * tag and length are defined in readInstruction and initFromFile, respectively. + */ + LocalVariableInstruction(final short canon_tag, final short c_tag) { + super(); + this.canon_tag = canon_tag; + this.c_tag = c_tag; + } + + + /** + * Empty constructor needed for 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(final short opcode, final short c_tag, final 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 + */ + @Override + public void dump( final DataOutputStream out ) throws IOException { + if (wide()) { + out.writeByte(Const.WIDE); + } + out.writeByte(super.getOpcode()); + if (super.getLength() > 1) { // Otherwise ILOAD_n, instruction, e.g. + if (wide()) { + out.writeShort(n); + } else { + out.writeByte(n); + } + } + } + + + /** + * Long output format: + * + * <name of opcode> "["<opcode number>"]" + * "("<length of instruction>")" "<"< local variable index>">" + * + * @param verbose long/short format switch + * @return mnemonic for instruction + */ + @Override + public String toString( final boolean verbose ) { + final short _opcode = super.getOpcode(); + if (((_opcode >= Const.ILOAD_0) && (_opcode <= Const.ALOAD_3)) + || ((_opcode >= Const.ISTORE_0) && (_opcode <= Const.ASTORE_3))) { + return super.toString(verbose); + } + return super.toString(verbose) + " " + n; + } + + + /** + * Read needed data (e.g. index) from file. + *
      +     * (ILOAD <= tag <= ALOAD_3) || (ISTORE <= tag <= ASTORE_3)
      +     * 
      + */ + @Override + protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException { + if (wide) { + n = bytes.readUnsignedShort(); + super.setLength(4); + } else { + final short _opcode = super.getOpcode(); + if (((_opcode >= Const.ILOAD) && (_opcode <= Const.ALOAD)) + || ((_opcode >= Const.ISTORE) && (_opcode <= Const.ASTORE))) { + n = bytes.readUnsignedByte(); + super.setLength(2); + } else if (_opcode <= Const.ALOAD_3) { // compact load instruction such as ILOAD_2 + n = (_opcode - Const.ILOAD_0) % 4; + super.setLength(1); + } else { // Assert ISTORE_0 <= tag <= ASTORE_3 + n = (_opcode - Const.ISTORE_0) % 4; + super.setLength(1); + } + } + } + + + /** + * @return local variable index (n) referred by this instruction. + */ + @Override + public final int getIndex() { + return n; + } + + + /** + * Set the local variable index. + * also updates opcode and length + * TODO Why? + * @see #setIndexOnly(int) + */ + @Override + public void setIndex( final int n ) { // TODO could be package-protected? + if ((n < 0) || (n > Const.MAX_SHORT)) { + throw new ClassGenException("Illegal value: " + n); + } + this.n = n; + // Cannot be < 0 as this is checked above + if (n <= 3) { // Use more compact instruction xLOAD_n + super.setOpcode((short) (c_tag + n)); + super.setLength(1); + } else { + super.setOpcode(canon_tag); + if (wide()) { + super.setLength(4); + } else { + super.setLength(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 + */ + @Override + public Type getType( final ConstantPoolGen cp ) { + switch (canon_tag) { + case Const.ILOAD: + case Const.ISTORE: + return Type.INT; + case Const.LLOAD: + case Const.LSTORE: + return Type.LONG; + case Const.DLOAD: + case Const.DSTORE: + return Type.DOUBLE; + case Const.FLOAD: + case Const.FSTORE: + return Type.FLOAT; + case Const.ALOAD: + case Const.ASTORE: + return Type.OBJECT; + default: + throw new ClassGenException("Oops: unknown case in switch" + canon_tag); + } + } + + /** + * Sets the index of the referenced variable (n) only + * @since 6.0 + * @see #setIndex(int) + */ + final void setIndexOnly(final int n) { + this.n = n; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/MONITORENTER.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MONITORENTER.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/MONITORENTER.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MONITORENTER.java index e62a13f9..099a065c --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/MONITORENTER.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MONITORENTER.java @@ -1,53 +1,57 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * MONITORENTER - Enter monitor for object - *
      Stack: ..., objectref -> ...
      - * - * @version $Id: MONITORENTER.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class MONITORENTER extends Instruction implements ExceptionThrower, StackConsumer { - - public MONITORENTER() { - super(org.apache.bcel5_2_0.Constants.MONITORENTER, (short) 1); - } - - - public Class[] getExceptions() { - return new Class[] { - org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.ExceptionConst; + +/** + * MONITORENTER - Enter monitor for object + *
      Stack: ..., objectref -> ...
      + * + * @version $Id: MONITORENTER.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class MONITORENTER extends Instruction implements ExceptionThrower, StackConsumer { + + public MONITORENTER() { + super(org.apache.bcel.Const.MONITORENTER, (short) 1); + } + + + @Override + public Class[] getExceptions() { + return new Class[] { + ExceptionConst.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitExceptionThrower(this); + v.visitStackConsumer(this); + v.visitMONITORENTER(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/MONITOREXIT.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MONITOREXIT.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/MONITOREXIT.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MONITOREXIT.java index d9cb66a3..67b92872 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/MONITOREXIT.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MONITOREXIT.java @@ -1,53 +1,57 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * MONITOREXIT - Exit monitor for object - *
      Stack: ..., objectref -> ...
      - * - * @version $Id: MONITOREXIT.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class MONITOREXIT extends Instruction implements ExceptionThrower, StackConsumer { - - public MONITOREXIT() { - super(org.apache.bcel5_2_0.Constants.MONITOREXIT, (short) 1); - } - - - public Class[] getExceptions() { - return new Class[] { - org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.ExceptionConst; + +/** + * MONITOREXIT - Exit monitor for object + *
      Stack: ..., objectref -> ...
      + * + * @version $Id: MONITOREXIT.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class MONITOREXIT extends Instruction implements ExceptionThrower, StackConsumer { + + public MONITOREXIT() { + super(org.apache.bcel.Const.MONITOREXIT, (short) 1); + } + + + @Override + public Class[] getExceptions() { + return new Class[] { + ExceptionConst.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitExceptionThrower(this); + v.visitStackConsumer(this); + v.visitMONITOREXIT(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/MULTIANEWARRAY.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MULTIANEWARRAY.java old mode 100755 new mode 100644 similarity index 55% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/MULTIANEWARRAY.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MULTIANEWARRAY.java index e830db8f..6b91efe2 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/MULTIANEWARRAY.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MULTIANEWARRAY.java @@ -1,147 +1,152 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.ExceptionConstants; -import org.apache.bcel5_2_0.classfile.ConstantPool; -import org.apache.bcel5_2_0.util.ByteSequence; - -/** - * MULTIANEWARRAY - Create new mutidimensional array of references - *
      Stack: ..., count1, [count2, ...] -> ..., arrayref
      - * - * @version $Id: MULTIANEWARRAY.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.ExceptionConst; +import org.apache.bcel.classfile.ConstantPool; +import org.apache.bcel.util.ByteSequence; + +/** + * MULTIANEWARRAY - Create new mutidimensional array of references + *
      Stack: ..., count1, [count2, ...] -> ..., arrayref
      + * + * @version $Id: MULTIANEWARRAY.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class MULTIANEWARRAY extends CPInstruction implements LoadClass, AllocationInstruction, + ExceptionThrower { + + private short dimensions; + + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + MULTIANEWARRAY() { + } + + + public MULTIANEWARRAY(final int index, final short dimensions) { + super(org.apache.bcel.Const.MULTIANEWARRAY, index); + if (dimensions < 1) { + throw new ClassGenException("Invalid dimensions value: " + dimensions); + } + this.dimensions = dimensions; + super.setLength(4); + } + + + /** + * Dump instruction as byte code to stream out. + * @param out Output stream + */ + @Override + public void dump( final DataOutputStream out ) throws IOException { + out.writeByte(super.getOpcode()); + out.writeShort(super.getIndex()); + out.writeByte(dimensions); + } + + + /** + * Read needed data (i.e., no. dimension) from file. + */ + @Override + protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException { + super.initFromFile(bytes, wide); + dimensions = bytes.readByte(); + super.setLength(4); + } + + + /** + * @return number of dimensions to be created + */ + public final short getDimensions() { + return dimensions; + } + + + /** + * @return mnemonic for instruction + */ + @Override + public String toString( final boolean verbose ) { + return super.toString(verbose) + " " + super.getIndex() + " " + dimensions; + } + + + /** + * @return mnemonic for instruction with symbolic references resolved + */ + @Override + public String toString( final 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 + */ + @Override + public int consumeStack( final ConstantPoolGen cpg ) { + return dimensions; + } + + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_CLASS_AND_INTERFACE_RESOLUTION, + ExceptionConst.ILLEGAL_ACCESS_ERROR, + ExceptionConst.NEGATIVE_ARRAY_SIZE_EXCEPTION); + } + + + @Override + public ObjectType getLoadClassType( final 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitLoadClass(this); + v.visitAllocationInstruction(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitCPInstruction(this); + v.visitMULTIANEWARRAY(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MethodGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MethodGen.java new file mode 100644 index 00000000..a0e0b54f --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MethodGen.java @@ -0,0 +1,1280 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.Hashtable; +import java.util.List; +import java.util.Stack; + +import org.apache.bcel.Const; +import org.apache.bcel.classfile.AnnotationEntry; +import org.apache.bcel.classfile.Annotations; +import org.apache.bcel.classfile.Attribute; +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.CodeException; +import org.apache.bcel.classfile.ExceptionTable; +import org.apache.bcel.classfile.LineNumber; +import org.apache.bcel.classfile.LineNumberTable; +import org.apache.bcel.classfile.LocalVariable; +import org.apache.bcel.classfile.LocalVariableTable; +import org.apache.bcel.classfile.LocalVariableTypeTable; +import org.apache.bcel.classfile.Method; +import org.apache.bcel.classfile.ParameterAnnotationEntry; +import org.apache.bcel.classfile.ParameterAnnotations; +import org.apache.bcel.classfile.RuntimeVisibleParameterAnnotations; +import org.apache.bcel.classfile.Utility; +import org.apache.bcel.util.BCELComparator; + +/** + * 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: MethodGen.java 1812710 2017-10-20 06:24:15Z kinow $ + * @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 LocalVariableTypeTable local_variable_type_table = null; + private final List variable_vec = new ArrayList<>(); + private final List line_number_vec = new ArrayList<>(); + private final List exception_vec = new ArrayList<>(); + private final List throws_vec = new ArrayList<>(); + private final List code_attrs_vec = new ArrayList<>(); + + private List[] param_annotations; // Array of lists containing AnnotationGen objects + private boolean hasParameterAnnotations = false; + private boolean haveUnpackedParameterAnnotations = false; + + private static BCELComparator bcelComparator = new BCELComparator() { + + @Override + public boolean equals( final Object o1, final Object o2 ) { + final MethodGen THIS = (MethodGen) o1; + final MethodGen THAT = (MethodGen) o2; + return THIS.getName().equals(THAT.getName()) + && THIS.getSignature().equals(THAT.getSignature()); + } + + + @Override + public int hashCode( final Object o ) { + final MethodGen THIS = (MethodGen) o; + return THIS.getSignature().hashCode() ^ THIS.getName().hashCode(); + } + }; + + + /** + * 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(final int access_flags, final Type return_type, final Type[] arg_types, String[] arg_names, + final String method_name, final String class_name, final InstructionList il, final ConstantPoolGen cp) { + super(access_flags); + setType(return_type); + setArgumentTypes(arg_types); + setArgumentNames(arg_names); + setName(method_name); + setClassName(class_name); + setInstructionList(il); + setConstantPool(cp); + final boolean abstract_ = isAbstract() || isNative(); + InstructionHandle start = null; + final InstructionHandle end = null; + if (!abstract_) { + start = il.getStart(); + // end == null => live to end of method + /* Add local variables, namely the implicit `this' and the arguments + */ + if (!isStatic() && (class_name != null)) { // Instance method -> `this' is local var 0 + addLocalVariable("this", ObjectType.getInstance(class_name), start, end); + } + } + if (arg_types != null) { + final int size = arg_types.length; + for (final Type arg_type : arg_types) { + if (Type.VOID == arg_type) { + throw new ClassGenException("'void' is an illegal argument type for a method"); + } + } + 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); + } + if (!abstract_) { + 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(final Method m, final String class_name, final ConstantPoolGen cp) { + this(m.getAccessFlags(), Type.getReturnType(m.getSignature()), Type.getArgumentTypes(m + .getSignature()), null /* may be overridden anyway */ + , m.getName(), class_name, + ((m.getAccessFlags() & (Const.ACC_ABSTRACT | Const.ACC_NATIVE)) == 0) + ? new InstructionList(m.getCode().getCode()) + : null, cp); + final Attribute[] attributes = m.getAttributes(); + for (final Attribute attribute : attributes) { + Attribute a = attribute; + if (a instanceof Code) { + final Code c = (Code) a; + setMaxStack(c.getMaxStack()); + setMaxLocals(c.getMaxLocals()); + final CodeException[] ces = c.getExceptionTable(); + if (ces != null) { + for (final CodeException ce : ces) { + final int type = ce.getCatchType(); + ObjectType c_type = null; + if (type > 0) { + final String cen = m.getConstantPool().getConstantString(type, + Const.CONSTANT_Class); + c_type = ObjectType.getInstance(cen); + } + final int end_pc = ce.getEndPC(); + final 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); + } + } + final Attribute[] c_attributes = c.getAttributes(); + for (final Attribute c_attribute : c_attributes) { + a = c_attribute; + if (a instanceof LineNumberTable) { + final LineNumber[] ln = ((LineNumberTable) a).getLineNumberTable(); + for (final LineNumber l : ln) { + final InstructionHandle ih = il.findHandle(l.getStartPC()); + if (ih != null) { + addLineNumber(ih, l.getLineNumber()); + } + } + } else if (a instanceof LocalVariableTable) { + updateLocalVariableTable((LocalVariableTable) a); + } else if (a instanceof LocalVariableTypeTable) { + this.local_variable_type_table = (LocalVariableTypeTable) a.copy(cp.getConstantPool()); + } else { + addCodeAttribute(a); + } + } + } else if (a instanceof ExceptionTable) { + final String[] names = ((ExceptionTable) a).getExceptionNames(); + for (final String name2 : names) { + addException(name2); + } + } else if (a instanceof Annotations) { + final Annotations runtimeAnnotations = (Annotations) a; + final AnnotationEntry[] aes = runtimeAnnotations.getAnnotationEntries(); + for (final AnnotationEntry element : aes) { + addAnnotationEntry(new AnnotationEntryGen(element, cp, false)); + } + } 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 + * @param orig_index the index of the local variable prior to any modifications + * @return new local variable object + * @see LocalVariable + */ + public LocalVariableGen addLocalVariable( final String name, final Type type, final int slot, + final InstructionHandle start, final InstructionHandle end, final int orig_index ) { + final byte t = type.getType(); + if (t != Const.T_ADDRESS) { + final int add = type.getSize(); + if (slot + add > max_locals) { + max_locals = slot + add; + } + final LocalVariableGen l = new LocalVariableGen(slot, name, type, start, end, orig_index); + int i; + if ((i = variable_vec.indexOf(l)) >= 0) { + variable_vec.set(i, l); + } else { + variable_vec.add(l); + } + return l; + } + throw new IllegalArgumentException("Can not use " + type + + " as type for local variable"); + } + + + /** + * 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( final String name, final Type type, final int slot, + final InstructionHandle start, final InstructionHandle end ) { + return addLocalVariable(name, type, slot, start, end, slot); + } + + /** + * 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( final String name, final Type type, final InstructionHandle start, + final 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( final LocalVariableGen l ) { + l.dispose(); + variable_vec.remove(l); + } + + + /** + * Remove all local variables. + */ + public void removeLocalVariables() { + for (final LocalVariableGen lv : variable_vec) { + lv.dispose(); + } + variable_vec.clear(); + } + + + /* + * 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() { + final int size = variable_vec.size(); + final LocalVariableGen[] lg = new LocalVariableGen[size]; + variable_vec.toArray(lg); + for (int i = 0; i < size; i++) { + if ((lg[i].getStart() == null) && (il != null)) { + lg[i].setStart(il.getStart()); + } + if ((lg[i].getEnd() == null) && (il != null)) { + lg[i].setEnd(il.getEnd()); + } + } + if (size > 1) { + Arrays.sort(lg, new Comparator() { + @Override + public int compare(final LocalVariableGen o1, final LocalVariableGen o2) { + return o1.getIndex() - o2.getIndex(); + } + }); + } + return lg; + } + + + /** + * @return `LocalVariableTable' attribute of all the local variables of this method. + */ + public LocalVariableTable getLocalVariableTable( final ConstantPoolGen cp ) { + final LocalVariableGen[] lg = getLocalVariables(); + final int size = lg.length; + final 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()); + } + + /** + * @return `LocalVariableTypeTable' attribute of this method. + */ + public LocalVariableTypeTable getLocalVariableTypeTable() { + return local_variable_type_table; + } + + /** + * 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( final InstructionHandle ih, final int src_line ) { + final LineNumberGen l = new LineNumberGen(ih, src_line); + line_number_vec.add(l); + return l; + } + + + /** + * Remove a line number. + */ + public void removeLineNumber( final 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() { + final 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( final ConstantPoolGen cp ) { + final int size = line_number_vec.size(); + final LineNumber[] ln = new LineNumber[size]; + for (int i = 0; i < size; i++) { + ln[i] = line_number_vec.get(i).getLineNumber(); + } + 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 class type of handled exception or null if any + * exception is handled + * @return new exception handler object + */ + public CodeExceptionGen addExceptionHandler( final InstructionHandle start_pc, + final InstructionHandle end_pc, final InstructionHandle handler_pc, final ObjectType catch_type ) { + if ((start_pc == null) || (end_pc == null) || (handler_pc == null)) { + throw new ClassGenException("Exception handler target is null instruction"); + } + final 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( final 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() { + final CodeExceptionGen[] cg = new CodeExceptionGen[exception_vec.size()]; + exception_vec.toArray(cg); + return cg; + } + + + /** + * @return code exceptions for `Code' attribute + */ + private CodeException[] getCodeExceptions() { + final int size = exception_vec.size(); + final CodeException[] c_exc = new CodeException[size]; + for (int i = 0; i < size; i++) { + final CodeExceptionGen c = exception_vec.get(i); + c_exc[i] = c.getCodeException(super.getConstantPool()); + } + return c_exc; + } + + + /** + * Add an exception possibly thrown by this method. + * + * @param class_name (fully qualified) name of exception + */ + public void addException( final String class_name ) { + throws_vec.add(class_name); + } + + + /** + * Remove an exception. + */ + public void removeException( final String c ) { + throws_vec.remove(c); + } + + + /** + * Remove all exceptions. + */ + public void removeExceptions() { + throws_vec.clear(); + } + + + /* + * @return array of thrown exceptions + */ + public String[] getExceptions() { + final 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( final ConstantPoolGen cp ) { + final int size = throws_vec.size(); + final int[] ex = new int[size]; + for (int i = 0; i < size; i++) { + ex[i] = cp.addClass(throws_vec.get(i)); + } + 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( final Attribute a ) { + code_attrs_vec.add(a); + } + + + /** + * Remove the LocalVariableTypeTable + */ + public void removeLocalVariableTypeTable( ) { + local_variable_type_table = null; + } + + /** + * Remove a code attribute. + */ + public void removeCodeAttribute( final Attribute a ) { + code_attrs_vec.remove(a); + } + + + /** + * Remove all code attributes. + */ + public void removeCodeAttributes() { + local_variable_type_table = null; + code_attrs_vec.clear(); + } + + + /** + * @return all attributes of this method. + */ + public Attribute[] getCodeAttributes() { + final Attribute[] attributes = new Attribute[code_attrs_vec.size()]; + code_attrs_vec.toArray(attributes); + return attributes; + } + + /** + * @since 6.0 + */ + public void addAnnotationsAsAttribute(final ConstantPoolGen cp) { + final Attribute[] attrs = AnnotationEntryGen.getAnnotationAttributes(cp, super.getAnnotationEntries()); + for (final Attribute attr : attrs) { + addAttribute(attr); + } + } + + /** + * @since 6.0 + */ + public void addParameterAnnotationsAsAttribute(final ConstantPoolGen cp) { + if (!hasParameterAnnotations) { + return; + } + final Attribute[] attrs = AnnotationEntryGen.getParameterAnnotationAttributes(cp,param_annotations); + if (attrs != null) { + for (final Attribute attr : attrs) { + addAttribute(attr); + } + } + } + + + /** + * 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() { + final String signature = getSignature(); + final ConstantPoolGen _cp = super.getConstantPool(); + final int name_index = _cp.addUtf8(super.getName()); + final 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) { + updateLocalVariableTable(getLocalVariableTable(_cp)); + addCodeAttribute(lvt = getLocalVariableTable(_cp)); + } + if (local_variable_type_table != null) { + // LocalVariable length in LocalVariableTypeTable is not updated automatically. It's a difference with LocalVariableTable. + if (lvt != null) { + adjustLocalVariableTypeTable(lvt); + } + addCodeAttribute(local_variable_type_table); + } + if ((line_number_vec.size() > 0) && !strip_attributes) { + addCodeAttribute(lnt = getLineNumberTable(_cp)); + } + final Attribute[] code_attrs = getCodeAttributes(); + /* Each attribute causes 6 additional header bytes + */ + int attrs_len = 0; + for (final Attribute code_attr : code_attrs) { + attrs_len += code_attr.getLength() + 6; + } + final CodeException[] c_exc = getCodeExceptions(); + final int exc_len = c_exc.length * 8; // Every entry takes 8 bytes + Code code = null; + if ((il != null) && !isAbstract() && !isNative()) { + // Remove any stale code attribute + final Attribute[] attributes = getAttributes(); + for (final Attribute a : attributes) { + if (a instanceof Code) { + removeAttribute(a); + } + } + 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); + } + addAnnotationsAsAttribute(_cp); + addParameterAnnotationsAsAttribute(_cp); + ExceptionTable et = null; + if (throws_vec.size() > 0) { + addAttribute(et = getExceptionTable(_cp)); + // Add `Exceptions' if there are "throws" clauses + } + final Method m = new Method(super.getAccessFlags(), name_index, signature_index, getAttributes(), _cp + .getConstantPool()); + // Undo effects of adding attributes + if (lvt != null) { + removeCodeAttribute(lvt); + } + if (local_variable_type_table != null) { + removeCodeAttribute(local_variable_type_table); + } + if (lnt != null) { + removeCodeAttribute(lnt); + } + if (code != null) { + removeAttribute(code); + } + if (et != null) { + removeAttribute(et); + } + return m; + } + + private void updateLocalVariableTable(final LocalVariableTable a) { + final LocalVariable[] lv = a.getLocalVariableTable(); + removeLocalVariables(); + for (final LocalVariable l : lv) { + InstructionHandle start = il.findHandle(l.getStartPC()); + final InstructionHandle end = il.findHandle(l.getStartPC() + l.getLength()); + // Repair malformed handles + if (null == start) { + start = il.getStart(); + } + // end == null => live to end of method + // Since we are recreating the LocalVaraible, we must + // propagate the orig_index to new copy. + addLocalVariable(l.getName(), Type.getType(l.getSignature()), l + .getIndex(), start, end, l.getOrigIndex()); + } + } + + private void adjustLocalVariableTypeTable(final LocalVariableTable lvt) { + final LocalVariable[] lv = lvt.getLocalVariableTable(); + final LocalVariable[] lvg = local_variable_type_table.getLocalVariableTypeTable(); + + for (final LocalVariable element : lvg) { + for (final LocalVariable l : lv) { + if (element.getName().equals(l.getName()) && element.getIndex() == l.getOrigIndex()) { + element.setLength(l.getLength()); + element.setStartPC(l.getStartPC()); + element.setIndex(l.getIndex()); + break; + } + } + } + } + + + /** + * Remove all NOPs from the instruction list (if possible) and update every + * object referring 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.getNext(); + if ((next != null) && (ih.getInstruction() instanceof NOP)) { + try { + il.delete(ih); + } catch (final TargetLostException e) { + for (final InstructionHandle target : e.getTargets()) { + for (final InstructionTargeter targeter : target.getTargeters()) { + targeter.updateTarget(target, next); + } + } + } + } + } + } + } + + + /** + * Set maximum number of local variables. + */ + public void setMaxLocals( final int m ) { + max_locals = m; + } + + + public int getMaxLocals() { + return max_locals; + } + + + /** + * Set maximum stack size for this method. + */ + public void setMaxStack( final int m ) { // TODO could be package-protected? + max_stack = m; + } + + + public int getMaxStack() { + return max_stack; + } + + + /** @return class that contains this method + */ + public String getClassName() { + return class_name; + } + + + public void setClassName( final String class_name ) { // TODO could be package-protected? + this.class_name = class_name; + } + + + public void setReturnType( final Type return_type ) { + setType(return_type); + } + + + public Type getReturnType() { + return getType(); + } + + + public void setArgumentTypes( final Type[] arg_types ) { + this.arg_types = arg_types; + } + + + public Type[] getArgumentTypes() { + return arg_types.clone(); + } + + + public void setArgumentType( final int i, final Type type ) { + arg_types[i] = type; + } + + + public Type getArgumentType( final int i ) { + return arg_types[i]; + } + + + public void setArgumentNames( final String[] arg_names ) { + this.arg_names = arg_names; + } + + + public String[] getArgumentNames() { + return arg_names.clone(); + } + + + public void setArgumentName( final int i, final String name ) { + arg_names[i] = name; + } + + + public String getArgumentName( final int i ) { + return arg_names[i]; + } + + + public InstructionList getInstructionList() { + return il; + } + + + public void setInstructionList( final InstructionList il ) { // TODO could be package-protected? + this.il = il; + } + + + @Override + public String getSignature() { + return Type.getMethodSignature(super.getType(), arg_types); + } + + + /** + * Computes max. stack size by performing control flow analysis. + */ + public void setMaxStack() { // TODO could be package-protected? (some tests would need repackaging) + if (il != null) { + max_stack = getMaxStack(super.getConstantPool(), il, getExceptionHandlers()); + } else { + max_stack = 0; + } + } + + + /** + * Compute maximum number of local variables. + */ + public void setMaxLocals() { // TODO could be package-protected? (some tests would need repackaging) + if (il != null) { + int max = isStatic() ? 0 : 1; + if (arg_types != null) { + for (final Type arg_type : arg_types) { + max += arg_type.getSize(); + } + } + for (InstructionHandle ih = il.getStart(); ih != null; ih = ih.getNext()) { + final Instruction ins = ih.getInstruction(); + if ((ins instanceof LocalVariableInstruction) || (ins instanceof RET) + || (ins instanceof IINC)) { + final int index = ((IndexedInstruction) ins).getIndex() + + ((TypedInstruction) ins).getType(super.getConstantPool()).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( final boolean flag ) { + strip_attributes = flag; + } + + static final class BranchTarget { + + final InstructionHandle target; + final int stackDepth; + + + BranchTarget(final InstructionHandle target, final int stackDepth) { + this.target = target; + this.stackDepth = stackDepth; + } + } + + static final class BranchStack { + + private final Stack branchTargets = new Stack<>(); + private final Hashtable visitedTargets = new Hashtable<>(); + + + public void push( final InstructionHandle target, final int stackDepth ) { + if (visited(target)) { + return; + } + branchTargets.push(visit(target, stackDepth)); + } + + + public BranchTarget pop() { + if (!branchTargets.empty()) { + final BranchTarget bt = branchTargets.pop(); + return bt; + } + return null; + } + + + private BranchTarget visit( final InstructionHandle target, final int stackDepth ) { + final BranchTarget bt = new BranchTarget(target, stackDepth); + visitedTargets.put(target, bt); + return bt; + } + + + private boolean visited( final 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( final ConstantPoolGen cp, final InstructionList il, final CodeExceptionGen[] et ) { + final 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 (final CodeExceptionGen element : et) { + final InstructionHandle handler_pc = element.getHandlerPC(); + if (handler_pc != null) { + branchTargets.push(handler_pc, 1); + } + } + int stackDepth = 0; + int maxStackDepth = 0; + InstructionHandle ih = il.getStart(); + while (ih != null) { + final Instruction instruction = ih.getInstruction(); + final short opcode = instruction.getOpcode(); + final 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) { + final BranchInstruction branch = (BranchInstruction) instruction; + if (instruction instanceof Select) { + // explore all of the select's targets. the default target is handled below. + final Select select = (Select) branch; + final InstructionHandle[] targets = select.getTargets(); + for (final InstructionHandle target : targets) { + branchTargets.push(target, 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 == Const.JSR || opcode == Const.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 == Const.ATHROW || opcode == Const.RET + || (opcode >= Const.IRETURN && opcode <= Const.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) { + final BranchTarget bt = branchTargets.pop(); + if (bt != null) { + ih = bt.target; + stackDepth = bt.stackDepth; + } + } + } + return maxStackDepth; + } + + private List observers; + + + /** Add observer for this object. + */ + public void addObserver( final MethodObserver o ) { + if (observers == null) { + observers = new ArrayList<>(); + } + observers.add(o); + } + + + /** Remove observer for this object. + */ + public void removeObserver( final 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 (final MethodObserver observer : observers) { + observer.notify(this); + } + } + } + + + /** + * Return string representation close to declaration format, + * `public static void main(String[]) throws IOException', e.g. + * + * @return String representation of the method. + */ + @Override + public final String toString() { + final String access = Utility.accessToString(super.getAccessFlags()); + String signature = Type.getMethodSignature(super.getType(), arg_types); + signature = Utility.methodSignatureToString(signature, super.getName(), access, true, + getLocalVariableTable(super.getConstantPool())); + final StringBuilder buf = new StringBuilder(signature); + for (final Attribute a : getAttributes()) { + if (!((a instanceof Code) || (a instanceof ExceptionTable))) { + buf.append(" [").append(a).append("]"); + } + } + + if (throws_vec.size() > 0) { + for (final String throwsDescriptor : throws_vec) { + buf.append("\n\t\tthrows ").append(throwsDescriptor); + } + } + return buf.toString(); + } + + + /** @return deep copy of this method + */ + public MethodGen copy( final String class_name, final ConstantPoolGen cp ) { + final Method m = ((MethodGen) clone()).getMethod(); + final MethodGen mg = new MethodGen(m, class_name, super.getConstantPool()); + if (super.getConstantPool() != cp) { + mg.setConstantPool(cp); + mg.getInstructionList().replaceConstantPool(super.getConstantPool(), cp); + } + return mg; + } + + //J5TODO: Should param_annotations be an array of arrays? Rather than an array of lists, this + // is more likely to suggest to the caller it is readonly (which a List does not). + /** + * Return a list of AnnotationGen objects representing parameter annotations + * @since 6.0 + */ + public List getAnnotationsOnParameter(final int i) { + ensureExistingParameterAnnotationsUnpacked(); + if (!hasParameterAnnotations || i>arg_types.length) { + return null; + } + return param_annotations[i]; + } + + /** + * Goes through the attributes on the method and identifies any that are + * RuntimeParameterAnnotations, extracting their contents and storing them + * as parameter annotations. There are two kinds of parameter annotation - + * visible and invisible. Once they have been unpacked, these attributes are + * deleted. (The annotations will be rebuilt as attributes when someone + * builds a Method object out of this MethodGen object). + */ + private void ensureExistingParameterAnnotationsUnpacked() + { + if (haveUnpackedParameterAnnotations) { + return; + } + // Find attributes that contain parameter annotation data + final Attribute[] attrs = getAttributes(); + ParameterAnnotations paramAnnVisAttr = null; + ParameterAnnotations paramAnnInvisAttr = null; + for (final Attribute attribute : attrs) { + if (attribute instanceof ParameterAnnotations) + { + // Initialize param_annotations + if (!hasParameterAnnotations) + { + @SuppressWarnings("unchecked") // OK + final List[] parmList = new List[arg_types.length]; + param_annotations = parmList; + for (int j = 0; j < arg_types.length; j++) { + param_annotations[j] = new ArrayList<>(); + } + } + hasParameterAnnotations = true; + final ParameterAnnotations rpa = (ParameterAnnotations) attribute; + if (rpa instanceof RuntimeVisibleParameterAnnotations) { + paramAnnVisAttr = rpa; + } else { + paramAnnInvisAttr = rpa; + } + final ParameterAnnotationEntry[] parameterAnnotationEntries = rpa.getParameterAnnotationEntries(); + for (int j = 0; j < parameterAnnotationEntries.length; j++) + { + // This returns Annotation[] ... + final ParameterAnnotationEntry immutableArray = rpa.getParameterAnnotationEntries()[j]; + // ... which needs transforming into an AnnotationGen[] ... + final List mutable = makeMutableVersion(immutableArray.getAnnotationEntries()); + // ... then add these to any we already know about + param_annotations[j].addAll(mutable); + } + } + } + if (paramAnnVisAttr != null) { + removeAttribute(paramAnnVisAttr); + } + if (paramAnnInvisAttr != null) { + removeAttribute(paramAnnInvisAttr); + } + haveUnpackedParameterAnnotations = true; + } + + private List makeMutableVersion(final AnnotationEntry[] mutableArray) + { + final List result = new ArrayList<>(); + for (final AnnotationEntry element : mutableArray) { + result.add(new AnnotationEntryGen(element, getConstantPool(), + false)); + } + return result; + } + + public void addParameterAnnotation(final int parameterIndex, + final AnnotationEntryGen annotation) + { + ensureExistingParameterAnnotationsUnpacked(); + if (!hasParameterAnnotations) + { + @SuppressWarnings("unchecked") // OK + final List[] parmList = new List[arg_types.length]; + param_annotations = parmList; + hasParameterAnnotations = true; + } + final List existingAnnotations = param_annotations[parameterIndex]; + if (existingAnnotations != null) + { + existingAnnotations.add(annotation); + } + else + { + final List l = new ArrayList<>(); + l.add(annotation); + param_annotations[parameterIndex] = l; + } + } + + + + + /** + * @return Comparison strategy object + */ + public static BCELComparator getComparator() { + return bcelComparator; + } + + + /** + * @param comparator Comparison strategy object + */ + public static void setComparator( final BCELComparator comparator ) { + bcelComparator = comparator; + } + + + /** + * Return value as defined by given BCELComparator strategy. + * By default two MethodGen objects are said to be equal when + * their names and signatures are equal. + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals( final Object obj ) { + return bcelComparator.equals(this, obj); + } + + + /** + * Return value as defined by given BCELComparator strategy. + * By default return the hashcode of the method's name XOR signature. + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return bcelComparator.hashCode(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MethodObserver.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MethodObserver.java new file mode 100644 index 00000000..cec658f2 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MethodObserver.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Implement this interface if you're interested in changes to a MethodGen object + * and register yourself with addObserver(). + * + * @version $Id: MethodObserver.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public interface MethodObserver { + + void notify( MethodGen method ); +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NEW.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NEW.java new file mode 100644 index 00000000..4df9b93d --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NEW.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.ExceptionConst; + +/** + * NEW - Create new object + *
      Stack: ... -> ..., objectref
      + * + * @version $Id: NEW.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class NEW extends CPInstruction implements LoadClass, AllocationInstruction, + ExceptionThrower, StackProducer { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + NEW() { + } + + + public NEW(final int index) { + super(org.apache.bcel.Const.NEW, index); + } + + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_CLASS_AND_INTERFACE_RESOLUTION, + ExceptionConst.ILLEGAL_ACCESS_ERROR, + ExceptionConst.INSTANTIATION_ERROR); + } + + + @Override + public ObjectType getLoadClassType( final 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 + */ + @Override + public void accept( final 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/NEWARRAY.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NEWARRAY.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/NEWARRAY.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NEWARRAY.java index 997cde61..cf30fe34 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/NEWARRAY.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NEWARRAY.java @@ -1,121 +1,127 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.util.ByteSequence; - -/** - * NEWARRAY - Create new array of basic type (int, short, ...) - *
      Stack: ..., count -> ..., arrayref
      - * type must be one of T_INT, T_SHORT, ... - * - * @version $Id: NEWARRAY.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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.bcel5_2_0.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.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.ExceptionConst; +import org.apache.bcel.util.ByteSequence; + +/** + * NEWARRAY - Create new array of basic type (int, short, ...) + *
      Stack: ..., count -> ..., arrayref
      + * type must be one of T_INT, T_SHORT, ... + * + * @version $Id: NEWARRAY.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class NEWARRAY extends Instruction implements AllocationInstruction, ExceptionThrower, + StackProducer { + + private byte type; + + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + NEWARRAY() { + } + + + public NEWARRAY(final byte type) { + super(org.apache.bcel.Const.NEWARRAY, (short) 2); + this.type = type; + } + + + public NEWARRAY(final BasicType type) { + this(type.getType()); + } + + + /** + * Dump instruction as byte code to stream out. + * @param out Output stream + */ + @Override + public void dump( final DataOutputStream out ) throws IOException { + out.writeByte(super.getOpcode()); + 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 + */ + @Override + public String toString( final boolean verbose ) { + return super.toString(verbose) + " " + org.apache.bcel.Const.getTypeName(type); + } + + + /** + * Read needed data (e.g. index) from file. + */ + @Override + protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException { + type = bytes.readByte(); + super.setLength(2); + } + + + @Override + public Class[] getExceptions() { + return new Class[] { + ExceptionConst.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitAllocationInstruction(this); + v.visitExceptionThrower(this); + v.visitStackProducer(this); + v.visitNEWARRAY(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/NOP.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NOP.java old mode 100755 new mode 100644 similarity index 53% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/NOP.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NOP.java index 7b07722d..fc9cf86c --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/NOP.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NOP.java @@ -1,43 +1,44 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * NOP - Do nothing - * - * @version $Id: NOP.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class NOP extends Instruction { - - public NOP() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * NOP - Do nothing + * + * @version $Id: NOP.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public class NOP extends Instruction { + + public NOP() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitNOP(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NameSignatureInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NameSignatureInstruction.java new file mode 100644 index 00000000..32231c7a --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NameSignatureInstruction.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.bcel.generic; + +import org.apache.bcel.classfile.ConstantCP; +import org.apache.bcel.classfile.ConstantNameAndType; +import org.apache.bcel.classfile.ConstantPool; +import org.apache.bcel.classfile.ConstantUtf8; + +/** + * Super class for FieldOrMethod and INVOKEDYNAMIC, since they both have + * names and signatures + * + * @version $Id: FieldOrMethod.java 1481383 2013-05-11 17:34:32Z dbrosius $ + * @since 6.0 + */ +public abstract class NameSignatureInstruction extends CPInstruction { + + public NameSignatureInstruction() { + super(); + } + + public NameSignatureInstruction(final short opcode, final int index) { + super(opcode, index); + } + + public ConstantNameAndType getNameAndType(final ConstantPoolGen cpg) { + final ConstantPool cp = cpg.getConstantPool(); + final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex()); + return (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex()); + } + /** @return signature of referenced method/field. + */ + public String getSignature(final ConstantPoolGen cpg) { + final ConstantPool cp = cpg.getConstantPool(); + final ConstantNameAndType cnat = getNameAndType(cpg); + return ((ConstantUtf8) cp.getConstant(cnat.getSignatureIndex())).getBytes(); + } + + /** @return name of referenced method/field. + */ + public String getName(final ConstantPoolGen cpg) { + final ConstantPool cp = cpg.getConstantPool(); + final ConstantNameAndType cnat = getNameAndType(cpg); + return ((ConstantUtf8) cp.getConstant(cnat.getNameIndex())).getBytes(); + } + +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NamedAndTyped.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NamedAndTyped.java new file mode 100644 index 00000000..df14562e --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NamedAndTyped.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Denote entity that has both name and type. This is true for local variables, + * methods and fields. + * + * @version $Id: NamedAndTyped.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public interface NamedAndTyped { + + String getName(); + + + Type getType(); + + + void setName( String name ); + + + void setType( Type type ); +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ObjectType.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ObjectType.java old mode 100755 new mode 100644 similarity index 57% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ObjectType.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ObjectType.java index 476d1cf4..bcee3daf --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ObjectType.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ObjectType.java @@ -1,155 +1,164 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.Repository; -import org.apache.bcel5_2_0.classfile.JavaClass; - -/** - * Denotes reference such as java.lang.String. - * - * @version $Id: ObjectType.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public 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. - * @deprecated this method returns an inaccurate result - * if the class or interface referenced cannot - * be found: use referencesClassExact() instead - */ - public boolean referencesClass() { - try { - JavaClass jc = Repository.lookupClass(class_name); - return jc.isClass(); - } catch (ClassNotFoundException e) { - return false; - } - } - - - /** - * If "this" doesn't reference an interface, it references a class - * or a non-existant entity. - * @deprecated this method returns an inaccurate result - * if the class or interface referenced cannot - * be found: use referencesInterfaceExact() instead - */ - public boolean referencesInterface() { - try { - JavaClass jc = Repository.lookupClass(class_name); - return !jc.isClass(); - } catch (ClassNotFoundException e) { - return false; - } - } - - - /** - * Return true if this type references a class, - * false if it references an interface. - * @return true if the type references a class, false if - * it references an interface - * @throws ClassNotFoundException if the class or interface - * referenced by this type can't be found - */ - public boolean referencesClassExact() throws ClassNotFoundException { - JavaClass jc = Repository.lookupClass(class_name); - return jc.isClass(); - } - - - /** - * Return true if this type references an interface, - * false if it references a class. - * @return true if the type references an interface, false if - * it references a class - * @throws ClassNotFoundException if the class or interface - * referenced by this type can't be found - */ - public boolean referencesInterfaceExact() throws ClassNotFoundException { - JavaClass jc = Repository.lookupClass(class_name); - return !jc.isClass(); - } - - - /** - * Return true if this type is a subclass of given ObjectType. - * @throws ClassNotFoundException if any of this class's superclasses - * can't be found - */ - public boolean subclassOf( ObjectType superclass ) throws ClassNotFoundException { - if (this.referencesInterface() || superclass.referencesInterface()) { - return false; - } - return Repository.instanceOf(this.class_name, superclass.class_name); - } - - - /** - * Java Virtual Machine Specification edition 2, paragraph 5.4.4 Access Control - * @throws ClassNotFoundException if the class referenced by this type - * can't be found - */ - public boolean accessibleTo( ObjectType accessor ) throws ClassNotFoundException { - 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()); - } - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.Const; +import org.apache.bcel.Repository; +import org.apache.bcel.classfile.JavaClass; + +/** + * Denotes reference such as java.lang.String. + * + * @version $Id: ObjectType.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class ObjectType extends ReferenceType { + + private final String class_name; // Class name of type + + /** + * @since 6.0 + */ + public static ObjectType getInstance(final String class_name) { + return new ObjectType(class_name); + } + + /** + * @param class_name fully qualified class name, e.g. java.lang.String + */ + public ObjectType(final String class_name) { + super(Const.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. + */ + @Override + public int hashCode() { + return class_name.hashCode(); + } + + + /** @return true if both type objects refer to the same class. + */ + @Override + public boolean equals( final 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. + * @deprecated (since 6.0) this method returns an inaccurate result + * if the class or interface referenced cannot + * be found: use referencesClassExact() instead + */ + @Deprecated + public boolean referencesClass() { + try { + final JavaClass jc = Repository.lookupClass(class_name); + return jc.isClass(); + } catch (final ClassNotFoundException e) { + return false; + } + } + + + /** + * If "this" doesn't reference an interface, it references a class + * or a non-existant entity. + * @deprecated (since 6.0) this method returns an inaccurate result + * if the class or interface referenced cannot + * be found: use referencesInterfaceExact() instead + */ + @Deprecated + public boolean referencesInterface() { + try { + final JavaClass jc = Repository.lookupClass(class_name); + return !jc.isClass(); + } catch (final ClassNotFoundException e) { + return false; + } + } + + + /** + * Return true if this type references a class, + * false if it references an interface. + * @return true if the type references a class, false if + * it references an interface + * @throws ClassNotFoundException if the class or interface + * referenced by this type can't be found + */ + public boolean referencesClassExact() throws ClassNotFoundException { + final JavaClass jc = Repository.lookupClass(class_name); + return jc.isClass(); + } + + + /** + * Return true if this type references an interface, + * false if it references a class. + * @return true if the type references an interface, false if + * it references a class + * @throws ClassNotFoundException if the class or interface + * referenced by this type can't be found + */ + public boolean referencesInterfaceExact() throws ClassNotFoundException { + final JavaClass jc = Repository.lookupClass(class_name); + return !jc.isClass(); + } + + + /** + * Return true if this type is a subclass of given ObjectType. + * @throws ClassNotFoundException if any of this class's superclasses + * can't be found + */ + public boolean subclassOf( final ObjectType superclass ) throws ClassNotFoundException { + if (this.referencesInterfaceExact() || superclass.referencesInterfaceExact()) { + return false; + } + return Repository.instanceOf(this.class_name, superclass.class_name); + } + + + /** + * Java Virtual Machine Specification edition 2, � 5.4.4 Access Control + * @throws ClassNotFoundException if the class referenced by this type + * can't be found + */ + public boolean accessibleTo( final ObjectType accessor ) throws ClassNotFoundException { + final JavaClass jc = Repository.lookupClass(class_name); + if (jc.isPublic()) { + return true; + } + final JavaClass acc = Repository.lookupClass(accessor.class_name); + return acc.getPackageName().equals(jc.getPackageName()); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/POP.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/POP.java old mode 100755 new mode 100644 similarity index 58% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/POP.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/POP.java index b9eaf898..b308d7bb --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/POP.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/POP.java @@ -1,48 +1,49 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * POP - Pop top operand stack word - * - *
      Stack: ..., word -> ...
      - * - * @version $Id: POP.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class POP extends StackInstruction implements PopInstruction { - - public POP() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * POP - Pop top operand stack word + * + *
      Stack: ..., word -> ...
      + * + * @version $Id: POP.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public class POP extends StackInstruction implements PopInstruction { + + public POP() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitPopInstruction(this); + v.visitStackInstruction(this); + v.visitPOP(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/POP2.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/POP2.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/POP2.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/POP2.java index 36007ef8..6627ab09 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/POP2.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/POP2.java @@ -1,48 +1,49 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * POP2 - Pop two top operand stack words - * - *
      Stack: ..., word2, word1 -> ...
      - * - * @version $Id: POP2.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class POP2 extends StackInstruction implements PopInstruction { - - public POP2() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * POP2 - Pop two top operand stack words + * + *
      Stack: ..., word2, word1 -> ...
      + * + * @version $Id: POP2.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public class POP2 extends StackInstruction implements PopInstruction { + + public POP2() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitPopInstruction(this); + v.visitStackInstruction(this); + v.visitPOP2(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/PUSH.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PUSH.java old mode 100755 new mode 100644 similarity index 52% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/PUSH.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PUSH.java index 1fab5546..23c941c4 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/PUSH.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PUSH.java @@ -1,178 +1,192 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.Constants; - -/** - * Wrapper class for push operations, which are implemented either as BIPUSH, - * LDC or xCONST_n instructions. - * - * @version $Id: PUSH.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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)) { - instruction = INSTRUCTIONS[Constants.ICONST_0 + value]; - } else if ((value >= -128) && (value <= 127)) { - instruction = new BIPUSH((byte) value); - } else if ((value >= -32768) && (value <= 32767)) { - instruction = new SIPUSH((short) value); - } else { - 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 { - 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 { - 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 { - 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 { - 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); - } - } - - - /** - * creates a push object from a Character value. Warning: Make sure not to attempt to allow - * autoboxing to create this value parameter, as an alternative constructor will be called - * - * @param cp Constant pool - * @param value to be pushed - */ - public PUSH(ConstantPoolGen cp, Character value) { - this(cp, 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)"; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.Const; + +/** + * Wrapper class for push operations, which are implemented either as BIPUSH, + * LDC or xCONST_n instructions. + * + * @version $Id: PUSH.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +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(final ConstantPoolGen cp, final int value) { + if ((value >= -1) && (value <= 5)) { + instruction = InstructionConst.getInstruction(Const.ICONST_0 + value); + } else if (Instruction.isValidByte(value)) { + instruction = new BIPUSH((byte) value); + } else if (Instruction.isValidShort(value)) { + instruction = new SIPUSH((short) value); + } else { + instruction = new LDC(cp.addInteger(value)); + } + } + + + /** + * @param cp Constant pool + * @param value to be pushed + */ + public PUSH(final ConstantPoolGen cp, final boolean value) { + instruction = InstructionConst.getInstruction(Const.ICONST_0 + (value ? 1 : 0)); + } + + + /** + * @param cp Constant pool + * @param value to be pushed + */ + public PUSH(final ConstantPoolGen cp, final float value) { + if (value == 0.0) { + instruction = InstructionConst.FCONST_0; + } else if (value == 1.0) { + instruction = InstructionConst.FCONST_1; + } else if (value == 2.0) { + instruction = InstructionConst.FCONST_2; + } else { + instruction = new LDC(cp.addFloat(value)); + } + } + + + /** + * @param cp Constant pool + * @param value to be pushed + */ + public PUSH(final ConstantPoolGen cp, final long value) { + if (value == 0) { + instruction = InstructionConst.LCONST_0; + } else if (value == 1) { + instruction = InstructionConst.LCONST_1; + } else { + instruction = new LDC2_W(cp.addLong(value)); + } + } + + + /** + * @param cp Constant pool + * @param value to be pushed + */ + public PUSH(final ConstantPoolGen cp, final double value) { + if (value == 0.0) { + instruction = InstructionConst.DCONST_0; + } else if (value == 1.0) { + instruction = InstructionConst.DCONST_1; + } else { + instruction = new LDC2_W(cp.addDouble(value)); + } + } + + + /** + * @param cp Constant pool + * @param value to be pushed + */ + public PUSH(final ConstantPoolGen cp, final String value) { + if (value == null) { + instruction = InstructionConst.ACONST_NULL; + } else { + instruction = new LDC(cp.addString(value)); + } + } + + /** + * + * @param cp + * @param value + * @since 6.0 + */ + public PUSH(final ConstantPoolGen cp, final ObjectType value) { + if (value == null) { + instruction = InstructionConst.ACONST_NULL; + } else { + instruction = new LDC(cp.addClass(value)); + } + } + + /** + * @param cp Constant pool + * @param value to be pushed + */ + public PUSH(final ConstantPoolGen cp, final 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); + } + } + + + /** + * creates a push object from a Character value. Warning: Make sure not to attempt to allow + * autoboxing to create this value parameter, as an alternative constructor will be called + * + * @param cp Constant pool + * @param value to be pushed + */ + public PUSH(final ConstantPoolGen cp, final Character value) { + this(cp, value.charValue()); + } + + + /** + * @param cp Constant pool + * @param value to be pushed + */ + public PUSH(final ConstantPoolGen cp, final Boolean value) { + this(cp, value.booleanValue()); + } + + + @Override + public final InstructionList getInstructionList() { + return new InstructionList(instruction); + } + + + public final Instruction getInstruction() { + return instruction; + } + + + /** + * @return mnemonic for instruction + */ + @Override + public String toString() { + return instruction + " (PUSH)"; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PUTFIELD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PUTFIELD.java new file mode 100644 index 00000000..a4ede188 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PUTFIELD.java @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.Const; +import org.apache.bcel.ExceptionConst; + +/** + * PUTFIELD - Put field in object + *
      Stack: ..., objectref, value -> ...
      + * OR + *
      Stack: ..., objectref, value.word1, value.word2 -> ...
      + * + * @version $Id: PUTFIELD.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class PUTFIELD extends FieldInstruction implements PopInstruction, ExceptionThrower { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + PUTFIELD() { + } + + + public PUTFIELD(final int index) { + super(Const.PUTFIELD, index); + } + + + @Override + public int consumeStack( final ConstantPoolGen cpg ) { + return getFieldSize(cpg) + 1; + } + + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, + ExceptionConst.NULL_POINTER_EXCEPTION, + ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR); + } + + + /** + * 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 + */ + @Override + public void accept( final 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.visitPUTFIELD(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/PUTSTATIC.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PUTSTATIC.java old mode 100755 new mode 100644 similarity index 51% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/PUTSTATIC.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PUTSTATIC.java index b6715859..928b42a7 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/PUTSTATIC.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PUTSTATIC.java @@ -1,79 +1,79 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.ExceptionConstants; - -/** - * PUTSTATIC - Put static field in class - *
      Stack: ..., value -> ...
      - * OR - *
      Stack: ..., value.word1, value.word2 -> ...
      - * - * @version $Id: PUTSTATIC.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.Const; +import org.apache.bcel.ExceptionConst; + +/** + * PUTSTATIC - Put static field in class + *
      Stack: ..., value -> ...
      + * OR + *
      Stack: ..., value.word1, value.word2 -> ...
      + * + * @version $Id: PUTSTATIC.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class PUTSTATIC extends FieldInstruction implements ExceptionThrower, PopInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + PUTSTATIC() { + } + + + public PUTSTATIC(final int index) { + super(Const.PUTSTATIC, index); + } + + + @Override + public int consumeStack( final ConstantPoolGen cpg ) { + return getFieldSize(cpg); + } + + + @Override + public Class[] getExceptions() { + return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, + ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR); + } + + + /** + * 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 + */ + @Override + public void accept( final 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PopInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PopInstruction.java new file mode 100644 index 00000000..7f8a9149 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PopInstruction.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Denotes an unparameterized instruction to pop a value on top from the stack, + * such as ISTORE, POP, PUTSTATIC. + * + * @version $Id: PopInstruction.java 1747278 2016-06-07 17:28:43Z britter $ + * @see ISTORE + * @see POP + */ +public interface PopInstruction extends StackConsumer { +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/PushInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PushInstruction.java old mode 100755 new mode 100644 similarity index 52% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/PushInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PushInstruction.java index 03633555..b0429f53 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/PushInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PushInstruction.java @@ -1,34 +1,34 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Denotes an unparameterized instruction to produce a value on top of the stack, - * such as ILOAD, LDC, SIPUSH, DUP, ICONST, etc. - * - * @version $Id: PushInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - - * @see ILOAD - * @see ICONST - * @see LDC - * @see DUP - * @see SIPUSH - * @see GETSTATIC - */ -public interface PushInstruction extends StackProducer { -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Denotes an unparameterized instruction to produce a value on top of the stack, + * such as ILOAD, LDC, SIPUSH, DUP, ICONST, etc. + * + * @version $Id: PushInstruction.java 1747278 2016-06-07 17:28:43Z britter $ + + * @see ILOAD + * @see ICONST + * @see LDC + * @see DUP + * @see SIPUSH + * @see GETSTATIC + */ +public interface PushInstruction extends StackProducer { +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/RET.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/RET.java old mode 100755 new mode 100644 similarity index 56% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/RET.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/RET.java index f0b93f2c..b0ad0c27 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/RET.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/RET.java @@ -1,140 +1,147 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.util.ByteSequence; - -/** - * RET - Return from subroutine - * - *
      Stack: ... -> ...
      - * - * @version $Id: RET.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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.bcel5_2_0.Constants.WIDE); - } - out.writeByte(opcode); - if (wide) { - out.writeShort(index); - } else { - out.writeByte(index); - } - } - - - private final void setWide() { - wide = index > org.apache.bcel5_2_0.Constants.MAX_BYTE; - if (wide) { - 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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.util.ByteSequence; + +/** + * RET - Return from subroutine + * + *
      Stack: ... -> ...
      + * + * @version $Id: RET.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +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 Instruction.readInstruction. + * Not to be used otherwise. + */ + RET() { + } + + + public RET(final int index) { + super(org.apache.bcel.Const.RET, (short) 2); + setIndex(index); // May set wide as side effect + } + + + /** + * Dump instruction as byte code to stream out. + * @param out Output stream + */ + @Override + public void dump( final DataOutputStream out ) throws IOException { + if (wide) { + out.writeByte(org.apache.bcel.Const.WIDE); + } + out.writeByte(super.getOpcode()); + if (wide) { + out.writeShort(index); + } else { + out.writeByte(index); + } + } + + + private void setWide() { + wide = index > org.apache.bcel.Const.MAX_BYTE; + if (wide) { + super.setLength(4); // Including the wide byte + } else { + super.setLength(2); + } + } + + + /** + * Read needed data (e.g. index) from file. + */ + @Override + protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException { + this.wide = wide; + if (wide) { + index = bytes.readUnsignedShort(); + super.setLength(4); + } else { + index = bytes.readUnsignedByte(); + super.setLength(2); + } + } + + + /** + * @return index of local variable containg the return address + */ + @Override + public final int getIndex() { + return index; + } + + + /** + * Set index of local variable containg the return address + */ + @Override + public final void setIndex( final int n ) { + if (n < 0) { + throw new ClassGenException("Negative index value: " + n); + } + index = n; + setWide(); + } + + + /** + * @return mnemonic for instruction + */ + @Override + public String toString( final boolean verbose ) { + return super.toString(verbose) + " " + index; + } + + + /** @return return address type + */ + @Override + public Type getType( final 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitRET(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/RETURN.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/RETURN.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/RETURN.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/RETURN.java index fa7587c5..ca4fdeb5 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/RETURN.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/RETURN.java @@ -1,48 +1,49 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * RETURN - Return from void method - *
      Stack: ... -> <empty>
      - * - * @version $Id: RETURN.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class RETURN extends ReturnInstruction { - - public RETURN() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * RETURN - Return from void method + *
      Stack: ... -> <empty>
      + * + * @version $Id: RETURN.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class RETURN extends ReturnInstruction { + + public RETURN() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackConsumer(this); + v.visitReturnInstruction(this); + v.visitRETURN(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ReferenceType.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ReferenceType.java old mode 100755 new mode 100644 similarity index 74% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ReferenceType.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ReferenceType.java index f302fade..6fdcda50 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ReferenceType.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ReferenceType.java @@ -1,330 +1,330 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.Repository; -import org.apache.bcel5_2_0.classfile.JavaClass; - -/** - * Super class for object and array types. - * - * @version $Id: ReferenceType.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public abstract 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, ""); - } - - - /** - * 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. - * - * @throws ClassNotFoundException if any classes or interfaces required - * to determine assignment compatibility can't be found - */ - public boolean isCastableTo( Type t ) throws ClassNotFoundException { - 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. - * @throws ClassNotFoundException if any classes or interfaces required - * to determine assignment compatibility can't be found - */ - public boolean isAssignmentCompatibleWith( Type t ) throws ClassNotFoundException { - 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).referencesClassExact())) { - /* 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).referencesClassExact())) { - 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).referencesInterfaceExact())) { - if (Repository.implementationOf(((ObjectType) this).getClassName(), - ((ObjectType) T).getClassName())) { - return true; - } - } - } - /* If this is an interface type, then: - */ - if ((this instanceof ObjectType) && (((ObjectType) this).referencesInterfaceExact())) { - /* If T is a class type, then T must be Object (paragraph 2.4.7). - */ - if ((T instanceof ObjectType) && (((ObjectType) T).referencesClassExact())) { - 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 (paragraph 2.13.2). - */ - if ((T instanceof ObjectType) && (((ObjectType) T).referencesInterfaceExact())) { - 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 (paragraph 2.4.7). - */ - if ((T instanceof ObjectType) && (((ObjectType) T).referencesClassExact())) { - 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 (paragraph 2.4.1). - */ - Type sc = ((ArrayType) this).getElementType(); - Type tc = ((ArrayType) T).getElementType(); - if (sc instanceof BasicType && tc instanceof BasicType && sc.equals(tc)) { - return true; - } - /* TC and SC are reference types (paragraph 2.4.6), and type SC is - * assignable to TC by these runtime rules. - */ - if (tc instanceof ReferenceType && sc instanceof ReferenceType - && ((ReferenceType) sc).isAssignmentCompatibleWith(tc)) { - return true; - } - } - /* If T is an interface type, T must be one of the interfaces implemented by arrays (paragraph 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).referencesInterfaceExact())) { - 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; - * unless their dimensions match. Then an ArrayType of the same - * number of dimensions is returned, with its basic type being the - * first common super class of the basic types of "this" and t. - * 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, "paragraph 4.9.2 The Bytecode Verifier". - * - * @throws ClassNotFoundException on failure to find superclasses of this - * type, or the type passed as a parameter - */ - public ReferenceType getFirstCommonSuperclass( ReferenceType t ) throws ClassNotFoundException { - if (this.equals(Type.NULL)) { - return t; - } - if (t.equals(Type.NULL)) { - return this; - } - if (this.equals(t)) { - return this; - /* - * TODO: Above 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 :) - */ - } - /* This code is from a bug report by Konstantin Shagin */ - if ((this instanceof ArrayType) && (t instanceof ArrayType)) { - ArrayType arrType1 = (ArrayType) this; - ArrayType arrType2 = (ArrayType) t; - if ((arrType1.getDimensions() == arrType2.getDimensions()) - && arrType1.getBasicType() instanceof ObjectType - && arrType2.getBasicType() instanceof ObjectType) { - return new ArrayType(((ObjectType) arrType1.getBasicType()) - .getFirstCommonSuperclass((ObjectType) arrType2.getBasicType()), arrType1 - .getDimensions()); - } - } - 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; - } - - - /** - * 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, "paragraph 4.9.2 The Bytecode Verifier". - * - * @deprecated use getFirstCommonSuperclass(ReferenceType t) which has - * slightly changed semantics. - * @throws ClassNotFoundException on failure to find superclasses of this - * type, or the type passed as a parameter - */ - public ReferenceType firstCommonSuperclass( ReferenceType t ) throws ClassNotFoundException { - if (this.equals(Type.NULL)) { - return t; - } - if (t.equals(Type.NULL)) { - return this; - } - if (this.equals(t)) { - return this; - /* - * TODO: Above 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; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.Const; +import org.apache.bcel.Repository; +import org.apache.bcel.classfile.JavaClass; + +/** + * Super class for object and array types. + * + * @version $Id: ReferenceType.java 1749603 2016-06-21 20:50:19Z ggregory $ + */ +public abstract class ReferenceType extends Type { + + protected ReferenceType(final byte t, final String s) { + super(t, s); + } + + + /** Class is non-abstract but not instantiable from the outside + */ + ReferenceType() { + super(Const.T_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. + * + * @throws ClassNotFoundException if any classes or interfaces required + * to determine assignment compatibility can't be found + */ + public boolean isCastableTo( final Type t ) throws ClassNotFoundException { + if (this.equals(Type.NULL)) { + return t instanceof ReferenceType; // 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. + * @throws ClassNotFoundException if any classes or interfaces required + * to determine assignment compatibility can't be found + */ + public boolean isAssignmentCompatibleWith( final Type t ) throws ClassNotFoundException { + if (!(t instanceof ReferenceType)) { + return false; + } + final 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).referencesClassExact())) { + /* 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).referencesClassExact())) { + 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).referencesInterfaceExact())) { + if (Repository.implementationOf(((ObjectType) this).getClassName(), + ((ObjectType) T).getClassName())) { + return true; + } + } + } + /* If this is an interface type, then: + */ + if ((this instanceof ObjectType) && (((ObjectType) this).referencesInterfaceExact())) { + /* If T is a class type, then T must be Object (�2.4.7). + */ + if ((T instanceof ObjectType) && (((ObjectType) T).referencesClassExact())) { + 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).referencesInterfaceExact())) { + 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).referencesClassExact())) { + 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). + */ + final Type sc = ((ArrayType) this).getElementType(); + final Type tc = ((ArrayType) T).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(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).referencesInterfaceExact())) { + for (final String element : Const.getInterfacesImplementedByArrays()) { + if (T.equals(ObjectType.getInstance(element))) { + 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; + * unless their dimensions match. Then an ArrayType of the same + * number of dimensions is returned, with its basic type being the + * first common super class of the basic types of "this" and t. + * 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". + * + * @throws ClassNotFoundException on failure to find superclasses of this + * type, or the type passed as a parameter + */ + public ReferenceType getFirstCommonSuperclass( final ReferenceType t ) throws ClassNotFoundException { + if (this.equals(Type.NULL)) { + return t; + } + if (t.equals(Type.NULL)) { + return this; + } + if (this.equals(t)) { + return this; + /* + * TODO: Above 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 :) + */ + } + /* This code is from a bug report by Konstantin Shagin */ + if ((this instanceof ArrayType) && (t instanceof ArrayType)) { + final ArrayType arrType1 = (ArrayType) this; + final ArrayType arrType2 = (ArrayType) t; + if ((arrType1.getDimensions() == arrType2.getDimensions()) + && arrType1.getBasicType() instanceof ObjectType + && arrType2.getBasicType() instanceof ObjectType) { + return new ArrayType(((ObjectType) arrType1.getBasicType()) + .getFirstCommonSuperclass((ObjectType) arrType2.getBasicType()), arrType1 + .getDimensions()); + } + } + 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).referencesInterfaceExact()) + || ((t instanceof ObjectType) && ((ObjectType) t).referencesInterfaceExact())) { + 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. + final ObjectType thiz = (ObjectType) this; + final ObjectType other = (ObjectType) t; + final JavaClass[] thiz_sups = Repository.getSuperClasses(thiz.getClassName()); + final JavaClass[] other_sups = Repository.getSuperClasses(other.getClassName()); + if ((thiz_sups == null) || (other_sups == null)) { + return null; + } + // Waaahh... + final JavaClass[] this_sups = new JavaClass[thiz_sups.length + 1]; + final 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 (final JavaClass t_sup : t_sups) { + for (final JavaClass this_sup : this_sups) { + if (this_sup.equals(t_sup)) { + return ObjectType.getInstance(this_sup.getClassName()); + } + } + } + // Huh? Did you ask for Type.OBJECT's superclass?? + return null; + } + + /** + * 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". + * + * @deprecated use getFirstCommonSuperclass(ReferenceType t) which has + * slightly changed semantics. + * @throws ClassNotFoundException on failure to find superclasses of this + * type, or the type passed as a parameter + */ + @Deprecated + public ReferenceType firstCommonSuperclass( final ReferenceType t ) throws ClassNotFoundException { + if (this.equals(Type.NULL)) { + return t; + } + if (t.equals(Type.NULL)) { + return this; + } + if (this.equals(t)) { + return this; + /* + * TODO: Above 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. + final ObjectType thiz = (ObjectType) this; + final ObjectType other = (ObjectType) t; + final JavaClass[] thiz_sups = Repository.getSuperClasses(thiz.getClassName()); + final JavaClass[] other_sups = Repository.getSuperClasses(other.getClassName()); + if ((thiz_sups == null) || (other_sups == null)) { + return null; + } + // Waaahh... + final JavaClass[] this_sups = new JavaClass[thiz_sups.length + 1]; + final 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 (final JavaClass t_sup : t_sups) { + for (final JavaClass this_sup : this_sups) { + if (this_sup.equals(t_sup)) { + return ObjectType.getInstance(this_sup.getClassName()); + } + } + } + // Huh? Did you ask for Type.OBJECT's superclass?? + return null; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ReturnInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ReturnInstruction.java new file mode 100644 index 00000000..cbd18183 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ReturnInstruction.java @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.Const; +import org.apache.bcel.ExceptionConst; + +/** + * Super class for the xRETURN family of instructions. + * + * @version $Id: ReturnInstruction.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public abstract class ReturnInstruction extends Instruction implements ExceptionThrower, + TypedInstruction, StackConsumer { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + ReturnInstruction() { + } + + + /** + * @param opcode of instruction + */ + protected ReturnInstruction(final short opcode) { + super(opcode, (short) 1); + } + + + public Type getType() { + final short _opcode = super.getOpcode(); + switch (_opcode) { + case Const.IRETURN: + return Type.INT; + case Const.LRETURN: + return Type.LONG; + case Const.FRETURN: + return Type.FLOAT; + case Const.DRETURN: + return Type.DOUBLE; + case Const.ARETURN: + return Type.OBJECT; + case Const.RETURN: + return Type.VOID; + default: // Never reached + throw new ClassGenException("Unknown type " + _opcode); + } + } + + + @Override + public Class[] getExceptions() { + return new Class[] { + ExceptionConst.ILLEGAL_MONITOR_STATE + }; + } + + + /** @return type associated with the instruction + */ + @Override + public Type getType( final ConstantPoolGen cp ) { + return getType(); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ReturnaddressType.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ReturnaddressType.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ReturnaddressType.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ReturnaddressType.java index 085f6c71..7d7373a1 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ReturnaddressType.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ReturnaddressType.java @@ -1,82 +1,84 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.Constants; - -/** - * Returnaddress, the type JSR or JSR_W instructions push upon the stack. - * - * see vmspec2 paragraph 3.3.3 - * @version $Id: ReturnaddressType.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author Enver Haase - */ -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, ""); - } - - - /** - * Creates a ReturnaddressType object with a target. - */ - public ReturnaddressType(InstructionHandle returnTarget) { - super(Constants.T_ADDRESS, ""); - this.returnTarget = returnTarget; - } - - - /** @return a hash code value for the object. - */ - public int hashCode() { - if (returnTarget == null) { - return 0; - } - return returnTarget.hashCode(); - } - - - /** - * Returns if the two Returnaddresses refer to the same target. - */ - public boolean equals( Object rat ) { - if (!(rat instanceof ReturnaddressType)) { - return false; - } - ReturnaddressType that = (ReturnaddressType) rat; - if (this.returnTarget == null || that.returnTarget == null) { - return that.returnTarget == this.returnTarget; - } - return that.returnTarget.equals(this.returnTarget); - } - - - /** - * @return the target of this ReturnaddressType - */ - public InstructionHandle getTarget() { - return returnTarget; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import org.apache.bcel.Const; + +/** + * Returnaddress, the type JSR or JSR_W instructions push upon the stack. + * + * see vmspec2 �3.3.3 + * @version $Id: ReturnaddressType.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +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(Const.T_ADDRESS, ""); + } + + + /** + * Creates a ReturnaddressType object with a target. + */ + public ReturnaddressType(final InstructionHandle returnTarget) { + super(Const.T_ADDRESS, ""); + this.returnTarget = returnTarget; + } + + + /** @return a hash code value for the object. + */ + @Override + public int hashCode() { + if (returnTarget == null) { + return 0; + } + return returnTarget.hashCode(); + } + + + /** + * Returns if the two Returnaddresses refer to the same target. + */ + @Override + public boolean equals( final Object rat ) { + if (!(rat instanceof ReturnaddressType)) { + return false; + } + final ReturnaddressType that = (ReturnaddressType) rat; + if (this.returnTarget == null || that.returnTarget == null) { + return that.returnTarget == this.returnTarget; + } + return that.returnTarget.equals(this.returnTarget); + } + + + /** + * @return the target of this ReturnaddressType + */ + public InstructionHandle getTarget() { + return returnTarget; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/SALOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SALOAD.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/SALOAD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SALOAD.java index e978805e..8ed4fbcd --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/SALOAD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SALOAD.java @@ -1,48 +1,49 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * SALOAD - Load short from array - *
      Stack: ..., arrayref, index -> ..., value
      - * - * @version $Id: SALOAD.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class SALOAD extends ArrayInstruction implements StackProducer { - - public SALOAD() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * SALOAD - Load short from array + *
      Stack: ..., arrayref, index -> ..., value
      + * + * @version $Id: SALOAD.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class SALOAD extends ArrayInstruction implements StackProducer { + + public SALOAD() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackProducer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitSALOAD(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/SASTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SASTORE.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/SASTORE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SASTORE.java index a3c6a1bd..00b679bb --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/SASTORE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SASTORE.java @@ -1,48 +1,49 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * SASTORE - Store into short array - *
      Stack: ..., arrayref, index, value -> ...
      - * - * @version $Id: SASTORE.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class SASTORE extends ArrayInstruction implements StackConsumer { - - public SASTORE() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * SASTORE - Store into short array + *
      Stack: ..., arrayref, index, value -> ...
      + * + * @version $Id: SASTORE.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public class SASTORE extends ArrayInstruction implements StackConsumer { + + public SASTORE() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitSASTORE(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/SIPUSH.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SIPUSH.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/SIPUSH.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SIPUSH.java index 117f69a1..6410c131 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/SIPUSH.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SIPUSH.java @@ -1,104 +1,110 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.util.ByteSequence; - -/** - * SIPUSH - Push short - * - *
      Stack: ... -> ..., value
      - * - * @version $Id: SIPUSH.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.util.ByteSequence; + +/** + * SIPUSH - Push short + * + *
      Stack: ... -> ..., value
      + * + * @version $Id: SIPUSH.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public class SIPUSH extends Instruction implements ConstantPushInstruction { + + private short b; + + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + SIPUSH() { + } + + + public SIPUSH(final short b) { + super(org.apache.bcel.Const.SIPUSH, (short) 3); + this.b = b; + } + + + /** + * Dump instruction as short code to stream out. + */ + @Override + public void dump( final DataOutputStream out ) throws IOException { + super.dump(out); + out.writeShort(b); + } + + + /** + * @return mnemonic for instruction + */ + @Override + public String toString( final boolean verbose ) { + return super.toString(verbose) + " " + b; + } + + + /** + * Read needed data (e.g. index) from file. + */ + @Override + protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException { + super.setLength(3); + b = bytes.readShort(); + } + + + @Override + public Number getValue() { + return Integer.valueOf(b); + } + + + /** @return Type.SHORT + */ + @Override + public Type getType( final 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitPushInstruction(this); + v.visitStackProducer(this); + v.visitTypedInstruction(this); + v.visitConstantPushInstruction(this); + v.visitSIPUSH(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/SWAP.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SWAP.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/SWAP.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SWAP.java index 34d0287c..2211f497 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/SWAP.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SWAP.java @@ -1,47 +1,48 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * SWAP - Swa top operand stack word - *
      Stack: ..., word2, word1 -> ..., word1, word2
      - * - * @version $Id: SWAP.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class SWAP extends StackInstruction implements StackConsumer, StackProducer { - - public SWAP() { - super(org.apache.bcel5_2_0.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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * SWAP - Swa top operand stack word + *
      Stack: ..., word2, word1 -> ..., word1, word2
      + * + * @version $Id: SWAP.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class SWAP extends StackInstruction implements StackConsumer, StackProducer { + + public SWAP() { + super(org.apache.bcel.Const.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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitStackProducer(this); + v.visitStackInstruction(this); + v.visitSWAP(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/SWITCH.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SWITCH.java old mode 100755 new mode 100644 similarity index 70% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/SWITCH.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SWITCH.java index d74508e3..7e2773db --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/SWITCH.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SWITCH.java @@ -1,153 +1,156 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * 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: SWITCH.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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) { - 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; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * 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: SWITCH.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +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(final int[] match, final InstructionHandle[] targets, final InstructionHandle target, final int max_gap) { + this.match = match.clone(); + this.targets = targets.clone(); + if ((match_length = match.length) < 2) { + 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(final int[] match, final InstructionHandle[] targets, final InstructionHandle target) { + this(match, targets, target, 1); + } + + + private void fillup( final int max_gap, final InstructionHandle target ) { + final int max_size = match_length + match_length * max_gap; + final int[] m_vec = new int[max_size]; + final 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++) { + final int prev = match[i - 1]; + final 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 void sort( final int l, final int r ) { + int i = l; + int j = r; + int h; + final int 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 boolean matchIsOrdered( final int max_gap ) { + for (int i = 1; i < match_length; i++) { + if (match[i] - match[i - 1] > max_gap) { + return false; + } + } + return true; + } + + + @Override + public final InstructionList getInstructionList() { + return new InstructionList(instruction); + } + + + public final Instruction getInstruction() { + return instruction; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Select.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Select.java new file mode 100644 index 00000000..f3a2865f --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Select.java @@ -0,0 +1,393 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.util.ByteSequence; + +/** + * Select - Abstract super class for LOOKUPSWITCH and TABLESWITCH instructions. + * + *

      We use our super's target property as the default target. + * + * @version $Id: Select.java 1812166 2017-10-13 23:48:11Z ggregory $ + * @see LOOKUPSWITCH + * @see TABLESWITCH + * @see InstructionList + */ +public abstract class Select extends BranchInstruction implements VariableLengthInstruction, + StackConsumer /* @since 6.0 */, StackProducer { + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected int[] match; // matches, i.e., case 1: ... TODO could be package-protected? + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected int[] indices; // target offsets TODO could be package-protected? + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected InstructionHandle[] targets; // target objects in instruction list TODO could be package-protected? + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected int fixed_length; // fixed length defined by subclasses TODO could be package-protected? + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected int match_length; // number of cases TODO could be package-protected? + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected int padding = 0; // number of pad bytes for alignment TODO could be package-protected? + + + /** + * Empty constructor needed for 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 defaultTarget default instruction target + */ + Select(final short opcode, final int[] match, final InstructionHandle[] targets, final InstructionHandle defaultTarget) { + // don't set default target before instuction is built + super(opcode, null); + this.match = match; + this.targets = targets; + // now it's safe to set default target + setTarget(defaultTarget); + for (final InstructionHandle target2 : targets) { + notifyTarget(null, target2, this); + } + if ((match_length = match.length) != targets.length) { + throw new ClassGenException("Match and target array have not the same length: Match length: " + + match.length + " Target length: " + targets.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 + */ + @Override + protected int updatePosition( final int offset, final int max_offset ) { + setPosition(getPosition() + offset); // Additional offset caused by preceding SWITCHs, GOTOs, etc. + final short old_length = (short) super.getLength(); + /* Alignment on 4-byte-boundary, + 1, because of tag byte. + */ + padding = (4 - ((getPosition() + 1) % 4)) % 4; + super.setLength((short) (fixed_length + padding)); // Update length + return super.getLength() - old_length; + } + + + /** + * Dump instruction as byte code to stream out. + * @param out Output stream + */ + @Override + public void dump( final DataOutputStream out ) throws IOException { + out.writeByte(super.getOpcode()); + for (int i = 0; i < padding; i++) { + out.writeByte(0); + } + super.setIndex(getTargetOffset()); // Write default target offset + out.writeInt(super.getIndex()); + } + + + /** + * Read needed data (e.g. index) from file. + */ + @Override + protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException { + padding = (4 - (bytes.getIndex() % 4)) % 4; // Compute number of pad bytes + for (int i = 0; i < padding; i++) { + bytes.readByte(); + } + // Default branch target common for both cases (TABLESWITCH, LOOKUPSWITCH) + super.setIndex(bytes.readInt()); + } + + + /** + * @return mnemonic for instruction + */ + @Override + public String toString( final boolean verbose ) { + final StringBuilder buf = new StringBuilder(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("(").append(match[i]).append(", ").append(s).append(" = {").append( + indices[i]).append("})"); + } + } else { + buf.append(" ..."); + } + return buf.toString(); + } + + + /** + * Set branch target for `i'th case + */ + public void setTarget( final int i, final InstructionHandle target ) { // TODO could be package-protected? + notifyTarget(targets[i], target, this); + targets[i] = target; + } + + + /** + * @param old_ih old target + * @param new_ih new target + */ + @Override + public void updateTarget( final InstructionHandle old_ih, final InstructionHandle new_ih ) { + boolean targeted = false; + if (super.getTarget() == 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 + */ + @Override + public boolean containsTarget( final InstructionHandle ih ) { + if (super.getTarget() == ih) { + return true; + } + for (final InstructionHandle target2 : targets) { + if (target2 == ih) { + return true; + } + } + return false; + } + + + @Override + protected Object clone() throws CloneNotSupportedException { + final Select copy = (Select) super.clone(); + copy.match = match.clone(); + copy.indices = indices.clone(); + copy.targets = targets.clone(); + return copy; + } + + + /** + * Inform targets that they're not targeted anymore. + */ + @Override + void dispose() { + super.dispose(); + for (final InstructionHandle target2 : targets) { + target2.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; + } + + /** + * @return match entry + * @since 6.0 + */ + final int getMatch(final int index) { + return match[index]; + } + + + /** + * @return index entry from indices + * @since 6.0 + */ + final int getIndices(final int index) { + return indices[index]; + } + + /** + * @return target entry + * @since 6.0 + */ + final InstructionHandle getTarget(final int index) { + return targets[index]; + } + + + /** + * @return the fixed_length + * @since 6.0 + */ + final int getFixed_length() { + return fixed_length; + } + + + /** + * @param fixed_length the fixed_length to set + * @since 6.0 + */ + final void setFixed_length(final int fixed_length) { + this.fixed_length = fixed_length; + } + + + /** + * @return the match_length + * @since 6.0 + */ + final int getMatch_length() { + return match_length; + } + + + /** + * @param match_length the match_length to set + * @since 6.0 + */ + final int setMatch_length(final int match_length) { + this.match_length = match_length; + return match_length; + } + + /** + * + * @param index + * @param value + * @since 6.0 + */ + final void setMatch(final int index, final int value) { + match[index] = value; + } + + /** + * + * @param array + * @since 6.0 + */ + final void setIndices(final int[] array) { + indices = array; + } + + /** + * + * @param array + * @since 6.0 + */ + final void setMatches(final int[] array) { + match = array; + } + + /** + * + * @param array + * @since 6.0 + */ + final void setTargets(final InstructionHandle[] array) { + targets = array; + } + + /** + * + * @return the padding + * @since 6.0 + */ + final int getPadding() { + return padding; + } + + + /** @since 6.0 */ + final int setIndices(final int i, final int value) { + indices[i] = value; + return value; // Allow use in nested calls + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SimpleElementValueGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SimpleElementValueGen.java new file mode 100644 index 00000000..99ed6d40 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SimpleElementValueGen.java @@ -0,0 +1,269 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +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.ConstantUtf8; +import org.apache.bcel.classfile.ElementValue; +import org.apache.bcel.classfile.SimpleElementValue; + +/** + * @since 6.0 + */ +public class SimpleElementValueGen extends ElementValueGen +{ + // For primitive types and string type, this points to the value entry in + // the cpGen + // For 'class' this points to the class entry in the cpGen + private int idx; + + // ctors for each supported type... type could be inferred but for now lets + // force it to be passed + /** + * Protected ctor used for deserialization, doesn't *put* an entry in the + * constant pool, assumes the one at the supplied index is correct. + */ + protected SimpleElementValueGen(final int type, final int idx, final ConstantPoolGen cpGen) + { + super(type, cpGen); + this.idx = idx; + } + + public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final int value) + { + super(type, cpGen); + idx = getConstantPool().addInteger(value); + } + + public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final long value) + { + super(type, cpGen); + idx = getConstantPool().addLong(value); + } + + public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final double value) + { + super(type, cpGen); + idx = getConstantPool().addDouble(value); + } + + public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final float value) + { + super(type, cpGen); + idx = getConstantPool().addFloat(value); + } + + public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final short value) + { + super(type, cpGen); + idx = getConstantPool().addInteger(value); + } + + public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final byte value) + { + super(type, cpGen); + idx = getConstantPool().addInteger(value); + } + + public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final char value) + { + super(type, cpGen); + idx = getConstantPool().addInteger(value); + } + + public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final boolean value) + { + super(type, cpGen); + if (value) { + idx = getConstantPool().addInteger(1); + } else { + idx = getConstantPool().addInteger(0); + } + } + + public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final String value) + { + super(type, cpGen); + idx = getConstantPool().addUtf8(value); + } + + /** + * The boolean controls whether we copy info from the 'old' constant pool to + * the 'new'. You need to use this ctor if the annotation is being copied + * from one file to another. + */ + public SimpleElementValueGen(final SimpleElementValue value, + final ConstantPoolGen cpool, final boolean copyPoolEntries) + { + super(value.getElementValueType(), cpool); + if (!copyPoolEntries) + { + // J5ASSERT: Could assert value.stringifyValue() is the same as + // cpool.getConstant(SimpleElementValuevalue.getIndex()) + idx = value.getIndex(); + } + else + { + switch (value.getElementValueType()) + { + case STRING: + idx = cpool.addUtf8(value.getValueString()); + break; + case PRIMITIVE_INT: + idx = cpool.addInteger(value.getValueInt()); + break; + case PRIMITIVE_BYTE: + idx = cpool.addInteger(value.getValueByte()); + break; + case PRIMITIVE_CHAR: + idx = cpool.addInteger(value.getValueChar()); + break; + case PRIMITIVE_LONG: + idx = cpool.addLong(value.getValueLong()); + break; + case PRIMITIVE_FLOAT: + idx = cpool.addFloat(value.getValueFloat()); + break; + case PRIMITIVE_DOUBLE: + idx = cpool.addDouble(value.getValueDouble()); + break; + case PRIMITIVE_BOOLEAN: + if (value.getValueBoolean()) + { + idx = cpool.addInteger(1); + } + else + { + idx = cpool.addInteger(0); + } + break; + case PRIMITIVE_SHORT: + idx = cpool.addInteger(value.getValueShort()); + break; + default: + throw new RuntimeException( + "SimpleElementValueGen class does not know how to copy this type " + super.getElementValueType()); + } + } + } + + /** + * Return immutable variant + */ + @Override + public ElementValue getElementValue() + { + return new SimpleElementValue(super.getElementValueType(), idx, getConstantPool().getConstantPool()); + } + + public int getIndex() + { + return idx; + } + + public String getValueString() + { + if (super.getElementValueType() != STRING) { + throw new RuntimeException( + "Dont call getValueString() on a non STRING ElementValue"); + } + final ConstantUtf8 c = (ConstantUtf8) getConstantPool().getConstant(idx); + return c.getBytes(); + } + + public int getValueInt() + { + if (super.getElementValueType() != PRIMITIVE_INT) { + throw new RuntimeException( + "Dont call getValueString() on a non STRING ElementValue"); + } + final ConstantInteger c = (ConstantInteger) getConstantPool().getConstant(idx); + return c.getBytes(); + } + + // Whatever kind of value it is, return it as a string + @Override + public String stringifyValue() + { + switch (super.getElementValueType()) + { + case PRIMITIVE_INT: + final ConstantInteger c = (ConstantInteger) getConstantPool().getConstant(idx); + return Integer.toString(c.getBytes()); + case PRIMITIVE_LONG: + final ConstantLong j = (ConstantLong) getConstantPool().getConstant(idx); + return Long.toString(j.getBytes()); + case PRIMITIVE_DOUBLE: + final ConstantDouble d = (ConstantDouble) getConstantPool().getConstant(idx); + return Double.toString(d.getBytes()); + case PRIMITIVE_FLOAT: + final ConstantFloat f = (ConstantFloat) getConstantPool().getConstant(idx); + return Float.toString(f.getBytes()); + case PRIMITIVE_SHORT: + final ConstantInteger s = (ConstantInteger) getConstantPool().getConstant(idx); + return Integer.toString(s.getBytes()); + case PRIMITIVE_BYTE: + final ConstantInteger b = (ConstantInteger) getConstantPool().getConstant(idx); + return Integer.toString(b.getBytes()); + case PRIMITIVE_CHAR: + final ConstantInteger ch = (ConstantInteger) getConstantPool().getConstant(idx); + return Integer.toString(ch.getBytes()); + case PRIMITIVE_BOOLEAN: + final ConstantInteger bo = (ConstantInteger) getConstantPool().getConstant(idx); + if (bo.getBytes() == 0) { + return "false"; + } + return "true"; + case STRING: + final ConstantUtf8 cu8 = (ConstantUtf8) getConstantPool().getConstant(idx); + return cu8.getBytes(); + default: + throw new RuntimeException( + "SimpleElementValueGen class does not know how to stringify type " + super.getElementValueType()); + } + } + + @Override + public void dump(final DataOutputStream dos) throws IOException + { + dos.writeByte(super.getElementValueType()); // u1 kind of value + switch (super.getElementValueType()) + { + case PRIMITIVE_INT: + case PRIMITIVE_BYTE: + case PRIMITIVE_CHAR: + case PRIMITIVE_FLOAT: + case PRIMITIVE_LONG: + case PRIMITIVE_BOOLEAN: + case PRIMITIVE_SHORT: + case PRIMITIVE_DOUBLE: + case STRING: + dos.writeShort(idx); + break; + default: + throw new RuntimeException( + "SimpleElementValueGen doesnt know how to write out type " + super.getElementValueType()); + } + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StackConsumer.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StackConsumer.java new file mode 100644 index 00000000..21150fa6 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StackConsumer.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Denote an instruction that may consume a value from the stack. + * + * @version $Id: StackConsumer.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public interface StackConsumer { + + /** @return how many words are consumed from stack + */ + int consumeStack( ConstantPoolGen cpg ); +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StackInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StackInstruction.java new file mode 100644 index 00000000..b12630b3 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StackInstruction.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Super class for stack operations like DUP and POP. + * + * @version $Id: StackInstruction.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public abstract class StackInstruction extends Instruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + */ + StackInstruction() { + } + + + /** + * @param opcode instruction opcode + */ + protected StackInstruction(final short opcode) { + super(opcode, (short) 1); + } + + + /** @return Type.UNKNOWN + */ + public Type getType( final ConstantPoolGen cp ) { + return Type.UNKNOWN; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StackProducer.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StackProducer.java new file mode 100644 index 00000000..d07a5f85 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StackProducer.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Denote an instruction that may produce a value on top of the stack + * (this excludes DUP_X1, e.g.) + * + * @version $Id: StackProducer.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public interface StackProducer { + + /** @return how many words are produced on stack + */ + int produceStack( ConstantPoolGen cpg ); +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/StoreInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StoreInstruction.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/StoreInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StoreInstruction.java index bbb8849d..c53e6edb --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/StoreInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StoreInstruction.java @@ -1,63 +1,64 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Denotes an unparameterized instruction to store a value into a local variable, - * e.g. ISTORE. - * - * @version $Id: StoreInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.visitTypedInstruction(this); - v.visitLocalVariableInstruction(this); - v.visitStoreInstruction(this); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Denotes an unparameterized instruction to store a value into a local variable, + * e.g. ISTORE. + * + * @version $Id: StoreInstruction.java 1812166 2017-10-13 23:48:11Z ggregory $ + */ +public abstract class StoreInstruction extends LocalVariableInstruction implements PopInstruction { + + /** + * Empty constructor needed for Instruction.readInstruction. + * Not to be used otherwise. + * tag and length are defined in readInstruction and initFromFile, respectively. + */ + StoreInstruction(final short canon_tag, final 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(final short opcode, final short c_tag, final 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackConsumer(this); + v.visitPopInstruction(this); + v.visitTypedInstruction(this); + v.visitLocalVariableInstruction(this); + v.visitStoreInstruction(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/TABLESWITCH.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/TABLESWITCH.java new file mode 100644 index 00000000..78f0deb8 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/TABLESWITCH.java @@ -0,0 +1,113 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.apache.bcel.util.ByteSequence; + +/** + * TABLESWITCH - Switch within given range of values, i.e., low..high + * + * @version $Id: TABLESWITCH.java 1812166 2017-10-13 23:48:11Z ggregory $ + * @see SWITCH + */ +public class TABLESWITCH extends Select { + + /** + * Empty constructor needed for 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 defaultTarget default branch + */ + public TABLESWITCH(final int[] match, final InstructionHandle[] targets, final InstructionHandle defaultTarget) { + super(org.apache.bcel.Const.TABLESWITCH, match, targets, defaultTarget); + /* Alignment remainder assumed 0 here, until dump time */ + final short _length = (short) (13 + getMatch_length() * 4); + super.setLength(_length); + setFixed_length(_length); + } + + + /** + * Dump instruction as byte code to stream out. + * @param out Output stream + */ + @Override + public void dump( final DataOutputStream out ) throws IOException { + super.dump(out); + final int _match_length = getMatch_length(); + final int low = (_match_length > 0) ? super.getMatch(0) : 0; + out.writeInt(low); + final int high = (_match_length > 0) ? super.getMatch(_match_length - 1) : 0; + out.writeInt(high); + for (int i = 0; i < _match_length; i++) { + out.writeInt(setIndices(i, getTargetOffset(super.getTarget(i)))); + } + } + + + /** + * Read needed data (e.g. index) from file. + */ + @Override + protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException { + super.initFromFile(bytes, wide); + final int low = bytes.readInt(); + final int high = bytes.readInt(); + final int _match_length = high - low + 1; + setMatch_length(_match_length); + final short _fixed_length = (short) (13 + _match_length * 4); + setFixed_length(_fixed_length); + super.setLength((short) (_fixed_length + super.getPadding())); + super.setMatches(new int[_match_length]); + super.setIndices(new int[_match_length]); + super.setTargets(new InstructionHandle[_match_length]); + for (int i = 0; i < _match_length; i++) { + super.setMatch(i, low + i); + super.setIndices(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 + */ + @Override + public void accept( final Visitor v ) { + v.visitVariableLengthInstruction(this); + v.visitStackConsumer(this); + v.visitBranchInstruction(this); + v.visitSelect(this); + v.visitTABLESWITCH(this); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/TargetLostException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/TargetLostException.java new file mode 100644 index 00000000..a0f2e023 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/TargetLostException.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Thrown by InstructionList.remove() when one or multiple disposed instructions + * are still being referenced by an 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:

      + * + *
      + *     ...
      + *     try {
      + *         il.delete(start_ih, end_ih);
      + *     } catch(TargetLostException e) {
      + *         for (InstructionHandle target : e.getTargets()) {
      + *             for (InstructionTargeter targeter : target.getTargeters()) {
      + *                 targeter.updateTarget(target, new_target);
      + *             }
      + *         }
      + *     }
      + * 
      + * + * @see InstructionHandle + * @see InstructionList + * @see InstructionTargeter + * @version $Id: TargetLostException.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public final class TargetLostException extends Exception { + + private static final long serialVersionUID = -6857272667645328384L; + private final InstructionHandle[] targets; + + + TargetLostException(final InstructionHandle[] t, final String mesg) { + super(mesg); + targets = t; + } + + + /** + * @return list of instructions still being targeted. + */ + public InstructionHandle[] getTargets() { + return targets; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Type.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Type.java new file mode 100644 index 00000000..d98cc734 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Type.java @@ -0,0 +1,404 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.bcel.Const; +import org.apache.bcel.classfile.ClassFormatException; +import org.apache.bcel.classfile.Utility; + +/** + * 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: Type.java 1749603 2016-06-21 20:50:19Z ggregory $ + */ +public abstract class Type { + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected byte type; // TODO should be final (and private) + + /** + * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter + */ + @Deprecated + protected String signature; // signature for the type TODO should be private + /** Predefined constants + */ + public static final BasicType VOID = new BasicType(Const.T_VOID); + public static final BasicType BOOLEAN = new BasicType(Const.T_BOOLEAN); + public static final BasicType INT = new BasicType(Const.T_INT); + public static final BasicType SHORT = new BasicType(Const.T_SHORT); + public static final BasicType BYTE = new BasicType(Const.T_BYTE); + public static final BasicType LONG = new BasicType(Const.T_LONG); + public static final BasicType DOUBLE = new BasicType(Const.T_DOUBLE); + public static final BasicType FLOAT = new BasicType(Const.T_FLOAT); + public static final BasicType CHAR = new BasicType(Const.T_CHAR); + public static final ObjectType OBJECT = new ObjectType("java.lang.Object"); + public static final ObjectType CLASS = new ObjectType("java.lang.Class"); + 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]; // EMPTY, so immutable + public static final ReferenceType NULL = new ReferenceType() { + }; + public static final Type UNKNOWN = new Type(Const.T_UNKNOWN, "") { + }; + + + protected Type(final byte t, final String s) { + type = t; + signature = s; + } + + + /** + * @return hashcode of Type + */ + @Override + public int hashCode() { + return type ^ signature.hashCode(); + } + + + /** + * @return whether the Types are equal + */ + @Override + public boolean equals(final Object o) { + if (o instanceof Type) { + final Type t = (Type)o; + return (type == t.type) && signature.equals(t.signature); + } + return false; + } + + + /** + * @return signature for given type. + */ + public String getSignature() { + return signature; + } + + + /** + * @return type as defined in Constants + */ + public byte getType() { + return type; + } + + /** + * boolean, short and char variable are considered as int in the stack or local variable area. + * Returns {@link Type#INT} for {@link Type#BOOLEAN}, {@link Type#SHORT} or {@link Type#CHAR}, otherwise + * returns the given type. + * @since 6.0 + */ + public Type normalizeForStackOrLocal() { + if (this == Type.BOOLEAN || this == Type.BYTE || this == Type.SHORT || this == Type.CHAR) { + return Type.INT; + } + return this; + } + + /** + * @return stack size of this type (2 for long and double, 0 for void, 1 otherwise) + */ + public int getSize() { + switch (type) { + case Const.T_DOUBLE: + case Const.T_LONG: + return 2; + case Const.T_VOID: + return 0; + default: + return 1; + } + } + + + /** + * @return Type string, e.g. `int[]' + */ + @Override + public String toString() { + return ((this.equals(Type.NULL) || (type >= Const.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( final Type return_type, final Type[] arg_types ) { + final StringBuilder buf = new StringBuilder("("); + if (arg_types != null) { + for (final Type arg_type : arg_types) { + buf.append(arg_type.getSignature()); + } + } + buf.append(')'); + buf.append(return_type.getSignature()); + return buf.toString(); + } + + private static final ThreadLocal consumed_chars = new ThreadLocal() { + + @Override + protected Integer initialValue() { + return Integer.valueOf(0); + } + };//int consumed_chars=0; // Remember position in string, see getArgumentTypes + + + private static int unwrap( final ThreadLocal tl ) { + return tl.get().intValue(); + } + + + private static void wrap( final ThreadLocal tl, final int value ) { + tl.set(Integer.valueOf(value)); + } + + + /** + * Convert signature to a Type object. + * @param signature signature string such as Ljava/lang/String; + * @return type object + */ + // @since 6.0 no longer final + public static Type getType( final String signature ) throws StringIndexOutOfBoundsException { + final byte type = Utility.typeOfSignature(signature); + if (type <= Const.T_VOID) { + //corrected concurrent private static field acess + wrap(consumed_chars, 1); + return BasicType.getType(type); + } else if (type == Const.T_ARRAY) { + int dim = 0; + do { // Count dimensions + dim++; + } while (signature.charAt(dim) == '['); + // Recurse, but just once, if the signature is ok + final Type t = getType(signature.substring(dim)); + //corrected concurrent private static field acess + // consumed_chars += dim; // update counter - is replaced by + final int _temp = unwrap(consumed_chars) + dim; + wrap(consumed_chars, _temp); + return new ArrayType(t, dim); + } else { // type == T_REFERENCE + // Utility.signatureToString understands how to parse + // generic types. + final String parsedSignature = Utility.signatureToString(signature, false); + wrap(consumed_chars, parsedSignature.length() + 2); // "Lblabla;" `L' and `;' are removed + return ObjectType.getInstance(parsedSignature.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( final String signature ) { + try { + // Read return type after `)' + final int index = signature.lastIndexOf(')') + 1; + return getType(signature.substring(index)); + } catch (final StringIndexOutOfBoundsException e) { // Should never occur + throw new ClassFormatException("Invalid method signature: " + signature, e); + } + } + + + /** + * 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( final String signature ) { + final List vec = new ArrayList<>(); + int index; + Type[] types; + try { // Read all declarations between for `(' and `)' + if (signature.charAt(0) != '(') { + throw new ClassFormatException("Invalid method signature: " + signature); + } + index = 1; // current string position + while (signature.charAt(index) != ')') { + vec.add(getType(signature.substring(index))); + //corrected concurrent private static field acess + index += unwrap(consumed_chars); // update position + } + } catch (final StringIndexOutOfBoundsException e) { // Should never occur + throw new ClassFormatException("Invalid method signature: " + signature, e); + } + types = new Type[vec.size()]; + vec.toArray(types); + return types; + } + + + /** Convert runtime java.lang.Class to BCEL Type object. + * @param cl Java class + * @return corresponding Type object + */ + public static Type getType( final java.lang.Class cl ) { + if (cl == null) { + throw new IllegalArgumentException("Class must not be null"); + } + /* That's an amzingly easy case, because getName() returns + * the signature. That's what we would have liked anyway. + */ + if (cl.isArray()) { + return getType(cl.getName()); + } else if (cl.isPrimitive()) { + if (cl == Integer.TYPE) { + return INT; + } else if (cl == Void.TYPE) { + return VOID; + } else if (cl == Double.TYPE) { + return DOUBLE; + } else if (cl == Float.TYPE) { + return FLOAT; + } else if (cl == Boolean.TYPE) { + return BOOLEAN; + } else if (cl == Byte.TYPE) { + return BYTE; + } else if (cl == Short.TYPE) { + return SHORT; + } else if (cl == Byte.TYPE) { + return BYTE; + } else if (cl == Long.TYPE) { + return LONG; + } else if (cl == Character.TYPE) { + return CHAR; + } else { + throw new IllegalStateException("Ooops, what primitive type is " + cl); + } + } else { // "Real" class + return ObjectType.getInstance(cl.getName()); + } + } + + + /** + * Convert runtime java.lang.Class[] to BCEL Type objects. + * @param classes an array of runtime class objects + * @return array of corresponding Type objects + */ + public static Type[] getTypes( final java.lang.Class[] classes ) { + final Type[] ret = new Type[classes.length]; + for (int i = 0; i < ret.length; i++) { + ret[i] = getType(classes[i]); + } + return ret; + } + + + public static String getSignature( final java.lang.reflect.Method meth ) { + final StringBuilder sb = new StringBuilder("("); + final Class[] params = meth.getParameterTypes(); // avoid clone + for (final Class param : params) { + sb.append(getType(param).getSignature()); + } + sb.append(")"); + sb.append(getType(meth.getReturnType()).getSignature()); + return sb.toString(); + } + + static int size(final int coded) { + return coded & 3; + } + + static int consumed(final int coded) { + return coded >> 2; + } + + static int encode(final int size, final int consumed) { + return consumed << 2 | size; + } + + static int getArgumentTypesSize( final String signature ) { + int res = 0; + int index; + try { // Read all declarations between for `(' and `)' + if (signature.charAt(0) != '(') { + throw new ClassFormatException("Invalid method signature: " + signature); + } + index = 1; // current string position + while (signature.charAt(index) != ')') { + final int coded = getTypeSize(signature.substring(index)); + res += size(coded); + index += consumed(coded); + } + } catch (final StringIndexOutOfBoundsException e) { // Should never occur + throw new ClassFormatException("Invalid method signature: " + signature, e); + } + return res; + } + + static int getTypeSize( final String signature ) throws StringIndexOutOfBoundsException { + final byte type = Utility.typeOfSignature(signature); + if (type <= Const.T_VOID) { + return encode(BasicType.getType(type).getSize(), 1); + } else if (type == Const.T_ARRAY) { + int dim = 0; + do { // Count dimensions + dim++; + } while (signature.charAt(dim) == '['); + // Recurse, but just once, if the signature is ok + final int consumed = consumed(getTypeSize(signature.substring(dim))); + return encode(1, dim + consumed); + } else { // type == T_REFERENCE + final int index = signature.indexOf(';'); // Look for closing `;' + if (index < 0) { + throw new ClassFormatException("Invalid signature: " + signature); + } + return encode(1, index + 1); + } + } + + + static int getReturnTypeSize(final String signature) { + final int index = signature.lastIndexOf(')') + 1; + return Type.size(getTypeSize(signature.substring(index))); + } + + + /* + * Currently only used by the ArrayType constructor. + * The signature has a complicated dependency on other parameter + * so it's tricky to do it in a call to the super ctor. + */ + void setSignature(final String signature) { + this.signature = signature; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/TypedInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/TypedInstruction.java new file mode 100644 index 00000000..c2b7c1a7 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/TypedInstruction.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Get the type associated with an instruction, int for ILOAD, or the type + * of the field of a PUTFIELD instruction, e.g.. + * + * @version $Id: TypedInstruction.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public interface TypedInstruction { + + Type getType( ConstantPoolGen cpg ); +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/UnconditionalBranch.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/UnconditionalBranch.java new file mode 100644 index 00000000..9268481f --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/UnconditionalBranch.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Denotes an instruction to perform an unconditional branch, i.e., GOTO, JSR. + * + * @version $Id: UnconditionalBranch.java 1747278 2016-06-07 17:28:43Z britter $ + + * @see GOTO + * @see JSR + */ +public interface UnconditionalBranch { +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/VariableLengthInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/VariableLengthInstruction.java new file mode 100644 index 00000000..3c0ede2f --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/VariableLengthInstruction.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * Denotes an instruction to be a variable length instruction, such as + * GOTO, JSR, LOOKUPSWITCH and TABLESWITCH. + * + * @version $Id: VariableLengthInstruction.java 1747278 2016-06-07 17:28:43Z britter $ + + * @see GOTO + * @see JSR + * @see LOOKUPSWITCH + * @see TABLESWITCH + */ +public interface VariableLengthInstruction { +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Visitor.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Visitor.java new file mode 100644 index 00000000..c4ae31c1 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Visitor.java @@ -0,0 +1,574 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.generic; + +/** + * 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: Visitor.java 1747278 2016-06-07 17:28:43Z britter $ + */ +public interface Visitor { + + void visitStackInstruction( StackInstruction obj ); + + + void visitLocalVariableInstruction( LocalVariableInstruction obj ); + + + void visitBranchInstruction( BranchInstruction obj ); + + + void visitLoadClass( LoadClass obj ); + + + void visitFieldInstruction( FieldInstruction obj ); + + + void visitIfInstruction( IfInstruction obj ); + + + void visitConversionInstruction( ConversionInstruction obj ); + + + void visitPopInstruction( PopInstruction obj ); + + + void visitStoreInstruction( StoreInstruction obj ); + + + void visitTypedInstruction( TypedInstruction obj ); + + + void visitSelect( Select obj ); + + + void visitJsrInstruction( JsrInstruction obj ); + + + void visitGotoInstruction( GotoInstruction obj ); + + + void visitUnconditionalBranch( UnconditionalBranch obj ); + + + void visitPushInstruction( PushInstruction obj ); + + + void visitArithmeticInstruction( ArithmeticInstruction obj ); + + + void visitCPInstruction( CPInstruction obj ); + + + void visitInvokeInstruction( InvokeInstruction obj ); + + + void visitArrayInstruction( ArrayInstruction obj ); + + + void visitAllocationInstruction( AllocationInstruction obj ); + + + void visitReturnInstruction( ReturnInstruction obj ); + + + void visitFieldOrMethod( FieldOrMethod obj ); + + + void visitConstantPushInstruction( ConstantPushInstruction obj ); + + + void visitExceptionThrower( ExceptionThrower obj ); + + + void visitLoadInstruction( LoadInstruction obj ); + + + void visitVariableLengthInstruction( VariableLengthInstruction obj ); + + + void visitStackProducer( StackProducer obj ); + + + void visitStackConsumer( StackConsumer obj ); + + + void visitACONST_NULL( ACONST_NULL obj ); + + + void visitGETSTATIC( GETSTATIC obj ); + + + void visitIF_ICMPLT( IF_ICMPLT obj ); + + + void visitMONITOREXIT( MONITOREXIT obj ); + + + void visitIFLT( IFLT obj ); + + + void visitLSTORE( LSTORE obj ); + + + void visitPOP2( POP2 obj ); + + + void visitBASTORE( BASTORE obj ); + + + void visitISTORE( ISTORE obj ); + + + void visitCHECKCAST( CHECKCAST obj ); + + + void visitFCMPG( FCMPG obj ); + + + void visitI2F( I2F obj ); + + + void visitATHROW( ATHROW obj ); + + + void visitDCMPL( DCMPL obj ); + + + void visitARRAYLENGTH( ARRAYLENGTH obj ); + + + void visitDUP( DUP obj ); + + + void visitINVOKESTATIC( INVOKESTATIC obj ); + + + void visitLCONST( LCONST obj ); + + + void visitDREM( DREM obj ); + + + void visitIFGE( IFGE obj ); + + + void visitCALOAD( CALOAD obj ); + + + void visitLASTORE( LASTORE obj ); + + + void visitI2D( I2D obj ); + + + void visitDADD( DADD obj ); + + + void visitINVOKESPECIAL( INVOKESPECIAL obj ); + + + void visitIAND( IAND obj ); + + + void visitPUTFIELD( PUTFIELD obj ); + + + void visitILOAD( ILOAD obj ); + + + void visitDLOAD( DLOAD obj ); + + + void visitDCONST( DCONST obj ); + + + void visitNEW( NEW obj ); + + + void visitIFNULL( IFNULL obj ); + + + void visitLSUB( LSUB obj ); + + + void visitL2I( L2I obj ); + + + void visitISHR( ISHR obj ); + + + void visitTABLESWITCH( TABLESWITCH obj ); + + + void visitIINC( IINC obj ); + + + void visitDRETURN( DRETURN obj ); + + + void visitFSTORE( FSTORE obj ); + + + void visitDASTORE( DASTORE obj ); + + + void visitIALOAD( IALOAD obj ); + + + void visitDDIV( DDIV obj ); + + + void visitIF_ICMPGE( IF_ICMPGE obj ); + + + void visitLAND( LAND obj ); + + + void visitIDIV( IDIV obj ); + + + void visitLOR( LOR obj ); + + + void visitCASTORE( CASTORE obj ); + + + void visitFREM( FREM obj ); + + + void visitLDC( LDC obj ); + + + void visitBIPUSH( BIPUSH obj ); + + + void visitDSTORE( DSTORE obj ); + + + void visitF2L( F2L obj ); + + + void visitFMUL( FMUL obj ); + + + void visitLLOAD( LLOAD obj ); + + + void visitJSR( JSR obj ); + + + void visitFSUB( FSUB obj ); + + + void visitSASTORE( SASTORE obj ); + + + void visitALOAD( ALOAD obj ); + + + void visitDUP2_X2( DUP2_X2 obj ); + + + void visitRETURN( RETURN obj ); + + + void visitDALOAD( DALOAD obj ); + + + void visitSIPUSH( SIPUSH obj ); + + + void visitDSUB( DSUB obj ); + + + void visitL2F( L2F obj ); + + + void visitIF_ICMPGT( IF_ICMPGT obj ); + + + void visitF2D( F2D obj ); + + + void visitI2L( I2L obj ); + + + void visitIF_ACMPNE( IF_ACMPNE obj ); + + + void visitPOP( POP obj ); + + + void visitI2S( I2S obj ); + + + void visitIFEQ( IFEQ obj ); + + + void visitSWAP( SWAP obj ); + + + void visitIOR( IOR obj ); + + + void visitIREM( IREM obj ); + + + void visitIASTORE( IASTORE obj ); + + + void visitNEWARRAY( NEWARRAY obj ); + + + void visitINVOKEINTERFACE( INVOKEINTERFACE obj ); + + + void visitINEG( INEG obj ); + + + void visitLCMP( LCMP obj ); + + + void visitJSR_W( JSR_W obj ); + + + void visitMULTIANEWARRAY( MULTIANEWARRAY obj ); + + + void visitDUP_X2( DUP_X2 obj ); + + + void visitSALOAD( SALOAD obj ); + + + void visitIFNONNULL( IFNONNULL obj ); + + + void visitDMUL( DMUL obj ); + + + void visitIFNE( IFNE obj ); + + + void visitIF_ICMPLE( IF_ICMPLE obj ); + + + void visitLDC2_W( LDC2_W obj ); + + + void visitGETFIELD( GETFIELD obj ); + + + void visitLADD( LADD obj ); + + + void visitNOP( NOP obj ); + + + void visitFALOAD( FALOAD obj ); + + + void visitINSTANCEOF( INSTANCEOF obj ); + + + void visitIFLE( IFLE obj ); + + + void visitLXOR( LXOR obj ); + + + void visitLRETURN( LRETURN obj ); + + + void visitFCONST( FCONST obj ); + + + void visitIUSHR( IUSHR obj ); + + + void visitBALOAD( BALOAD obj ); + + + void visitDUP2( DUP2 obj ); + + + void visitIF_ACMPEQ( IF_ACMPEQ obj ); + + + void visitIMPDEP1( IMPDEP1 obj ); + + + void visitMONITORENTER( MONITORENTER obj ); + + + void visitLSHL( LSHL obj ); + + + void visitDCMPG( DCMPG obj ); + + + void visitD2L( D2L obj ); + + + void visitIMPDEP2( IMPDEP2 obj ); + + + void visitL2D( L2D obj ); + + + void visitRET( RET obj ); + + + void visitIFGT( IFGT obj ); + + + void visitIXOR( IXOR obj ); + + + void visitINVOKEVIRTUAL( INVOKEVIRTUAL obj ); + + + /** + * @since 6.0 + */ + void visitINVOKEDYNAMIC( INVOKEDYNAMIC obj ); + + + void visitFASTORE( FASTORE obj ); + + + void visitIRETURN( IRETURN obj ); + + + void visitIF_ICMPNE( IF_ICMPNE obj ); + + + void visitFLOAD( FLOAD obj ); + + + void visitLDIV( LDIV obj ); + + + void visitPUTSTATIC( PUTSTATIC obj ); + + + void visitAALOAD( AALOAD obj ); + + + void visitD2I( D2I obj ); + + + void visitIF_ICMPEQ( IF_ICMPEQ obj ); + + + void visitAASTORE( AASTORE obj ); + + + void visitARETURN( ARETURN obj ); + + + void visitDUP2_X1( DUP2_X1 obj ); + + + void visitFNEG( FNEG obj ); + + + void visitGOTO_W( GOTO_W obj ); + + + void visitD2F( D2F obj ); + + + void visitGOTO( GOTO obj ); + + + void visitISUB( ISUB obj ); + + + void visitF2I( F2I obj ); + + + void visitDNEG( DNEG obj ); + + + void visitICONST( ICONST obj ); + + + void visitFDIV( FDIV obj ); + + + void visitI2B( I2B obj ); + + + void visitLNEG( LNEG obj ); + + + void visitLREM( LREM obj ); + + + void visitIMUL( IMUL obj ); + + + void visitIADD( IADD obj ); + + + void visitLSHR( LSHR obj ); + + + void visitLOOKUPSWITCH( LOOKUPSWITCH obj ); + + + void visitDUP_X1( DUP_X1 obj ); + + + void visitFCMPL( FCMPL obj ); + + + void visitI2C( I2C obj ); + + + void visitLMUL( LMUL obj ); + + + void visitLUSHR( LUSHR obj ); + + + void visitISHL( ISHL obj ); + + + void visitLALOAD( LALOAD obj ); + + + void visitASTORE( ASTORE obj ); + + + void visitANEWARRAY( ANEWARRAY obj ); + + + void visitFRETURN( FRETURN obj ); + + + void visitFADD( FADD obj ); + + + void visitBREAKPOINT( BREAKPOINT obj ); +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/package.html b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/package.html new file mode 100644 index 00000000..d1403224 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/package.html @@ -0,0 +1,32 @@ + + + + + + + +

      +This package contains the "generic" part of the +Byte Code Engineering +Library, i.e., classes to dynamically modify class objects and +byte code instructions. +

      + + diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/package.html b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/package.html new file mode 100644 index 00000000..a80b66a5 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/package.html @@ -0,0 +1,33 @@ + + + + + + + +

      +This package contains basic classes for the +Byte Code Engineering Library + and constants defined by the + + JVM specification. +

      + + diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/AttributeHTML.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/AttributeHTML.java old mode 100755 new mode 100644 similarity index 56% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/AttributeHTML.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/AttributeHTML.java index 5f4e5227..01ea4be7 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/AttributeHTML.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/AttributeHTML.java @@ -1,212 +1,213 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.util; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintWriter; - -import org.apache.bcel5_2_0.classfile.Attribute; -import org.apache.bcel5_2_0.classfile.Code; -import org.apache.bcel5_2_0.classfile.CodeException; -import org.apache.bcel5_2_0.classfile.ConstantPool; -import org.apache.bcel5_2_0.classfile.ConstantUtf8; -import org.apache.bcel5_2_0.classfile.ConstantValue; -import org.apache.bcel5_2_0.classfile.ExceptionTable; -import org.apache.bcel5_2_0.classfile.InnerClass; -import org.apache.bcel5_2_0.classfile.InnerClasses; -import org.apache.bcel5_2_0.classfile.LineNumber; -import org.apache.bcel5_2_0.classfile.LineNumberTable; -import org.apache.bcel5_2_0.classfile.LocalVariable; -import org.apache.bcel5_2_0.classfile.LocalVariableTable; -import org.apache.bcel5_2_0.classfile.SourceFile; -import org.apache.bcel5_2_0.classfile.Utility; - -/** - * Convert found attributes into HTML file. - * - * @version $Id: AttributeHTML.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * - */ -final class AttributeHTML implements org.apache.bcel5_2_0.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(""); - } - - - private final String codeLink( int link, int method_number ) { - return "" + link + ""; - } - - - final void close() { - file.println("
      "); - 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) { - return; - } - attr_count++; // Increment number of attributes found so far - if (attr_count % 2 == 0) { - file.print(""); - } else { - file.print(""); - } - file.println("

      " + attr_count + " " + ATTRIBUTE_NAMES[tag] - + "

      "); - /* Handle different attributes - */ - switch (tag) { - case ATTR_CODE: - Code c = (Code) attribute; - // Some directly printable values - file.print("
      • Maximum stack size = " + c.getMaxStack() - + "
      • \n
      • Number of local variables = " + c.getMaxLocals() - + "
      • \n
      • Byte code
      \n"); - // Get handled exceptions and list them - CodeException[] ce = c.getExceptionTable(); - int len = ce.length; - if (len > 0) { - file.print("

      Exceptions handled

        "); - for (int i = 0; i < len; i++) { - int catch_type = ce[i].getCatchType(); // Index in constant pool - file.print("
      • "); - if (catch_type != 0) { - file.print(constant_html.referenceConstant(catch_type)); // Create Link to _cp.html - } else { - file.print("Any Exception"); - } - file.print("
        (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) + ")
      • "); - } - file.print("
      "); - } - break; - case ATTR_CONSTANT_VALUE: - index = ((ConstantValue) attribute).getConstantValueIndex(); - // Reference _cp.html - file.print("\n"); - break; - case ATTR_SOURCE_FILE: - index = ((SourceFile) attribute).getSourceFileIndex(); - // Reference _cp.html - file.print("\n"); - break; - case ATTR_EXCEPTIONS: - // List thrown exceptions - int[] indices = ((ExceptionTable) attribute).getExceptionIndexTable(); - file.print("\n"); - break; - case ATTR_LINE_NUMBER_TABLE: - LineNumber[] line_numbers = ((LineNumberTable) attribute).getLineNumberTable(); - // List line number pairs - file.print("

      "); - for (int i = 0; i < line_numbers.length; i++) { - file.print("(" + line_numbers[i].getStartPC() + ", " - + 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("

        "); - 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("
      • " + Class2HTML.referenceType(signature) + " " - + vars[i].getName() + " in slot %" + vars[i].getIndex() - + "
        Valid from lines " + "" - + start + " to " + "" + end + "
      • "); - } - file.print("
      \n"); - break; - case ATTR_INNER_CLASSES: - InnerClass[] classes = ((InnerClasses) attribute).getInnerClasses(); - // List inner classes - file.print("
        "); - 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 = "<anonymous>"; - } - access = Utility.accessToString(classes[i].getInnerAccessFlags()); - file.print("
      • " + access + " " - + constant_html.referenceConstant(classes[i].getInnerClassIndex()) - + " in class " - + constant_html.referenceConstant(classes[i].getOuterClassIndex()) - + " named " + name + "
      • \n"); - } - file.print("
      \n"); - break; - default: // Such as Unknown attribute or Deprecated - file.print("

      " + attribute.toString()); - } - file.println(""); - file.flush(); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.util; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintWriter; + +import org.apache.bcel.Const; +import org.apache.bcel.classfile.Attribute; +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.CodeException; +import org.apache.bcel.classfile.ConstantPool; +import org.apache.bcel.classfile.ConstantUtf8; +import org.apache.bcel.classfile.ConstantValue; +import org.apache.bcel.classfile.ExceptionTable; +import org.apache.bcel.classfile.InnerClass; +import org.apache.bcel.classfile.InnerClasses; +import org.apache.bcel.classfile.LineNumber; +import org.apache.bcel.classfile.LineNumberTable; +import org.apache.bcel.classfile.LocalVariable; +import org.apache.bcel.classfile.LocalVariableTable; +import org.apache.bcel.classfile.SourceFile; +import org.apache.bcel.classfile.Utility; + +/** + * Convert found attributes into HTML file. + * + * @version $Id: AttributeHTML.java 1806200 2017-08-25 16:33:06Z ggregory $ + * + */ +final class AttributeHTML { + + private final String class_name; // name of current class + private final PrintWriter file; // file to write to + private int attr_count = 0; + private final ConstantHTML constant_html; + private final ConstantPool constant_pool; + + + AttributeHTML(final String dir, final String class_name, final ConstantPool constant_pool, + final 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(""); + } + + + private String codeLink( final int link, final int method_number ) { + return "" + link + ""; + } + + + final void close() { + file.println("
      "); + file.close(); + } + + + final void writeAttribute( final Attribute attribute, final String anchor ) { + writeAttribute(attribute, anchor, 0); + } + + + final void writeAttribute( final Attribute attribute, final String anchor, final int method_number ) { + final byte tag = attribute.getTag(); + int index; + if (tag == Const.ATTR_UNKNOWN) { + return; + } + attr_count++; // Increment number of attributes found so far + if (attr_count % 2 == 0) { + file.print(""); + } else { + file.print(""); + } + file.println("

      " + attr_count + " " + Const.getAttributeName(tag) + + "

      "); + /* Handle different attributes + */ + switch (tag) { + case Const.ATTR_CODE: + final Code c = (Code) attribute; + // Some directly printable values + file.print("
      • Maximum stack size = " + c.getMaxStack() + + "
      • \n
      • Number of local variables = " + c.getMaxLocals() + + "
      • \n
      • Byte code
      \n"); + // Get handled exceptions and list them + final CodeException[] ce = c.getExceptionTable(); + final int len = ce.length; + if (len > 0) { + file.print("

      Exceptions handled

        "); + for (final CodeException cex : ce) { + final int catch_type = cex.getCatchType(); // Index in constant pool + file.print("
      • "); + if (catch_type != 0) { + file.print(constant_html.referenceConstant(catch_type)); // Create Link to _cp.html + } else { + file.print("Any Exception"); + } + file.print("
        (Ranging from lines " + + codeLink(cex.getStartPC(), method_number) + " to " + + codeLink(cex.getEndPC(), method_number) + ", handled at line " + + codeLink(cex.getHandlerPC(), method_number) + ")
      • "); + } + file.print("
      "); + } + break; + case Const.ATTR_CONSTANT_VALUE: + index = ((ConstantValue) attribute).getConstantValueIndex(); + // Reference _cp.html + file.print("\n"); + break; + case Const.ATTR_SOURCE_FILE: + index = ((SourceFile) attribute).getSourceFileIndex(); + // Reference _cp.html + file.print("\n"); + break; + case Const.ATTR_EXCEPTIONS: + // List thrown exceptions + final int[] indices = ((ExceptionTable) attribute).getExceptionIndexTable(); + file.print("\n"); + break; + case Const.ATTR_LINE_NUMBER_TABLE: + final LineNumber[] line_numbers = ((LineNumberTable) attribute).getLineNumberTable(); + // List line number pairs + file.print("

      "); + for (int i = 0; i < line_numbers.length; i++) { + file.print("(" + line_numbers[i].getStartPC() + ", " + + line_numbers[i].getLineNumber() + ")"); + if (i < line_numbers.length - 1) { + file.print(", "); // breakable + } + } + break; + case Const.ATTR_LOCAL_VARIABLE_TABLE: + final LocalVariable[] vars = ((LocalVariableTable) attribute).getLocalVariableTable(); + // List name, range and type + file.print("

        "); + for (final LocalVariable var : vars) { + index = var.getSignatureIndex(); + String signature = ((ConstantUtf8) constant_pool.getConstant(index, + Const.CONSTANT_Utf8)).getBytes(); + signature = Utility.signatureToString(signature, false); + final int start = var.getStartPC(); + final int end = start + var.getLength(); + file.println("
      • " + Class2HTML.referenceType(signature) + " " + + var.getName() + " in slot %" + var.getIndex() + + "
        Valid from lines " + "" + + start + " to " + "" + end + "
      • "); + } + file.print("
      \n"); + break; + case Const.ATTR_INNER_CLASSES: + final InnerClass[] classes = ((InnerClasses) attribute).getInnerClasses(); + // List inner classes + file.print("
        "); + for (final InnerClass classe : classes) { + String name; + String access; + index = classe.getInnerNameIndex(); + if (index > 0) { + name = ((ConstantUtf8) constant_pool.getConstant(index, Const.CONSTANT_Utf8)) + .getBytes(); + } else { + name = "<anonymous>"; + } + access = Utility.accessToString(classe.getInnerAccessFlags()); + file.print("
      • " + access + " " + + constant_html.referenceConstant(classe.getInnerClassIndex()) + + " in class " + + constant_html.referenceConstant(classe.getOuterClassIndex()) + + " named " + name + "
      • \n"); + } + file.print("
      \n"); + break; + default: // Such as Unknown attribute or Deprecated + file.print("

      " + attribute); + } + file.println(""); + file.flush(); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/BCELComparator.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/BCELComparator.java old mode 100755 new mode 100644 similarity index 52% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/BCELComparator.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/BCELComparator.java index cdf7715f..4f6dbfbf --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/BCELComparator.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/BCELComparator.java @@ -1,45 +1,45 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.util; - -/** - * Used for BCEL comparison strategy - * - * @author M. Dahm - * @version $Id: BCELComparator.java 410087 2006-05-29 12:12:19Z tcurdt $ - * @since 5.2 - */ -public interface BCELComparator { - - /** - * Compare two objects and return what THIS.equals(THAT) should return - * - * @param THIS - * @param THAT - * @return true if and only if THIS equals THAT - */ - public boolean equals( Object THIS, Object THAT ); - - - /** - * Return hashcode for THIS.hashCode() - * - * @param THIS - * @return hashcode for THIS.hashCode() - */ - public int hashCode( Object THIS ); -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.util; + +/** + * Used for BCEL comparison strategy + * + * @version $Id: BCELComparator.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @since 5.2 + */ +public interface BCELComparator { + + /** + * Compare two objects and return what THIS.equals(THAT) should return + * + * @param THIS + * @param THAT + * @return true if and only if THIS equals THAT + */ + boolean equals( Object THIS, Object THAT ); + + + /** + * Return hashcode for THIS.hashCode() + * + * @param THIS + * @return hashcode for THIS.hashCode() + */ + int hashCode( Object THIS ); +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/BCELFactory.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/BCELFactory.java new file mode 100644 index 00000000..b350b0e5 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/BCELFactory.java @@ -0,0 +1,347 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.util; + +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import org.apache.bcel.Const; +import org.apache.bcel.classfile.Utility; +import org.apache.bcel.generic.AllocationInstruction; +import org.apache.bcel.generic.ArrayInstruction; +import org.apache.bcel.generic.ArrayType; +import org.apache.bcel.generic.BranchHandle; +import org.apache.bcel.generic.BranchInstruction; +import org.apache.bcel.generic.CHECKCAST; +import org.apache.bcel.generic.CPInstruction; +import org.apache.bcel.generic.CodeExceptionGen; +import org.apache.bcel.generic.ConstantPoolGen; +import org.apache.bcel.generic.ConstantPushInstruction; +import org.apache.bcel.generic.EmptyVisitor; +import org.apache.bcel.generic.FieldInstruction; +import org.apache.bcel.generic.IINC; +import org.apache.bcel.generic.INSTANCEOF; +import org.apache.bcel.generic.Instruction; +import org.apache.bcel.generic.InstructionConst; +import org.apache.bcel.generic.InstructionHandle; +import org.apache.bcel.generic.InvokeInstruction; +import org.apache.bcel.generic.LDC; +import org.apache.bcel.generic.LDC2_W; +import org.apache.bcel.generic.LocalVariableInstruction; +import org.apache.bcel.generic.MULTIANEWARRAY; +import org.apache.bcel.generic.MethodGen; +import org.apache.bcel.generic.NEWARRAY; +import org.apache.bcel.generic.ObjectType; +import org.apache.bcel.generic.RET; +import org.apache.bcel.generic.ReturnInstruction; +import org.apache.bcel.generic.Select; +import org.apache.bcel.generic.Type; + +/** + * Factory creates il.append() statements, and sets instruction targets. + * A helper class for BCELifier. + * + * @see BCELifier + * @version $Id: BCELFactory.java 1749603 2016-06-21 20:50:19Z ggregory $ + */ +class BCELFactory extends EmptyVisitor { + + private static final String CONSTANT_PREFIX = Const.class.getSimpleName()+"."; + private final MethodGen _mg; + private final PrintWriter _out; + private final ConstantPoolGen _cp; + + + BCELFactory(final MethodGen mg, final PrintWriter out) { + _mg = mg; + _cp = mg.getConstantPool(); + _out = out; + } + + private final Map branch_map = new HashMap<>(); + + + public void start() { + if (!_mg.isAbstract() && !_mg.isNative()) { + for (InstructionHandle ih = _mg.getInstructionList().getStart(); ih != null; ih = ih + .getNext()) { + final Instruction i = ih.getInstruction(); + if (i instanceof BranchInstruction) { + branch_map.put(i, ih); // memorize container + } + if (ih.hasTargeters()) { + if (i instanceof BranchInstruction) { + _out.println(" InstructionHandle ih_" + ih.getPosition() + ";"); + } else { + _out.print(" InstructionHandle ih_" + ih.getPosition() + " = "); + } + } else { + _out.print(" "); + } + if (!visitInstruction(i)) { + i.accept(this); + } + } + updateBranchTargets(); + updateExceptionHandlers(); + } + } + + + private boolean visitInstruction( final Instruction i ) { + final short opcode = i.getOpcode(); + if ((InstructionConst.getInstruction(opcode) != null) + && !(i instanceof ConstantPushInstruction) && !(i instanceof ReturnInstruction)) { // Handled below + _out.println("il.append(InstructionConst." + + i.getName().toUpperCase(Locale.ENGLISH) + ");"); + return true; + } + return false; + } + + + @Override + public void visitLocalVariableInstruction( final LocalVariableInstruction i ) { + final short opcode = i.getOpcode(); + final Type type = i.getType(_cp); + if (opcode == Const.IINC) { + _out.println("il.append(new IINC(" + i.getIndex() + ", " + ((IINC) i).getIncrement() + + "));"); + } else { + final String kind = (opcode < Const.ISTORE) ? "Load" : "Store"; + _out.println("il.append(_factory.create" + kind + "(" + BCELifier.printType(type) + + ", " + i.getIndex() + "));"); + } + } + + + @Override + public void visitArrayInstruction( final ArrayInstruction i ) { + final short opcode = i.getOpcode(); + final Type type = i.getType(_cp); + final String kind = (opcode < Const.IASTORE) ? "Load" : "Store"; + _out.println("il.append(_factory.createArray" + kind + "(" + BCELifier.printType(type) + + "));"); + } + + + @Override + public void visitFieldInstruction( final FieldInstruction i ) { + final short opcode = i.getOpcode(); + final String class_name = i.getClassName(_cp); + final String field_name = i.getFieldName(_cp); + final Type type = i.getFieldType(_cp); + _out.println("il.append(_factory.createFieldAccess(\"" + class_name + "\", \"" + field_name + + "\", " + BCELifier.printType(type) + ", " + CONSTANT_PREFIX + + Const.getOpcodeName(opcode).toUpperCase(Locale.ENGLISH) + "));"); + } + + + @Override + public void visitInvokeInstruction( final InvokeInstruction i ) { + final short opcode = i.getOpcode(); + final String class_name = i.getClassName(_cp); + final String method_name = i.getMethodName(_cp); + final Type type = i.getReturnType(_cp); + final Type[] arg_types = i.getArgumentTypes(_cp); + _out.println("il.append(_factory.createInvoke(\"" + class_name + "\", \"" + method_name + + "\", " + BCELifier.printType(type) + ", " + + BCELifier.printArgumentTypes(arg_types) + ", " + CONSTANT_PREFIX + + Const.getOpcodeName(opcode).toUpperCase(Locale.ENGLISH) + "));"); + } + + + @Override + public void visitAllocationInstruction( final AllocationInstruction i ) { + Type type; + if (i instanceof CPInstruction) { + type = ((CPInstruction) i).getType(_cp); + } else { + type = ((NEWARRAY) i).getType(); + } + final short opcode = ((Instruction) i).getOpcode(); + int dim = 1; + switch (opcode) { + case Const.NEW: + _out.println("il.append(_factory.createNew(\"" + ((ObjectType) type).getClassName() + + "\"));"); + break; + case Const.MULTIANEWARRAY: + dim = ((MULTIANEWARRAY) i).getDimensions(); + //$FALL-THROUGH$ + case Const.ANEWARRAY: + case Const.NEWARRAY: + if (type instanceof ArrayType) { + type = ((ArrayType) type).getBasicType(); + } + _out.println("il.append(_factory.createNewArray(" + BCELifier.printType(type) + + ", (short) " + dim + "));"); + break; + default: + throw new RuntimeException("Oops: " + opcode); + } + } + + + private void createConstant( final Object value ) { + String embed = value.toString(); + if (value instanceof String) { + embed = '"' + Utility.convertString(embed) + '"'; + } else if (value instanceof Character) { + embed = "(char)0x" + Integer.toHexString(((Character) value).charValue()); + } else if (value instanceof Float) { + embed += "f"; + } else if (value instanceof Long) { + embed += "L"; + } else if (value instanceof ObjectType) { + final ObjectType ot = (ObjectType) value; + embed = "new ObjectType(\""+ot.getClassName()+"\")"; + } + + _out.println("il.append(new PUSH(_cp, " + embed + "));"); + } + + + @Override + public void visitLDC( final LDC i ) { + createConstant(i.getValue(_cp)); + } + + + @Override + public void visitLDC2_W( final LDC2_W i ) { + createConstant(i.getValue(_cp)); + } + + + @Override + public void visitConstantPushInstruction( final ConstantPushInstruction i ) { + createConstant(i.getValue()); + } + + + @Override + public void visitINSTANCEOF( final INSTANCEOF i ) { + final Type type = i.getType(_cp); + _out.println("il.append(new INSTANCEOF(_cp.addClass(" + BCELifier.printType(type) + ")));"); + } + + + @Override + public void visitCHECKCAST( final CHECKCAST i ) { + final Type type = i.getType(_cp); + _out.println("il.append(_factory.createCheckCast(" + BCELifier.printType(type) + "));"); + } + + + @Override + public void visitReturnInstruction( final ReturnInstruction i ) { + final Type type = i.getType(_cp); + _out.println("il.append(_factory.createReturn(" + BCELifier.printType(type) + "));"); + } + + // Memorize BranchInstructions that need an update + private final List branches = new ArrayList<>(); + + + @Override + public void visitBranchInstruction( final BranchInstruction bi ) { + final BranchHandle bh = (BranchHandle) branch_map.get(bi); + final int pos = bh.getPosition(); + final String name = bi.getName() + "_" + pos; + if (bi instanceof Select) { + final Select s = (Select) bi; + branches.add(bi); + final StringBuilder args = new StringBuilder("new int[] { "); + final int[] matchs = s.getMatchs(); + for (int i = 0; i < matchs.length; i++) { + args.append(matchs[i]); + if (i < matchs.length - 1) { + args.append(", "); + } + } + args.append(" }"); + _out.print("Select " + name + " = new " + bi.getName().toUpperCase(Locale.ENGLISH) + + "(" + args + ", new InstructionHandle[] { "); + for (int i = 0; i < matchs.length; i++) { + _out.print("null"); + if (i < matchs.length - 1) { + _out.print(", "); + } + } + _out.println(" }, null);"); + } else { + final int t_pos = bh.getTarget().getPosition(); + String target; + if (pos > t_pos) { + target = "ih_" + t_pos; + } else { + branches.add(bi); + target = "null"; + } + _out.println(" BranchInstruction " + name + " = _factory.createBranchInstruction(" + + CONSTANT_PREFIX + bi.getName().toUpperCase(Locale.ENGLISH) + ", " + target + + ");"); + } + if (bh.hasTargeters()) { + _out.println(" ih_" + pos + " = il.append(" + name + ");"); + } else { + _out.println(" il.append(" + name + ");"); + } + } + + + @Override + public void visitRET( final RET i ) { + _out.println("il.append(new RET(" + i.getIndex() + ")));"); + } + + + private void updateBranchTargets() { + for (final BranchInstruction bi : branches) { + final BranchHandle bh = (BranchHandle) branch_map.get(bi); + final int pos = bh.getPosition(); + final String name = bi.getName() + "_" + pos; + int t_pos = bh.getTarget().getPosition(); + _out.println(" " + name + ".setTarget(ih_" + t_pos + ");"); + if (bi instanceof Select) { + final InstructionHandle[] ihs = ((Select) bi).getTargets(); + for (int j = 0; j < ihs.length; j++) { + t_pos = ihs[j].getPosition(); + _out.println(" " + name + ".setTarget(" + j + ", ih_" + t_pos + ");"); + } + } + } + } + + + private void updateExceptionHandlers() { + final CodeExceptionGen[] handlers = _mg.getExceptionHandlers(); + for (final CodeExceptionGen h : handlers) { + final String type = (h.getCatchType() == null) ? "null" : BCELifier.printType(h + .getCatchType()); + _out.println(" method.addExceptionHandler(" + "ih_" + h.getStartPC().getPosition() + + ", " + "ih_" + h.getEndPC().getPosition() + ", " + "ih_" + + h.getHandlerPC().getPosition() + ", " + type + ");"); + } + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/BCELifier.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/BCELifier.java new file mode 100644 index 00000000..6b85577f --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/BCELifier.java @@ -0,0 +1,301 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.util; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.util.Locale; + +import org.apache.bcel.Const; +import org.apache.bcel.Repository; +import org.apache.bcel.classfile.ClassParser; +import org.apache.bcel.classfile.ConstantValue; +import org.apache.bcel.classfile.Field; +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.Method; +import org.apache.bcel.classfile.Utility; +import org.apache.bcel.generic.ArrayType; +import org.apache.bcel.generic.ConstantPoolGen; +import org.apache.bcel.generic.MethodGen; +import org.apache.bcel.generic.Type; + +/** + * This class takes a given JavaClass object and converts it to a + * Java program that creates that very class using BCEL. This + * gives new users of BCEL a useful example showing how things + * are done with BCEL. It does not cover all features of BCEL, + * but tries to mimic hand-written code as close as possible. + * + * @version $Id: BCELifier.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class BCELifier extends org.apache.bcel.classfile.EmptyVisitor { + + /** + * Enum corresponding to flag source. + */ + public enum FLAGS { + UNKNOWN, + CLASS, + METHOD, + } + + // The base package name for imports; assumes Const is at the top level + // N.B we use the class so renames will be detected by the compiler/IDE + private static final String BASE_PACKAGE = Const.class.getPackage().getName(); + private static final String CONSTANT_PREFIX = Const.class.getSimpleName()+"."; + + private final JavaClass _clazz; + private final PrintWriter _out; + private final ConstantPoolGen _cp; + + /** @param clazz Java class to "decompile" + * @param out where to output Java program + */ + public BCELifier(final JavaClass clazz, final OutputStream out) { + _clazz = clazz; + _out = new PrintWriter(out); + _cp = new ConstantPoolGen(_clazz.getConstantPool()); + } + + + /** Start Java code generation + */ + public void start() { + visitJavaClass(_clazz); + _out.flush(); + } + + + @Override + public void visitJavaClass( final JavaClass clazz ) { + String class_name = clazz.getClassName(); + final String super_name = clazz.getSuperclassName(); + final String package_name = clazz.getPackageName(); + final String inter = Utility.printArray(clazz.getInterfaceNames(), false, true); + if (!"".equals(package_name)) { + class_name = class_name.substring(package_name.length() + 1); + _out.println("package " + package_name + ";"); + _out.println(); + } + _out.println("import " + BASE_PACKAGE + ".generic.*;"); + _out.println("import " + BASE_PACKAGE + ".classfile.*;"); + _out.println("import " + BASE_PACKAGE + ".*;"); + _out.println("import java.io.*;"); + _out.println(); + _out.println("public class " + class_name + "Creator {"); + _out.println(" private InstructionFactory _factory;"); + _out.println(" private ConstantPoolGen _cp;"); + _out.println(" private ClassGen _cg;"); + _out.println(); + _out.println(" public " + class_name + "Creator() {"); + _out.println(" _cg = new ClassGen(\"" + + (("".equals(package_name)) ? class_name : package_name + "." + class_name) + + "\", \"" + super_name + "\", " + "\"" + clazz.getSourceFileName() + "\", " + + printFlags(clazz.getAccessFlags(), FLAGS.CLASS) + ", " + + "new String[] { " + inter + " });"); + _out.println(); + _out.println(" _cp = _cg.getConstantPool();"); + _out.println(" _factory = new InstructionFactory(_cg, _cp);"); + _out.println(" }"); + _out.println(); + printCreate(); + final Field[] fields = clazz.getFields(); + if (fields.length > 0) { + _out.println(" private void createFields() {"); + _out.println(" FieldGen field;"); + for (final Field field : fields) { + field.accept(this); + } + _out.println(" }"); + _out.println(); + } + final Method[] methods = clazz.getMethods(); + for (int i = 0; i < methods.length; i++) { + _out.println(" private void createMethod_" + i + "() {"); + methods[i].accept(this); + _out.println(" }"); + _out.println(); + } + printMain(); + _out.println("}"); + } + + + private void printCreate() { + _out.println(" public void create(OutputStream out) throws IOException {"); + final Field[] fields = _clazz.getFields(); + if (fields.length > 0) { + _out.println(" createFields();"); + } + final Method[] methods = _clazz.getMethods(); + for (int i = 0; i < methods.length; i++) { + _out.println(" createMethod_" + i + "();"); + } + _out.println(" _cg.getJavaClass().dump(out);"); + _out.println(" }"); + _out.println(); + } + + + private void printMain() { + final String class_name = _clazz.getClassName(); + _out.println(" public static void main(String[] args) throws Exception {"); + _out.println(" " + class_name + "Creator creator = new " + class_name + "Creator();"); + _out.println(" creator.create(new FileOutputStream(\"" + class_name + ".class\"));"); + _out.println(" }"); + } + + + @Override + public void visitField( final Field field ) { + _out.println(); + _out.println(" field = new FieldGen(" + printFlags(field.getAccessFlags()) + ", " + + printType(field.getSignature()) + ", \"" + field.getName() + "\", _cp);"); + final ConstantValue cv = field.getConstantValue(); + if (cv != null) { + final String value = cv.toString(); + _out.println(" field.setInitValue(" + value + ")"); + } + _out.println(" _cg.addField(field.getField());"); + } + + + @Override + public void visitMethod( final Method method ) { + final MethodGen mg = new MethodGen(method, _clazz.getClassName(), _cp); + _out.println(" InstructionList il = new InstructionList();"); + _out.println(" MethodGen method = new MethodGen(" + + printFlags(method.getAccessFlags(), FLAGS.METHOD) + ", " + + printType(mg.getReturnType()) + ", " + + printArgumentTypes(mg.getArgumentTypes()) + ", " + + "new String[] { " + Utility.printArray(mg.getArgumentNames(), false, true) + + " }, \"" + method.getName() + "\", \"" + _clazz.getClassName() + "\", il, _cp);"); + _out.println(); + final BCELFactory factory = new BCELFactory(mg, _out); + factory.start(); + _out.println(" method.setMaxStack();"); + _out.println(" method.setMaxLocals();"); + _out.println(" _cg.addMethod(method.getMethod());"); + _out.println(" il.dispose();"); + } + + + static String printFlags( final int flags ) { + return printFlags(flags, FLAGS.UNKNOWN); + } + + /** + * Return a string with the flag settings + * @param flags the flags field to interpret + * @param location the item type + * @return the formatted string + * @since 6.0 made public + */ + public static String printFlags( final int flags, final FLAGS location ) { + if (flags == 0) { + return "0"; + } + final StringBuilder buf = new StringBuilder(); + for (int i = 0, pow = 1; pow <= Const.MAX_ACC_FLAG; i++) { + if ((flags & pow) != 0) { + if ((pow == Const.ACC_SYNCHRONIZED) && (location == FLAGS.CLASS)) { + buf.append(CONSTANT_PREFIX+"ACC_SUPER | "); + } else if ((pow == Const.ACC_VOLATILE) && (location == FLAGS.METHOD)) { + buf.append(CONSTANT_PREFIX+"ACC_BRIDGE | "); + } else if ((pow == Const.ACC_TRANSIENT) && (location == FLAGS.METHOD)) { + buf.append(CONSTANT_PREFIX+"ACC_VARARGS | "); + } else { + if (i < Const.ACCESS_NAMES_LENGTH) { + buf.append(CONSTANT_PREFIX+"ACC_").append(Const.getAccessName(i).toUpperCase(Locale.ENGLISH)).append( " | "); + } else { + buf.append(String.format (CONSTANT_PREFIX+"ACC_BIT %x | ", pow)); + } + } + } + pow <<= 1; + } + final String str = buf.toString(); + return str.substring(0, str.length() - 3); + } + + + static String printArgumentTypes( final Type[] arg_types ) { + if (arg_types.length == 0) { + return "Type.NO_ARGS"; + } + final StringBuilder args = new StringBuilder(); + for (int i = 0; i < arg_types.length; i++) { + args.append(printType(arg_types[i])); + if (i < arg_types.length - 1) { + args.append(", "); + } + } + return "new Type[] { " + args.toString() + " }"; + } + + + static String printType( final Type type ) { + return printType(type.getSignature()); + } + + + static String printType( final String signature ) { + final Type type = Type.getType(signature); + final byte t = type.getType(); + if (t <= Const.T_VOID) { + return "Type." + Const.getTypeName(t).toUpperCase(Locale.ENGLISH); + } else if (type.toString().equals("java.lang.String")) { + return "Type.STRING"; + } else if (type.toString().equals("java.lang.Object")) { + return "Type.OBJECT"; + } else if (type.toString().equals("java.lang.StringBuffer")) { + return "Type.STRINGBUFFER"; + } else if (type instanceof ArrayType) { + final ArrayType at = (ArrayType) type; + return "new ArrayType(" + printType(at.getBasicType()) + ", " + at.getDimensions() + + ")"; + } else { + return "new ObjectType(\"" + Utility.signatureToString(signature, false) + "\")"; + } + } + + + /** Default main method + */ + public static void main( final String[] argv ) throws Exception { + if (argv.length != 1) { + System.out.println("Usage: BCELifier classname"); + System.out.println("\tThe class must exist on the classpath"); + return; + } + final JavaClass java_class = getJavaClass(argv[0]); + final BCELifier bcelifier = new BCELifier(java_class, System.out); + bcelifier.start(); + } + + + // Needs to be accessible from unit test code + static JavaClass getJavaClass(final String name) throws ClassNotFoundException, IOException { + JavaClass java_class; + if ((java_class = Repository.lookupClass(name)) == null) { + java_class = new ClassParser(name).parse(); // May throw IOException + } + return java_class; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ByteSequence.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ByteSequence.java old mode 100755 new mode 100644 similarity index 53% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ByteSequence.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ByteSequence.java index 802469b4..55825523 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ByteSequence.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ByteSequence.java @@ -1,68 +1,67 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.util; - -import java.io.ByteArrayInputStream; -import java.io.DataInputStream; - -/** - * 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: ByteSequence.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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--; - } - } - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.util; + +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; + +/** + * 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: ByteSequence.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public final class ByteSequence extends DataInputStream { + + private final ByteArrayStream byteStream; + + + public ByteSequence(final byte[] bytes) { + super(new ByteArrayStream(bytes)); + byteStream = (ByteArrayStream) in; + } + + + public final int getIndex() { + return byteStream.getPosition(); + } + + + final void unreadByte() { + byteStream.unreadByte(); + } + + private static final class ByteArrayStream extends ByteArrayInputStream { + + ByteArrayStream(final byte[] bytes) { + super(bytes); + } + + final int getPosition() { + // pos is protected in ByteArrayInputStream + return pos; + } + + final void unreadByte() { + if (pos > 0) { + pos--; + } + } + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/Class2HTML.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/Class2HTML.java new file mode 100644 index 00000000..0b56034f --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/Class2HTML.java @@ -0,0 +1,238 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.util; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.HashSet; +import java.util.Set; + +import org.apache.bcel.Const; +import org.apache.bcel.Constants; +import org.apache.bcel.classfile.Attribute; +import org.apache.bcel.classfile.ClassParser; +import org.apache.bcel.classfile.ConstantPool; +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.Method; +import org.apache.bcel.classfile.Utility; + +/** + * 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. + * + *

        + *
      1. "package"."class".html as the main file which defines the frames for + * the following subfiles. + *
      2. "package"."class"_attributes.html contains all (known) attributes found in the file + *
      3. "package"."class"_cp.html contains the constant pool + *
      4. "package"."class"_code.html contains the byte code + *
      5. "package"."class"_methods.html contains references to all methods and fields of the class + *
      + * + * All subfiles reference each other appropriately, e.g. clicking on a + * method in the Method's frame will jump to the appropriate method in + * the Code frame. + * + * @version $Id: Class2HTML.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class Class2HTML implements Constants { + + private final JavaClass java_class; // current class object + private final 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; + private static final Set basic_types = new HashSet<>(); + + static { + basic_types.add("int"); + basic_types.add("short"); + basic_types.add("boolean"); + basic_types.add("void"); + basic_types.add("char"); + basic_types.add("byte"); + basic_types.add("long"); + basic_types.add("double"); + basic_types.add("float"); + } + + /** + * 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(final JavaClass java_class, final String dir) throws IOException { + final 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 `.' + final int index = class_name.lastIndexOf('.'); + if (index > -1) { + class_package = class_name.substring(0, index); + } else { + class_package = ""; // default package + } + final 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. + */ + final AttributeHTML attribute_html = new AttributeHTML(dir, class_name, constant_pool, + constant_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( final String[] argv ) throws IOException { + final String[] file_name = new String[argv.length]; + int files = 0; + ClassParser parser = null; + JavaClass java_class = null; + String zip_file = null; + final char sep = File.separatorChar; + String dir = "." + sep; // Where to store HTML files + /* 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; + } + final File store = new File(dir); + if (!store.isDirectory()) { + final boolean created = store.mkdirs(); // Create target directory if necessary + if (!created) { + if (!store.isDirectory()) { + System.out.println("Tried to create the directory " + dir + " but failed"); + } + } + } + } else if (argv[i].equals("-zip")) { + zip_file = argv[++i]; + } else { + System.out.println("Unknown option " + argv[i]); + } + } else { + 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."); + } + } + } + + + /** + * Utility method that converts a class reference in the constant pool, + * i.e., an index to a string. + */ + static String referenceClass( final int index ) { + String str = constant_pool.getConstantString(index, Const.CONSTANT_Class); + str = Utility.compactClassName(str); + str = Utility.compactClassName(str, class_package + ".", true); + return "" + str + + ""; + } + + + static String referenceType( final String type ) { + String short_type = Utility.compactClassName(type); + short_type = Utility.compactClassName(short_type, class_package + ".", true); + final int index = type.indexOf('['); // Type is an array? + String base_type = type; + if (index > -1) { + base_type = type.substring(0, index); // Tack of the `[' + } + // test for basic type + if (basic_types.contains(base_type)) { + return "" + type + ""; + } + return "" + short_type + ""; + } + + + static String toHTML( final String str ) { + final StringBuilder buf = new StringBuilder(); + for (int i = 0; i < str.length(); i++) { + char ch; + switch (ch = str.charAt(i)) { + case '<': + buf.append("<"); + break; + case '>': + buf.append(">"); + break; + case '\n': + buf.append("\\n"); + break; + case '\r': + buf.append("\\r"); + break; + default: + buf.append(ch); + } + } + return buf.toString(); + } + + + private void writeMainHTML( final AttributeHTML attribute_html ) throws IOException { + try (PrintWriter file = new PrintWriter(new FileOutputStream(dir + class_name + ".html"))) { + file.println("\n" + "Documentation for " + class_name + "" + "\n" + + "\n" + "\n" + + "\n" + "\n" + "\n" + + "\n" + "\n" + + "\n" + ""); + } + final Attribute[] attributes = java_class.getAttributes(); + for (int i = 0; i < attributes.length; i++) { + attribute_html.writeAttribute(attributes[i], "class" + i); + } + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassLoader.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassLoader.java old mode 100755 new mode 100644 similarity index 62% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassLoader.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassLoader.java index 686d4f8e..cd430071 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassLoader.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassLoader.java @@ -1,185 +1,192 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.util; - -import java.io.ByteArrayInputStream; -import java.util.Hashtable; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.classfile.ClassParser; -import org.apache.bcel5_2_0.classfile.ConstantClass; -import org.apache.bcel5_2_0.classfile.ConstantPool; -import org.apache.bcel5_2_0.classfile.ConstantUtf8; -import org.apache.bcel5_2_0.classfile.JavaClass; -import org.apache.bcel5_2_0.classfile.Utility; - -/** - *

      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.

      - * - *

      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().

      - * - *

      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."

      - * - * @version $Id: ClassLoader.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @see JavaWrapper - * @see ClassPath - */ -public class ClassLoader extends java.lang.ClassLoader { - - public static final String[] DEFAULT_IGNORED_PACKAGES = { - "java.", "javax.", "sun." - }; - private Hashtable classes = new Hashtable(); // Hashtable is synchronized thus thread-safe - private String[] ignored_packages; - private Repository repository = SyntheticRepository.getInstance(); - - - /** Ignored packages are by default ( "java.", "sun.", - * "javax."), i.e. loaded by system class loader - */ - public ClassLoader() { - this(DEFAULT_IGNORED_PACKAGES); - } - - - /** @param deferTo delegate class loader to use for ignored packages - */ - public ClassLoader(java.lang.ClassLoader deferTo) { - super(deferTo); - this.ignored_packages = DEFAULT_IGNORED_PACKAGES; - this.repository = new ClassLoaderRepository(deferTo); - } - - - /** @param ignored_packages classes contained in these packages will be loaded - * with the system class loader - */ - public ClassLoader(String[] ignored_packages) { - this.ignored_packages = ignored_packages; - } - - - /** @param ignored_packages classes contained in these packages will be loaded - * with the system class loader - * @param deferTo delegate class loader to use for ignored packages - */ - public ClassLoader(java.lang.ClassLoader deferTo, String[] ignored_packages) { - this(ignored_packages); - this.repository = new ClassLoaderRepository(deferTo); - } - - - 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 = getParent().loadClass(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 - if ((clazz = repository.loadClass(class_name)) != null) { - clazz = modifyClass(clazz); - } else { - throw new ClassNotFoundException(class_name); - } - } - if (clazz != null) { - byte[] bytes = clazz.getBytes(); - cl = defineClass(class_name, bytes, 0, bytes.length); - } else { - 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
      - * - * The default implementation interprets the string as a encoded compressed - * Java class, unpacks and decodes it with the Utility.decode() method, and - * parses the 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; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.util; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.Hashtable; + +import org.apache.bcel.Constants; +import org.apache.bcel.classfile.ClassParser; +import org.apache.bcel.classfile.ConstantClass; +import org.apache.bcel.classfile.ConstantPool; +import org.apache.bcel.classfile.ConstantUtf8; +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.Utility; + +/** + *

      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.

      + * + *

      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().

      + * + *

      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."

      + * + * @version $Id: ClassLoader.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see JavaWrapper + * @see ClassPath + * @deprecated 6.0 Do not use - does not work + */ +@Deprecated +public class ClassLoader extends java.lang.ClassLoader { + + private static final String BCEL_TOKEN = "$$BCEL$$"; + + public static final String[] DEFAULT_IGNORED_PACKAGES = { + "java.", "javax.", "sun." + }; + + private final Hashtable> classes = new Hashtable<>(); + // Hashtable is synchronized thus thread-safe + private final String[] ignored_packages; + private Repository repository = SyntheticRepository.getInstance(); + + + /** Ignored packages are by default ( "java.", "sun.", + * "javax."), i.e. loaded by system class loader + */ + public ClassLoader() { + this(DEFAULT_IGNORED_PACKAGES); + } + + + /** @param deferTo delegate class loader to use for ignored packages + */ + public ClassLoader(final java.lang.ClassLoader deferTo) { + super(deferTo); + this.ignored_packages = DEFAULT_IGNORED_PACKAGES; + this.repository = new ClassLoaderRepository(deferTo); + } + + + /** @param ignored_packages classes contained in these packages will be loaded + * with the system class loader + */ + public ClassLoader(final String[] ignored_packages) { + this.ignored_packages = ignored_packages; + } + + + /** @param ignored_packages classes contained in these packages will be loaded + * with the system class loader + * @param deferTo delegate class loader to use for ignored packages + */ + public ClassLoader(final java.lang.ClassLoader deferTo, final String[] ignored_packages) { + this(ignored_packages); + this.repository = new ClassLoaderRepository(deferTo); + } + + @Override + protected Class loadClass( final String class_name, final boolean resolve ) throws ClassNotFoundException { + Class cl = null; + /* First try: lookup hash table. + */ + if ((cl = classes.get(class_name)) == null) { + /* Second try: Load system class using system class loader. You better + * don't mess around with them. + */ + for (final String ignored_package : ignored_packages) { + if (class_name.startsWith(ignored_package)) { + cl = getParent().loadClass(class_name); + break; + } + } + if (cl == null) { + JavaClass clazz = null; + /* Third try: Special request? + */ + if (class_name.contains(BCEL_TOKEN)) { + clazz = createClass(class_name); + } else { // Fourth try: Load classes via repository + if ((clazz = repository.loadClass(class_name)) != null) { + clazz = modifyClass(clazz); + } else { + throw new ClassNotFoundException(class_name); + } + } + if (clazz != null) { + final byte[] bytes = clazz.getBytes(); + cl = defineClass(class_name, bytes, 0, bytes.length); + } else { + 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( final 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 considered to be a package name. You can encode your own + * arguments into the subsequent string. You must ensure however not + * to use any "illegal" characters, i.e., characters that may not + * appear in a Java class name too
      + * + * The default implementation interprets the string as a encoded compressed + * Java class, unpacks and decodes it with the Utility.decode() method, and + * parses the resulting byte array and returns the resulting JavaClass object. + * + * @param class_name compressed byte code with "$$BCEL$$" in it + */ + protected JavaClass createClass( final String class_name ) { + final int index = class_name.indexOf(BCEL_TOKEN); + final String real_name = class_name.substring(index + BCEL_TOKEN.length()); + JavaClass clazz = null; + try { + final byte[] bytes = Utility.decode(real_name, true); + final ClassParser parser = new ClassParser(new ByteArrayInputStream(bytes), "foo"); + clazz = parser.parse(); + } catch (final IOException e) { + e.printStackTrace(); + return null; + } + // Adapt the class name to the passed value + final ConstantPool cp = clazz.getConstantPool(); + final ConstantClass cl = (ConstantClass) cp.getConstant(clazz.getClassNameIndex(), + Constants.CONSTANT_Class); + final ConstantUtf8 name = (ConstantUtf8) cp.getConstant(cl.getNameIndex(), + Constants.CONSTANT_Utf8); + name.setBytes(class_name.replace('.', '/')); + return clazz; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassLoaderRepository.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassLoaderRepository.java new file mode 100644 index 00000000..829a70a0 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassLoaderRepository.java @@ -0,0 +1,123 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.util; + +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; + +import org.apache.bcel.classfile.ClassParser; +import org.apache.bcel.classfile.JavaClass; + +/** + * The repository maintains information about which classes have + * been loaded. + * + * It loads its data from the ClassLoader implementation + * passed into its constructor. + * + * @see org.apache.bcel.Repository + * + * @version $Id: ClassLoaderRepository.java 1749603 2016-06-21 20:50:19Z ggregory $ + */ +public class ClassLoaderRepository implements Repository { + + private final java.lang.ClassLoader loader; + private final Map loadedClasses = new HashMap<>(); // CLASSNAME X JAVACLASS + + + public ClassLoaderRepository(final java.lang.ClassLoader loader) { + this.loader = loader; + } + + + /** + * Store a new JavaClass into this Repository. + */ + @Override + public void storeClass( final JavaClass clazz ) { + loadedClasses.put(clazz.getClassName(), clazz); + clazz.setRepository(this); + } + + + /** + * Remove class from repository + */ + @Override + public void removeClass( final JavaClass clazz ) { + loadedClasses.remove(clazz.getClassName()); + } + + + /** + * Find an already defined JavaClass. + */ + @Override + public JavaClass findClass( final String className ) { + return loadedClasses.containsKey(className) ? loadedClasses.get(className) : null; + } + + + /** + * Lookup a JavaClass object from the Class Name provided. + */ + @Override + public JavaClass loadClass(final String className) throws ClassNotFoundException { + final String classFile = className.replace('.', '/'); + JavaClass RC = findClass(className); + if (RC != null) { + return RC; + } + try (InputStream is = loader.getResourceAsStream(classFile + ".class")) { + if (is == null) { + throw new ClassNotFoundException(className + " not found."); + } + final ClassParser parser = new ClassParser(is, className); + RC = parser.parse(); + storeClass(RC); + return RC; + } catch (final IOException e) { + throw new ClassNotFoundException(className + " not found: " + e, e); + } + } + + + @Override + public JavaClass loadClass( final Class clazz ) throws ClassNotFoundException { + return loadClass(clazz.getName()); + } + + + /** Clear all entries from cache. + */ + @Override + public void clear() { + loadedClasses.clear(); + } + + + /* + * @return null + */ + @Override + public ClassPath getClassPath() { + return null; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassPath.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassPath.java new file mode 100644 index 00000000..5095e876 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassPath.java @@ -0,0 +1,546 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.util; + +import java.io.DataInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FilenameFilter; +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.Locale; +import java.util.StringTokenizer; +import java.util.Vector; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +/** + * Responsible for loading (class) files from the CLASSPATH. Inspired by + * sun.tools.ClassPath. + * + * @version $Id: ClassPath.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class ClassPath { + + public static final ClassPath SYSTEM_CLASS_PATH = new ClassPath(getClassPath()); + + private static final FilenameFilter ARCHIVE_FILTER = new FilenameFilter() { + + @Override + public boolean accept( final File dir, String name ) { + name = name.toLowerCase(Locale.ENGLISH); + return name.endsWith(".zip") || name.endsWith(".jar"); + } + }; + + private final PathEntry[] paths; + private final String class_path; + private ClassPath parent; + + public ClassPath(final ClassPath parent, final String class_path) { + this(class_path); + this.parent = parent; + } + + /** + * Search for classes in given path. + * + * @param class_path + */ + public ClassPath(final String class_path) { + this.class_path = class_path; + final List list = new ArrayList<>(); + for (final StringTokenizer tok = new StringTokenizer(class_path, File.pathSeparator); tok.hasMoreTokens();) { + final String path = tok.nextToken(); + if (!path.isEmpty()) { + final File file = new File(path); + try { + if (file.exists()) { + if (file.isDirectory()) { + list.add(new Dir(path)); + } else { + list.add(new Zip(new ZipFile(file))); + } + } + } catch (final IOException e) { + if (path.endsWith(".zip") || path.endsWith(".jar")) { + System.err.println("CLASSPATH component " + file + ": " + e); + } + } + } + } + paths = new PathEntry[list.size()]; + list.toArray(paths); + } + + /** + * Search for classes in CLASSPATH. + * @deprecated Use SYSTEM_CLASS_PATH constant + */ + @Deprecated + public ClassPath() { + this(getClassPath()); + } + + /** @return used class path string + */ + @Override + public String toString() { + if (parent != null) { + return parent + File.pathSeparator + class_path; + } + return class_path; + } + + @Override + public int hashCode() { + if (parent != null) { + return class_path.hashCode() + parent.hashCode(); + } + return class_path.hashCode(); + } + + + @Override + public boolean equals( final Object o ) { + if (o instanceof ClassPath) { + final ClassPath cp = (ClassPath)o; + return class_path.equals(cp.toString()); + } + return false; + } + + + private static void getPathComponents( final String path, final List list ) { + if (path != null) { + final StringTokenizer tok = new StringTokenizer(path, File.pathSeparator); + while (tok.hasMoreTokens()) { + final String name = tok.nextToken(); + final File file = new File(name); + if (file.exists()) { + list.add(name); + } + } + } + } + + + /** Checks for class path components in the following properties: + * "java.class.path", "sun.boot.class.path", "java.ext.dirs" + * + * @return class path as used by default by BCEL + */ + // @since 6.0 no longer final + public static String getClassPath() { + final String class_path = System.getProperty("java.class.path"); + final String boot_path = System.getProperty("sun.boot.class.path"); + final String ext_path = System.getProperty("java.ext.dirs"); + final List list = new ArrayList<>(); + getPathComponents(class_path, list); + getPathComponents(boot_path, list); + final List dirs = new ArrayList<>(); + getPathComponents(ext_path, dirs); + for (final String d : dirs) { + final File ext_dir = new File(d); + final String[] extensions = ext_dir.list(ARCHIVE_FILTER); + if (extensions != null) { + for (final String extension : extensions) { + list.add(ext_dir.getPath() + File.separatorChar + extension); + } + } + } + final StringBuilder buf = new StringBuilder(); + String separator = ""; + for (final String path : list) { + buf.append(separator); + separator = File.pathSeparator; + buf.append(path); + } + return buf.toString().intern(); + } + + + /** + * @param name fully qualified class name, e.g. java.lang.String + * @return input stream for class + */ + public InputStream getInputStream( final String name ) throws IOException { + return getInputStream(name.replace('.', '/'), ".class"); + } + + + /** + * Return stream for class or resource on CLASSPATH. + * + * @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( final String name, final String suffix ) throws IOException { + InputStream is = null; + try { + is = getClass().getClassLoader().getResourceAsStream(name + suffix); // may return null + } catch (final Exception e) { + // ignored + } + if (is != null) { + return is; + } + return getClassFile(name, suffix).getInputStream(); + } + + /** + * @param name fully qualified resource name, e.g. java/lang/String.class + * @return InputStream supplying the resource, or null if no resource with that name. + * @since 6.0 + */ + public InputStream getResourceAsStream(final String name) { + for (final PathEntry path : paths) { + InputStream is; + if ((is = path.getResourceAsStream(name)) != null) { + return is; + } + } + return null; + } + + /** + * @param name fully qualified resource name, e.g. java/lang/String.class + * @return URL supplying the resource, or null if no resource with that name. + * @since 6.0 + */ + public URL getResource(final String name) { + for (final PathEntry path : paths) { + URL url; + if ((url = path.getResource(name)) != null) { + return url; + } + } + return null; + } + + /** + * @param name fully qualified resource name, e.g. java/lang/String.class + * @return An Enumeration of URLs supplying the resource, or an + * empty Enumeration if no resource with that name. + * @since 6.0 + */ + public Enumeration getResources(final String name) { + final Vector results = new Vector<>(); + for (final PathEntry path : paths) { + URL url; + if ((url = path.getResource(name)) != null) { + results.add(url); + } + } + return results.elements(); + } + + /** + * @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( final String name, final String suffix ) throws IOException { + ClassFile cf = null; + + if (parent != null) { + cf = parent.getClassFileInternal(name, suffix); + } + + if (cf == null) { + cf = getClassFileInternal(name, suffix); + } + + if (cf != null) { + return cf; + } + + throw new IOException("Couldn't find: " + name + suffix); + } + + private ClassFile getClassFileInternal(final String name, final String suffix) throws IOException { + + for (final PathEntry path : paths) { + final ClassFile cf = path.getClassFile(name, suffix); + + if(cf != null) { + return cf; + } + } + + return null; + } + + + /** + * @param name fully qualified class name, e.g. java.lang.String + * @return input stream for class + */ + public ClassFile getClassFile( final 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(final String name, final String suffix) throws IOException { + DataInputStream dis = null; + try (InputStream is = getInputStream(name, suffix)) { + if (is == null) { + throw new IOException("Couldn't find: " + name + suffix); + } + dis = new DataInputStream(is); + final byte[] bytes = new byte[is.available()]; + dis.readFully(bytes); + return bytes; + } finally { + if (dis != null) { + dis.close(); + } + } + } + + + /** + * @return byte array for class + */ + public byte[] getBytes( final 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 { + final 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( final String name, final String suffix ) throws IOException { + return getClassFile(name, suffix).getPath(); + } + + private abstract static class PathEntry { + + abstract ClassFile getClassFile( String name, String suffix ) throws IOException; + abstract URL getResource(String name); + abstract InputStream getResourceAsStream(String name); + } + + /** Contains information about file/ZIP entry of the Java class. + */ + public interface ClassFile { + + /** @return input stream for class file. + */ + InputStream getInputStream() throws IOException; + + + /** @return canonical path to class file. + */ + String getPath(); + + + /** @return base path of found class, i.e. class is contained relative + * to that path, which may either denote a directory, or zip file + */ + String getBase(); + + + /** @return modification time of class file. + */ + long getTime(); + + + /** @return size of class file. + */ + long getSize(); + } + + private static class Dir extends PathEntry { + + private final String dir; + + + Dir(final String d) { + dir = d; + } + + @Override + URL getResource(final String name) { + // Resource specification uses '/' whatever the platform + final File file = new File(dir + File.separatorChar + name.replace('/', File.separatorChar)); + try { + return file.exists() ? file.toURI().toURL() : null; + } catch (final MalformedURLException e) { + return null; + } + } + + @Override + InputStream getResourceAsStream(final String name) { + // Resource specification uses '/' whatever the platform + final File file = new File(dir + File.separatorChar + name.replace('/', File.separatorChar)); + try { + return file.exists() ? new FileInputStream(file) : null; + } catch (final IOException e) { + return null; + } + } + + @Override + ClassFile getClassFile( final String name, final String suffix ) throws IOException { + final File file = new File(dir + File.separatorChar + + name.replace('.', File.separatorChar) + suffix); + return file.exists() ? new ClassFile() { + + @Override + public InputStream getInputStream() throws IOException { + return new FileInputStream(file); + } + + + @Override + public String getPath() { + try { + return file.getCanonicalPath(); + } catch (final IOException e) { + return null; + } + } + + + @Override + public long getTime() { + return file.lastModified(); + } + + + @Override + public long getSize() { + return file.length(); + } + + + @Override + public String getBase() { + return dir; + } + } : null; + } + + + @Override + public String toString() { + return dir; + } + } + + private static class Zip extends PathEntry { + + private final ZipFile zip; + + + Zip(final ZipFile z) { + zip = z; + } + + @Override + URL getResource(final String name) { + final ZipEntry entry = zip.getEntry(name); + try { + return (entry != null) ? new URL("jar:file:" + zip.getName() + "!/" + name) : null; + } catch (final MalformedURLException e) { + return null; + } + } + + @Override + InputStream getResourceAsStream(final String name) { + final ZipEntry entry = zip.getEntry(name); + try { + return (entry != null) ? zip.getInputStream(entry) : null; + } catch (final IOException e) { + return null; + } + } + + @Override + ClassFile getClassFile( final String name, final String suffix ) throws IOException { + final ZipEntry entry = zip.getEntry(name.replace('.', '/') + suffix); + + if (entry == null) { + return null; + } + + return new ClassFile() { + + @Override + public InputStream getInputStream() throws IOException { + return zip.getInputStream(entry); + } + + + @Override + public String getPath() { + return entry.toString(); + } + + + @Override + public long getTime() { + return entry.getTime(); + } + + + @Override + public long getSize() { + return entry.getSize(); + } + + + @Override + public String getBase() { + return zip.getName(); + } + }; + } + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassPathRepository.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassPathRepository.java new file mode 100644 index 00000000..f58d1b11 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassPathRepository.java @@ -0,0 +1,164 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.util; + +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; + +import org.apache.bcel.classfile.ClassParser; +import org.apache.bcel.classfile.JavaClass; + +/** + * This repository is used in situations where a Class is created outside the realm of a ClassLoader. Classes are loaded from the file systems using the paths + * specified in the given class path. By default, this is the value returned by ClassPath.getClassPath().
      + * + * @see org.apache.bcel.Repository + */ +public class ClassPathRepository implements Repository { + + private ClassPath _path = null; + private final Map _loadedClasses = new HashMap<>(); // CLASSNAME X JAVACLASS + + public ClassPathRepository(final ClassPath path) { + _path = path; + } + + /** + * Store a new JavaClass instance into this Repository. + */ + @Override + public void storeClass(final JavaClass clazz) { + _loadedClasses.put(clazz.getClassName(), clazz); + clazz.setRepository(this); + } + + /** + * Remove class from repository + */ + @Override + public void removeClass(final JavaClass clazz) { + _loadedClasses.remove(clazz.getClassName()); + } + + /** + * Find an already defined (cached) JavaClass object by name. + */ + @Override + public JavaClass findClass(final String className) { + return _loadedClasses.get(className); + } + + /** + * Find a JavaClass object by name. If it is already in this Repository, the Repository version is returned. Otherwise, the Repository's classpath is + * searched for the class (and it is added to the Repository if found). + * + * @param className + * the name of the class + * @return the JavaClass object + * @throws ClassNotFoundException + * if the class is not in the Repository, and could not be found on the classpath + */ + @Override + public JavaClass loadClass(String className) throws ClassNotFoundException { + if ((className == null) || className.isEmpty()) { + throw new IllegalArgumentException("Invalid class name " + className); + } + className = className.replace('/', '.'); // Just in case, canonical form + final JavaClass clazz = findClass(className); + if (clazz != null) { + return clazz; + } + try { + return loadClass(_path.getInputStream(className), className); + } catch (final IOException e) { + throw new ClassNotFoundException("Exception while looking for class " + className + ": " + e, e); + } + } + + /** + * Find the JavaClass object for a runtime Class object. If a class with the same name is already in this Repository, the Repository version is returned. + * Otherwise, getResourceAsStream() is called on the Class object to find the class's representation. If the representation is found, it is added to the + * Repository. + * + * @see Class + * @param clazz + * the runtime Class object + * @return JavaClass object for given runtime class + * @throws ClassNotFoundException + * if the class is not in the Repository, and its representation could not be found + */ + @Override + public JavaClass loadClass(final Class clazz) throws ClassNotFoundException { + final String className = clazz.getName(); + final JavaClass repositoryClass = findClass(className); + if (repositoryClass != null) { + return repositoryClass; + } + String name = className; + final int i = name.lastIndexOf('.'); + if (i > 0) { + name = name.substring(i + 1); + } + JavaClass cls = null; + try (InputStream clsStream = clazz.getResourceAsStream(name + ".class")) { + return cls = loadClass(clsStream, className); + } catch (final IOException e) { + return cls; + } + } + + private JavaClass loadClass(final InputStream is, final String className) throws ClassNotFoundException { + try { + if (is != null) { + final ClassParser parser = new ClassParser(is, className); + final JavaClass clazz = parser.parse(); + storeClass(clazz); + return clazz; + } + } catch (final IOException e) { + throw new ClassNotFoundException("Exception while looking for class " + className + ": " + e, e); + } finally { + if (is != null) { + try { + is.close(); + } catch (final IOException e) { + // ignored + } + } + } + throw new ClassNotFoundException("SyntheticRepository could not load " + className); + } + + /** + * ClassPath associated with the Repository. + */ + @Override + public ClassPath getClassPath() { + return _path; + } + + /** + * Clear all entries from cache. + */ + @Override + public void clear() { + _loadedClasses.clear(); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassQueue.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassQueue.java new file mode 100644 index 00000000..f8fa1edd --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassQueue.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.util; + +import java.util.LinkedList; + +import org.apache.bcel.classfile.JavaClass; + +/** + * Utility class implementing a (typesafe) queue of JavaClass + * objects. + * + * @version $Id: ClassQueue.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class ClassQueue { + + /** + * @deprecated (since 6.0) will be made private; do not access + */ + @Deprecated + protected LinkedList vec = new LinkedList<>(); // TODO not used externally + + + public void enqueue( final JavaClass clazz ) { + vec.addLast(clazz); + } + + + public JavaClass dequeue() { + return vec.removeFirst(); + } + + + public boolean empty() { + return vec.isEmpty(); + } + + + @Override + public String toString() { + return vec.toString(); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassSet.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassSet.java new file mode 100644 index 00000000..706c4835 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassSet.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.util; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import org.apache.bcel.classfile.JavaClass; + +/** + * Utility class implementing a (typesafe) set of JavaClass objects. + * Since JavaClass has no equals() method, the name of the class is + * used for comparison. + * + * @version $Id: ClassSet.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see ClassStack + */ +public class ClassSet { + + private final Map map = new HashMap<>(); + + + public boolean add( final JavaClass clazz ) { + boolean result = false; + if (!map.containsKey(clazz.getClassName())) { + result = true; + map.put(clazz.getClassName(), clazz); + } + return result; + } + + + public void remove( final JavaClass clazz ) { + map.remove(clazz.getClassName()); + } + + + public boolean empty() { + return map.isEmpty(); + } + + + public JavaClass[] toArray() { + final Collection values = map.values(); + final JavaClass[] classes = new JavaClass[values.size()]; + values.toArray(classes); + return classes; + } + + + public String[] getClassNames() { + return map.keySet().toArray(new String[map.size()]); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassStack.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassStack.java new file mode 100644 index 00000000..d8051970 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassStack.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.util; + +import java.util.Stack; + +import org.apache.bcel.classfile.JavaClass; + +/** + * Utility class implementing a (typesafe) stack of JavaClass objects. + * + * @version $Id: ClassStack.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see Stack + */ +public class ClassStack { + + private final Stack stack = new Stack<>(); + + + public void push( final JavaClass clazz ) { + stack.push(clazz); + } + + + public JavaClass pop() { + return stack.pop(); + } + + + public JavaClass top() { + return stack.peek(); + } + + + public boolean empty() { + return stack.empty(); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassVector.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassVector.java new file mode 100644 index 00000000..bfb291c8 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassVector.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.util; + +import java.util.ArrayList; +import java.util.List; + +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: ClassVector.java 1806200 2017-08-25 16:33:06Z ggregory $ + * + * @deprecated as of 5.1.1 - 7/17/2005 + */ +@Deprecated +public class ClassVector implements java.io.Serializable { + + private static final long serialVersionUID = 5600397075672780806L; + @Deprecated + protected List vec = new ArrayList<>(); + + + public void addElement( final JavaClass clazz ) { + vec.add(clazz); + } + + + public JavaClass elementAt( final int index ) { + return vec.get(index); + } + + + public void removeElementAt( final int index ) { + vec.remove(index); + } + + + public JavaClass[] toArray() { + final JavaClass[] classes = new JavaClass[vec.size()]; + vec.toArray(classes); + return classes; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/CodeHTML.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/CodeHTML.java old mode 100755 new mode 100644 similarity index 54% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/CodeHTML.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/CodeHTML.java index 6045c31c..5b582737 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/CodeHTML.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/CodeHTML.java @@ -1,565 +1,583 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.util; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.BitSet; - -import org.apache.bcel5_2_0.classfile.Attribute; -import org.apache.bcel5_2_0.classfile.Code; -import org.apache.bcel5_2_0.classfile.CodeException; -import org.apache.bcel5_2_0.classfile.ConstantFieldref; -import org.apache.bcel5_2_0.classfile.ConstantInterfaceMethodref; -import org.apache.bcel5_2_0.classfile.ConstantMethodref; -import org.apache.bcel5_2_0.classfile.ConstantNameAndType; -import org.apache.bcel5_2_0.classfile.ConstantPool; -import org.apache.bcel5_2_0.classfile.LocalVariable; -import org.apache.bcel5_2_0.classfile.LocalVariableTable; -import org.apache.bcel5_2_0.classfile.Method; -import org.apache.bcel5_2_0.classfile.Utility; - -/** - * Convert code into HTML file. - * - * @version $Id: CodeHTML.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * - */ -final class CodeHTML implements org.apache.bcel5_2_0.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(""); - for (int i = 0; i < methods.length; i++) { - writeMethod(methods[i], i); - } - file.println(""); - 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(); - StringBuilder buf; - String name, signature; - int default_offset = 0, low, high; - int index, class_index, vindex, constant; - int[] jump_table; - int no_pad_bytes = 0, offset; - buf = new StringBuilder(256); - buf.append("").append(OPCODE_NAMES[opcode]).append(""); - /* 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(""); - // 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(""); - } - buf.append("\n"); - // Print target and default indices in second row - for (int i = 0; i < jump_table.length; i++) { - buf.append(""); - } - buf.append("\n
      ").append(low + i).append("default
      ").append(jump_table[i]).append("").append(default_offset).append( - "
      \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(""); - // 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(""); - } - buf.append("\n"); - // Print target and default indices in second row - for (int i = 0; i < npairs; i++) { - buf.append(""); - } - buf.append("\n
      ").append(match).append("default
      ").append(jump_table[i]).append("").append(default_offset).append( - "
      \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("").append(index).append(""); - break; - /* Same for 32-bit wide jumps - */ - case GOTO_W: - case JSR_W: - int windex = bytes.getIndex() + bytes.readInt() - 1; - buf.append("").append(windex).append(""); - 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("%").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("").append(TYPE_NAMES[bytes.readByte()]).append( - ""); - 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("").append(field_name) - .append("\n"); - } else { - buf.append(constant_html.referenceConstant(class_index)).append(".").append( - 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).append(".").append(str).append( - "").append("("); - // 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("):").append(Class2HTML.referenceType(type)); - break; - /* Operands are references to items in constant pool - */ - case LDC_W: - case LDC2_W: - index = bytes.readShort(); - buf.append("").append( - Class2HTML.toHTML(constant_pool.constantToString(index, - constant_pool.getConstant(index).getTag()))).append(""); - break; - case LDC: - index = bytes.readUnsignedByte(); - buf.append("").append( - Class2HTML.toHTML(constant_pool.constantToString(index, - constant_pool.getConstant(index).getTag()))).append(""); - 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)).append(":").append(dimensions) - .append("-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("%").append(vindex).append(" ").append(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(" "); - } - } - } - buf.append(""); - return buf.toString(); - } - - - /** - * Find all target addresses in code, so that they can be marked - * with <A NAME = ...>. 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, " ", " "); - // Get the method's attributes, the Code Attribute in particular - Attribute[] attributes = method.getAttributes(); - file.print("

      " + access + " " + "" + Class2HTML.referenceType(type) + " " - + html_name + "("); - for (int i = 0; i < args.length; i++) { - file.print(Class2HTML.referenceType(args[i])); - if (i < args.length - 1) { - file.print(", "); - } - } - file.println(")

      "); - Code c = null; - byte[] code = null; - if (attributes.length > 0) { - file.print("

      Attributes

        \n"); - for (int i = 0; i < attributes.length; i++) { - byte tag = attributes[i].getTag(); - if (tag != ATTR_UNKNOWN) { - file.print("
      • " - + ATTRIBUTE_NAMES[tag] + "
      • \n"); - } else { - file.print("
      • " + attributes[i] + "
      • "); - } - if (tag == ATTR_CODE) { - c = (Code) attributes[i]; - Attribute[] attributes2 = c.getAttributes(); - code = c.getCode(); - file.print("
          "); - for (int j = 0; j < attributes2.length; j++) { - tag = attributes2[j].getTag(); - file.print("
        • " - + ATTRIBUTE_NAMES[tag] + "
        • \n"); - } - file.print("
        "); - } - } - file.println("
      "); - } - 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("" - + ""); - 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 = ""; - } - String anchor2; - if (stream.getIndex() == code.length) { - anchor2 = "" + offset - + ""; - } else { - anchor2 = "" + offset; - } - file - .println(""); - } - // Mark last line, may be targetted from Attributes window - file.println(""); - file.println("
      Byte
      offset
      InstructionArgument
      " + anchor2 + "" + anchor + str - + "
      "); - } - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.util; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.BitSet; + +import org.apache.bcel.Const; +import org.apache.bcel.classfile.Attribute; +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.CodeException; +import org.apache.bcel.classfile.ConstantFieldref; +import org.apache.bcel.classfile.ConstantInterfaceMethodref; +import org.apache.bcel.classfile.ConstantInvokeDynamic; +import org.apache.bcel.classfile.ConstantMethodref; +import org.apache.bcel.classfile.ConstantNameAndType; +import org.apache.bcel.classfile.ConstantPool; +import org.apache.bcel.classfile.LocalVariable; +import org.apache.bcel.classfile.LocalVariableTable; +import org.apache.bcel.classfile.Method; +import org.apache.bcel.classfile.Utility; + +/** + * Convert code into HTML file. + * + * @version $Id: CodeHTML.java 1806200 2017-08-25 16:33:06Z ggregory $ + * + */ +final class CodeHTML { + + private final String class_name; // name of current class +// private Method[] methods; // Methods to print + private final PrintWriter file; // file to write to + private BitSet goto_set; + private final ConstantPool constant_pool; + private final ConstantHTML constant_html; + private static boolean wide = false; + + + CodeHTML(final String dir, final String class_name, final Method[] methods, final ConstantPool constant_pool, + final 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(""); + for (int i = 0; i < methods.length; i++) { + writeMethod(methods[i], i); + } + file.println(""); + 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 String codeToHTML( final ByteSequence bytes, final int method_number ) throws IOException { + final short opcode = (short) bytes.readUnsignedByte(); + String name; + String signature; + int default_offset = 0; + int low; + int high; + int index; + int class_index; + int vindex; + int constant; + int[] jump_table; + int no_pad_bytes = 0; + int offset; + final StringBuilder buf = new StringBuilder(256); // CHECKSTYLE IGNORE MagicNumber + buf.append("").append(Const.getOpcodeName(opcode)).append(""); + /* Special case: Skip (0-3) padding bytes, i.e., the + * following bytes are 4-byte-aligned + */ + if ((opcode == Const.TABLESWITCH) || (opcode == Const.LOOKUPSWITCH)) { + final 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 Const.TABLESWITCH: + low = bytes.readInt(); + high = bytes.readInt(); + offset = bytes.getIndex() - 12 - no_pad_bytes - 1; + default_offset += offset; + buf.append(""); + // 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(""); + } + buf.append("\n"); + // Print target and default indices in second row + for (final int element : jump_table) { + buf.append(""); + } + buf.append("\n
      ").append(low + i).append("default
      ").append(element).append("").append(default_offset).append( + "
      \n"); + break; + /* Lookup switch has variable length arguments. + */ + case Const.LOOKUPSWITCH: + final int npairs = bytes.readInt(); + offset = bytes.getIndex() - 8 - no_pad_bytes - 1; + jump_table = new int[npairs]; + default_offset += offset; + buf.append(""); + // Print switch indices in first row (and default) + for (int i = 0; i < npairs; i++) { + final int match = bytes.readInt(); + jump_table[i] = offset + bytes.readInt(); + buf.append(""); + } + buf.append("\n"); + // Print target and default indices in second row + for (int i = 0; i < npairs; i++) { + buf.append(""); + } + buf.append("\n
      ").append(match).append("default
      ").append(jump_table[i]).append("").append(default_offset).append( + "
      \n"); + break; + /* Two address bytes + offset from start of byte stream form the + * jump target. + */ + case Const.GOTO: + case Const.IFEQ: + case Const.IFGE: + case Const.IFGT: + case Const.IFLE: + case Const.IFLT: + case Const.IFNE: + case Const.IFNONNULL: + case Const.IFNULL: + case Const.IF_ACMPEQ: + case Const.IF_ACMPNE: + case Const.IF_ICMPEQ: + case Const.IF_ICMPGE: + case Const.IF_ICMPGT: + case Const.IF_ICMPLE: + case Const.IF_ICMPLT: + case Const.IF_ICMPNE: + case Const.JSR: + index = bytes.getIndex() + bytes.readShort() - 1; + buf.append("").append(index).append(""); + break; + /* Same for 32-bit wide jumps + */ + case Const.GOTO_W: + case Const.JSR_W: + final int windex = bytes.getIndex() + bytes.readInt() - 1; + buf.append("").append(windex).append(""); + break; + /* Index byte references local variable (register) + */ + case Const.ALOAD: + case Const.ASTORE: + case Const.DLOAD: + case Const.DSTORE: + case Const.FLOAD: + case Const.FSTORE: + case Const.ILOAD: + case Const.ISTORE: + case Const.LLOAD: + case Const.LSTORE: + case Const.RET: + if (wide) { + vindex = bytes.readShort(); + wide = false; // Clear flag + } else { + vindex = bytes.readUnsignedByte(); + } + buf.append("%").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 Const.WIDE: + wide = true; + buf.append("(wide)"); + break; + /* Array of basic type. + */ + case Const.NEWARRAY: + buf.append("").append(Const.getTypeName(bytes.readByte())).append( + ""); + break; + /* Access object/class fields. + */ + case Const.GETFIELD: + case Const.GETSTATIC: + case Const.PUTFIELD: + case Const.PUTSTATIC: + index = bytes.readShort(); + final ConstantFieldref c1 = (ConstantFieldref) constant_pool.getConstant(index, + Const.CONSTANT_Fieldref); + class_index = c1.getClassIndex(); + name = constant_pool.getConstantString(class_index, Const.CONSTANT_Class); + name = Utility.compactClassName(name, false); + index = c1.getNameAndTypeIndex(); + final String field_name = constant_pool.constantToString(index, Const.CONSTANT_NameAndType); + if (name.equals(class_name)) { // Local field + buf.append("").append(field_name) + .append("\n"); + } else { + buf.append(constant_html.referenceConstant(class_index)).append(".").append( + field_name); + } + break; + /* Operands are references to classes in constant pool + */ + case Const.CHECKCAST: + case Const.INSTANCEOF: + case Const.NEW: + index = bytes.readShort(); + buf.append(constant_html.referenceConstant(index)); + break; + /* Operands are references to methods in constant pool + */ + case Const.INVOKESPECIAL: + case Const.INVOKESTATIC: + case Const.INVOKEVIRTUAL: + case Const.INVOKEINTERFACE: + case Const.INVOKEDYNAMIC: + final int m_index = bytes.readShort(); + String str; + if (opcode == Const.INVOKEINTERFACE) { // Special treatment needed + bytes.readUnsignedByte(); // Redundant + bytes.readUnsignedByte(); // Reserved +// int nargs = bytes.readUnsignedByte(); // Redundant +// int reserved = bytes.readUnsignedByte(); // Reserved + final ConstantInterfaceMethodref c = (ConstantInterfaceMethodref) constant_pool + .getConstant(m_index, Const.CONSTANT_InterfaceMethodref); + class_index = c.getClassIndex(); + index = c.getNameAndTypeIndex(); + name = Class2HTML.referenceClass(class_index); + } else if (opcode == Const.INVOKEDYNAMIC) { // Special treatment needed + bytes.readUnsignedByte(); // Reserved + bytes.readUnsignedByte(); // Reserved + final ConstantInvokeDynamic c = (ConstantInvokeDynamic) constant_pool + .getConstant(m_index, Const.CONSTANT_InvokeDynamic); + index = c.getNameAndTypeIndex(); + name = "#" + c.getBootstrapMethodAttrIndex(); + } else { + // UNDONE: Java8 now allows INVOKESPECIAL and INVOKESTATIC to + // reference EITHER a Methodref OR an InterfaceMethodref. + // Not sure if that affects this code or not. (markro) + final ConstantMethodref c = (ConstantMethodref) constant_pool.getConstant(m_index, + Const.CONSTANT_Methodref); + class_index = c.getClassIndex(); + index = c.getNameAndTypeIndex(); + name = Class2HTML.referenceClass(class_index); + } + str = Class2HTML.toHTML(constant_pool.constantToString(constant_pool.getConstant( + index, Const.CONSTANT_NameAndType))); + // Get signature, i.e., types + final ConstantNameAndType c2 = (ConstantNameAndType) constant_pool.getConstant(index, + Const.CONSTANT_NameAndType); + signature = constant_pool.constantToString(c2.getSignatureIndex(), Const.CONSTANT_Utf8); + final String[] args = Utility.methodSignatureArgumentTypes(signature, false); + final String type = Utility.methodSignatureReturnType(signature, false); + buf.append(name).append(".").append(str).append( + "").append("("); + // 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("):").append(Class2HTML.referenceType(type)); + break; + /* Operands are references to items in constant pool + */ + case Const.LDC_W: + case Const.LDC2_W: + index = bytes.readShort(); + buf.append("").append( + Class2HTML.toHTML(constant_pool.constantToString(index, + constant_pool.getConstant(index).getTag()))).append(""); + break; + case Const.LDC: + index = bytes.readUnsignedByte(); + buf.append("").append( + Class2HTML.toHTML(constant_pool.constantToString(index, + constant_pool.getConstant(index).getTag()))).append(""); + break; + /* Array of references. + */ + case Const.ANEWARRAY: + index = bytes.readShort(); + buf.append(constant_html.referenceConstant(index)); + break; + /* Multidimensional array of references. + */ + case Const.MULTIANEWARRAY: + index = bytes.readShort(); + final int dimensions = bytes.readByte(); + buf.append(constant_html.referenceConstant(index)).append(":").append(dimensions) + .append("-dimensional"); + break; + /* Increment local variable. + */ + case Const.IINC: + if (wide) { + vindex = bytes.readShort(); + constant = bytes.readShort(); + wide = false; + } else { + vindex = bytes.readUnsignedByte(); + constant = bytes.readByte(); + } + buf.append("%").append(vindex).append(" ").append(constant); + break; + default: + if (Const.getNoOfOperands(opcode) > 0) { + for (int i = 0; i < Const.getOperandTypeCount(opcode); i++) { + switch (Const.getOperandType(opcode, i)) { + case Const.T_BYTE: + buf.append(bytes.readUnsignedByte()); + break; + case Const.T_SHORT: // Either branch or index + buf.append(bytes.readShort()); + break; + case Const.T_INT: + buf.append(bytes.readInt()); + break; + default: // Never reached + throw new IllegalStateException("Unreachable default case reached! "+Const.getOperandType(opcode, i)); + } + buf.append(" "); + } + } + } + buf.append(""); + return buf.toString(); + } + + + /** + * Find all target addresses in code, so that they can be marked + * with <A NAME = ...>. Target addresses are kept in an BitSet object. + */ + private void findGotos( final ByteSequence bytes, final 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) { + final CodeException[] ce = code.getExceptionTable(); + for (final CodeException cex : ce) { + goto_set.set(cex.getStartPC()); + goto_set.set(cex.getEndPC()); + goto_set.set(cex.getHandlerPC()); + } + // Look for local variables and their range + final Attribute[] attributes = code.getAttributes(); + for (final Attribute attribute : attributes) { + if (attribute.getTag() == Const.ATTR_LOCAL_VARIABLE_TABLE) { + final LocalVariable[] vars = ((LocalVariableTable) attribute) + .getLocalVariableTable(); + for (final LocalVariable var : vars) { + final int start = var.getStartPC(); + final int end = start + var.getLength(); + goto_set.set(start); + goto_set.set(end); + } + break; + } + } + } + // Get target addresses from GOTO, JSR, TABLESWITCH, etc. + for (; bytes.available() > 0;) { + opcode = bytes.readUnsignedByte(); + //System.out.println(getOpcodeName(opcode)); + switch (opcode) { + case Const.TABLESWITCH: + case Const.LOOKUPSWITCH: + //bytes.readByte(); // Skip already read byte + final int remainder = bytes.getIndex() % 4; + final int no_pad_bytes = (remainder == 0) ? 0 : 4 - remainder; + int default_offset; + int 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 == Const.TABLESWITCH) { + final int low = bytes.readInt(); + final 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 + final 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(); + bytes.readInt(); + index = offset + bytes.readInt(); + goto_set.set(index); + } + } + break; + case Const.GOTO: + case Const.IFEQ: + case Const.IFGE: + case Const.IFGT: + case Const.IFLE: + case Const.IFLT: + case Const.IFNE: + case Const.IFNONNULL: + case Const.IFNULL: + case Const.IF_ACMPEQ: + case Const.IF_ACMPNE: + case Const.IF_ICMPEQ: + case Const.IF_ICMPGE: + case Const.IF_ICMPGT: + case Const.IF_ICMPLE: + case Const.IF_ICMPLT: + case Const.IF_ICMPNE: + case Const.JSR: + //bytes.readByte(); // Skip already read byte + index = bytes.getIndex() + bytes.readShort() - 1; + goto_set.set(index); + break; + case Const.GOTO_W: + case Const.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( final Method method, final int method_number ) throws IOException { + // Get raw signature + final String signature = method.getSignature(); + // Get array of strings containing the argument types + final String[] args = Utility.methodSignatureArgumentTypes(signature, false); + // Get return type string + final String type = Utility.methodSignatureReturnType(signature, false); + // Get method name + final String name = method.getName(); + final String html_name = Class2HTML.toHTML(name); + // Get method's access flags + String access = Utility.accessToString(method.getAccessFlags()); + access = Utility.replace(access, " ", " "); + // Get the method's attributes, the Code Attribute in particular + final Attribute[] attributes = method.getAttributes(); + file.print("

      " + access + " " + "" + Class2HTML.referenceType(type) + " " + + html_name + "("); + for (int i = 0; i < args.length; i++) { + file.print(Class2HTML.referenceType(args[i])); + if (i < args.length - 1) { + file.print(", "); + } + } + file.println(")

      "); + Code c = null; + byte[] code = null; + if (attributes.length > 0) { + file.print("

      Attributes

        \n"); + for (int i = 0; i < attributes.length; i++) { + byte tag = attributes[i].getTag(); + if (tag != Const.ATTR_UNKNOWN) { + file.print("
      • " + + Const.getAttributeName(tag) + "
      • \n"); + } else { + file.print("
      • " + attributes[i] + "
      • "); + } + if (tag == Const.ATTR_CODE) { + c = (Code) attributes[i]; + final Attribute[] attributes2 = c.getAttributes(); + code = c.getCode(); + file.print(""); + } + } + file.println("
      "); + } + 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 + try (ByteSequence stream = new ByteSequence(code)) { + stream.mark(stream.available()); + findGotos(stream, c); + stream.reset(); + file.println("" + + ""); + for (; stream.available() > 0;) { + final int offset = stream.getIndex(); + final 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 = ""; + } + String anchor2; + if (stream.getIndex() == code.length) { + anchor2 = "" + offset + ""; + } else { + anchor2 = "" + offset; + } + file.println(""); + } + } + // Mark last line, may be targetted from Attributes window + file.println(""); + file.println("
      Byte
      offset
      InstructionArgument
      " + anchor2 + "" + anchor + str + "
      "); + } + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ConstantHTML.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ConstantHTML.java old mode 100755 new mode 100644 similarity index 59% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ConstantHTML.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ConstantHTML.java index 2afd9f37..a1af88d9 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ConstantHTML.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ConstantHTML.java @@ -1,235 +1,233 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.util; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintWriter; - -import org.apache.bcel5_2_0.classfile.Constant; -import org.apache.bcel5_2_0.classfile.ConstantClass; -import org.apache.bcel5_2_0.classfile.ConstantFieldref; -import org.apache.bcel5_2_0.classfile.ConstantInterfaceMethodref; -import org.apache.bcel5_2_0.classfile.ConstantMethodref; -import org.apache.bcel5_2_0.classfile.ConstantNameAndType; -import org.apache.bcel5_2_0.classfile.ConstantPool; -import org.apache.bcel5_2_0.classfile.ConstantString; -import org.apache.bcel5_2_0.classfile.Method; -import org.apache.bcel5_2_0.classfile.Utility; - -/** - * Convert constant pool into HTML file. - * - * @version $Id: ConstantHTML.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * - */ -final class ConstantHTML implements org.apache.bcel5_2_0.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] = "<unknown>"; - file.println(""); - // Loop through constants, constants[0] is reserved - for (int i = 1; i < constants.length; i++) { - if (i % 2 == 0) { - file.print("\n"); - } - file.println("
      "); - } else { - file.print("
      "); - } - if (constants[i] != null) { - writeConstant(i); - } - file.print("
      "); - 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("

      " + index + " " + CONSTANT_NAMES[tag] - + "

      "); - /* 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); - StringBuilder buf = new StringBuilder("("); - for (int i = 0; i < args.length; i++) { - buf.append(Class2HTML.referenceType(args[i])); - if (i < args.length - 1) { - buf.append(", "); - } - } - buf.append(")"); - String arg_types = buf.toString(); - if (method_class.equals(class_name)) { - ref = "" - + html_method_name + ""; - } else { - ref = "" - + short_method_class + "." + html_method_name; - } - constant_ref[index] = ret_type + " " + short_method_class - + "." + html_method_name + " " + arg_types; - file.println("

      " + ret_type + " " + ref + arg_types - + " \n

      "); - 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)) { - ref = "" + field_name + ""; - } else { - ref = "" + short_field_class - + "." + field_name + "\n"; - } - constant_ref[index] = "" + short_field_class + "." - + field_name + ""; - file.println("

      " + ref + "
      \n" + "

      "); - 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 = "" + short_class_name - + ""; - constant_ref[index] = "" + short_class_name + ""; - file.println("

      " + ref + "

      \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("

      " + str + "

      \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("

      " - + Class2HTML.toHTML(constant_pool.constantToString(index, tag)) - + "

      \n"); - break; - default: - file - .println("

      " - + Class2HTML.toHTML(constant_pool.constantToString(index, tag)) - + "\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; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.util; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintWriter; + +import org.apache.bcel.Const; +import org.apache.bcel.classfile.Constant; +import org.apache.bcel.classfile.ConstantClass; +import org.apache.bcel.classfile.ConstantFieldref; +import org.apache.bcel.classfile.ConstantInterfaceMethodref; +import org.apache.bcel.classfile.ConstantMethodref; +import org.apache.bcel.classfile.ConstantNameAndType; +import org.apache.bcel.classfile.ConstantPool; +import org.apache.bcel.classfile.ConstantString; +import org.apache.bcel.classfile.Method; +import org.apache.bcel.classfile.Utility; + +/** + * Convert constant pool into HTML file. + * + * @version $Id: ConstantHTML.java 1806200 2017-08-25 16:33:06Z ggregory $ + * + */ +final class ConstantHTML { + + private final String class_name; // name of current class + private final String class_package; // name of package + private final ConstantPool constant_pool; // reference to constant pool + private final PrintWriter file; // file to write to + private final String[] constant_ref; // String to return for cp[i] + private final Constant[] constants; // The constants in the cp + private final Method[] methods; + + + ConstantHTML(final String dir, final String class_name, final String class_package, final Method[] methods, + final 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] = "<unknown>"; + file.println(""); + // Loop through constants, constants[0] is reserved + for (int i = 1; i < constants.length; i++) { + if (i % 2 == 0) { + file.print("\n"); + } + file.println("
      "); + } else { + file.print("
      "); + } + if (constants[i] != null) { + writeConstant(i); + } + file.print("
      "); + file.close(); + } + + + String referenceConstant( final int index ) { + return constant_ref[index]; + } + + + private void writeConstant( final int index ) { + final byte tag = constants[index].getTag(); + int class_index; + int name_index; + String ref; + // The header is always the same + file.println("

      " + index + " " + Const.getConstantName(tag) + + "

      "); + /* For every constant type get the needed parameters and print them appropiately + */ + switch (tag) { + case Const.CONSTANT_InterfaceMethodref: + case Const.CONSTANT_Methodref: + // Get class_index and name_and_type_index, depending on type + if (tag == Const.CONSTANT_Methodref) { + final ConstantMethodref c = (ConstantMethodref) constant_pool.getConstant(index, + Const.CONSTANT_Methodref); + class_index = c.getClassIndex(); + name_index = c.getNameAndTypeIndex(); + } else { + final ConstantInterfaceMethodref c1 = (ConstantInterfaceMethodref) constant_pool + .getConstant(index, Const.CONSTANT_InterfaceMethodref); + class_index = c1.getClassIndex(); + name_index = c1.getNameAndTypeIndex(); + } + // Get method name and its class + final String method_name = constant_pool.constantToString(name_index, + Const.CONSTANT_NameAndType); + final String html_method_name = Class2HTML.toHTML(method_name); + // Partially compacted class name, i.e., / -> . + final String method_class = constant_pool.constantToString(class_index, Const.CONSTANT_Class); + String 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 + final ConstantNameAndType c2 = (ConstantNameAndType) constant_pool.getConstant( + name_index, Const.CONSTANT_NameAndType); + final String signature = constant_pool.constantToString(c2.getSignatureIndex(), + Const.CONSTANT_Utf8); + // Get array of strings containing the argument types + final String[] args = Utility.methodSignatureArgumentTypes(signature, false); + // Get return type string + final String type = Utility.methodSignatureReturnType(signature, false); + final String ret_type = Class2HTML.referenceType(type); + final StringBuilder buf = new StringBuilder("("); + for (int i = 0; i < args.length; i++) { + buf.append(Class2HTML.referenceType(args[i])); + if (i < args.length - 1) { + buf.append(", "); + } + } + buf.append(")"); + final String arg_types = buf.toString(); + if (method_class.equals(class_name)) { + ref = "" + + html_method_name + ""; + } else { + ref = "" + + short_method_class + "." + html_method_name; + } + constant_ref[index] = ret_type + " " + short_method_class + + "." + html_method_name + " " + arg_types; + file.println("

      " + ret_type + " " + ref + arg_types + + " \n

      "); + break; + case Const.CONSTANT_Fieldref: + // Get class_index and name_and_type_index + final ConstantFieldref c3 = (ConstantFieldref) constant_pool.getConstant(index, + Const.CONSTANT_Fieldref); + class_index = c3.getClassIndex(); + name_index = c3.getNameAndTypeIndex(); + // Get method name and its class (compacted) + final String field_class = constant_pool.constantToString(class_index, Const.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 + final String field_name = constant_pool + .constantToString(name_index, Const.CONSTANT_NameAndType); + if (field_class.equals(class_name)) { + ref = "" + field_name + ""; + } else { + ref = "" + short_field_class + + "." + field_name + "\n"; + } + constant_ref[index] = "" + short_field_class + "." + + field_name + ""; + file.println("

      " + ref + "
      \n" + "

      "); + break; + case Const.CONSTANT_Class: + final ConstantClass c4 = (ConstantClass) constant_pool.getConstant(index, Const.CONSTANT_Class); + name_index = c4.getNameIndex(); + final 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 = "" + short_class_name + + ""; + constant_ref[index] = "" + short_class_name + ""; + file.println("

      " + ref + "

      \n"); + break; + case Const.CONSTANT_String: + final ConstantString c5 = (ConstantString) constant_pool.getConstant(index, + Const.CONSTANT_String); + name_index = c5.getStringIndex(); + final String str = Class2HTML.toHTML(constant_pool.constantToString(index, tag)); + file.println("

      " + str + "

      \n"); + break; + case Const.CONSTANT_NameAndType: + final ConstantNameAndType c6 = (ConstantNameAndType) constant_pool.getConstant(index, + Const.CONSTANT_NameAndType); + name_index = c6.getNameIndex(); + final int signature_index = c6.getSignatureIndex(); + file.println("

      " + + Class2HTML.toHTML(constant_pool.constantToString(index, tag)) + + "

      \n"); + break; + default: + file.println("

      " + Class2HTML.toHTML(constant_pool.constantToString(index, tag)) + "\n"); + } // switch + } + + + private int getMethodNumber( final String str ) { + for (int i = 0; i < methods.length; i++) { + final String cmp = methods[i].getName() + methods[i].getSignature(); + if (cmp.equals(str)) { + return i; + } + } + return -1; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/InstructionFinder.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/InstructionFinder.java new file mode 100644 index 00000000..0a02af08 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/InstructionFinder.java @@ -0,0 +1,420 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.util; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.bcel.Const; +import org.apache.bcel.generic.ClassGenException; +import org.apache.bcel.generic.InstructionHandle; +import org.apache.bcel.generic.InstructionList; + +/** + * 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. + * + *

      + * This class internally uses the java.util.regex + * package to search for regular expressions. + * + * A typical application would look like this: + * + *

      + *
      + *
      + *   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]);
      + *   ...
      + *   }
      + *
      + *
      + * 
      + * + * @version $Id: InstructionFinder.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see org.apache.bcel.generic.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 Map map = new HashMap<>(); + private final 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(final 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() { + final int size = il.getLength(); + final 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 String mapName( final String pattern ) { + final String result = map.get(pattern); + if (result != null) { + return result; + } + for (short i = 0; i < NO_OPCODES; i++) { + if (pattern.equals(Const.getOpcodeName(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 String compilePattern( final String pattern ) { + //Bug: BCEL-77 - Instructions are assumed to be english, to avoid odd Locale issues + final String lower = pattern.toLowerCase(Locale.ENGLISH); + final StringBuilder buf = new StringBuilder(); + final int size = pattern.length(); + for (int i = 0; i < size; i++) { + char ch = lower.charAt(i); + if (Character.isLetterOrDigit(ch)) { + final StringBuilder name = new StringBuilder(); + 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( final int matched_from, final int match_length ) { + final 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. + *

      + * Example pattern: + * + *

      +     * search("BranchInstruction NOP ((IfInstruction|GOTO)+ ISTORE Instruction)*");
      +     * 
      + * + *

      + * 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( final String pattern, final InstructionHandle from, final CodeConstraint constraint ) { + final 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."); + } + final Pattern regex = Pattern.compile(search); + final List matches = new ArrayList<>(); + final Matcher matcher = regex.matcher(il_string); + while (start < il_string.length() && matcher.find(start)) { + final int startExpr = matcher.start(); + final int endExpr = matcher.end(); + final int lenExpr = endExpr - startExpr; + final InstructionHandle[] match = getMatch(startExpr, lenExpr); + if ((constraint == null) || constraint.checkCode(match)) { + matches.add(match); + } + start = endExpr; + } + return matches.iterator(); + } + + + /** + * 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( final 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( final String pattern, final 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( final String pattern, final CodeConstraint constraint ) { + return search(pattern, il.getStart(), constraint); + } + + + /** + * Convert opcode number to char. + */ + private static char makeChar( final 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 + */ + 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|invokedynamic)"); + 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|invokedynamic|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|invokedynamic|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|invokedynamic|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|invokedynamic|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|invokedynamic|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|invokedynamic|ldc|invokestatic|daload)"); + map.put("loadclass", "(multianewarray|invokeinterface|invokedynamic|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(Const.ICONST_0, Const.ICONST_5, Const.ICONST_M1)); + map.put("lconst", new String(new char[] { '(', makeChar(Const.LCONST_0), '|', makeChar(Const.LCONST_1), ')' })); + map.put("dconst", new String(new char[] { '(', makeChar(Const.DCONST_0), '|', makeChar(Const.DCONST_1), ')' })); + map.put("fconst", new String(new char[] { '(', makeChar(Const.FCONST_0), '|', makeChar(Const.FCONST_1), '|', makeChar(Const.FCONST_2), ')' })); + map.put("lload", precompile(Const.LLOAD_0, Const.LLOAD_3, Const.LLOAD)); + map.put("iload", precompile(Const.ILOAD_0, Const.ILOAD_3, Const.ILOAD)); + map.put("dload", precompile(Const.DLOAD_0, Const.DLOAD_3, Const.DLOAD)); + map.put("fload", precompile(Const.FLOAD_0, Const.FLOAD_3, Const.FLOAD)); + map.put("aload", precompile(Const.ALOAD_0, Const.ALOAD_3, Const.ALOAD)); + map.put("lstore", precompile(Const.LSTORE_0, Const.LSTORE_3, Const.LSTORE)); + map.put("istore", precompile(Const.ISTORE_0, Const.ISTORE_3, Const.ISTORE)); + map.put("dstore", precompile(Const.DSTORE_0, Const.DSTORE_3, Const.DSTORE)); + map.put("fstore", precompile(Const.FSTORE_0, Const.FSTORE_3, Const.FSTORE)); + map.put("astore", precompile(Const.ASTORE_0, Const.ASTORE_3, Const.ASTORE)); + // Compile strings + for (final Map.Entry entry : map.entrySet()) { + final String key = entry.getKey(); + final String value = entry.getValue(); + final 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 + final StringBuilder buf = new StringBuilder("("); + for (short i = 0; i < NO_OPCODES; i++) { + if (Const.getNoOfOperands(i) != Const.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( final short from, final short to, final short extra ) { + final StringBuilder buf = new StringBuilder("("); + 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.getOpcodeName(ch - OFFSET)); +// } else { +// buf.append((ch - OFFSET)); +// } +// } else { +// buf.append(ch); +// } +// } +// return buf.toString(); +// } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/JavaWrapper.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/JavaWrapper.java old mode 100755 new mode 100644 similarity index 60% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/JavaWrapper.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/JavaWrapper.java index 4e44aae9..0349536a --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/JavaWrapper.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/JavaWrapper.java @@ -1,117 +1,116 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.util; - -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; - -/** - * 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.
      - * Call this wrapper with - *

      java org.apache.bcel.util.JavaWrapper <real.class.name> [arguments]
      - *

      - * 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 - *

      java org.apache.bcel.util.JavaWrapper -Dbcel.classloader=foo.MyLoader <real.class.name> [arguments]
      - *

      - * - * @version $Id: JavaWrapper.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.util; + +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; + +/** + * 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.
      + * Call this wrapper with: + * + *
      java org.apache.bcel.util.JavaWrapper <real.class.name> [arguments]
      + * + *

      To use your own class loader you can set the "bcel.classloader" system property

      + *

      java org.apache.bcel.util.JavaWrapper -Dbcel.classloader=foo.MyLoader <real.class.name> [arguments]
      + * + * @version $Id: JavaWrapper.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see ClassLoader + */ +public class JavaWrapper { + + private final java.lang.ClassLoader loader; + + + private static java.lang.ClassLoader getClassLoader() { + final String s = System.getProperty("bcel.classloader"); + if ((s == null) || "".equals(s)) { + throw new IllegalArgumentException("The property 'bcel.classloader' must be defined"); + } + try { + return (java.lang.ClassLoader) Class.forName(s).newInstance(); + } catch (final Exception e) { + throw new RuntimeException(e.toString(), e); + } + } + + + public JavaWrapper(final 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( final String class_name, final String[] argv ) throws ClassNotFoundException { + final Class cl = loader.loadClass(class_name); + Method method = null; + try { + method = cl.getMethod("main", new Class[] { + argv.getClass() + }); + /* Method main is sane ? + */ + final int m = method.getModifiers(); + final Class r = method.getReturnType(); + if (!(Modifier.isPublic(m) && Modifier.isStatic(m)) || Modifier.isAbstract(m) + || (r != Void.TYPE)) { + throw new NoSuchMethodException(); + } + } catch (final 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 (final 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( final 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; + } + final String class_name = argv[0]; + final String[] new_argv = new String[argv.length - 1]; + System.arraycopy(argv, 1, new_argv, 0, new_argv.length); + final JavaWrapper wrapper = new JavaWrapper(); + wrapper.runMain(class_name, new_argv); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/MemorySensitiveClassPathRepository.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/MemorySensitiveClassPathRepository.java new file mode 100644 index 00000000..4251d035 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/MemorySensitiveClassPathRepository.java @@ -0,0 +1,171 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.util; + +import java.io.IOException; +import java.io.InputStream; +import java.lang.ref.SoftReference; +import java.util.HashMap; +import java.util.Map; + +import org.apache.bcel.classfile.ClassParser; +import org.apache.bcel.classfile.JavaClass; + +/** + * This repository is used in situations where a Class is created outside the realm of a ClassLoader. Classes are loaded from the file systems using the paths + * specified in the given class path. By default, this is the value returned by ClassPath.getClassPath(). This repository holds onto classes with + * SoftReferences, and will reload as needed, in cases where memory sizes are important.
      + * + * @see org.apache.bcel.Repository + */ +public class MemorySensitiveClassPathRepository implements Repository { + + private ClassPath _path = null; + private final Map> _loadedClasses = new HashMap<>(); // CLASSNAME X JAVACLASS + + public MemorySensitiveClassPathRepository(final ClassPath path) { + this._path = path; + } + + /** + * Store a new JavaClass instance into this Repository. + */ + @Override + public void storeClass(final JavaClass clazz) { + _loadedClasses.put(clazz.getClassName(), new SoftReference<>(clazz)); + clazz.setRepository(this); + } + + /** + * Remove class from repository + */ + @Override + public void removeClass(final JavaClass clazz) { + _loadedClasses.remove(clazz.getClassName()); + } + + /** + * Find an already defined (cached) JavaClass object by name. + */ + @Override + public JavaClass findClass(final String className) { + final SoftReference ref = _loadedClasses.get(className); + if (ref == null) { + return null; + } + return ref.get(); + } + + /** + * Find a JavaClass object by name. If it is already in this Repository, the Repository version is returned. Otherwise, the Repository's classpath is + * searched for the class (and it is added to the Repository if found). + * + * @param className + * the name of the class + * @return the JavaClass object + * @throws ClassNotFoundException + * if the class is not in the Repository, and could not be found on the classpath + */ + @Override + public JavaClass loadClass(String className) throws ClassNotFoundException { + if ((className == null) || className.isEmpty()) { + throw new IllegalArgumentException("Invalid class name " + className); + } + className = className.replace('/', '.'); // Just in case, canonical form + final JavaClass clazz = findClass(className); + if (clazz != null) { + return clazz; + } + try { + return loadClass(_path.getInputStream(className), className); + } catch (final IOException e) { + throw new ClassNotFoundException("Exception while looking for class " + className + ": " + e, e); + } + } + + /** + * Find the JavaClass object for a runtime Class object. If a class with the same name is already in this Repository, the Repository version is returned. + * Otherwise, getResourceAsStream() is called on the Class object to find the class's representation. If the representation is found, it is added to the + * Repository. + * + * @see Class + * @param clazz + * the runtime Class object + * @return JavaClass object for given runtime class + * @throws ClassNotFoundException + * if the class is not in the Repository, and its representation could not be found + */ + @Override + public JavaClass loadClass(final Class clazz) throws ClassNotFoundException { + final String className = clazz.getName(); + final JavaClass repositoryClass = findClass(className); + if (repositoryClass != null) { + return repositoryClass; + } + String name = className; + final int i = name.lastIndexOf('.'); + if (i > 0) { + name = name.substring(i + 1); + } + JavaClass cls = null; + try (InputStream clsStream = clazz.getResourceAsStream(name + ".class")) { + return cls = loadClass(clsStream, className); + } catch (final IOException e) { + return cls; + } + + } + + private JavaClass loadClass(final InputStream is, final String className) throws ClassNotFoundException { + try { + if (is != null) { + final ClassParser parser = new ClassParser(is, className); + final JavaClass clazz = parser.parse(); + storeClass(clazz); + return clazz; + } + } catch (final IOException e) { + throw new ClassNotFoundException("Exception while looking for class " + className + ": " + e, e); + } finally { + if (is != null) { + try { + is.close(); + } catch (final IOException e) { + // ignored + } + } + } + throw new ClassNotFoundException("SyntheticRepository could not load " + className); + } + + /** + * ClassPath associated with the Repository. + */ + @Override + public ClassPath getClassPath() { + return _path; + } + + /** + * Clear all entries from cache. + */ + @Override + public void clear() { + _loadedClasses.clear(); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/MethodHTML.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/MethodHTML.java old mode 100755 new mode 100644 similarity index 61% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/MethodHTML.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/MethodHTML.java index 79031659..92b7c7fa --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/MethodHTML.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/MethodHTML.java @@ -1,157 +1,159 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.util; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintWriter; - -import org.apache.bcel5_2_0.classfile.Attribute; -import org.apache.bcel5_2_0.classfile.Code; -import org.apache.bcel5_2_0.classfile.ConstantValue; -import org.apache.bcel5_2_0.classfile.ExceptionTable; -import org.apache.bcel5_2_0.classfile.Field; -import org.apache.bcel5_2_0.classfile.Method; -import org.apache.bcel5_2_0.classfile.Utility; - -/** - * Convert methods and fields into HTML file. - * - * @version $Id: MethodHTML.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * - */ -final class MethodHTML implements org.apache.bcel5_2_0.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(""); - file.println("" - + ""); - for (int i = 0; i < fields.length; i++) { - writeField(fields[i]); - } - file.println("
      Access flagsTypeField name
      "); - file.println("" - + "" - + ""); - for (int i = 0; i < methods.length; i++) { - writeMethod(methods[i], i); - } - file.println("
      Access flagsReturn typeMethod nameArguments
      "); - 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, " ", " "); - file.print("" + access + "\n" - + Class2HTML.referenceType(type) + "" + name - + ""); - attributes = field.getAttributes(); - // Write them to the Attributes.html file with anchor "[]" - 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("= " + str + "\n"); - break; - } - } - file.println(""); - } - - - 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 and spaces are places to break - * lines. Both we don't want... - */ - access = Utility.replace(access, " ", " "); - html_name = Class2HTML.toHTML(name); - file.print("" + access + ""); - file.print("" + Class2HTML.referenceType(type) + "" + "" + html_name - + "\n("); - for (int i = 0; i < args.length; i++) { - file.print(Class2HTML.referenceType(args[i])); - if (i < args.length - 1) { - file.print(", "); - } - } - file.print(")"); - // 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("throws"); - 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(""); - } 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); - } - } - } - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.util; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintWriter; + +import org.apache.bcel.Const; +import org.apache.bcel.classfile.Attribute; +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.ConstantValue; +import org.apache.bcel.classfile.ExceptionTable; +import org.apache.bcel.classfile.Field; +import org.apache.bcel.classfile.Method; +import org.apache.bcel.classfile.Utility; + +/** + * Convert methods and fields into HTML file. + * + * @version $Id: MethodHTML.java 1806200 2017-08-25 16:33:06Z ggregory $ + * + */ +final class MethodHTML { + + private final String class_name; // name of current class + private final PrintWriter file; // file to write to + private final ConstantHTML constant_html; + private final AttributeHTML attribute_html; + + + MethodHTML(final String dir, final String class_name, final Method[] methods, final Field[] fields, + final ConstantHTML constant_html, final 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(""); + file.println("" + + ""); + for (final Field field : fields) { + writeField(field); + } + file.println("
      Access flagsTypeField name
      "); + file.println("" + + "" + + ""); + for (int i = 0; i < methods.length; i++) { + writeMethod(methods[i], i); + } + file.println("
      Access flagsReturn typeMethod nameArguments
      "); + file.close(); + } + + + /** + * Print field of class. + * + * @param field field to print + * @throws java.io.IOException + */ + private void writeField( final Field field ) throws IOException { + final String type = Utility.signatureToString(field.getSignature()); + final String name = field.getName(); + String access = Utility.accessToString(field.getAccessFlags()); + Attribute[] attributes; + access = Utility.replace(access, " ", " "); + file.print("" + access + "\n" + + Class2HTML.referenceType(type) + "" + name + + ""); + attributes = field.getAttributes(); + // Write them to the Attributes.html file with anchor "[]" + 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() == Const.ATTR_CONSTANT_VALUE) { // Default value + final String str = ((ConstantValue) attributes[i]).toString(); + // Reference attribute in _attributes.html + file.print("= " + str + "\n"); + break; + } + } + file.println(""); + } + + + private void writeMethod( final Method method, final int method_number ) { + // Get raw signature + final String signature = method.getSignature(); + // Get array of strings containing the argument types + final String[] args = Utility.methodSignatureArgumentTypes(signature, false); + // Get return type string + final String type = Utility.methodSignatureReturnType(signature, false); + // Get method name + final String name = method.getName(); + String html_name; + // Get method's access flags + String access = Utility.accessToString(method.getAccessFlags()); + // Get the method's attributes, the Code Attribute in particular + final Attribute[] attributes = method.getAttributes(); + /* HTML doesn't like names like and spaces are places to break + * lines. Both we don't want... + */ + access = Utility.replace(access, " ", " "); + html_name = Class2HTML.toHTML(name); + file.print("" + access + ""); + file.print("" + Class2HTML.referenceType(type) + "" + "" + html_name + + "\n("); + for (int i = 0; i < args.length; i++) { + file.print(Class2HTML.referenceType(args[i])); + if (i < args.length - 1) { + file.print(", "); + } + } + file.print(")"); + // Check for thrown exceptions + for (int i = 0; i < attributes.length; i++) { + attribute_html.writeAttribute(attributes[i], "method" + method_number + "@" + i, + method_number); + final byte tag = attributes[i].getTag(); + if (tag == Const.ATTR_EXCEPTIONS) { + file.print("throws"); + final 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(""); + } else if (tag == Const.ATTR_CODE) { + final 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/Repository.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/Repository.java new file mode 100644 index 00000000..86fd57b2 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/Repository.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.util; + +import org.apache.bcel.classfile.JavaClass; + +/** + * Abstract definition of a class repository. Instances may be used + * to load classes from different sources and may be used in the + * Repository.setRepository method. + * + * @see org.apache.bcel.Repository + * @version $Id: Repository.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public interface Repository { + + /** + * Store the provided class under "clazz.getClassName()" + */ + void storeClass( JavaClass clazz ); + + + /** + * Remove class from repository + */ + void removeClass( JavaClass clazz ); + + + /** + * Find the class with the name provided, if the class + * isn't there, return NULL. + */ + JavaClass findClass( String className ); + + + /** + * Find the class with the name provided, if the class + * isn't there, make an attempt to load it. + */ + JavaClass loadClass( String className ) throws java.lang.ClassNotFoundException; + + + /** + * Find the JavaClass instance for the given run-time class object + */ + JavaClass loadClass( Class clazz ) throws java.lang.ClassNotFoundException; + + + /** Clear all entries from cache. + */ + void clear(); + + + /** Get the ClassPath associated with this Repository + */ + ClassPath getClassPath(); +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/SyntheticRepository.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/SyntheticRepository.java new file mode 100644 index 00000000..9efae63b --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/SyntheticRepository.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.util; + +import java.util.HashMap; +import java.util.Map; + +/** + * This repository is used in situations where a Class is created outside the realm of a ClassLoader. Classes are loaded from the file systems using the paths + * specified in the given class path. By default, this is the value returned by ClassPath.getClassPath().
      + * This repository uses a factory design, allowing it to maintain a collection of different classpaths, and as such It is designed to be used as a singleton per + * classpath. + * + * @see org.apache.bcel.Repository + * + * @version $Id: SyntheticRepository.java 1748124 2016-06-13 08:02:16Z ggregory $ + */ +public class SyntheticRepository extends MemorySensitiveClassPathRepository { + + // private static final String DEFAULT_PATH = ClassPath.getClassPath(); + private static final Map instances = new HashMap<>(); // CLASSPATH X REPOSITORY + + private SyntheticRepository(final ClassPath path) { + super(path); + } + + public static SyntheticRepository getInstance() { + return getInstance(ClassPath.SYSTEM_CLASS_PATH); + } + + public static SyntheticRepository getInstance(final ClassPath classPath) { + SyntheticRepository rep = instances.get(classPath); + if (rep == null) { + rep = new SyntheticRepository(classPath); + instances.put(classPath, rep); + } + return rep; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/package.html b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/package.html new file mode 100644 index 00000000..d1b2aaa3 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/package.html @@ -0,0 +1,41 @@ + + + + + + + +

      +This package contains utility classes for the +Byte Code Engineering +Library, namely: +

      +

      +

        +
      • Collection classes for JavaClass objects
      • +
      • A converter for class files to HTML
      • +
      • A tool to find instructions patterns via regular expressions
      • +
      • A class to find classes as defined in the CLASSPATH
      • +
      • A class loader that allows to create classes at run time
      • +
      + +

      + + diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/GraphicalVerifier.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/GraphicalVerifier.java new file mode 100644 index 00000000..7e8d9a43 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/GraphicalVerifier.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier; + +import java.awt.Dimension; +import java.awt.Toolkit; +import javax.swing.UIManager; + +import org.apache.bcel.generic.Type; + +/** + * A graphical user interface application demonstrating JustIce. + * + * @version $Id: GraphicalVerifier.java 1749603 2016-06-21 20:50:19Z ggregory $ + */ +public class GraphicalVerifier { + + private final boolean packFrame = false; + + + /** Constructor. */ + public GraphicalVerifier() { + final 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 + final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + final 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.getClassNamesJList().setModel(new VerifierFactoryListModel()); + VerifierFactory.getVerifier(Type.OBJECT.getClassName()); // Fill list with java.lang.Object + frame.getClassNamesJList().setSelectedIndex(0); // default, will verify java.lang.Object + } + + + /** Main method. */ + public static void main( final String[] args ) { + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (final Exception e) { + e.printStackTrace(); + } + new GraphicalVerifier(); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/NativeVerifier.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/NativeVerifier.java new file mode 100644 index 00000000..2d5d56dd --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/NativeVerifier.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier; + +/** + * 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: NativeVerifier.java 1749603 2016-06-21 20:50:19Z ggregory $ + */ +public abstract class NativeVerifier { + + /** + * This class must not be instantiated. + */ + private NativeVerifier() { + } + + + /** + * Works only on the first argument. + */ + public static void main( final String[] args ) { + if (args.length != 1) { + System.out.println("Verifier front-end: need exactly one argument."); + System.exit(1); + } + final 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 (final ExceptionInInitializerError eiie) { //subclass of LinkageError! + System.out.println("NativeVerifier: ExceptionInInitializerError encountered on '" + + args[0] + "'."); + System.out.println(eiie); + System.exit(1); + } catch (final LinkageError le) { + System.out.println("NativeVerifier: LinkageError encountered on '" + args[0] + "'."); + System.out.println(le); + System.exit(1); + } catch (final ClassNotFoundException cnfe) { + System.out.println("NativeVerifier: FILE NOT FOUND: '" + args[0] + "'."); + System.exit(1); + } catch (final Throwable t) { // OK to catch Throwable here as we call exit. + 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/PassVerifier.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/PassVerifier.java new file mode 100644 index 00000000..972480ec --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/PassVerifier.java @@ -0,0 +1,105 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier; + +import java.util.ArrayList; +import java.util.List; + +/** + * 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: PassVerifier.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see Verifier + * @see #verify() + */ +public abstract class PassVerifier { + + /** The (warning) messages. */ + private final List messages = new ArrayList<>(); + /** 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( final 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!) + return messages.toArray(new String[messages.size()]); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/TransitiveHull.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/TransitiveHull.java new file mode 100644 index 00000000..a50ecf49 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/TransitiveHull.java @@ -0,0 +1,105 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier; + +import org.apache.bcel.Repository; +import org.apache.bcel.classfile.JavaClass; + +/** + * 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: TransitiveHull.java 1749603 2016-06-21 20:50:19Z ggregory $ + */ +public class TransitiveHull implements VerifierFactoryObserver { + + /** Used for indentation. */ + private int indent = 0; + + + /** Not publicly instantiable. */ + private TransitiveHull() { + } + + + /* Implementing VerifierFactoryObserver. */ + @Override + public void update( final String classname ) { + System.gc(); // avoid swapping if possible. + for (int i = 0; i < indent; i++) { + System.out.print(" "); + } + System.out.println(classname); + indent += 1; + final Verifier v = VerifierFactory.getVerifier(classname); + VerificationResult vr; + vr = v.doPass1(); + if (vr != VerificationResult.VR_OK) { + System.out.println("Pass 1:\n" + vr); + } + vr = v.doPass2(); + if (vr != VerificationResult.VR_OK) { + System.out.println("Pass 2:\n" + vr); + } + if (vr == VerificationResult.VR_OK) { + try { + final 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.out.println(v.getClassName() + ", Pass 3a, method " + i + " ['" + + jc.getMethods()[i] + "']:\n" + vr); + } + vr = v.doPass3b(i); + if (vr != VerificationResult.VR_OK) { + System.out.println(v.getClassName() + ", Pass 3b, method " + i + " ['" + + jc.getMethods()[i] + "']:\n" + vr); + } + } + } catch (final ClassNotFoundException e) { + System.err.println("Could not find class " + v.getClassName() + " in Repository"); + } + } + 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( final String[] args ) { + if (args.length != 1) { + System.out.println("Need exactly one argument: The root class to verify."); + System.exit(1); + } + final int dotclasspos = args[0].lastIndexOf(".class"); + if (dotclasspos != -1) { + args[0] = args[0].substring(0, dotclasspos); + } + args[0] = args[0].replace('/', '.'); + final 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerificationResult.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerificationResult.java new file mode 100644 index 00000000..753e0dca --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerificationResult.java @@ -0,0 +1,127 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier; + +/** + * A VerificationResult is what a PassVerifier returns + * after verifying. + * + * @version $Id: VerificationResult.java 1811486 2017-10-08 12:49:43Z dbrosius $ + */ +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 {@link #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 {@link #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 final int numeric; + + /** The detailed message. */ + private final String detailMessage; + + + /** The usual constructor. */ + public VerificationResult(final int status, final String message) { + numeric = status; + detailMessage = message; + } + + + /** + * Returns one of the {@link #VERIFIED_OK}, {@link #VERIFIED_NOTYET}, + * {@link #VERIFIED_REJECTED} constants. + */ + public int getStatus() { + return numeric; + } + + + /** Returns a detailed message. */ + public String getMessage() { + return detailMessage; + } + + + /** + * @return a hash code value for the object. + */ + @Override + public int hashCode() { + return numeric ^ detailMessage.hashCode(); + } + + + /** + * Returns if two VerificationResult instances are equal. + */ + @Override + public boolean equals( final Object o ) { + if (!(o instanceof VerificationResult)) { + return false; + } + final VerificationResult other = (VerificationResult) o; + return (other.numeric == this.numeric) && other.detailMessage.equals(this.detailMessage); + } + + + /** + * Returns a String representation of the VerificationResult. + */ + @Override + 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/Verifier.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/Verifier.java new file mode 100644 index 00000000..8a85f75c --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/Verifier.java @@ -0,0 +1,242 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.verifier.statics.Pass1Verifier; +import org.apache.bcel.verifier.statics.Pass2Verifier; +import org.apache.bcel.verifier.statics.Pass3aVerifier; +import org.apache.bcel.verifier.structurals.Pass3bVerifier; + +/** + * 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. + * Verifier instances are usually generated by the VerifierFactory. + * + * @version $Id: Verifier.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see VerifierFactory + * @see 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 final Map p3avs = new HashMap<>(); + /** The Pass3bVerifiers for this Verifier instance. Key: Interned string specifying the method number. */ + private final Map 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( final int method_no ) { + final String key = Integer.toString(method_no); + Pass3aVerifier p3av; + p3av = 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( final int method_no ) { + final String key = Integer.toString(method_no); + Pass3bVerifier p3bv; + p3bv = p3bvs.get(key); + if (p3bvs.get(key) == null) { + p3bv = new Pass3bVerifier(this, method_no); + p3bvs.put(key, p3bv); + } + return p3bv.verify(); + } + + + /** + * Instantiation is done by the VerifierFactory. + * + * @see VerifierFactory + */ + Verifier(final 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() throws ClassNotFoundException { + final List messages = new ArrayList<>(); + if (p1v != null) { + final String[] p1m = p1v.getMessages(); + for (final String element : p1m) { + messages.add("Pass 1: " + element); + } + } + if (p2v != null) { + final String[] p2m = p2v.getMessages(); + for (final String element : p2m) { + messages.add("Pass 2: " + element); + } + } + for (final Pass3aVerifier pv : p3avs.values()) { + final String[] p3am = pv.getMessages(); + final int meth = pv.getMethodNo(); + for (final String element : p3am) { + messages.add("Pass 3a, method " + meth + " ('" + + org.apache.bcel.Repository.lookupClass(classname).getMethods()[meth] + + "'): " + element); + } + } + for (final Pass3bVerifier pv : p3bvs.values()) { + final String[] p3bm = pv.getMessages(); + final int meth = pv.getMethodNo(); + for (final String element : p3bm) { + messages.add("Pass 3b, method " + meth + " ('" + + org.apache.bcel.Repository.lookupClass(classname).getMethods()[meth] + + "'): " + element); + } + } + + return messages.toArray(new String[messages.size()]); + } + + + /** + * 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( final String[] args ) { + System.out + .println("JustIce by Enver Haase, (C) 2001-2002.\n\n\n"); + for (int k = 0; k < args.length; k++) { + try { + if (args[k].endsWith(".class")) { + final 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 verifying: " + args[k] + "\n"); + final 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) { + final JavaClass jc = org.apache.bcel.Repository.lookupClass(args[k]); + for (int i = 0; i < jc.getMethods().length; i++) { + vr = v.doPass3a(i); + System.out.println("Pass 3a, method number " + 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:"); + final String[] warnings = v.getMessages(); + if (warnings.length == 0) { + System.out.println(""); + } + for (final String warning : warnings) { + System.out.println(warning); + } + System.out.println("\n"); + // avoid swapping. + v.flush(); + org.apache.bcel.Repository.clearCache(); + System.gc(); + } catch (final ClassNotFoundException e) { + e.printStackTrace(); + } + } + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierAppFrame.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierAppFrame.java new file mode 100644 index 00000000..6e4a823a --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierAppFrame.java @@ -0,0 +1,421 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier; + +import java.awt.AWTEvent; +import java.awt.CardLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.InputEvent; +import java.awt.event.WindowEvent; +import javax.swing.BorderFactory; +import javax.swing.JFrame; +import javax.swing.JList; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTextPane; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionEvent; + +import org.apache.bcel.Repository; +import org.apache.bcel.classfile.JavaClass; + +/** + * This class implements a machine-generated frame for use with + * the GraphicalVerfifier. + * + * @version $Id: VerifierAppFrame.java 1749603 2016-06-21 20:50:19Z ggregory $ + * @see GraphicalVerifier + */ +public class VerifierAppFrame extends JFrame { + + private static final long serialVersionUID = -542458133073307640L; + private static final String JUSTICE_VERSION = "JustIce by Enver Haase"; + + private JPanel contentPane; + private final JSplitPane jSplitPane1 = new JSplitPane(); + private final JPanel jPanel1 = new JPanel(); + private final JPanel jPanel2 = new JPanel(); + private final JSplitPane jSplitPane2 = new JSplitPane(); + private final JPanel jPanel3 = new JPanel(); + private final JList classNamesJList = new JList<>(); + private final GridLayout gridLayout1 = new GridLayout(); + private final JPanel messagesPanel = new JPanel(); + private final GridLayout gridLayout2 = new GridLayout(); + private final JMenuBar jMenuBar1 = new JMenuBar(); + private final JMenu jMenu1 = new JMenu(); + private final JScrollPane jScrollPane1 = new JScrollPane(); + private final JScrollPane messagesScrollPane = new JScrollPane(); + private final JScrollPane jScrollPane3 = new JScrollPane(); + private final GridLayout gridLayout4 = new GridLayout(); + private final JScrollPane jScrollPane4 = new JScrollPane(); + private final CardLayout cardLayout1 = new CardLayout(); + private String current_class; + private final GridLayout gridLayout3 = new GridLayout(); + private final JTextPane pass1TextPane = new JTextPane(); + private final JTextPane pass2TextPane = new JTextPane(); + private final JTextPane messagesTextPane = new JTextPane(); + private final JMenuItem newFileMenuItem = new JMenuItem(); + private final JSplitPane jSplitPane3 = new JSplitPane(); + private final JSplitPane jSplitPane4 = new JSplitPane(); + private final JScrollPane jScrollPane2 = new JScrollPane(); + private final JScrollPane jScrollPane5 = new JScrollPane(); + private final JScrollPane jScrollPane6 = new JScrollPane(); + private final JScrollPane jScrollPane7 = new JScrollPane(); + private final JList pass3aJList = new JList<>(); + private final JList pass3bJList = new JList<>(); + private final JTextPane pass3aTextPane = new JTextPane(); + private final JTextPane pass3bTextPane = new JTextPane(); + private final JMenu jMenu2 = new JMenu(); + private final JMenuItem whatisMenuItem = new JMenuItem(); + private final JMenuItem aboutMenuItem = new JMenuItem(); + + + /** Constructor. */ + public VerifierAppFrame() { + enableEvents(AWTEvent.WINDOW_EVENT_MASK); + try { + jbInit(); + } catch (final 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() { + + @Override + public void valueChanged( final 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, + InputEvent.CTRL_MASK, true)); + newFileMenuItem.addActionListener(new java.awt.event.ActionListener() { + + @Override + public void actionPerformed( final ActionEvent e ) { + newFileMenuItem_actionPerformed(e); + } + }); + pass3aTextPane.setEditable(false); + pass3bTextPane.setEditable(false); + pass3aJList.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + + @Override + public void valueChanged( final ListSelectionEvent e ) { + pass3aJList_valueChanged(e); + } + }); + pass3bJList.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + + @Override + public void valueChanged( final ListSelectionEvent e ) { + pass3bJList_valueChanged(e); + } + }); + jMenu2.setText("Help"); + whatisMenuItem.setText("What is..."); + whatisMenuItem.addActionListener(new java.awt.event.ActionListener() { + + @Override + public void actionPerformed( final ActionEvent e ) { + whatisMenuItem_actionPerformed(e); + } + }); + aboutMenuItem.setText("About"); + aboutMenuItem.addActionListener(new java.awt.event.ActionListener() { + + @Override + public void actionPerformed( final 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. */ + @Override + protected void processWindowEvent( final WindowEvent e ) { + super.processWindowEvent(e); + if (e.getID() == WindowEvent.WINDOW_CLOSING) { + System.exit(0); + } + } + + + synchronized void classNamesJList_valueChanged( final ListSelectionEvent e ) { + if (e.getValueIsAdjusting()) { + return; + } + current_class = classNamesJList.getSelectedValue(); + try { + verify(); + } catch (final ClassNotFoundException ex) { + // FIXME: report the error using the GUI + ex.printStackTrace(); + } + classNamesJList.setSelectedValue(current_class, true); + } + + + private void verify() throws ClassNotFoundException { + setTitle("PLEASE WAIT"); + final 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 String[0]); + pass3aTextPane.setBackground(Color.yellow); + pass3bTextPane.setText(""); + pass3bJList.setListData(new String[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 String[0]); + pass3bTextPane.setText(""); + pass3bTextPane.setBackground(Color.yellow); + pass3bJList.setListData(new String[0]); + } else { // must be Verified_OK, because Pass1 was OK (cannot be Verified_NOTYET). + pass2TextPane.setText(vr.getMessage()); + pass2TextPane.setBackground(Color.green); + final JavaClass jc = Repository.lookupClass(current_class); + /* + boolean all3aok = true; + boolean all3bok = true; + String all3amsg = ""; + String all3bmsg = ""; + */ + final 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); + } + } + final String[] msgs = v.getMessages(); + messagesTextPane.setBackground(msgs.length == 0 ? Color.green : Color.yellow); + final StringBuilder allmsgs = new StringBuilder(); + for (int i = 0; i < msgs.length; i++) { + msgs[i] = msgs[i].replace('\n', ' '); + allmsgs.append(msgs[i]).append("\n\n"); + } + messagesTextPane.setText(allmsgs.toString()); + setTitle(current_class + " - " + JUSTICE_VERSION); + } + + + void newFileMenuItem_actionPerformed( final ActionEvent e ) { + final String classname = JOptionPane + .showInputDialog("Please enter the fully qualified name of a class or interface to verify:"); + if ((classname == null) || (classname.isEmpty())) { + return; + } + VerifierFactory.getVerifier(classname); // let observers do the rest. + classNamesJList.setSelectedValue(classname, true); + } + + + synchronized void pass3aJList_valueChanged( final ListSelectionEvent e ) { + if (e.getValueIsAdjusting()) { + return; + } + final Verifier v = VerifierFactory.getVerifier(current_class); + final StringBuilder all3amsg = new StringBuilder(); + boolean all3aok = true; + boolean rejected = false; + for (int i = 0; i < pass3aJList.getModel().getSize(); i++) { + if (pass3aJList.isSelectedIndex(i)) { + final VerificationResult vr = v.doPass3a(i); + if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED) { + all3aok = false; + rejected = true; + } + JavaClass jc = null; + try { + jc = Repository.lookupClass(v.getClassName()); + all3amsg.append("Method '").append(jc.getMethods()[i]).append("': ") + .append(vr.getMessage().replace('\n', ' ') ).append("\n\n"); + } catch (final ClassNotFoundException ex) { + // FIXME: handle the error + ex.printStackTrace(); + } + } + } + pass3aTextPane.setText(all3amsg.toString()); + pass3aTextPane.setBackground(all3aok ? Color.green : (rejected ? Color.red : Color.yellow)); + } + + + synchronized void pass3bJList_valueChanged( final ListSelectionEvent e ) { + if (e.getValueIsAdjusting()) { + return; + } + final Verifier v = VerifierFactory.getVerifier(current_class); + final StringBuilder all3bmsg = new StringBuilder(); + boolean all3bok = true; + boolean rejected = false; + for (int i = 0; i < pass3bJList.getModel().getSize(); i++) { + if (pass3bJList.isSelectedIndex(i)) { + final VerificationResult vr = v.doPass3b(i); + if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED) { + all3bok = false; + rejected = true; + } + JavaClass jc = null; + try { + jc = Repository.lookupClass(v.getClassName()); + all3bmsg.append("Method '").append(jc.getMethods()[i]).append("': ") + .append(vr.getMessage().replace('\n', ' ')).append("\n\n"); + } catch (final ClassNotFoundException ex) { + // FIXME: handle the error + ex.printStackTrace(); + } + } + } + pass3bTextPane.setText(all3bmsg.toString()); + pass3bTextPane.setBackground(all3bok ? Color.green : (rejected ? Color.red : Color.yellow)); + } + + + void aboutMenuItem_actionPerformed( final ActionEvent e ) { + JOptionPane + .showMessageDialog( + this, + "JustIce is a Java class file verifier.\n"+ + "It was implemented by Enver Haase in 2001, 2002.\n", + JUSTICE_VERSION, JOptionPane.INFORMATION_MESSAGE); + } + + + void whatisMenuItem_actionPerformed( final 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).\n"+ + "The bottom box to the right shows (warning) messages; warnings do not cause a class to be rejected.", + JUSTICE_VERSION, JOptionPane.INFORMATION_MESSAGE); + } + + + /** + * @return the classNamesJList + */ + JList getClassNamesJList() { + return classNamesJList; + } + + +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierFactory.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierFactory.java new file mode 100644 index 00000000..48e0be63 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierFactory.java @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +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: VerifierFactory.java 1749603 2016-06-21 20:50:19Z ggregory $ + * @see Verifier + */ +public class VerifierFactory { + + /** + * The HashMap that holds the data about the already-constructed Verifier instances. + */ + private static final Map hashMap = new HashMap<>(); + /** + * The VerifierFactoryObserver instances that observe the VerifierFactory. + */ + private static final List 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( final String fully_qualified_classname ) { + Verifier v = 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( final String fully_qualified_classname ) { + // notify the observers + for (final VerifierFactoryObserver vfo : observers) { + 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() { + final Verifier[] vs = new Verifier[hashMap.values().size()]; + return 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( final VerifierFactoryObserver o ) { + observers.add(o); + } + + + /** + * Removes the VerifierFactoryObserver o from the list of observers. + */ + public static void detach( final VerifierFactoryObserver o ) { + observers.remove(o); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierFactoryListModel.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierFactoryListModel.java new file mode 100644 index 00000000..1fc5336f --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierFactoryListModel.java @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; + +import javax.swing.event.ListDataEvent; +import javax.swing.event.ListDataListener; + +/** + * This class implements an adapter; it implements both a Swing ListModel and a VerifierFactoryObserver. + * + * @version $Id: VerifierFactoryListModel.java 1749611 2016-06-21 21:53:40Z ggregory $ + */ +public class VerifierFactoryListModel implements VerifierFactoryObserver, javax.swing.ListModel { + + private final List listeners = new ArrayList<>(); + private final Set cache = new TreeSet<>(); + + public VerifierFactoryListModel() { + VerifierFactory.attach(this); + update(null); // fill cache. + } + + @Override + public synchronized void update(final String s) { + final Verifier[] verifiers = VerifierFactory.getVerifiers(); + final int num_of_verifiers = verifiers.length; + cache.clear(); + for (final Verifier verifier : verifiers) { + cache.add(verifier.getClassName()); + } + for (final ListDataListener listener : listeners) { + final ListDataEvent e = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, num_of_verifiers - 1); + listener.contentsChanged(e); + } + } + + @Override + public synchronized void addListDataListener(final ListDataListener l) { + listeners.add(l); + } + + @Override + public synchronized void removeListDataListener(final javax.swing.event.ListDataListener l) { + listeners.remove(l); + } + + @Override + public synchronized int getSize() { + return cache.size(); + } + + @Override + public synchronized String getElementAt(final int index) { + return cache.toArray(new String[cache.size()])[index]; + } + +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierFactoryObserver.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierFactoryObserver.java new file mode 100644 index 00000000..1637c524 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierFactoryObserver.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier; + +/** + * VerifierFactoryObserver instances are notified when new Verifier + * instances are created. + * + * @version $Id: VerifierFactoryObserver.java 1747278 2016-06-07 17:28:43Z britter $ + * + * @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. + */ + void update( String s ); +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifyDialog.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifyDialog.java new file mode 100644 index 00000000..8025f2d8 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifyDialog.java @@ -0,0 +1,564 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.bcel.verifier; + +import java.awt.Color; + +import org.apache.bcel.Repository; +import org.apache.bcel.classfile.JavaClass; + +/** + * 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: VerifyDialog.java 1749603 2016-06-21 20:50:19Z ggregory $ + * @see #main(String[]) + * @see #VerifyDialog(String) + */ +public class VerifyDialog extends javax.swing.JDialog { + + private static final long serialVersionUID = -6374807677043142313L; + /** 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. */ + private final 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 { + + @Override + public void actionPerformed( final 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(final java.awt.Dialog owner) { + super(owner); + } + + + /** Machine-generated. */ + public VerifyDialog(final java.awt.Dialog owner, final String title) { + super(owner, title); + } + + + /** Machine-generated. */ + public VerifyDialog(final java.awt.Dialog owner, final String title, final boolean modal) { + super(owner, title, modal); + } + + + /** Machine-generated. */ + public VerifyDialog(final java.awt.Dialog owner, final boolean modal) { + super(owner, modal); + } + + + /** Machine-generated. */ + public VerifyDialog(final java.awt.Frame owner) { + super(owner); + } + + + /** Machine-generated. */ + public VerifyDialog(final java.awt.Frame owner, final String title) { + super(owner, title); + } + + + /** Machine-generated. */ + public VerifyDialog(final java.awt.Frame owner, final String title, final boolean modal) { + super(owner, title, modal); + } + + + /** Machine-generated. */ + public VerifyDialog(final java.awt.Frame owner, final 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(); + final 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( final 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 (final java.lang.Throwable ivjExc) { + // user code begin {3} + // user code end + handleException(ivjExc); + } + } + + + /** Machine-generated. */ + private void connEtoC2( final 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 (final java.lang.Throwable ivjExc) { + // user code begin {3} + // user code end + handleException(ivjExc); + } + } + + + /** Machine-generated. */ + private void connEtoC3( final 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 (final java.lang.Throwable ivjExc) { + // user code begin {3} + // user code end + handleException(ivjExc); + } + } + + + /** Machine-generated. */ + private void connEtoC4( final 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 (final java.lang.Throwable ivjExc) { + // user code begin {3} + // user code end + handleException(ivjExc); + } + } + + + /** Machine-generated. */ + public void flushButton_ActionPerformed( final 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 (final 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 (final 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 (final 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 (final 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 (final 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 (final 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 (final 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 (final java.lang.Throwable ivjExc) { + // user code begin {2} + // user code end + handleException(ivjExc); + } + } + return ivjPass3Panel; + } + + + /** Machine-generated. */ + private void handleException( final java.lang.Throwable exception ) { + /* Uncomment the following lines to print uncaught exceptions to stdout */ + System.out.println("--------- UNCAUGHT EXCEPTION ---------"); + exception.printStackTrace(System.out); + // manually added code + if (exception instanceof ThreadDeath) { + throw (ThreadDeath) exception; + } + if (exception instanceof VirtualMachineError) { + throw (VirtualMachineError) exception; + } + } + + + /** 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 (final 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( final java.lang.String[] args ) { + classes_to_verify = args.length; + for (final String arg : args) { + try { + VerifyDialog aVerifyDialog; + aVerifyDialog = new VerifyDialog(arg); + aVerifyDialog.setModal(true); + aVerifyDialog.addWindowListener(new java.awt.event.WindowAdapter() { + + @Override + public void windowClosing( final java.awt.event.WindowEvent e ) { + classes_to_verify--; + if (classes_to_verify == 0) { + System.exit(0); + } + } + }); + aVerifyDialog.setVisible(true); + } catch (final Throwable exception) { + System.err.println("Exception occurred in main() of javax.swing.JDialog"); + exception.printStackTrace(System.out); + } + } + } + + + /** Machine-generated. */ + public void pass1Button_ActionPerformed( final java.awt.event.ActionEvent actionEvent ) { + final Verifier v = VerifierFactory.getVerifier(class_name); + final 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( final java.awt.event.ActionEvent actionEvent ) { + pass1Button_ActionPerformed(actionEvent); + final Verifier v = VerifierFactory.getVerifier(class_name); + final 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( final java.awt.event.ActionEvent actionEvent ) { + pass2Button_ActionPerformed(actionEvent); + Color color = Color.green; + final Verifier v = VerifierFactory.getVerifier(class_name); + VerificationResult vr = v.doPass2(); + if (vr.getStatus() == VerificationResult.VERIFIED_OK) { + JavaClass jc = null; + try { + jc = Repository.lookupClass(class_name); + final 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; + } + } + } catch (final ClassNotFoundException ex) { + // FIXME: report the error + ex.printStackTrace(); + } + } else { + color = Color.yellow; + } + getPass3Panel().setBackground(color); + getPass3Panel().repaint(); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/AssertionViolatedException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/AssertionViolatedException.java new file mode 100644 index 00000000..fa876050 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/AssertionViolatedException.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.exc; + + +/** + * 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 "JustIce". + * + * @version $Id: AssertionViolatedException.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public final class AssertionViolatedException extends RuntimeException{ + private static final long serialVersionUID = -129822266349567409L; + /** 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 "INTERNAL ERROR: ". + */ + public AssertionViolatedException(String message) { + super(message = "INTERNAL ERROR: "+message); // Thanks to Java, the constructor call here must be first. + detailMessage=message; + } + /** + * Constructs a new AssertionViolationException with the specified error message and initial cause + * @since 6.0 + */ + public AssertionViolatedException(String message, final Throwable initCause) { + super(message = "INTERNAL ERROR: "+message, initCause); + 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. + */ + @Override + public String getMessage() { + return detailMessage; + } + + /** + * DO NOT USE. It's for experimental testing during development only. + */ + public static void main(final String[] args) { + final AssertionViolatedException ave = new AssertionViolatedException("Oops!"); + ave.extendMessage("\nFOUND:\n\t","\nExiting!!\n"); + throw ave; + } + +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/ClassConstraintException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/ClassConstraintException.java new file mode 100644 index 00000000..c4beafbd --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/ClassConstraintException.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.exc; + + +/** + * 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: ClassConstraintException.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class ClassConstraintException extends VerificationException{ + private static final long serialVersionUID = -4745598983569128296L; + + /** + * 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(final String message) { + super (message); + } + + /** + * Constructs a new ClassConstraintException with the specified error message and cause + * @since 6.0 + */ + public ClassConstraintException(final String message, final Throwable initCause) { + super(message, initCause); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/CodeConstraintException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/CodeConstraintException.java new file mode 100644 index 00000000..6e692e5d --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/CodeConstraintException.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.exc; + +/** + * 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: CodeConstraintException.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public abstract class CodeConstraintException extends VerificationException{ + private static final long serialVersionUID = -7265388214714996640L; + /** + * Constructs a new CodeConstraintException with null as its error message string. + */ + CodeConstraintException() { + super(); + } + /** + * Constructs a new CodeConstraintException with the specified error message. + */ + CodeConstraintException(final String message) { + super(message); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/InvalidMethodException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/InvalidMethodException.java new file mode 100644 index 00000000..f04aaeb2 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/InvalidMethodException.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.exc; + +/** + * 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: InvalidMethodException.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class InvalidMethodException extends RuntimeException{ + + private static final long serialVersionUID = -7060302743724808051L; + + /** Constructs an InvalidMethodException with the specified detail message. */ + public InvalidMethodException(final String message) { + super(message); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/LinkingConstraintException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/LinkingConstraintException.java new file mode 100644 index 00000000..7defb5fe --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/LinkingConstraintException.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.exc; + +/** + * 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. + * TODO: At this time, this class is not used in JustIce. + * + * @version $Id: LinkingConstraintException.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class LinkingConstraintException extends StructuralCodeConstraintException{ + + private static final long serialVersionUID = -5239226345026321126L; +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/LoadingException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/LoadingException.java new file mode 100644 index 00000000..6ff0c8df --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/LoadingException.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.exc; + + +/** + * 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: LoadingException.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class LoadingException extends VerifierConstraintViolatedException{ + + private static final long serialVersionUID = -7911901533049018823L; + + /** + * 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(final String message) { + super (message); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/LocalVariableInfoInconsistentException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/LocalVariableInfoInconsistentException.java new file mode 100644 index 00000000..8e2a2034 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/LocalVariableInfoInconsistentException.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.exc; + + +/** + * 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: LocalVariableInfoInconsistentException.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class LocalVariableInfoInconsistentException extends ClassConstraintException{ + private static final long serialVersionUID = -2833180480144304190L; + + /** + * 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(final String message) { + super (message); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StaticCodeConstraintException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StaticCodeConstraintException.java new file mode 100644 index 00000000..7ebe32a1 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StaticCodeConstraintException.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.exc; + + +/** + * 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: StaticCodeConstraintException.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public abstract class StaticCodeConstraintException extends CodeConstraintException{ + private static final long serialVersionUID = 3858523065007725128L; + + public StaticCodeConstraintException(final String message) { + super(message); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StaticCodeInstructionConstraintException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StaticCodeInstructionConstraintException.java new file mode 100644 index 00000000..251f2019 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StaticCodeInstructionConstraintException.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.exc; + + +/** + * 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: StaticCodeInstructionConstraintException.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class StaticCodeInstructionConstraintException extends StaticCodeConstraintException{ + private static final long serialVersionUID = 4987255974346614794L; + + public StaticCodeInstructionConstraintException(final String message) { + super(message); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StaticCodeInstructionOperandConstraintException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StaticCodeInstructionOperandConstraintException.java new file mode 100644 index 00000000..43d4203f --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StaticCodeInstructionOperandConstraintException.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.exc; + + +/** + * 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: StaticCodeInstructionOperandConstraintException.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class StaticCodeInstructionOperandConstraintException extends StaticCodeConstraintException{ + private static final long serialVersionUID = 4780787099381933487L; + + public StaticCodeInstructionOperandConstraintException(final String message) { + super(message); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StructuralCodeConstraintException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StructuralCodeConstraintException.java new file mode 100644 index 00000000..c7174643 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StructuralCodeConstraintException.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.exc; + +/** + * 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: StructuralCodeConstraintException.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class StructuralCodeConstraintException extends CodeConstraintException{ + private static final long serialVersionUID = 5406842000007181420L; + /** + * Constructs a new StructuralCodeConstraintException with the specified error message. + */ + public StructuralCodeConstraintException(final String message) { + super(message); + } + /** + * Constructs a new StructuralCodeConstraintException with null as its error message string. + */ + public StructuralCodeConstraintException() { + super(); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/Utility.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/Utility.java new file mode 100644 index 00000000..a888c11c --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/Utility.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.exc; + + +import java.io.PrintWriter; +import java.io.StringWriter; + +/** + * A utility class providing convenience methods concerning Throwable instances. + * @version $Id: Utility.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @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(final Throwable t) { + final StringWriter sw = new StringWriter(); + final PrintWriter pw = new PrintWriter(sw); + t.printStackTrace(pw); + return sw.toString(); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/VerificationException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/VerificationException.java new file mode 100644 index 00000000..3fb46ad8 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/VerificationException.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.exc; + + +/** + * 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: VerificationException.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public abstract class VerificationException extends VerifierConstraintViolatedException{ + private static final long serialVersionUID = 8012776320318623652L; + + /** + * Constructs a new VerificationException with null as its error message string. + */ + VerificationException() { + super(); + } + /** + * Constructs a new VerificationException with the specified error message. + */ + VerificationException(final String message) { + super(message); + } + + /** + * Constructs a new VerificationException with the specified error message and exception + */ + VerificationException(final String message, final Throwable initCause) { + super(message, initCause); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/VerifierConstraintViolatedException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/VerifierConstraintViolatedException.java new file mode 100644 index 00000000..f0c09f0d --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/VerifierConstraintViolatedException.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.exc; + + +/** + * 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: VerifierConstraintViolatedException.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public abstract class VerifierConstraintViolatedException extends RuntimeException{ + // /** The name of the offending class that did not pass the verifier. */ + // String name_of_offending_class; + + private static final long serialVersionUID = 2946136970490179465L; + /** 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(final String message) { + super(message); // Not that important + detailMessage = message; + } + /** + * Constructs a new VerifierConstraintViolationException with the specified error message and cause + */ + VerifierConstraintViolatedException(final String message, final Throwable initCause) { + super(message, initCause); + 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. + */ + @Override + public String getMessage() { + return detailMessage; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/package.html b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/package.html new file mode 100644 index 00000000..06a36d77 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/package.html @@ -0,0 +1,33 @@ + + + + + + + + +Exception classes used by JustIce, mostly used internally. You don't need to bother with them. + +

      Package Specification

      + +Contained in this package are Exception classes for use with the JustIce verifier. + + + diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/package.html b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/package.html new file mode 100644 index 00000000..8b56efb4 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/package.html @@ -0,0 +1,34 @@ + + + + + + + + +BCEL's verifier JustIce is there to help you dump correct Java class files created or modified with BCEL. + +

      Package Specification

      + +This is the top-level package of the JustIce verifier. To actually use it, have a look at the VerifierFactory and +Verifier classes. + + + diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/DOUBLE_Upper.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/DOUBLE_Upper.java new file mode 100644 index 00000000..7ac24ddf --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/DOUBLE_Upper.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.statics; + + +import org.apache.bcel.Const; +import org.apache.bcel.generic.Type; + +/** + * This class represents the upper half of a DOUBLE variable. + * @version $Id: DOUBLE_Upper.java 1811533 2017-10-09 06:16:52Z britter $ + */ +public final class DOUBLE_Upper extends Type{ + + /** The one and only instance of this class. */ + private static final DOUBLE_Upper singleton = new DOUBLE_Upper(); + + /** The constructor; this class must not be instantiated from the outside. */ + private DOUBLE_Upper() { + super(Const.T_UNKNOWN, "Double_Upper"); + } + + /** Use this method to get the single instance of this class. */ + public static DOUBLE_Upper theInstance() { + return singleton; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/IntList.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/IntList.java new file mode 100644 index 00000000..306acebc --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/IntList.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.statics; + + +import java.util.ArrayList; +import java.util.List; + +/** + * A small utility class representing a set of basic int values. + * + * @version $Id: IntList.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class IntList{ + /** The int are stored as Integer objects here. */ + private final List theList; + /** This constructor creates an empty list. */ + IntList() { + theList = new ArrayList<>(); + } + /** Adds an element to the list. */ + void add(final int i) { + theList.add(Integer.valueOf(i)); + } + /** Checks if the specified int is already in the list. */ + boolean contains(final int i) { + final Integer[] ints = new Integer[theList.size()]; + theList.toArray(ints); + for (final Integer k : ints) { + if (i == k.intValue()) { + return true; + } + } + return false; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/LONG_Upper.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/LONG_Upper.java new file mode 100644 index 00000000..f7b7d641 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/LONG_Upper.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.statics; + + +import org.apache.bcel.Const; +import org.apache.bcel.generic.Type; + +/** + * This class represents the upper half of a LONG variable. + * @version $Id: LONG_Upper.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public final class LONG_Upper extends Type{ + + /** The one and only instance of this class. */ + private static final LONG_Upper singleton = new LONG_Upper(); + + /** The constructor; this class must not be instantiated from the outside. */ + private LONG_Upper() { + super(Const.T_UNKNOWN, "Long_Upper"); + } + + /** Use this method to get the single instance of this class. */ + public static LONG_Upper theInstance() { + return singleton; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/LocalVariableInfo.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/LocalVariableInfo.java new file mode 100644 index 00000000..3c8e0cc2 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/LocalVariableInfo.java @@ -0,0 +1,110 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.statics; + + +import java.util.Hashtable; + +import org.apache.bcel.generic.Type; +import org.apache.bcel.verifier.exc.LocalVariableInfoInconsistentException; + +/** + * 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: LocalVariableInfo.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class LocalVariableInfo{ + + /** The types database. KEY: String representing the offset integer. */ + private final Hashtable types = new Hashtable<>(); + /** The names database. KEY: String representing the offset integer. */ + private final Hashtable names = new Hashtable<>(); + + /** + * Adds a name of a local variable and a certain slot to our 'names' + * (Hashtable) database. + */ + private void setName(final int offset, final 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(final int offset, final 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(final int offset) { + return 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(final int offset) { + return 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(final String name, final int startpc, final int length, final 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(final int offset, final String name, final 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/LocalVariablesInfo.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/LocalVariablesInfo.java new file mode 100644 index 00000000..4b3d53bc --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/LocalVariablesInfo.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.statics; + + +import org.apache.bcel.generic.Type; +import org.apache.bcel.verifier.exc.AssertionViolatedException; +import org.apache.bcel.verifier.exc.LocalVariableInfoInconsistentException; + +/** + * A utility class holding the information about + * the names and the types of the local variables in + * a given method. + * + * @version $Id: LocalVariablesInfo.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class LocalVariablesInfo{ + + /** The information about the local variables is stored here. */ + private final LocalVariableInfo[] localVariableInfos; + + /** The constructor. */ + LocalVariablesInfo(final int max_locals) { + localVariableInfos = new LocalVariableInfo[max_locals]; + for (int i=0; i= 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(final int slot, final String name, final int startpc, final int length, final 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/Pass1Verifier.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/Pass1Verifier.java new file mode 100644 index 00000000..b188608b --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/Pass1Verifier.java @@ -0,0 +1,200 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.statics; + + +import org.apache.bcel.Repository; +import org.apache.bcel.classfile.ClassFormatException; +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.verifier.PassVerifier; +import org.apache.bcel.verifier.VerificationResult; +import org.apache.bcel.verifier.Verifier; +import org.apache.bcel.verifier.exc.LoadingException; +import org.apache.bcel.verifier.exc.Utility; + +/** + * 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: Pass1Verifier.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @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 final 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) { + try { + jc = Repository.lookupClass(myOwner.getClassName()); + } catch (final ClassNotFoundException e) { + // FIXME: currently, Pass1Verifier treats jc == null as a special + // case, so we don't need to do anything here. A better solution + // would be to simply throw the ClassNotFoundException + // out of this method. + } + } + return jc; + } + + /** + * Should only be instantiated by a Verifier. + * + * @see Verifier + */ + public Pass1Verifier(final 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 explicitly stated by + * The Java Virtual Machine Specification, 2nd edition: + *
        + *
      • The first four bytes must contain the right magic number (0xCAFEBABE). + *
      • All recognized attributes must be of the proper length. + *
      • The class file must not be truncated or have extra bytes at the end. + *
      • The constant pool must not contain any superficially unrecognizable information. + *
      + * A more in-depth documentation of what pass one should do was written by + * Philip W. L. Fong: + *
        + *
      • the file should not be truncated. + *
      • the file should not have extra bytes at the end. + *
      • all variable-length structures should be well-formatted: + *
          + *
        • there should only be constant_pool_count-1 many entries in the constant pool. + *
        • all constant pool entries should have size the same as indicated by their type tag. + *
        • there are exactly interfaces_count many entries in the interfaces array of the class file. + *
        • there are exactly fields_count many entries in the fields array of the class file. + *
        • there are exactly methods_count many entries in the methods array of the class file. + *
        • there are exactly attributes_count many entries in the attributes array of the class file, + * fields, methods, and code attribute. + *
        • 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. + *
        • 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). + *
        + *
      • Also, certain constant values are checked for validity: + *
          + *
        • The magic number should be 0xCAFEBABE. + *
        • The major and minor version numbers are valid. + *
        • All the constant pool type tags are recognizable. + *
        • All undocumented access flags are masked off before use. Strictly speaking, this is not really a check. + *
        • 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. + *
        • the field super_class should point to a string that represents a legal non-array class name. + *
        • 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). + *
        + *
      • Extra checks done in pass 1: + *
          + *
        • the constant values of static fields should have the same type as the fields. + *
        • the number of words in a parameter list does not exceed 255 and locals_max. + *
        • the name and signature of fields and methods are verified to be of legal format. + *
        + *
      + * (From the Paper + * The Mysterious Pass One, first draft, September 2, 1997.) + * + *

      However, most of this is done by parsing a class file or generating a class file into BCEL's internal data structure. + * Therefore, all that is really done here is look up the class file from BCEL's repository. + * 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 + * @see org.apache.bcel.Const#JVM_CLASSFILE_MAGIC + */ + @Override + 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(final LoadingException e) { + return new VerificationResult(VerificationResult.VERIFIED_REJECTED, e.getMessage()); + } + catch(final ClassFormatException e) { + return new VerificationResult(VerificationResult.VERIFIED_REJECTED, e.getMessage()); + } + catch(final 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; + } + //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 + * TODO. + */ + @Override + public String[] getMessages() { + // This method is only here to override the javadoc-comment. + return super.getMessages(); + } + +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/Pass2Verifier.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/Pass2Verifier.java new file mode 100644 index 00000000..f98e348d --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/Pass2Verifier.java @@ -0,0 +1,1571 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.statics; + + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Locale; +import java.util.Map; +import java.util.Set; + +import org.apache.bcel.Const; +import org.apache.bcel.Constants; +import org.apache.bcel.Repository; +import org.apache.bcel.classfile.Attribute; +import org.apache.bcel.classfile.ClassFormatException; +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.CodeException; +import org.apache.bcel.classfile.Constant; +import org.apache.bcel.classfile.ConstantClass; +import org.apache.bcel.classfile.ConstantDouble; +import org.apache.bcel.classfile.ConstantFieldref; +import org.apache.bcel.classfile.ConstantFloat; +import org.apache.bcel.classfile.ConstantInteger; +import org.apache.bcel.classfile.ConstantInterfaceMethodref; +import org.apache.bcel.classfile.ConstantLong; +import org.apache.bcel.classfile.ConstantMethodref; +import org.apache.bcel.classfile.ConstantNameAndType; +import org.apache.bcel.classfile.ConstantPool; +import org.apache.bcel.classfile.ConstantString; +import org.apache.bcel.classfile.ConstantUtf8; +import org.apache.bcel.classfile.ConstantValue; +import org.apache.bcel.classfile.Deprecated; +import org.apache.bcel.classfile.DescendingVisitor; +import org.apache.bcel.classfile.EmptyVisitor; +import org.apache.bcel.classfile.ExceptionTable; +import org.apache.bcel.classfile.Field; +import org.apache.bcel.classfile.InnerClass; +import org.apache.bcel.classfile.InnerClasses; +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.LineNumber; +import org.apache.bcel.classfile.LineNumberTable; +import org.apache.bcel.classfile.LocalVariable; +import org.apache.bcel.classfile.LocalVariableTable; +import org.apache.bcel.classfile.Method; +import org.apache.bcel.classfile.Node; +import org.apache.bcel.classfile.SourceFile; +import org.apache.bcel.classfile.Synthetic; +import org.apache.bcel.classfile.Unknown; +import org.apache.bcel.generic.ArrayType; +import org.apache.bcel.generic.ObjectType; +import org.apache.bcel.generic.Type; +import org.apache.bcel.verifier.PassVerifier; +import org.apache.bcel.verifier.VerificationResult; +import org.apache.bcel.verifier.Verifier; +import org.apache.bcel.verifier.VerifierFactory; +import org.apache.bcel.verifier.exc.AssertionViolatedException; +import org.apache.bcel.verifier.exc.ClassConstraintException; +import org.apache.bcel.verifier.exc.LocalVariableInfoInconsistentException; + +/** + * 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: Pass2Verifier.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @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 final Verifier myOwner; + + /** + * Should only be instantiated by a Verifier. + * + * @see Verifier + */ + public Pass2Verifier(final 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 null 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 + * Repository.lookupClass(myOwner.getClassname()).getMethods()[method_nr];. + * You should not add own information. Leave that to JustIce. + */ + public LocalVariablesInfo getLocalVariablesInfo(final 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.
      + * Note that most referenced classes are not 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.
      + * 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 Pass3aVerifier + */ + @Override + public VerificationResult do_verify() { + try { + final 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 (final ClassConstraintException cce) { + vr = new VerificationResult(VerificationResult.VERIFIED_REJECTED, cce.getMessage()); + } + return vr; + } + return VerificationResult.VR_NOTYET; + + } catch (final ClassNotFoundException e) { + // FIXME: this might not be the best way to handle missing classes. + throw new AssertionViolatedException("Missing class: " + e, e); + } + } + + /** + * Ensures that every class has a super class and that + * final 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() { + try { + final Set 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{ + final String supername = jc.getSuperclassName(); + if (! hs.add(supername)) { // If supername already is in the list + throw new ClassConstraintException("Circular superclass hierarchy detected."); + } + final Verifier v = VerifierFactory.getVerifier(supername); + final 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."); + } + } + } + + } catch (final ClassNotFoundException e) { + // FIXME: this might not be the best way to handle missing classes. + throw new AssertionViolatedException("Missing class: " + e, e); + } + } + + /** + * Ensures that final methods are not overridden. + * 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). + * + * @throws ClassConstraintException otherwise. + * @see #constant_pool_entries_satisfy_static_constraints() + * @see #every_class_has_an_accessible_superclass() + */ + private void final_methods_are_not_overridden() { + try { + final Map hashmap = new HashMap<>(); + JavaClass jc = Repository.lookupClass(myOwner.getClassName()); + + int supidx = -1; + while (supidx != 0) { + supidx = jc.getSuperclassNameIndex(); + + final Method[] methods = jc.getMethods(); + for (final Method method : methods) { + final String nameAndSig = method.getName() + method.getSignature(); + + if (hashmap.containsKey(nameAndSig)) { + if (method.isFinal()) { + if (!(method.isPrivate())) { + throw new ClassConstraintException("Method '" + nameAndSig + "' in class '" + hashmap.get(nameAndSig) + + "' overrides the final (not-overridable) definition in class '" + jc.getClassName() + "'."); + } + addMessage("Method '" + nameAndSig + "' in class '" + hashmap.get(nameAndSig) + + "' overrides the final (not-overridable) definition in class '" + jc.getClassName() + + "'. This is okay, as the original definition was private; however this constraint leverage"+ + " was introduced by JLS 8.4.6 (not vmspec2) and the behaviour of the Sun verifiers."); + } else { + if (!method.isStatic()) { // static methods don't inherit + hashmap.put(nameAndSig, jc.getClassName()); + } + } + } else { + if (!method.isStatic()) { // static methods don't inherit + hashmap.put(nameAndSig, 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). + } + + } catch (final ClassNotFoundException e) { + // FIXME: this might not be the best way to handle missing classes. + throw new AssertionViolatedException("Missing class: " + e, e); + } + + } + + /** + * 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() { + try { + // 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. + final JavaClass jc = Repository.lookupClass(myOwner.getClassName()); + new CPESSC_Visitor(jc); // constructor implicitly traverses jc + + } catch (final ClassNotFoundException e) { + // FIXME: this might not be the best way to handle missing classes. + throw new AssertionViolatedException("Missing class: " + e, e); + } + } + + /** + * 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 final class CPESSC_Visitor extends org.apache.bcel.classfile.EmptyVisitor{ + private final Class CONST_Class; + /* + private Class CONST_Fieldref; + private Class CONST_Methodref; + private Class CONST_InterfaceMethodref; + */ + private final Class CONST_String; + private final Class CONST_Integer; + private final Class CONST_Float; + private final Class CONST_Long; + private final Class CONST_Double; + private final Class CONST_NameAndType; + private final 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 final DescendingVisitor carrier; + + private final Set field_names = new HashSet<>(); + private final Set field_names_and_desc = new HashSet<>(); + private final Set method_names_and_desc = new HashSet<>(); + + private CPESSC_Visitor(final JavaClass _jc) { + jc = _jc; + cp = _jc.getConstantPool(); + cplen = cp.getLength(); + + CONST_Class = ConstantClass.class; + /* + CONST_Fieldref = ConstantFieldref.class; + CONST_Methodref = ConstantMethodref.class; + CONST_InterfaceMethodref = ConstantInterfaceMethodref.class; + */ + CONST_String = ConstantString.class; + CONST_Integer = ConstantInteger.class; + CONST_Float = ConstantFloat.class; + CONST_Long = ConstantLong.class; + CONST_Double = ConstantDouble.class; + CONST_NameAndType = ConstantNameAndType.class; + CONST_Utf8 = ConstantUtf8.class; + + carrier = new DescendingVisitor(_jc, this); + carrier.visit(); + } + + private void checkIndex(final Node referrer, final int index, final Class shouldbe) { + if ((index < 0) || (index >= cplen)) { + throw new ClassConstraintException("Invalid index '"+index+"' used by '"+tostring(referrer)+"'."); + } + final 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) // + /////////////////////////////////////// + @Override + public void visitJavaClass(final JavaClass obj) { + final 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! + final boolean hasInnerClass = new InnerClassDetector(jc).innerClassReferenced(); + + for (final Attribute att : atts) { + if ((!(att instanceof SourceFile)) && + (!(att instanceof Deprecated)) && + (!(att instanceof InnerClasses)) && + (!(att instanceof Synthetic))) { + addMessage("Attribute '" + tostring(att) + "' as an attribute of the ClassFile structure '" + + tostring(obj) + "' is unknown and will therefore be ignored."); + } + + if (att instanceof SourceFile) { + if (!foundSourceFile) { + 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 (att instanceof InnerClasses) { + if (!foundInnerClasses) { + 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(att) + + "' 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) // + ///////////////////////////// + @Override + public void visitConstantClass(final ConstantClass obj) { + if (obj.getTag() != Const.CONSTANT_Class) { + throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'."); + } + checkIndex(obj, obj.getNameIndex(), CONST_Utf8); + + } + @Override + public void visitConstantFieldref(final ConstantFieldref obj) { + if (obj.getTag() != Const.CONSTANT_Fieldref) { + throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'."); + } + checkIndex(obj, obj.getClassIndex(), CONST_Class); + checkIndex(obj, obj.getNameAndTypeIndex(), CONST_NameAndType); + } + @Override + public void visitConstantMethodref(final ConstantMethodref obj) { + if (obj.getTag() != Const.CONSTANT_Methodref) { + throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'."); + } + checkIndex(obj, obj.getClassIndex(), CONST_Class); + checkIndex(obj, obj.getNameAndTypeIndex(), CONST_NameAndType); + } + @Override + public void visitConstantInterfaceMethodref(final ConstantInterfaceMethodref obj) { + if (obj.getTag() != Const.CONSTANT_InterfaceMethodref) { + throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'."); + } + checkIndex(obj, obj.getClassIndex(), CONST_Class); + checkIndex(obj, obj.getNameAndTypeIndex(), CONST_NameAndType); + } + @Override + public void visitConstantString(final ConstantString obj) { + if (obj.getTag() != Const.CONSTANT_String) { + throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'."); + } + checkIndex(obj, obj.getStringIndex(), CONST_Utf8); + } + @Override + public void visitConstantInteger(final ConstantInteger obj) { + if (obj.getTag() != Const.CONSTANT_Integer) { + throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'."); + } + // no indices to check + } + @Override + public void visitConstantFloat(final ConstantFloat obj) { + if (obj.getTag() != Const.CONSTANT_Float) { + throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'."); + } + //no indices to check + } + @Override + public void visitConstantLong(final ConstantLong obj) { + if (obj.getTag() != Const.CONSTANT_Long) { + throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'."); + } + //no indices to check + } + @Override + public void visitConstantDouble(final ConstantDouble obj) { + if (obj.getTag() != Const.CONSTANT_Double) { + throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'."); + } + //no indices to check + } + @Override + public void visitConstantNameAndType(final ConstantNameAndType obj) { + if (obj.getTag() != Const.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); + } + @Override + public void visitConstantUtf8(final ConstantUtf8 obj) { + if (obj.getTag() != Const.CONSTANT_Utf8) { + throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'."); + } + //no indices to check + } + ////////////////////////// + // FIELDS (vmspec2 4.5) // + ////////////////////////// + @Override + public void visitField(final 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() & ~(Const.ACC_PUBLIC|Const.ACC_PRIVATE|Const.ACC_PROTECTED|Const.ACC_STATIC| + Const.ACC_FINAL|Const.ACC_VOLATILE|Const.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); + + final 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); + + final String sig = ((ConstantUtf8) (cp.getConstant(obj.getSignatureIndex()))).getBytes(); // Field or Method sig.(=descriptor) + + try{ + Type.getType(sig); /* Don't need the return value */ + } + catch (final ClassFormatException cfe) { + throw new ClassConstraintException("Illegal descriptor (==signature) '"+sig+"' used by '"+tostring(obj)+"'.", cfe); + } + + final 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); + + final Attribute[] atts = obj.getAttributes(); + for (final Attribute att : atts) { + if ((!(att instanceof ConstantValue)) && + (!(att instanceof Synthetic)) && + (!(att instanceof Deprecated))) { + addMessage("Attribute '" + tostring(att) + "' as an attribute of Field '" + + tostring(obj) + "' is unknown and will therefore be ignored."); + } + if (!(att instanceof ConstantValue)) { + addMessage("Attribute '" + tostring(att) + "' 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) // + /////////////////////////// + @Override + public void visitMethod(final Method obj) { + + checkIndex(obj, obj.getNameIndex(), CONST_Utf8); + + final 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); + + final 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 (final ClassFormatException cfe) { + throw new ClassConstraintException( + "Illegal descriptor (==signature) '"+sig+"' used by Method '"+tostring(obj)+"'.", cfe); + } + + // Check if referenced objects exist. + Type act = t; + if (act instanceof ArrayType) { + act = ((ArrayType) act).getBasicType(); + } + if (act instanceof ObjectType) { + final Verifier v = VerifierFactory.getVerifier( ((ObjectType) act).getClassName() ); + final 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 (final Type element : ts) { + act = element; + if (act instanceof ArrayType) { + act = ((ArrayType) act).getBasicType(); + } + if (act instanceof ObjectType) { + final Verifier v = VerifierFactory.getVerifier( ((ObjectType) act).getClassName() ); + final 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(Const.STATIC_INITIALIZER_NAME) && (ts.length != 0)) { + throw new ClassConstraintException( + "Method '"+tostring(obj)+"' has illegal name '"+name+"'."+ + " Its 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."); + } + } + + // A specific instance initialization method... (vmspec2,Page 116). + if (name.equals(Const.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."); + } + } + } + else{ // isInterface! + if (!name.equals(Const.STATIC_INITIALIZER_NAME)) {//vmspec2, p.116, 2nd paragraph + if (jc.getMajor() >= Const.MAJOR_1_8) { + if (!(obj.isPublic() ^ obj.isPrivate())) { + throw new ClassConstraintException("Interface method '" + tostring(obj) + "' must have" + + " exactly one of its ACC_PUBLIC and ACC_PRIVATE modifiers set."); + } + if (obj.isProtected() + || obj.isFinal() + || obj.isSynchronized() + || obj.isNative()) { + throw new ClassConstraintException("Interface method '"+tostring(obj)+ "' must not have" + + " any of the ACC_PROTECTED, ACC_FINAL, ACC_SYNCHRONIZED, or ACC_NATIVE modifiers set."); + } + + } else { + 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_ABSTRACT 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."); + } + } + } + } + + if ((obj.getAccessFlags() & + ~(Const.ACC_PUBLIC|Const.ACC_PRIVATE|Const.ACC_PROTECTED|Const.ACC_STATIC|Const.ACC_FINAL| + Const.ACC_SYNCHRONIZED|Const.ACC_NATIVE|Const.ACC_ABSTRACT|Const.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)."); + } + + final 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); + + final Attribute[] atts = obj.getAttributes(); + int num_code_atts = 0; + for (final Attribute att : atts) { + if ((!(att instanceof Code)) && + (!(att instanceof ExceptionTable)) && + (!(att instanceof Synthetic)) && + (!(att instanceof Deprecated))) { + addMessage("Attribute '" + tostring(att) + "' as an attribute of Method '" + tostring(obj) + + "' is unknown and will therefore be ignored."); + } + if ((!(att instanceof Code)) && + (!(att instanceof ExceptionTable))) { + addMessage("Attribute '" + tostring(att) + "' as an attribute of Method '" + tostring(obj) + + "' is neither Code nor Exceptions and is therefore only of use for debuggers and such."); + } + if ((att instanceof Code) && (obj.isNative() || obj.isAbstract())) { + throw new ClassConstraintException("Native or abstract methods like '" + tostring(obj) + + "' must not have a Code attribute like '" + tostring(att) + "'."); //vmspec2 page120, 4.7.3 + } + if (att 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) // + /////////////////////////////////////////////////////// + @Override + public void visitSourceFile(final SourceFile obj) {//vmspec2 4.7.7 + + // zero or one SourceFile attr per ClassFile: see visitJavaClass() + + checkIndex(obj, obj.getNameIndex(), CONST_Utf8); + + final 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); + + final String sourcefilename = ((ConstantUtf8) cp.getConstant(obj.getSourceFileIndex())).getBytes(); //==obj.getSourceFileName() ? + final String sourcefilenamelc = sourcefilename.toLowerCase(Locale.ENGLISH); + + 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."); + } + } + @Override + public void visitDeprecated(final Deprecated obj) {//vmspec2 4.7.10 + checkIndex(obj, obj.getNameIndex(), CONST_Utf8); + + final 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+"'."); + } + } + @Override + public void visitSynthetic(final Synthetic obj) {//vmspec2 4.7.6 + checkIndex(obj, obj.getNameIndex(), CONST_Utf8); + final 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+"'."); + } + } + @Override + public void visitInnerClasses(final 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); + + final 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+"'."); + } + + final InnerClass[] ics = obj.getInnerClasses(); + + for (final InnerClass ic : ics) { + checkIndex(obj, ic.getInnerClassIndex(), CONST_Class); + final int outer_idx = ic.getOuterClassIndex(); + if (outer_idx != 0) { + checkIndex(obj, outer_idx, CONST_Class); + } + final int innername_idx = ic.getInnerNameIndex(); + if (innername_idx != 0) { + checkIndex(obj, innername_idx, CONST_Utf8); + } + int acc = ic.getInnerAccessFlags(); + acc = acc & (~ (Const.ACC_PUBLIC | Const.ACC_PRIVATE | Const.ACC_PROTECTED | + Const.ACC_STATIC | Const.ACC_FINAL | Const.ACC_INTERFACE | Const.ACC_ABSTRACT)); + if (acc != 0) { + addMessage( + "Unknown access flag for inner class '"+tostring(ic)+"' 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) // + //////////////////////////////////////////////////////// + @Override + public void visitConstantValue(final ConstantValue obj) {//vmspec2 4.7.2 + // Despite its name, this really is an Attribute, + // not a constant! + checkIndex(obj, obj.getNameIndex(), CONST_Utf8); + + final 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+"'."); + } + + final Object pred = carrier.predecessor(); + if (pred instanceof Field) { //ConstantValue attributes are quite senseless if the predecessor is not a field. + final Field f = (Field) pred; + // Field constraints have been checked before -- so we are safe using their type information. + final Type field_type = Type.getType(((ConstantUtf8) (cp.getConstant(f.getSignatureIndex()))).getBytes()); + + final int index = obj.getConstantValueIndex(); + if ((index < 0) || (index >= cplen)) { + throw new ClassConstraintException("Invalid index '"+index+"' used by '"+tostring(obj)+"'."); + } + final 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) // + ///////////////////////////////////////////////////////// + @Override + public void visitCode(final Code obj) {//vmspec2 4.7.3 + try { + // 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); + + final 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; + } + 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. + final CodeException[] exc_table = obj.getExceptionTable(); + for (final CodeException element : exc_table) { + final int exc_index = element.getCatchType(); + if (exc_index != 0) { // if 0, it catches all Throwables + checkIndex(obj, exc_index, CONST_Class); + final ConstantClass cc = (ConstantClass) (cp.getConstant(exc_index)); + // cannot be sure this ConstantClass has already been visited (checked)! + checkIndex(cc, cc.getNameIndex(), CONST_Utf8); + final 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(element)+"' that references '"+cname+ + "' as an Exception but it does not pass verification pass 1: "+vr); + } + // We cannot safely trust any other "instanceof" mechanism. We need to transitively verify + // the ancestor hierarchy. + JavaClass e = Repository.lookupClass(cname); + final JavaClass t = Repository.lookupClass(Type.THROWABLE.getClassName()); + final 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(element)+"' that references '"+cname+ + "' as an Exception but '"+e.getSuperclassName()+ + "' in the ancestor hierachy does not pass verification pass 1: "+vr); + } + e = Repository.lookupClass(e.getSuperclassName()); + } + if (e != t) { + throw new ClassConstraintException("Code attribute '"+tostring(obj)+"' (method '"+m+ + "') has an exception_table entry '"+tostring(element)+"' 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; + final Method[] ms = Repository.lookupClass(myOwner.getClassName()).getMethods(); + for (int mn=0; mn= code.getMaxLocals()) { + throw new ClassConstraintException("LocalVariableTable attribute '"+tostring(lvt)+ + "' references a LocalVariable '"+tostring(localvariable)+ + "' with an index that exceeds the surrounding Code attribute's max_locals value of '"+ + code.getMaxLocals()+"'."); + } + + try{ + localVariablesInfos[method_number].add(localindex, localname, localvariable.getStartPC(), + localvariable.getLength(), t); + } + catch(final LocalVariableInfoInconsistentException lviie) { + throw new ClassConstraintException("Conflicting information in LocalVariableTable '"+tostring(lvt)+ + "' found in Code attribute '"+tostring(obj)+ + "' (method '"+tostring(m)+"'). "+lviie.getMessage(), lviie); + } + }// for all local variables localvariables[i] in the LocalVariableTable attribute atts[a] END + + num_of_lvt_attribs++; + if (!m.isStatic() && 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 at most one LocalVariableTable attribute per local variable in the Code attribute.')."); + } + }// if atts[a] instanceof LocalVariableTable END + }// for all attributes atts[a] END + + } catch (final ClassNotFoundException e) { + // FIXME: this might not be the best way to handle missing classes. + throw new AssertionViolatedException("Missing class: " + e, e); + } + + }// visitCode(Code) END + + @Override + public void visitExceptionTable(final ExceptionTable obj) {//vmspec2 4.7.4 + try { + // incorrectly named, it's the Exceptions attribute (vmspec2 4.7.4) + checkIndex(obj, obj.getNameIndex(), CONST_Utf8); + + final 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+"'."); + } + + final int[] exc_indices = obj.getExceptionIndexTable(); + + for (final int exc_indice : exc_indices) { + checkIndex(obj, exc_indice, CONST_Class); + + final ConstantClass cc = (ConstantClass) (cp.getConstant(exc_indice)); + checkIndex(cc, cc.getNameIndex(), CONST_Utf8); // can't be sure this ConstantClass has already been visited (checked)! + //convert internal notation on-the-fly to external notation: + final 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("Exceptions attribute '"+tostring(obj)+"' references '"+cname+ + "' as an Exception but it does not pass verification pass 1: "+vr); + } + // We cannot safely trust any other "instanceof" mechanism. We need to transitively verify + // the ancestor hierarchy. + JavaClass e = Repository.lookupClass(cname); + final JavaClass t = Repository.lookupClass(Type.THROWABLE.getClassName()); + final 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); + } + 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()+"'."); + } + } + + } catch (final ClassNotFoundException e) { + // FIXME: this might not be the best way to handle missing classes. + throw new AssertionViolatedException("Missing class: " + e, e); + } + } + // SYNTHETIC: see above + // DEPRECATED: see above + ////////////////////////////////////////////////////////////// + // code_attribute-structure-ATTRIBUTES (vmspec2 4.7.3, 4.7) // + ////////////////////////////////////////////////////////////// + @Override + public void visitLineNumberTable(final LineNumberTable obj) {//vmspec2 4.7.8 + checkIndex(obj, obj.getNameIndex(), CONST_Utf8); + + final 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... + + } + @Override + public void visitLocalVariableTable(final 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) // + //////////////////////////////////////////////////// + @Override + public void visitUnknown(final 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 // + ////////// + @Override + public void visitLocalVariable(final LocalVariable obj) { + // This does not represent an Attribute but is only + // related to internal BCEL data representation. + + // see visitLocalVariableTable(LocalVariableTable) + } + @Override + public void visitCodeException(final 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) + } + @Override + public void visitConstantPool(final 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. + } + @Override + public void visitInnerClass(final InnerClass obj) { + // This does not represent an Attribute but is only + // related to internal BCEL data representation. + } + @Override + public void visitLineNumber(final 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. + * Precondition: index-style cross referencing in the constant + * pool must be valid. Simply invoke constant_pool_entries_satisfy_static_constraints() + * before. + * + * @throws ClassConstraintException otherwise. + * @see #constant_pool_entries_satisfy_static_constraints() + */ + private void field_and_method_refs_are_valid() { + try { + final JavaClass jc = Repository.lookupClass(myOwner.getClassName()); + final DescendingVisitor v = new DescendingVisitor(jc, new FAMRAV_Visitor(jc)); + v.visit(); + + } catch (final ClassNotFoundException e) { + // FIXME: this might not be the best way to handle missing classes. + throw new AssertionViolatedException("Missing class: " + e, e); + } + } + + /** + * A Visitor class that ensures the ConstantCP-subclassed entries + * of the constant pool are valid. + * Precondition: index-style cross referencing in the constant + * pool must be valid. + * + * @see #constant_pool_entries_satisfy_static_constraints() + * @see org.apache.bcel.classfile.ConstantCP + */ + private final class FAMRAV_Visitor extends EmptyVisitor{ + private final ConstantPool cp; // ==jc.getConstantPool() -- only here to save typing work. + private FAMRAV_Visitor(final JavaClass _jc) { + cp = _jc.getConstantPool(); + } + + @Override + public void visitConstantFieldref(final ConstantFieldref obj) { + if (obj.getTag() != Const.CONSTANT_Fieldref) { + throw new ClassConstraintException("ConstantFieldref '"+tostring(obj)+"' has wrong tag!"); + } + final int name_and_type_index = obj.getNameAndTypeIndex(); + final ConstantNameAndType cnat = (ConstantNameAndType) (cp.getConstant(name_and_type_index)); + final 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)+"'."); + } + + final int class_index = obj.getClassIndex(); + final ConstantClass cc = (ConstantClass) (cp.getConstant(class_index)); + final 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)+"'."); + } + + final String sig = ((ConstantUtf8) (cp.getConstant(cnat.getSignatureIndex()))).getBytes(); // Field or Method sig.(=descriptor) + + try{ + Type.getType(sig); /* Don't need the return value */ + } + catch (final ClassFormatException cfe) { + throw new ClassConstraintException("Illegal descriptor (==signature) '"+sig+"' used by '"+tostring(obj)+"'.", cfe); + } + } + + @Override + public void visitConstantMethodref(final ConstantMethodref obj) { + if (obj.getTag() != Const.CONSTANT_Methodref) { + throw new ClassConstraintException("ConstantMethodref '"+tostring(obj)+"' has wrong tag!"); + } + final int name_and_type_index = obj.getNameAndTypeIndex(); + final ConstantNameAndType cnat = (ConstantNameAndType) (cp.getConstant(name_and_type_index)); + final 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)+"'."); + } + + final int class_index = obj.getClassIndex(); + final ConstantClass cc = (ConstantClass) (cp.getConstant(class_index)); + final 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)+"'."); + } + + final String sig = ((ConstantUtf8) (cp.getConstant(cnat.getSignatureIndex()))).getBytes(); // Field or Method sig.(=descriptor) + + try{ + final Type t = Type.getReturnType(sig); + if ( name.equals(Const.CONSTRUCTOR_NAME) && (t != Type.VOID) ) { + throw new ClassConstraintException("Instance initialization method must have VOID return type."); + } + } + catch (final ClassFormatException cfe) { + throw new ClassConstraintException("Illegal descriptor (==signature) '"+sig+"' used by '"+tostring(obj)+"'.", cfe); + } + } + + @Override + public void visitConstantInterfaceMethodref(final ConstantInterfaceMethodref obj) { + if (obj.getTag() != Const.CONSTANT_InterfaceMethodref) { + throw new ClassConstraintException("ConstantInterfaceMethodref '"+tostring(obj)+"' has wrong tag!"); + } + final int name_and_type_index = obj.getNameAndTypeIndex(); + final ConstantNameAndType cnat = (ConstantNameAndType) (cp.getConstant(name_and_type_index)); + final 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)+"'."); + } + + final int class_index = obj.getClassIndex(); + final ConstantClass cc = (ConstantClass) (cp.getConstant(class_index)); + final 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)+"'."); + } + + final String sig = ((ConstantUtf8) (cp.getConstant(cnat.getSignatureIndex()))).getBytes(); // Field or Method sig.(=descriptor) + + try{ + final Type t = Type.getReturnType(sig); + if ( name.equals(Const.STATIC_INITIALIZER_NAME) && (t != Type.VOID) ) { + addMessage("Class or interface initialization method '"+Const.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 (final ClassFormatException cfe) { + throw new ClassConstraintException("Illegal descriptor (==signature) '"+sig+"' used by '"+tostring(obj)+"'.", cfe); + } + + } + + } + + /** + * This method returns true if and only if the supplied String + * represents a valid Java class name. + */ + private static boolean validClassName(final String name) { + /* + * TODO: implement. + * Are there any 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(final String name, final boolean allowStaticInit) { + if (validJavaLangMethodName(name)) { + return true; + } + + if (allowStaticInit) { + return name.equals(Const.CONSTRUCTOR_NAME) || name.equals(Const.STATIC_INITIALIZER_NAME); + } + return name.equals(Const.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(final 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(final String name) { + if (!Character.isJavaIdentifierStart(name.charAt(0))) { + return false; + } + + for (int i=1; i, thanks! + } + + // vmspec2 2.7, vmspec2 2.2 + if (!Character.isJavaIdentifierStart(name.charAt(0))) { + return false; + } + + for (int i=1; i= methods.length) { + throw new InvalidMethodException("METHOD DOES NOT EXIST!"); + } + final 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(final 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(final ClassConstraintException cce) { + vr = new VerificationResult(VerificationResult.VERIFIED_REJECTED, cce.getMessage()); + return vr; + } + try{ + pass3StaticInstructionChecks(); + pass3StaticInstructionOperandsChecks(); + } + catch(final StaticCodeConstraintException scce) { + vr = new VerificationResult(VerificationResult.VERIFIED_REJECTED, scce.getMessage()); + } + catch(final ClassCastException cce) { + vr = new VerificationResult(VerificationResult.VERIFIED_REJECTED, "Class Cast Exception: " + cce.getMessage()); + } + return vr; + } + //did not pass Pass 2. + return VerificationResult.VR_NOTYET; + } catch (final ClassNotFoundException e) { + // FIXME: maybe not the best way to handle this + throw new AssertionViolatedException("Missing class: " + e, e); + } + } + + /** + * 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() { + + final int[] instructionPositions = instructionList.getInstructionPositions(); + final int codeLength = code.getCode().length; + + ///////////////////// + // LineNumberTable // + ///////////////////// + final LineNumberTable lnt = code.getLineNumberTable(); + if (lnt != null) { + final LineNumber[] lineNumbers = lnt.getLineNumberTable(); + final IntList offsets = new IntList(); + lineNumber_loop: + for (final LineNumber lineNumber : lineNumbers) { // may appear in any order. + for (final int instructionPosition : instructionPositions) { + // TODO: Make this a binary search! The instructionPositions array is naturally ordered! + final int offset = lineNumber.getStartPC(); + if (instructionPosition == 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 ('" + lineNumber.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. */ + final Attribute[] atts = code.getAttributes(); + for (final Attribute att : atts) { + if (att instanceof LocalVariableTable) { + final LocalVariableTable lvt = (LocalVariableTable) att; + final LocalVariable[] localVariables = lvt.getLocalVariableTable(); + for (final LocalVariable localVariable : localVariables) { + final int startpc = localVariable.getStartPC(); + final int length = localVariable.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. + final CodeException[] exceptionTable = code.getExceptionTable(); + for (final CodeException element : exceptionTable) { + final int startpc = element.getStartPC(); + final int endpc = element.getEndPC(); + final int handlerpc = element.getHandlerPC(); + if (startpc >= endpc) { + throw new ClassConstraintException("Code attribute '"+code+"' has an exception_table entry '"+element+ + "' 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 '"+element+ + "' 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 '"+element+ + "' 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 '"+element+ + "' 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 >= Const.MAX_CODE_SIZE) {// length must be LESS than the max + throw new StaticCodeInstructionConstraintException( + "Code array in code attribute '"+code+"' too big: must be smaller than "+Const.MAX_CODE_SIZE+"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 implicitly 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) { + final 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. + final Instruction last = instructionList.getEnd().getInstruction(); + if (! ((last instanceof ReturnInstruction) || + (last instanceof RET) || + (last instanceof GotoInstruction) || + (last instanceof ATHROW) )) { + 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() { + try { + // 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. + + final ConstantPoolGen cpg = new ConstantPoolGen(Repository.lookupClass(myOwner.getClassName()).getConstantPool()); + final InstOperandConstraintVisitor v = new InstOperandConstraintVisitor(cpg); + + // Checks for the things BCEL does _not_ handle itself. + InstructionHandle ih = instructionList.getStart(); + while (ih != null) { + final Instruction i = ih.getInstruction(); + + // An "own" constraint, due to JustIce's new definition of what "subroutine" means. + if (i instanceof JsrInstruction) { + final 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(); + } + + } catch (final ClassNotFoundException e) { + // FIXME: maybe not the best way to handle this + throw new AssertionViolatedException("Missing class: " + e, e); + } + } + + /** A small utility method returning if a given int i is in the given int[] ints. */ + private static boolean contains(final int[] ints, final int i) { + for (final int k : ints) { + if (k==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 final ConstantPoolGen cpg; + + /** The only Constructor. */ + InstOperandConstraintVisitor(final 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() { + try { + return Repository.lookupClass(myOwner.getClassName()).getMethods()[method_no].getCode().getMaxLocals(); + } catch (final ClassNotFoundException e) { + // FIXME: maybe not the best way to handle this + throw new AssertionViolatedException("Missing class: " + e, e); + } + } + + /** + * A utility method to always raise an exeption. + */ + private void constraintViolated(final Instruction i, final 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(final Instruction i, final 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. + */ + @Override + public void visitLoadClass(final LoadClass o) { + final ObjectType t = o.getLoadClassType(cpg); + if (t != null) {// null means "no class is loaded" + final Verifier v = VerifierFactory.getVerifier(t.getClassName()); + final 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) + @Override + public void visitLDC(final LDC o) { + indexValid(o, o.getIndex()); + final Constant c = cpg.getConstant(o.getIndex()); + if (c instanceof ConstantClass) { + addMessage("Operand of LDC or LDC_W is CONSTANT_Class '"+c+"' - this is only supported in JDK 1.5 and higher."); + } + else{ + 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 + @Override + public void visitLDC2_W(final LDC2_W o) { + indexValid(o, o.getIndex()); + final 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(final StaticCodeInstructionOperandConstraintException e) { + throw new AssertionViolatedException("OOPS: Does not BCEL handle that? LDC2_W operand has a problem.", e); + } + } + + private ObjectType getObjectType(final FieldInstruction o) { + final ReferenceType rt = o.getReferenceType(cpg); + if(rt instanceof ObjectType) { + return (ObjectType)rt; + } + constraintViolated(o, "expecting ObjectType but got "+rt); + return null; + } + + /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ + //getfield, putfield, getstatic, putstatic + @Override + public void visitFieldInstruction(final FieldInstruction o) { + try { + indexValid(o, o.getIndex()); + final Constant c = cpg.getConstant(o.getIndex()); + if (! (c instanceof ConstantFieldref)) { + constraintViolated(o, "Indexing a constant that's not a CONSTANT_Fieldref but a '"+c+"'."); + } + + final String field_name = o.getFieldName(cpg); + + final JavaClass jc = Repository.lookupClass(getObjectType(o).getClassName()); + Field[] fields = jc.getFields(); + Field f = null; + for (final Field field : fields) { + if (field.getName().equals(field_name)) { + final Type f_type = Type.getType(field.getSignature()); + final Type o_type = o.getType(cpg); + /* TODO: Check if assignment compatibility is sufficient. + * What does Sun do? + */ + if (f_type.equals(o_type)) { + f = field; + break; + } + } + } + if (f == null) { + final JavaClass[] superclasses = jc.getSuperClasses(); + outer: + for (final JavaClass superclass : superclasses) { + fields = superclass.getFields(); + for (final Field field : fields) { + if (field.getName().equals(field_name)) { + final Type f_type = Type.getType(field.getSignature()); + final Type o_type = o.getType(cpg); + if (f_type.equals(o_type)) { + f = field; + if ((f.getAccessFlags() & (Const.ACC_PUBLIC | Const.ACC_PROTECTED)) == 0) { + f = null; + } + break outer; + } + } + } + } + if (f == null) { + constraintViolated(o, "Referenced field '"+field_name+"' does not exist in class '"+jc.getClassName()+"'."); + } + } + else{ + /* TODO: Check if assignment compatibility is sufficient. + What does Sun do? */ + Type.getType(f.getSignature()); + o.getType(cpg); +// Type f_type = Type.getType(f.getSignature()); +// Type o_type = o.getType(cpg); + + // Argh. Sun's implementation allows us to have multiple fields of + // the same name but with a different signature. + //if (! f_type.equals(o_type)) { + // constraintViolated(o, + // "Referenced field '"+field_name+"' has type '"+f_type+"' instead of '"+o_type+"' as expected."); + //} + + /* TODO: Check for access modifiers here. */ + } + } catch (final ClassNotFoundException e) { + // FIXME: maybe not the best way to handle this + throw new AssertionViolatedException("Missing class: " + e, e); + } + } + + /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ + @Override + public void visitInvokeInstruction(final InvokeInstruction o) { + indexValid(o, o.getIndex()); + if ( (o instanceof INVOKEVIRTUAL) || + (o instanceof INVOKESPECIAL) || + (o instanceof INVOKESTATIC) ) { + final 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. + final ConstantNameAndType cnat = (ConstantNameAndType) (cpg.getConstant(((ConstantMethodref) c).getNameAndTypeIndex())); + final ConstantUtf8 cutf8 = (ConstantUtf8) (cpg.getConstant(cnat.getNameIndex())); + if (cutf8.getBytes().equals(Const.CONSTRUCTOR_NAME) && (!(o instanceof INVOKESPECIAL)) ) { + constraintViolated(o, "Only INVOKESPECIAL is allowed to invoke instance initialization methods."); + } + if ( (! (cutf8.getBytes().equals(Const.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) { + final 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 or + final ConstantNameAndType cnat = + (ConstantNameAndType) (cpg.getConstant(((ConstantInterfaceMethodref)c).getNameAndTypeIndex())); + final String name = ((ConstantUtf8) (cpg.getConstant(cnat.getNameIndex()))).getBytes(); + if (name.equals(Const.CONSTRUCTOR_NAME)) { + constraintViolated(o, "Method to invoke must not be '"+Const.CONSTRUCTOR_NAME+"'."); + } + if (name.equals(Const.STATIC_INITIALIZER_NAME)) { + constraintViolated(o, "Method to invoke must not be '"+Const.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) { + final Verifier v = VerifierFactory.getVerifier(((ObjectType) t).getClassName()); + final VerificationResult vr = v.doPass2(); + if (vr.getStatus() != VerificationResult.VERIFIED_OK) { + constraintViolated(o, "Return type class/interface could not be verified successfully: '"+vr.getMessage()+"'."); + } + } + + final Type[] ts = o.getArgumentTypes(cpg); + for (final Type element : ts) { + t = element; + if (t instanceof ArrayType) { + t = ((ArrayType) t).getBasicType(); + } + if (t instanceof ObjectType) { + final Verifier v = VerifierFactory.getVerifier(((ObjectType) t).getClassName()); + final 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. */ + @Override + public void visitINSTANCEOF(final INSTANCEOF o) { + indexValid(o, o.getIndex()); + final 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. */ + @Override + public void visitCHECKCAST(final CHECKCAST o) { + indexValid(o, o.getIndex()); + final 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. */ + @Override + public void visitNEW(final NEW o) { + indexValid(o, o.getIndex()); + final Constant c = cpg.getConstant(o.getIndex()); + if (! (c instanceof ConstantClass)) { + constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '"+c+"'."); + } + else{ + final ConstantUtf8 cutf8 = (ConstantUtf8) (cpg.getConstant( ((ConstantClass) c).getNameIndex() )); + final 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. */ + @Override + public void visitMULTIANEWARRAY(final MULTIANEWARRAY o) { + indexValid(o, o.getIndex()); + final Constant c = cpg.getConstant(o.getIndex()); + if (! (c instanceof ConstantClass)) { + constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '"+c+"'."); + } + final int dimensions2create = o.getDimensions(); + if (dimensions2create < 1) { + constraintViolated(o, "Number of dimensions to create must be greater than zero."); + } + final Type t = o.getType(cpg); + if (t instanceof ArrayType) { + final 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. */ + @Override + public void visitANEWARRAY(final ANEWARRAY o) { + indexValid(o, o.getIndex()); + final Constant c = cpg.getConstant(o.getIndex()); + if (! (c instanceof ConstantClass)) { + constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '"+c+"'."); + } + final Type t = o.getType(cpg); + if (t instanceof ArrayType) { + final int dimensions = ((ArrayType) t).getDimensions(); + if (dimensions > Const.MAX_ARRAY_DIMENSIONS) { + constraintViolated(o, + "Not allowed to create an array with more than "+ Const.MAX_ARRAY_DIMENSIONS + " dimensions;"+ + " actual: " + dimensions); + } + } + } + + /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ + @Override + public void visitNEWARRAY(final NEWARRAY o) { + final byte t = o.getTypecode(); + if (! ( (t == Const.T_BOOLEAN) || + (t == Const.T_CHAR) || + (t == Const.T_FLOAT) || + (t == Const.T_DOUBLE) || + (t == Const.T_BYTE) || + (t == Const.T_SHORT) || + (t == Const.T_INT) || + (t == Const.T_LONG) ) ) { + constraintViolated(o, "Illegal type code '+t+' for 'atype' operand."); + } + } + + /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ + @Override + public void visitILOAD(final ILOAD o) { + final int idx = o.getIndex(); + if (idx < 0) { + constraintViolated(o, "Index '"+idx+"' must be non-negative."); + } + else{ + final 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. */ + @Override + public void visitFLOAD(final FLOAD o) { + final int idx = o.getIndex(); + if (idx < 0) { + constraintViolated(o, "Index '"+idx+"' must be non-negative."); + } + else{ + final 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. */ + @Override + public void visitALOAD(final ALOAD o) { + final int idx = o.getIndex(); + if (idx < 0) { + constraintViolated(o, "Index '"+idx+"' must be non-negative."); + } + else{ + final 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. */ + @Override + public void visitISTORE(final ISTORE o) { + final int idx = o.getIndex(); + if (idx < 0) { + constraintViolated(o, "Index '"+idx+"' must be non-negative."); + } + else{ + final 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. */ + @Override + public void visitFSTORE(final FSTORE o) { + final int idx = o.getIndex(); + if (idx < 0) { + constraintViolated(o, "Index '"+idx+"' must be non-negative."); + } + else{ + final 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. */ + @Override + public void visitASTORE(final ASTORE o) { + final int idx = o.getIndex(); + if (idx < 0) { + constraintViolated(o, "Index '"+idx+"' must be non-negative."); + } + else{ + final 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. */ + @Override + public void visitIINC(final IINC o) { + final int idx = o.getIndex(); + if (idx < 0) { + constraintViolated(o, "Index '"+idx+"' must be non-negative."); + } + else{ + final 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. */ + @Override + public void visitRET(final RET o) { + final int idx = o.getIndex(); + if (idx < 0) { + constraintViolated(o, "Index '"+idx+"' must be non-negative."); + } + else{ + final 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. */ + @Override + public void visitLLOAD(final LLOAD o) { + final 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{ + final 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. */ + @Override + public void visitDLOAD(final DLOAD o) { + final 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{ + final 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. */ + @Override + public void visitLSTORE(final LSTORE o) { + final 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{ + final 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. */ + @Override + public void visitDSTORE(final DSTORE o) { + final 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{ + final 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. */ + @Override + public void visitLOOKUPSWITCH(final LOOKUPSWITCH o) { + final int[] matchs = o.getMatchs(); + int max = Integer.MIN_VALUE; + for (int i=0; i= "low". We cannot check this, as BCEL hides + // it from us. + } + + /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ + @Override + public void visitPUTSTATIC(final PUTSTATIC o) { + try { + final String field_name = o.getFieldName(cpg); + final JavaClass jc = Repository.lookupClass(getObjectType(o).getClassName()); + final Field[] fields = jc.getFields(); + Field f = null; + for (final Field field : fields) { + if (field.getName().equals(field_name)) { + f = field; + break; + } + } + if (f == null) { + throw new AssertionViolatedException("Field '" + field_name + "' not found in " + jc.getClassName()); + } + + if (f.isFinal()) { + if (!(myOwner.getClassName().equals(getObjectType(o).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.getReferenceType(cpg)+"'."); + } + } + + if (! (f.isStatic())) { + constraintViolated(o, "Referenced field '"+f+"' is not static which it should be."); + } + + final String meth_name = Repository.lookupClass(myOwner.getClassName()).getMethods()[method_no].getName(); + + // If it's an interface, it can be set only in . + if ((!(jc.isClass())) && (!(meth_name.equals(Const.STATIC_INITIALIZER_NAME)))) { + constraintViolated(o, "Interface field '"+f+"' must be set in a '"+Const.STATIC_INITIALIZER_NAME+"' method."); + } + } catch (final ClassNotFoundException e) { + // FIXME: maybe not the best way to handle this + throw new AssertionViolatedException("Missing class: " + e, e); + } + } + + /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ + @Override + public void visitGETSTATIC(final GETSTATIC o) { + try { + final String field_name = o.getFieldName(cpg); + final JavaClass jc = Repository.lookupClass(getObjectType(o).getClassName()); + final Field[] fields = jc.getFields(); + Field f = null; + for (final Field field : fields) { + if (field.getName().equals(field_name)) { + f = field; + break; + } + } + if (f == null) { + throw new AssertionViolatedException("Field '" + field_name + "' not found in " + jc.getClassName()); + } + + if (! (f.isStatic())) { + constraintViolated(o, "Referenced field '"+f+"' is not static which it should be."); + } + } catch (final ClassNotFoundException e) { + // FIXME: maybe not the best way to handle this + throw new AssertionViolatedException("Missing class: " + e, e); + } + } + + /* 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. */ + @Override + public void visitINVOKEDYNAMIC(final INVOKEDYNAMIC o) { + throw new RuntimeException("INVOKEDYNAMIC instruction is not supported at this time"); + } + + /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ + @Override + public void visitINVOKEINTERFACE(final INVOKEINTERFACE o) { + try { + // 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. + final String classname = o.getClassName(cpg); + final JavaClass jc = Repository.lookupClass(classname); + final Method m = getMethodRecursive(jc, o); + if (m == null) { + constraintViolated(o, "Referenced method '"+o.getMethodName(cpg)+"' with expected signature '"+o.getSignature(cpg)+ + "' not found in class '"+jc.getClassName()+"'."); + } + if (jc.isClass()) { + constraintViolated(o, "Referenced class '"+jc.getClassName()+"' is a class, but not an interface as expected."); + } + } catch (final ClassNotFoundException e) { + // FIXME: maybe not the best way to handle this + throw new AssertionViolatedException("Missing class: " + e, e); + } + } + + /** + * Looks for the method referenced by the given invoke instruction in the given class + * or its super classes and super interfaces. + * @param jc the class that defines the referenced method + * @param invoke the instruction that references the method + * @return the referenced method or null if not found. + */ + private Method getMethodRecursive(final JavaClass jc, final InvokeInstruction invoke) throws ClassNotFoundException{ + Method m; + //look in the given class + m = getMethod(jc, invoke); + if(m != null) { + //method found in given class + return m; + } + //method not found, look in super classes + for (final JavaClass superclass : jc.getSuperClasses()) { + m = getMethod(superclass, invoke); + if(m != null) { + //method found in super class + return m; + } + } + //method not found, look in super interfaces + for (final JavaClass superclass : jc.getInterfaces()) { + m = getMethod(superclass, invoke); + if(m != null) { + //method found in super interface + return m; + } + } + //method not found in the hierarchy + return null; + } + /** + * Looks for the method referenced by the given invoke instruction in the given class. + * @param jc the class that defines the referenced method + * @param invoke the instruction that references the method + * @return the referenced method or null if not found. + */ + private Method getMethod(final JavaClass jc, final InvokeInstruction invoke) { + final Method[] ms = jc.getMethods(); + for (final Method element : ms) { + if ( (element.getName().equals(invoke.getMethodName(cpg))) && + (Type.getReturnType(element.getSignature()).equals(invoke.getReturnType(cpg))) && + (objarrayequals(Type.getArgumentTypes(element.getSignature()), invoke.getArgumentTypes(cpg))) ) { + return element; + } + } + + return null; + } + + /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ + @Override + public void visitINVOKESPECIAL(final INVOKESPECIAL o) { + try { + // 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. + final String classname = o.getClassName(cpg); + final JavaClass jc = Repository.lookupClass(classname); + final Method m = getMethodRecursive(jc, o); + if (m == null) { + constraintViolated(o, "Referenced method '"+o.getMethodName(cpg)+"' with expected signature '"+o.getSignature(cpg) + +"' not found in class '"+jc.getClassName()+"'."); + } + + JavaClass current = Repository.lookupClass(myOwner.getClassName()); + if (current.isSuper()) { + + if ((Repository.instanceOf( current, jc )) && (!current.equals(jc))) { + + if (! (o.getMethodName(cpg).equals(Const.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()); + + final Method[] meths = current.getMethods(); + for (final Method meth2 : meths) { + if ( (meth2.getName().equals(o.getMethodName(cpg))) && + (Type.getReturnType(meth2.getSignature()).equals(o.getReturnType(cpg))) && + (objarrayequals(Type.getArgumentTypes(meth2.getSignature()), o.getArgumentTypes(cpg))) ) { + meth = meth2; + 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."); + } + } + } + } + + } catch (final ClassNotFoundException e) { + // FIXME: maybe not the best way to handle this + throw new AssertionViolatedException("Missing class: " + e, e); + } + + } + + /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ + @Override + public void visitINVOKESTATIC(final INVOKESTATIC o) { + try { + // 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. + final String classname = o.getClassName(cpg); + final JavaClass jc = Repository.lookupClass(classname); + final Method m = getMethodRecursive(jc, o); + if (m == null) { + constraintViolated(o, "Referenced method '"+o.getMethodName(cpg)+"' with expected signature '"+ + o.getSignature(cpg) +"' not found in class '"+jc.getClassName()+"'."); + } else if (! (m.isStatic())) { // implies it's not abstract, verified in pass 2. + constraintViolated(o, "Referenced method '"+o.getMethodName(cpg)+"' has ACC_STATIC unset."); + } + + } catch (final ClassNotFoundException e) { + // FIXME: maybe not the best way to handle this + throw new AssertionViolatedException("Missing class: " + e, e); + } + } + + + /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ + @Override + public void visitINVOKEVIRTUAL(final INVOKEVIRTUAL o) { + try { + // 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. + final String classname = o.getClassName(cpg); + final JavaClass jc = Repository.lookupClass(classname); + final Method m = getMethodRecursive(jc, o); + if (m == null) { + constraintViolated(o, "Referenced method '"+o.getMethodName(cpg)+"' with expected signature '"+ + o.getSignature(cpg)+"' not found in class '"+jc.getClassName()+"'."); + } + if (! (jc.isClass())) { + constraintViolated(o, "Referenced class '"+jc.getClassName()+"' is an interface, but not a class as expected."); + } + + } catch (final ClassNotFoundException e) { + // FIXME: maybe not the best way to handle this + throw new AssertionViolatedException("Missing class: " + e, e); + } + } + + + // 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(final Object[] o, final Object[] p) { + if (o.length != p.length) { + return false; + } + + for (int i=0; iaccept() Visitor + * instances) have toString() 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 Code instance) is not satisfying the verifier's + * constraints, but in this case it could be possible for the toString() + * 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: StringRepresentation.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class StringRepresentation extends org.apache.bcel.classfile.EmptyVisitor { + /** The string representation, created by a visitXXX() method, output by toString(). */ + private String tostring; + /** The node we ask for its string representation. Not really needed; only for debug output. */ + private final Node n; + + /** + * Creates a new StringRepresentation object which is the representation of n. + * + * @see #toString() + */ + public StringRepresentation(final Node n) { + this.n = n; + n.accept(this); // assign a string representation to field 'tostring' if we know n's class. + } + + /** + * Returns the String representation. + */ + @Override + public String toString() { +// The run-time check below is needed because we don't want to omit inheritance +// of "EmptyVisitor" and provide a thousand empty methods. +// However, in terms of performance this would be a better idea. +// If some new "Node" is defined in BCEL (such as some concrete "Attribute"), we +// want to know that this class has also to be adapted. + if (tostring == null) { + throw new AssertionViolatedException( + "Please adapt '" + getClass() + "' to deal with objects of class '" + n.getClass() + "'."); + } + 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(final Node obj) { + String ret; + try { + ret = obj.toString(); + } + + catch (final RuntimeException e) { + // including ClassFormatException, trying to convert the "signature" of a ReturnaddressType LocalVariable + // (shouldn't occur, but people do crazy things) + 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(). + @Override + public void visitCode(final Code obj) { + //tostring = toString(obj); + tostring = ""; // We don't need real code outputs. + } + + /** + * @since 6.0 + */ + @Override + public void visitAnnotation(final Annotations obj) + { + //this is invoked whenever an annotation is found + //when verifier is passed over a class + tostring = toString(obj); + } + + /** + * @since 6.0 + */ + @Override + public void visitLocalVariableTypeTable(final LocalVariableTypeTable obj) + { + //this is invoked whenever a local variable type is found + //when verifier is passed over a class + tostring = toString(obj); + } + + @Override + public void visitCodeException(final CodeException obj) { + tostring = toString(obj); + } + + @Override + public void visitConstantClass(final ConstantClass obj) { + tostring = toString(obj); + } + + @Override + public void visitConstantDouble(final ConstantDouble obj) { + tostring = toString(obj); + } + + @Override + public void visitConstantFieldref(final ConstantFieldref obj) { + tostring = toString(obj); + } + + @Override + public void visitConstantFloat(final ConstantFloat obj) { + tostring = toString(obj); + } + + @Override + public void visitConstantInteger(final ConstantInteger obj) { + tostring = toString(obj); + } + + @Override + public void visitConstantInterfaceMethodref(final ConstantInterfaceMethodref obj) { + tostring = toString(obj); + } + + @Override + public void visitConstantLong(final ConstantLong obj) { + tostring = toString(obj); + } + + @Override + public void visitConstantMethodref(final ConstantMethodref obj) { + tostring = toString(obj); + } + + @Override + public void visitConstantNameAndType(final ConstantNameAndType obj) { + tostring = toString(obj); + } + + @Override + public void visitConstantPool(final ConstantPool obj) { + tostring = toString(obj); + } + + @Override + public void visitConstantString(final ConstantString obj) { + tostring = toString(obj); + } + + @Override + public void visitConstantUtf8(final ConstantUtf8 obj) { + tostring = toString(obj); + } + + @Override + public void visitConstantValue(final ConstantValue obj) { + tostring = toString(obj); + } + + @Override + public void visitDeprecated(final Deprecated obj) { + tostring = toString(obj); + } + + @Override + public void visitExceptionTable(final ExceptionTable obj) { + tostring = toString(obj); + } + + @Override + public void visitField(final Field obj) { + tostring = toString(obj); + } + + @Override + public void visitInnerClass(final InnerClass obj) { + tostring = toString(obj); + } + + @Override + public void visitInnerClasses(final InnerClasses obj) { + tostring = toString(obj); + } + + @Override + public void visitJavaClass(final JavaClass obj) { + tostring = toString(obj); + } + + @Override + public void visitLineNumber(final LineNumber obj) { + tostring = toString(obj); + } + + @Override + public void visitLineNumberTable(final LineNumberTable obj) { + tostring = ""; + } + + @Override + public void visitLocalVariable(final LocalVariable obj) { + tostring = toString(obj); + } + + @Override + public void visitLocalVariableTable(final LocalVariableTable obj) { + tostring = ""; + } + + @Override + public void visitMethod(final Method obj) { + tostring = toString(obj); + } + + @Override + public void visitSignature(final Signature obj) { + tostring = toString(obj); + } + + @Override + public void visitSourceFile(final SourceFile obj) { + tostring = toString(obj); + } + + @Override + public void visitStackMap(final StackMap obj) { + tostring = toString(obj); + } + + @Override + public void visitSynthetic(final Synthetic obj) { + tostring = toString(obj); + } + + @Override + public void visitUnknown(final Unknown obj) { + tostring = toString(obj); + } + + /** + * @since 6.0 + */ + @Override + public void visitEnclosingMethod(final EnclosingMethod obj) { + tostring = toString(obj); + } + + /** + * @since 6.0 + */ + @Override + public void visitBootstrapMethods(final BootstrapMethods obj) { + tostring = toString(obj); + } + + /** + * @since 6.0 + */ + @Override + public void visitMethodParameters(final MethodParameters obj) { + tostring = toString(obj); + } + + /** + * @since 6.0 + */ + @Override + public void visitConstantInvokeDynamic(final ConstantInvokeDynamic obj) { + tostring = toString(obj); + } + + /** + * @since 6.0 + */ + @Override + public void visitStackMapEntry(final StackMapEntry obj) { + tostring = toString(obj); + } + /** + * @since 6.0 + */ + + @Override + public void visitParameterAnnotation(final ParameterAnnotations obj) { + tostring = toString(obj); + } + + /** + * @since 6.0 + */ + @Override + public void visitAnnotationEntry(final AnnotationEntry obj) { + tostring = toString(obj); + } + + /** + * @since 6.0 + */ + @Override + public void visitAnnotationDefault(final AnnotationDefault obj) { + tostring = toString(obj); + } + + /** + * @since 6.0 + */ + @Override + public void visitConstantMethodType(final ConstantMethodType obj) { + tostring = toString(obj); + } + + /** + * @since 6.0 + */ + @Override + public void visitConstantMethodHandle(final ConstantMethodHandle obj) { + tostring = toString(obj); + } + + /** + * @since 6.0 + */ + @Override + public void visitParameterAnnotationEntry(final ParameterAnnotationEntry obj) { + tostring = toString(obj); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/package.html b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/package.html new file mode 100644 index 00000000..9a086d94 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/package.html @@ -0,0 +1,35 @@ + + + + + + + + +Provides PassVerifier classes used internally by JustIce. You don't need to bother with them. + +

      Package Specification

      + +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. + + + diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ControlFlowGraph.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ControlFlowGraph.java new file mode 100644 index 00000000..911817b4 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ControlFlowGraph.java @@ -0,0 +1,477 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.structurals; + + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.bcel.generic.ATHROW; +import org.apache.bcel.generic.BranchInstruction; +import org.apache.bcel.generic.GotoInstruction; +import org.apache.bcel.generic.Instruction; +import org.apache.bcel.generic.InstructionHandle; +import org.apache.bcel.generic.JsrInstruction; +import org.apache.bcel.generic.MethodGen; +import org.apache.bcel.generic.RET; +import org.apache.bcel.generic.ReturnInstruction; +import org.apache.bcel.generic.Select; +import org.apache.bcel.verifier.exc.AssertionViolatedException; +import org.apache.bcel.verifier.exc.StructuralCodeConstraintException; + +/** + * This class represents a control flow graph of a method. + * + * @version $Id: ControlFlowGraph.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +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 final InstructionHandle instruction; + + /** + * The 'incoming' execution Frames. + */ + private final Map inFrames; // key: the last-executed JSR + + /** + * The 'outgoing' execution Frames. + */ + private final Map 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 List executionPredecessors = null; // Type: InstructionContext + + /** + * Creates an InstructionHandleImpl object from an InstructionHandle. + * Creation of one per InstructionHandle suffices. Don't create more. + */ + public InstructionContextImpl(final InstructionHandle inst) { + if (inst == null) { + throw new AssertionViolatedException("Cannot instantiate InstructionContextImpl from NULL."); + } + + instruction = inst; + inFrames = new HashMap<>(); + outFrames = new HashMap<>(); + } + + /* Satisfies InstructionContext.getTag(). */ + @Override + public int getTag() { + return TAG; + } + + /* Satisfies InstructionContext.setTag(int). */ + @Override + public void setTag(final int tag) { // part of InstructionContext interface + TAG = tag; + } + + /** + * Returns the exception handlers of this instruction. + */ + @Override + public ExceptionHandler[] getExceptionHandlers() { + return exceptionhandlers.getExceptionHandlers(getInstruction()); + } + + /** + * Returns a clone of the "outgoing" frame situation with respect to the given ExecutionChain. + */ + @Override + public Frame getOutFrame(final ArrayList execChain) { + executionPredecessors = execChain; + + Frame org; + + final InstructionContext jsr = lastExecutionJSR(); + + org = outFrames.get(jsr); + + if (org == null) { + throw new AssertionViolatedException( + "outFrame not set! This:\n"+this+"\nExecutionChain: "+getExecutionChain()+"\nOutFrames: '"+outFrames+"'."); + } + return org.getClone(); + } + + @Override + public Frame getInFrame() { + Frame org; + + final InstructionContext jsr = lastExecutionJSR(); + + org = inFrames.get(jsr); + + if (org == null) { + throw new AssertionViolatedException("inFrame not set! This:\n"+this+"\nInFrames: '"+inFrames+"'."); + } + 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. + * The InstConstraintVisitor and ExecutionVisitor instances + * must be set up correctly. + * @return true - if and only if the "outgoing" frame situation + * changed from the one before execute()ing. + */ + @Override + public boolean execute(final Frame inFrame, final ArrayList execPreds, final InstConstraintVisitor icv, final ExecutionVisitor ev) { + + @SuppressWarnings("unchecked") // OK because execPreds is compatible type + final List clone = (List) execPreds.clone(); + executionPredecessors = 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 = 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. + final 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(final 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. + */ + @Override + 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? + final 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(final Frame inFrame) { + // TODO: Can be performance-improved. + final Frame inF = inFrames.get(lastExecutionJSR()); + final OperandStack oldstack = inF.getStack().getClone(); + final LocalVariables oldlocals = inF.getLocals().getClone(); + try { + inF.getStack().merge(inFrame.getStack()); + inF.getLocals().merge(inFrame.getLocals()); + } catch (final StructuralCodeConstraintException sce) { + extendMessageWithFlow(sce); + throw sce; + } + return !(oldstack.equals(inF.getStack()) && oldlocals.equals(inF.getLocals())); + } + + /** + * 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(final StructuralCodeConstraintException e) { + final String s = "Execution flow:\n"; + e.extendMessage("", s+getExecutionChain()); + } + + /* + * Fulfils the contract of InstructionContext.getInstruction(). + */ + @Override + 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() { + + final int size = executionPredecessors.size(); + int retcount = 0; + + for (int i=size-1; i>=0; i--) { + final InstructionContextImpl current = (InstructionContextImpl) (executionPredecessors.get(i)); + final 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(). */ + @Override + 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 Instruction inst = getInstruction().getInstruction(); + + if (inst instanceof RET) { + final 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. Only JustIce must not use it, but foreign users of the ControlFlowGraph +// will want it. Thanks Johannes Wust. +//throw new AssertionViolatedException("DID YOU REALLY WANT TO ASK FOR RET'S SUCCS?"); + + final InstructionHandle[] jsrs = s.getEnteringJsrInstructions(); + final InstructionHandle[] ret = new InstructionHandle[jsrs.length]; + for (int i=0; i instructionContexts = new HashMap<>(); + + /** + * A Control Flow Graph; with additional JustIce checks + * @param method_gen the method generator instance + */ + public ControlFlowGraph(final MethodGen method_gen) { + this(method_gen, true); + } + + /** + * A Control Flow Graph. + * @param method_gen the method generator instance + * @param enableJustIceCheck if true, additional JustIce checks are performed + * @since 6.0 + */ + public ControlFlowGraph(final MethodGen method_gen, final boolean enableJustIceCheck) { + subroutines = new Subroutines(method_gen, enableJustIceCheck); + exceptionhandlers = new ExceptionHandlers(method_gen); + + final InstructionHandle[] instructionhandles = method_gen.getInstructionList().getInstructionHandles(); + for (final InstructionHandle instructionhandle : instructionhandles) { + instructionContexts.put(instructionhandle, new InstructionContextImpl(instructionhandle)); + } + + //this.method_gen = method_gen; + } + + /** + * Returns the InstructionContext of a given instruction. + */ + public InstructionContext contextOf(final InstructionHandle inst) { + final InstructionContext ic = 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(final InstructionHandle[] insts) { + final InstructionContext[] ret = new InstructionContext[insts.length]; + for (int i=0; i(NOT ORDERED!). + */ + public InstructionContext[] getInstructionContexts() { + final InstructionContext[] ret = new InstructionContext[instructionContexts.values().size()]; + return instructionContexts.values().toArray(ret); + } + + /** + * Returns true, if and only if the said instruction is not reachable; that means, + * if it is not part of this ControlFlowGraph. + */ + public boolean isDead(final InstructionHandle i) { + return subroutines.subroutineOf(i) == null; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ExceptionHandler.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ExceptionHandler.java new file mode 100644 index 00000000..ddbe1e50 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ExceptionHandler.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.structurals; + + +import org.apache.bcel.generic.InstructionHandle; +import org.apache.bcel.generic.ObjectType; + +/** + * 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: ExceptionHandler.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class ExceptionHandler{ + /** The type of the exception to catch. NULL means ANY. */ + private final ObjectType catchtype; + + /** The InstructionHandle where the handling begins. */ + private final InstructionHandle handlerpc; + + /** Leave instance creation to JustIce. */ + ExceptionHandler(final ObjectType catch_type, final InstructionHandle handler_pc) { + catchtype = catch_type; + handlerpc = handler_pc; + } + + /** + * Returns the type of the exception that's handled. 'null' means 'ANY'. + */ + public ObjectType getExceptionType() { + return catchtype; + } + + /** + * Returns the InstructionHandle where the handler starts off. + */ + public InstructionHandle getHandlerStart() { + return handlerpc; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ExceptionHandlers.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ExceptionHandlers.java new file mode 100644 index 00000000..052045e0 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ExceptionHandlers.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.structurals; + + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.bcel.generic.CodeExceptionGen; +import org.apache.bcel.generic.InstructionHandle; +import org.apache.bcel.generic.MethodGen; + +/** + * This class allows easy access to ExceptionHandler objects. + * + * @version $Id: ExceptionHandlers.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class ExceptionHandlers{ + /** + * The ExceptionHandler instances. + * Key: InstructionHandle objects, Values: HashSet instances. + */ + private final Map> exceptionhandlers; + + /** + * Constructor. Creates a new ExceptionHandlers instance. + */ + public ExceptionHandlers(final MethodGen mg) { + exceptionhandlers = new HashMap<>(); + final CodeExceptionGen[] cegs = mg.getExceptionHandlers(); + for (final CodeExceptionGen ceg : cegs) { + final ExceptionHandler eh = new ExceptionHandler(ceg.getCatchType(), ceg.getHandlerPC()); + for (InstructionHandle ih=ceg.getStartPC(); ih != ceg.getEndPC().getNext(); ih=ih.getNext()) { + Set hs; + hs = 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(final InstructionHandle ih) { + final Set hsSet = exceptionhandlers.get(ih); + if (hsSet == null) { + return new ExceptionHandler[0]; + } + return hsSet.toArray(new ExceptionHandler[hsSet.size()]); + } + +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ExecutionVisitor.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ExecutionVisitor.java new file mode 100644 index 00000000..784bbf78 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ExecutionVisitor.java @@ -0,0 +1,1274 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.structurals; + + +import org.apache.bcel.Const; +import org.apache.bcel.classfile.Constant; +import org.apache.bcel.classfile.ConstantClass; +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; +// CHECKSTYLE:OFF (there are lots of references!) +import org.apache.bcel.generic.*; +//CHECKSTYLE:ON + +/** + * 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.

      + * + * Conventions: + * + *

      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: ExecutionVisitor.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @see #visitDSTORE(DSTORE o) + * @see InstConstraintVisitor + */ +public class ExecutionVisitor extends EmptyVisitor{ + + /** + * 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(final ConstantPoolGen cpg) { // TODO could be package-protected? + this.cpg = cpg; + } + + /** + * The only method granting access to the single instance of + * the ExecutionVisitor class. Before actively using this + * instance, SET THE ConstantPoolGen FIRST. + * @see #setConstantPoolGen(ConstantPoolGen) + */ + public void setFrame(final Frame f) { // TODO could be package-protected? + 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. */ + @Override + public void visitAALOAD(final AALOAD o) { + stack().pop(); // pop the index int +//System.out.print(stack().peek()); + final 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{ + final ArrayType at = (ArrayType) t; + stack().push(at.getElementType()); + } + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitAASTORE(final AASTORE o) { + stack().pop(); + stack().pop(); + stack().pop(); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitACONST_NULL(final ACONST_NULL o) { + stack().push(Type.NULL); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitALOAD(final ALOAD o) { + stack().push(locals().get(o.getIndex())); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitANEWARRAY(final ANEWARRAY o) { + stack().pop(); //count + stack().push( new ArrayType(o.getType(cpg), 1) ); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitARETURN(final ARETURN o) { + stack().pop(); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitARRAYLENGTH(final ARRAYLENGTH o) { + stack().pop(); + stack().push(Type.INT); + } + + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitASTORE(final 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. */ + @Override + public void visitATHROW(final ATHROW o) { + final 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. */ + @Override + public void visitBALOAD(final BALOAD o) { + stack().pop(); + stack().pop(); + stack().push(Type.INT); + } + + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitBASTORE(final BASTORE o) { + stack().pop(); + stack().pop(); + stack().pop(); + } + + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitBIPUSH(final BIPUSH o) { + stack().push(Type.INT); + } + + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitCALOAD(final CALOAD o) { + stack().pop(); + stack().pop(); + stack().push(Type.INT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitCASTORE(final CASTORE o) { + stack().pop(); + stack().pop(); + stack().pop(); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitCHECKCAST(final 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. */ + @Override + public void visitD2F(final D2F o) { + stack().pop(); + stack().push(Type.FLOAT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitD2I(final D2I o) { + stack().pop(); + stack().push(Type.INT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitD2L(final D2L o) { + stack().pop(); + stack().push(Type.LONG); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitDADD(final DADD o) { + stack().pop(); + stack().pop(); + stack().push(Type.DOUBLE); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitDALOAD(final DALOAD o) { + stack().pop(); + stack().pop(); + stack().push(Type.DOUBLE); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitDASTORE(final DASTORE o) { + stack().pop(); + stack().pop(); + stack().pop(); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitDCMPG(final DCMPG o) { + stack().pop(); + stack().pop(); + stack().push(Type.INT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitDCMPL(final DCMPL o) { + stack().pop(); + stack().pop(); + stack().push(Type.INT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitDCONST(final DCONST o) { + stack().push(Type.DOUBLE); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitDDIV(final DDIV o) { + stack().pop(); + stack().pop(); + stack().push(Type.DOUBLE); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitDLOAD(final DLOAD o) { + stack().push(Type.DOUBLE); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitDMUL(final DMUL o) { + stack().pop(); + stack().pop(); + stack().push(Type.DOUBLE); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitDNEG(final DNEG o) { + stack().pop(); + stack().push(Type.DOUBLE); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitDREM(final DREM o) { + stack().pop(); + stack().pop(); + stack().push(Type.DOUBLE); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitDRETURN(final DRETURN o) { + stack().pop(); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitDSTORE(final DSTORE o) { + locals().set(o.getIndex(), stack().pop()); + locals().set(o.getIndex()+1, Type.UNKNOWN); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitDSUB(final DSUB o) { + stack().pop(); + stack().pop(); + stack().push(Type.DOUBLE); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitDUP(final DUP o) { + final Type t = stack().pop(); + stack().push(t); + stack().push(t); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitDUP_X1(final DUP_X1 o) { + final Type w1 = stack().pop(); + final Type w2 = stack().pop(); + stack().push(w1); + stack().push(w2); + stack().push(w1); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitDUP_X2(final DUP_X2 o) { + final Type w1 = stack().pop(); + final Type w2 = stack().pop(); + if (w2.getSize() == 2) { + stack().push(w1); + stack().push(w2); + stack().push(w1); + } + else{ + final Type w3 = stack().pop(); + stack().push(w1); + stack().push(w3); + stack().push(w2); + stack().push(w1); + } + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitDUP2(final DUP2 o) { + final Type t = stack().pop(); + if (t.getSize() == 2) { + stack().push(t); + stack().push(t); + } + else{ // t.getSize() is 1 + final Type u = stack().pop(); + stack().push(u); + stack().push(t); + stack().push(u); + stack().push(t); + } + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitDUP2_X1(final DUP2_X1 o) { + final Type t = stack().pop(); + if (t.getSize() == 2) { + final Type u = stack().pop(); + stack().push(t); + stack().push(u); + stack().push(t); + } + else{ //t.getSize() is1 + final Type u = stack().pop(); + final 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. */ + @Override + public void visitDUP2_X2(final DUP2_X2 o) { + final Type t = stack().pop(); + if (t.getSize() == 2) { + final Type u = stack().pop(); + if (u.getSize() == 2) { + stack().push(t); + stack().push(u); + stack().push(t); + }else{ + final Type v = stack().pop(); + stack().push(t); + stack().push(v); + stack().push(u); + stack().push(t); + } + } + else{ //t.getSize() is 1 + final Type u = stack().pop(); + final Type v = stack().pop(); + if (v.getSize() == 2) { + stack().push(u); + stack().push(t); + stack().push(v); + stack().push(u); + stack().push(t); + }else{ + final 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. */ + @Override + public void visitF2D(final F2D o) { + stack().pop(); + stack().push(Type.DOUBLE); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitF2I(final F2I o) { + stack().pop(); + stack().push(Type.INT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitF2L(final F2L o) { + stack().pop(); + stack().push(Type.LONG); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitFADD(final FADD o) { + stack().pop(); + stack().pop(); + stack().push(Type.FLOAT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitFALOAD(final FALOAD o) { + stack().pop(); + stack().pop(); + stack().push(Type.FLOAT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitFASTORE(final FASTORE o) { + stack().pop(); + stack().pop(); + stack().pop(); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitFCMPG(final FCMPG o) { + stack().pop(); + stack().pop(); + stack().push(Type.INT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitFCMPL(final FCMPL o) { + stack().pop(); + stack().pop(); + stack().push(Type.INT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitFCONST(final FCONST o) { + stack().push(Type.FLOAT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitFDIV(final FDIV o) { + stack().pop(); + stack().pop(); + stack().push(Type.FLOAT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitFLOAD(final FLOAD o) { + stack().push(Type.FLOAT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitFMUL(final FMUL o) { + stack().pop(); + stack().pop(); + stack().push(Type.FLOAT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitFNEG(final FNEG o) { + stack().pop(); + stack().push(Type.FLOAT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitFREM(final FREM o) { + stack().pop(); + stack().pop(); + stack().push(Type.FLOAT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitFRETURN(final FRETURN o) { + stack().pop(); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitFSTORE(final FSTORE o) { + locals().set(o.getIndex(), stack().pop()); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitFSUB(final FSUB o) { + stack().pop(); + stack().pop(); + stack().push(Type.FLOAT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitGETFIELD(final 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. */ + @Override + public void visitGETSTATIC(final 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. */ + @Override + public void visitGOTO(final GOTO o) { + // no stack changes. + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitGOTO_W(final GOTO_W o) { + // no stack changes. + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitI2B(final I2B o) { + stack().pop(); + stack().push(Type.INT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitI2C(final I2C o) { + stack().pop(); + stack().push(Type.INT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitI2D(final I2D o) { + stack().pop(); + stack().push(Type.DOUBLE); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitI2F(final I2F o) { + stack().pop(); + stack().push(Type.FLOAT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitI2L(final I2L o) { + stack().pop(); + stack().push(Type.LONG); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitI2S(final I2S o) { + stack().pop(); + stack().push(Type.INT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitIADD(final IADD o) { + stack().pop(); + stack().pop(); + stack().push(Type.INT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitIALOAD(final IALOAD o) { + stack().pop(); + stack().pop(); + stack().push(Type.INT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitIAND(final IAND o) { + stack().pop(); + stack().pop(); + stack().push(Type.INT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitIASTORE(final IASTORE o) { + stack().pop(); + stack().pop(); + stack().pop(); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitICONST(final ICONST o) { + stack().push(Type.INT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitIDIV(final IDIV o) { + stack().pop(); + stack().pop(); + stack().push(Type.INT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitIF_ACMPEQ(final IF_ACMPEQ o) { + stack().pop(); + stack().pop(); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitIF_ACMPNE(final IF_ACMPNE o) { + stack().pop(); + stack().pop(); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitIF_ICMPEQ(final IF_ICMPEQ o) { + stack().pop(); + stack().pop(); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitIF_ICMPGE(final IF_ICMPGE o) { + stack().pop(); + stack().pop(); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitIF_ICMPGT(final IF_ICMPGT o) { + stack().pop(); + stack().pop(); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitIF_ICMPLE(final IF_ICMPLE o) { + stack().pop(); + stack().pop(); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitIF_ICMPLT(final IF_ICMPLT o) { + stack().pop(); + stack().pop(); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitIF_ICMPNE(final IF_ICMPNE o) { + stack().pop(); + stack().pop(); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitIFEQ(final IFEQ o) { + stack().pop(); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitIFGE(final IFGE o) { + stack().pop(); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitIFGT(final IFGT o) { + stack().pop(); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitIFLE(final IFLE o) { + stack().pop(); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitIFLT(final IFLT o) { + stack().pop(); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitIFNE(final IFNE o) { + stack().pop(); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitIFNONNULL(final IFNONNULL o) { + stack().pop(); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitIFNULL(final IFNULL o) { + stack().pop(); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitIINC(final IINC o) { + // stack is not changed. + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitILOAD(final ILOAD o) { + stack().push(Type.INT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitIMUL(final IMUL o) { + stack().pop(); + stack().pop(); + stack().push(Type.INT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitINEG(final INEG o) { + stack().pop(); + stack().push(Type.INT); + } + /** Symbolically executes the corresponding Java Virtual Machine instruction. */ + @Override + public void visitINSTANCEOF(final INSTANCEOF o) { + stack().pop(); + stack().push(Type.INT); + } + /** + * Symbolically executes the corresponding Java Virtual Machine instruction. + * @since 6.0 + */ + @Override + public void visitINVOKEDYNAMIC(final INVOKEDYNAMIC o) { + for (int i=0; i stack().slotsUsed()) { + constraintViolated(o, + "Cannot consume "+consume+" stack slots: only "+stack().slotsUsed()+" slot(s) left on stack!\nStack:\n"+stack()); + } + + final int produce = o.produceStack(cpg) - o.consumeStack(cpg); // Stack values are always consumed first; then produced. + if ( produce + stack().slotsUsed() > stack().maxStack() ) { + constraintViolated(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. + */ + @Override + public void visitLoadClass(final LoadClass o) { + final ObjectType t = o.getLoadClassType(cpg); + if (t != null) {// null means "no class is loaded" + final Verifier v = VerifierFactory.getVerifier(t.getClassName()); + final 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. + */ + @Override + public void visitStackConsumer(final StackConsumer o) { + _visitStackAccessor((Instruction) o); + } + + /** + * Ensures the general preconditions of a StackProducer instance. + */ + @Override + public void visitStackProducer(final 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. + */ + @Override + public void visitCPInstruction(final CPInstruction o) { + final 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. + */ + @Override + public void visitFieldInstruction(final 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 + final 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). + final Type t = o.getType(cpg); + if (t instanceof ObjectType) { + final String name = ((ObjectType)t).getClassName(); + final Verifier v = VerifierFactory.getVerifier( name ); + final VerificationResult vr = v.doPass2(); + if (vr.getStatus() != VerificationResult.VERIFIED_OK) { + constraintViolated(o, "Class '"+name+"' is referenced, but cannot be loaded and resolved: '"+vr+"'."); + } + } + } + + /** + * Ensures the general preconditions of an InvokeInstruction instance. + */ + @Override + public void visitInvokeInstruction(final 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. + */ + @Override + public void visitStackInstruction(final StackInstruction o) { + _visitStackAccessor(o); + } + + /** + * Assures the generic preconditions of a LocalVariableInstruction instance. + * That is, the index of the local variable must be valid. + */ + @Override + public void visitLocalVariableInstruction(final 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. + */ + @Override + public void visitLoadInstruction(final 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. + */ + @Override + public void visitStoreInstruction(final 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 implicitly 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 + final 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. + */ + @Override + public void visitReturnInstruction(final ReturnInstruction o) { + 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 (o instanceof RETURN) { + if (method_type != Type.VOID) { + constraintViolated(o, "RETURN instruction in non-void method."); + } + else{ + return; + } + } + if (o instanceof ARETURN) { + if (method_type == Type.VOID) { + constraintViolated(o, "ARETURN instruction in void method."); + } + if (stack().peek() == Type.NULL) { + return; + } + 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{ + 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. + */ + @Override + public void visitAALOAD(final AALOAD o) { + final Type arrayref = stack().peek(1); + final 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. + */ + @Override + public void visitAASTORE(final AASTORE o) { + final Type arrayref = stack().peek(2); + final Type index = stack().peek(1); + final 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()+"."); + } + // No check for array element assignment compatibility. This is done at runtime. + } + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitACONST_NULL(final ACONST_NULL o) { + // Nothing needs to be done here. + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitALOAD(final ALOAD o) { + //visitLoadInstruction(LoadInstruction) is called before. + + // Nothing else needs to be done here. + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitANEWARRAY(final 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. + */ + @Override + public void visitARETURN(final 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()+"'."); + } + final 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. + */ + @Override + public void visitARRAYLENGTH(final ARRAYLENGTH o) { + final Type arrayref = stack().peek(0); + arrayrefOfArrayType(o, arrayref); + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitASTORE(final 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. + */ + @Override + public void visitATHROW(final ATHROW o) { + try { + // 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; + } + + final ObjectType exc = (ObjectType) (stack().peek()); + final 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()+"'."); + } + } catch (final ClassNotFoundException e) { + // FIXME: maybe not the best way to handle this + throw new AssertionViolatedException("Missing class: " + e, e); + } + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitBALOAD(final BALOAD o) { + final Type arrayref = stack().peek(1); + final 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. + */ + @Override + public void visitBASTORE(final BASTORE o) { + final Type arrayref = stack().peek(2); + final Type index = stack().peek(1); + final Type value = stack().peek(0); + + indexOfInt(o, index); + valueOfInt(o, value); + 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. + */ + @Override + public void visitBIPUSH(final BIPUSH o) { + // Nothing to do... + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitBREAKPOINT(final 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. + */ + @Override + public void visitCALOAD(final CALOAD o) { + final Type arrayref = stack().peek(1); + final Type index = stack().peek(0); + + indexOfInt(o, index); + arrayrefOfArrayType(o, arrayref); + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitCASTORE(final CASTORE o) { + final Type arrayref = stack().peek(2); + final Type index = stack().peek(1); + final Type value = stack().peek(0); + + indexOfInt(o, index); + valueOfInt(o, value); + 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. + */ + @Override + public void visitCHECKCAST(final CHECKCAST o) { + // The objectref must be of type reference. + final 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. + final 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. + */ + @Override + public void visitD2F(final 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. + */ + @Override + public void visitD2I(final 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. + */ + @Override + public void visitD2L(final 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. + */ + @Override + public void visitDADD(final 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. + */ + @Override + public void visitDALOAD(final 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)+"'."); + } + final 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. + */ + @Override + public void visitDASTORE(final 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)+"'."); + } + final 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. + */ + @Override + public void visitDCMPG(final 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. + */ + @Override + public void visitDCMPL(final 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. + */ + @Override + public void visitDCONST(final DCONST o) { + // There's nothing to be done here. + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitDDIV(final 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. + */ + @Override + public void visitDLOAD(final DLOAD o) { + //visitLoadInstruction(LoadInstruction) is called before. + + // Nothing else needs to be done here. + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitDMUL(final 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. + */ + @Override + public void visitDNEG(final 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. + */ + @Override + public void visitDREM(final 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. + */ + @Override + public void visitDRETURN(final 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. + */ + @Override + public void visitDSTORE(final DSTORE o) { + //visitStoreInstruction(StoreInstruction) is called before. + + // Nothing else needs to be done here. + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitDSUB(final 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. + */ + @Override + public void visitDUP(final 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. + */ + @Override + public void visitDUP_X1(final 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. + */ + @Override + public void visitDUP_X2(final 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. + } + //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. + */ + @Override + public void visitDUP2(final DUP2 o) { + if (stack().peek().getSize() == 2) { + return; // Form 2, okay. + } + //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. + */ + @Override + public void visitDUP2_X1(final 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. + */ + @Override + public void visitDUP2_X2(final DUP2_X2 o) { + + if (stack().peek(0).getSize() == 2) { + if (stack().peek(1).getSize() == 2) { + return; // Form 4 + } + // 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 + } + 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. + */ + @Override + public void visitF2D(final 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. + */ + @Override + public void visitF2I(final 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. + */ + @Override + public void visitF2L(final 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. + */ + @Override + public void visitFADD(final 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. + */ + @Override + public void visitFALOAD(final 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)+"'."); + } + final 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. + */ + @Override + public void visitFASTORE(final 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)+"'."); + } + final 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. + */ + @Override + public void visitFCMPG(final 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. + */ + @Override + public void visitFCMPL(final 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. + */ + @Override + public void visitFCONST(final FCONST o) { + // nothing to do here. + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitFDIV(final 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. + */ + @Override + public void visitFLOAD(final FLOAD o) { + //visitLoadInstruction(LoadInstruction) is called before. + + // Nothing else needs to be done here. + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitFMUL(final 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. + */ + @Override + public void visitFNEG(final 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. + */ + @Override + public void visitFREM(final 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. + */ + @Override + public void visitFRETURN(final 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. + */ + @Override + public void visitFSTORE(final FSTORE o) { + //visitStoreInstruction(StoreInstruction) is called before. + + // Nothing else needs to be done here. + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitFSUB(final 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)+"'."); + } + } + + private ObjectType getObjectType(final FieldInstruction o) { + final ReferenceType rt = o.getReferenceType(cpg); + if(rt instanceof ObjectType) { + return (ObjectType)rt; + } + constraintViolated(o, "expecting ObjectType but got "+rt); + return null; + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitGETFIELD(final GETFIELD o) { + try { + final 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+"'."); + } + + final String field_name = o.getFieldName(cpg); + + final JavaClass jc = Repository.lookupClass(getObjectType(o).getClassName()); + Field[] fields = jc.getFields(); + Field f = null; + for (final Field field : fields) { + if (field.getName().equals(field_name)) { + final Type f_type = Type.getType(field.getSignature()); + final Type o_type = o.getType(cpg); + /* TODO: Check if assignment compatibility is sufficient. + * What does Sun do? + */ + if (f_type.equals(o_type)) { + f = field; + break; + } + } + } + + if (f == null) { + final JavaClass[] superclasses = jc.getSuperClasses(); + outer: + for (final JavaClass superclass : superclasses) { + fields = superclass.getFields(); + for (final Field field : fields) { + if (field.getName().equals(field_name)) { + final Type f_type = Type.getType(field.getSignature()); + final Type o_type = o.getType(cpg); + if (f_type.equals(o_type)) { + f = field; + if ((f.getAccessFlags() & (Const.ACC_PUBLIC | Const.ACC_PROTECTED)) == 0) { + f = null; + } + break outer; + } + } + } + } + if (f == null) { + throw new AssertionViolatedException("Field '" + field_name + "' not found in " + jc.getClassName()); + } + } + + if (f.isProtected()) { + final ObjectType classtype = getObjectType(o); + final ObjectType curr = ObjectType.getInstance(mg.getClassName()); + + if ( classtype.equals(curr) || + curr.subclassOf(classtype) ) { + final 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+"'."); + } + final 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."); + } + + } catch (final ClassNotFoundException e) { + // FIXME: maybe not the best way to handle this + throw new AssertionViolatedException("Missing class: " + e, e); + } + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitGETSTATIC(final GETSTATIC o) { + // Field must be static: see Pass 3a. + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitGOTO(final GOTO o) { + // nothing to do here. + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitGOTO_W(final GOTO_W o) { + // nothing to do here. + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitI2B(final 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. + */ + @Override + public void visitI2C(final 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. + */ + @Override + public void visitI2D(final 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. + */ + @Override + public void visitI2F(final 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. + */ + @Override + public void visitI2L(final 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. + */ + @Override + public void visitI2S(final 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. + */ + @Override + public void visitIADD(final 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. + */ + @Override + public void visitIALOAD(final 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)+"'."); + } + final 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. + */ + @Override + public void visitIAND(final 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. + */ + @Override + public void visitIASTORE(final 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)+"'."); + } + final 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. + */ + @Override + public void visitICONST(final ICONST o) { + //nothing to do here. + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitIDIV(final 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. + */ + @Override + public void visitIF_ACMPEQ(final 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. + */ + @Override + public void visitIF_ACMPNE(final 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. + */ + @Override + public void visitIF_ICMPEQ(final 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. + */ + @Override + public void visitIF_ICMPGE(final 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. + */ + @Override + public void visitIF_ICMPGT(final 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. + */ + @Override + public void visitIF_ICMPLE(final 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. + */ + @Override + public void visitIF_ICMPLT(final 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. + */ + @Override + public void visitIF_ICMPNE(final 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. + */ + @Override + public void visitIFEQ(final 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. + */ + @Override + public void visitIFGE(final 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. + */ + @Override + public void visitIFGT(final 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. + */ + @Override + public void visitIFLE(final 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. + */ + @Override + public void visitIFLT(final 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. + */ + @Override + public void visitIFNE(final 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. + */ + @Override + public void visitIFNONNULL(final 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. + */ + @Override + public void visitIFNULL(final 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. + */ + @Override + public void visitIINC(final 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. + */ + @Override + public void visitILOAD(final ILOAD o) { + // All done by visitLocalVariableInstruction(), visitLoadInstruction() + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitIMPDEP1(final 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. + */ + @Override + public void visitIMPDEP2(final 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. + */ + @Override + public void visitIMUL(final 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. + */ + @Override + public void visitINEG(final 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. + */ + @Override + public void visitINSTANCEOF(final INSTANCEOF o) { + // The objectref must be of type reference. + final 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. + final 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. + * @since 6.0 + */ + @Override + public void visitINVOKEDYNAMIC(final INVOKEDYNAMIC o) { + throw new RuntimeException("INVOKEDYNAMIC instruction is not supported at this time"); + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitINVOKEINTERFACE(final INVOKEINTERFACE o) { + // Method is not native, otherwise pass 3 would not happen. + + final 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. + // TODO: Do we want to do anything with it? + //ConstantInterfaceMethodref cimr = (ConstantInterfaceMethodref) (cpg.getConstant(o.getIndex())); + + // the o.getClassType(cpg) type has passed pass 2; see visitLoadClass(o). + + final Type t = o.getType(cpg); + if (t instanceof ObjectType) { + final String name = ((ObjectType)t).getClassName(); + final Verifier v = VerifierFactory.getVerifier( name ); + final VerificationResult vr = v.doPass2(); + if (vr.getStatus() != VerificationResult.VERIFIED_OK) { + constraintViolated(o, "Class '"+name+"' is referenced, but cannot be loaded and resolved: '"+vr+"'."); + } + } + + + final Type[] argtypes = o.getArgumentTypes(cpg); + final int nargs = argtypes.length; + + for (int i=nargs-1; i>=0; i--) { + final 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) { + final 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)."); + //} + referenceTypeIsInitialized(o, rFromStack); + } + 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)) { // could be a ReturnaddressType + constraintViolated(o, "Expecting an ObjectType as 'objectref' on the stack, not a '"+objref+"'."); + } + 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=0; i--) { + final 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) { + final ReferenceType rFromStack = (ReferenceType) fromStack; + final 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)."); + } + referenceTypeIsInitialized(o, rFromStack); + } + 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(Const.CONSTRUCTOR_NAME))) { + referenceTypeIsInitialized(o, (ReferenceType) objref); + if (!(objref instanceof ObjectType)) { + if (!(objref instanceof ArrayType)) { // could be a ReturnaddressType + constraintViolated(o, "Expecting an ObjectType as 'objectref' on the stack, not a '"+objref+"'."); + } + 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(); + } + + + final String theClass = o.getClassName(cpg); + if ( ! Repository.instanceOf(objref_classname, theClass) ) { + constraintViolated(o, "The 'objref' item '"+objref+"' does not implement '"+theClass+"' as expected."); + } + + } catch (final ClassNotFoundException e) { + // FIXME: maybe not the best way to handle this + throw new AssertionViolatedException("Missing class: " + e, e); + } + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitINVOKESTATIC(final INVOKESTATIC o) { + try { + // Method is not native, otherwise pass 3 would not happen. + + final Type t = o.getType(cpg); + if (t instanceof ObjectType) { + final String name = ((ObjectType)t).getClassName(); + final Verifier v = VerifierFactory.getVerifier( name ); + final VerificationResult vr = v.doPass2(); + if (vr.getStatus() != VerificationResult.VERIFIED_OK) { + constraintViolated(o, "Class '"+name+"' is referenced, but cannot be loaded and resolved: '"+vr+"'."); + } + } + + final Type[] argtypes = o.getArgumentTypes(cpg); + final int nargs = argtypes.length; + + for (int i=nargs-1; i>=0; i--) { + final 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) { + final ReferenceType rFromStack = (ReferenceType) fromStack; + final ReferenceType rFromDesc = (ReferenceType) fromDesc; + // TODO: This check can possibly 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)."); + } + referenceTypeIsInitialized(o, rFromStack); + } + else{ + constraintViolated(o, "Expecting a '"+fromDesc+"' but found a '"+fromStack+"' on the stack."); + } + } + } + } catch (final ClassNotFoundException e) { + // FIXME: maybe not the best way to handle this + throw new AssertionViolatedException("Missing class: " + e, e); + } + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitINVOKEVIRTUAL(final INVOKEVIRTUAL o) { + try { + // the o.getClassType(cpg) type has passed pass 2; see visitLoadClass(o). + + final Type t = o.getType(cpg); + if (t instanceof ObjectType) { + final String name = ((ObjectType)t).getClassName(); + final Verifier v = VerifierFactory.getVerifier( name ); + final VerificationResult vr = v.doPass2(); + if (vr.getStatus() != VerificationResult.VERIFIED_OK) { + constraintViolated(o, "Class '"+name+"' is referenced, but cannot be loaded and resolved: '"+vr+"'."); + } + } + + + final Type[] argtypes = o.getArgumentTypes(cpg); + final int nargs = argtypes.length; + + for (int i=nargs-1; i>=0; i--) { + final 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) { + final ReferenceType rFromStack = (ReferenceType) fromStack; + final ReferenceType rFromDesc = (ReferenceType) fromDesc; + // TODO: This can possibly 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)."); + } + referenceTypeIsInitialized(o, rFromStack); + } + 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)) { // could be a ReturnaddressType + constraintViolated(o, "Expecting an ObjectType as 'objectref' on the stack, not a '"+objref+"'."); + } + else{ + objref = GENERIC_ARRAY; + } + } + + final String objref_classname = ((ObjectType) objref).getClassName(); + + final String theClass = o.getClassName(cpg); + + if ( ! Repository.instanceOf(objref_classname, theClass) ) { + constraintViolated(o, "The 'objref' item '"+objref+"' does not implement '"+theClass+"' as expected."); + } + } catch (final ClassNotFoundException e) { + // FIXME: maybe not the best way to handle this + throw new AssertionViolatedException("Missing class: " + e, e); + } + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitIOR(final 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. + */ + @Override + public void visitIREM(final 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. + */ + @Override + public void visitIRETURN(final 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. + */ + @Override + public void visitISHL(final 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. + */ + @Override + public void visitISHR(final 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. + */ + @Override + public void visitISTORE(final ISTORE o) { + //visitStoreInstruction(StoreInstruction) is called before. + + // Nothing else needs to be done here. + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitISUB(final 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. + */ + @Override + public void visitIUSHR(final 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. + */ + @Override + public void visitIXOR(final 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. + */ + @Override + public void visitJSR(final JSR o) { + // nothing to do here. + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitJSR_W(final JSR_W o) { + // nothing to do here. + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitL2D(final 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. + */ + @Override + public void visitL2F(final 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. + */ + @Override + public void visitL2I(final 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. + */ + @Override + public void visitLADD(final 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. + */ + @Override + public void visitLALOAD(final 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)+"'."); + } + final 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. + */ + @Override + public void visitLAND(final 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. + */ + @Override + public void visitLASTORE(final 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)+"'."); + } + final 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. + */ + @Override + public void visitLCMP(final 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. + */ + @Override + public void visitLCONST(final LCONST o) { + // Nothing to do here. + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitLDC(final LDC o) { + // visitCPInstruction is called first. + + final Constant c = cpg.getConstant(o.getIndex()); + if (! ( ( c instanceof ConstantInteger) || + ( c instanceof ConstantFloat ) || + ( c instanceof ConstantString ) || + ( c instanceof ConstantClass ) ) ) { + constraintViolated(o, + "Referenced constant should be a CONSTANT_Integer, a CONSTANT_Float, a CONSTANT_String or a CONSTANT_Class, but is '"+ + c + "'."); + } + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + public void visitLDC_W(final LDC_W o) { + // visitCPInstruction is called first. + + final Constant c = cpg.getConstant(o.getIndex()); + if (! ( ( c instanceof ConstantInteger) || + ( c instanceof ConstantFloat ) || + ( c instanceof ConstantString ) || + ( c instanceof ConstantClass ) ) ) { + constraintViolated(o, + "Referenced constant should be a CONSTANT_Integer, a CONSTANT_Float, a CONSTANT_String or a CONSTANT_Class, but is '"+ + c + "'."); + } + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitLDC2_W(final LDC2_W o) { + // visitCPInstruction is called first. + + final 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. + */ + @Override + public void visitLDIV(final 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. + */ + @Override + public void visitLLOAD(final LLOAD o) { + //visitLoadInstruction(LoadInstruction) is called before. + + // Nothing else needs to be done here. + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitLMUL(final 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. + */ + @Override + public void visitLNEG(final 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. + */ + @Override + public void visitLOOKUPSWITCH(final 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. + */ + @Override + public void visitLOR(final 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. + */ + @Override + public void visitLREM(final 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. + */ + @Override + public void visitLRETURN(final 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. + */ + @Override + public void visitLSHL(final 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. + */ + @Override + public void visitLSHR(final 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. + */ + @Override + public void visitLSTORE(final LSTORE o) { + //visitStoreInstruction(StoreInstruction) is called before. + + // Nothing else needs to be done here. + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitLSUB(final 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. + */ + @Override + public void visitLUSHR(final 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. + */ + @Override + public void visitLXOR(final 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. + */ + @Override + public void visitMONITORENTER(final 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. + */ + @Override + public void visitMONITOREXIT(final 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. + */ + @Override + public void visitMULTIANEWARRAY(final MULTIANEWARRAY o) { + final int dimensions = o.getDimensions(); + // Dimensions argument is okay: see Pass 3a. + for (int i=0; i, see Pass 3a. + + } catch (final ClassNotFoundException e) { + // FIXME: maybe not the best way to handle this + throw new AssertionViolatedException("Missing class: " + e, e); + } + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitRET(final 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. + */ + @Override + public void visitRETURN(final RETURN o) { + if (mg.getName().equals(Const.CONSTRUCTOR_NAME)) {// If we leave an method + if ((Frame.getThis() != 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. + */ + @Override + public void visitSALOAD(final 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)+"'."); + } + final 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. + */ + @Override + public void visitSASTORE(final 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)+"'."); + } + final 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. + */ + @Override + public void visitSIPUSH(final SIPUSH o) { + // nothing to do here. Generic visitXXX() methods did the trick before. + } + + /** + * Ensures the specific preconditions of the said instruction. + */ + @Override + public void visitSWAP(final 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. + */ + @Override + public void visitTABLESWITCH(final TABLESWITCH o) { + indexOfInt(o, stack().peek()); + // See Pass 3a. + } + +} + diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/InstructionContext.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/InstructionContext.java new file mode 100644 index 00000000..df812d10 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/InstructionContext.java @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.structurals; + + +import java.util.ArrayList; + +import org.apache.bcel.generic.InstructionHandle; + +/** + * An InstructionContext offers convenient access + * to information like control flow successors and + * such. + * + * @version $Id: InstructionContext.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +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) + */ + 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() + */ + 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); + + Frame getInFrame(); + + /** + * This method returns the outgoing execution frame situation; + * therefore it has to be calculated by execute(Frame, ArrayList) + * first. + * + * @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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/LocalVariables.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/LocalVariables.java new file mode 100644 index 00000000..2b1172a0 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/LocalVariables.java @@ -0,0 +1,218 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.structurals; + + +import org.apache.bcel.generic.ReferenceType; +import org.apache.bcel.generic.Type; +import org.apache.bcel.verifier.exc.AssertionViolatedException; +import org.apache.bcel.verifier.exc.StructuralCodeConstraintException; + +/** + * This class implements an array of local variables used for symbolic JVM + * simulation. + * + * @version $Id: LocalVariables.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class LocalVariables implements Cloneable { + /** The Type[] containing the local variable slots. */ + private final Type[] locals; + + /** + * Creates a new LocalVariables object. + */ + public LocalVariables(final int maxLocals) { + locals = new Type[maxLocals]; + for (int i=0; i stack = new ArrayList<>(); + + /** The maximum number of stack slots this OperandStack instance may hold. */ + private final int maxStack; + + /** + * Creates an empty stack with a maximum of maxStack slots. + */ + public OperandStack(final 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(final int maxStack, final 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. + */ + @Override + public Object clone() { + final OperandStack newstack = new OperandStack(this.maxStack); + @SuppressWarnings("unchecked") // OK because this.stack is the same type + final ArrayList clone = (ArrayList) this.stack.clone(); + newstack.stack = clone; + return newstack; + } + + /** + * Clears the stack. + */ + public void clear() { + stack = new ArrayList<>(); + } + + /** @return a hash code value for the object. + */ + @Override + public int hashCode() { return stack.hashCode(); } + + /** + * Returns true if and only if this OperandStack + * equals another, meaning equal lengths and equal + * objects on the stacks. + */ + @Override + public boolean equals(final Object o) { + if (!(o instanceof OperandStack)) { + return false; + } + final 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(final int i) { + return stack.get(size()-i-1); + } + + /** + * Returns the element on top of the stack. The element is popped off the stack. + */ + public Type pop() { + final Type e = stack.remove(size()-1); + return e; + } + + /** + * Pops i elements off the stack. ALWAYS RETURNS "null"!!! + */ + public Type pop(final int i) { + for (int j=0; j= 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. + */ + public 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 ics = new Vector<>(); + private final List> ecs = new Vector<>(); + public void add(final InstructionContext ic, final ArrayList executionChain) { + ics.add(ic); + ecs.add(executionChain); + } + public boolean isEmpty() { + return ics.isEmpty(); + } + public void remove(final int i) { + ics.remove(i); + ecs.remove(i); + } + public InstructionContext getIC(final int i) { + return ics.get(i); + } + public ArrayList getEC(final int i) { + return 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 final Verifier myOwner; + + /** The method number to verify. */ + private final int method_no; + + /** + * This class should only be instantiated by a Verifier. + * + * @see org.apache.bcel.verifier.Verifier + */ + public Pass3bVerifier(final Verifier owner, final 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(final MethodGen m,final ControlFlowGraph cfg, final InstructionContext start, + final Frame vanillaFrame, final InstConstraintVisitor icv, final ExecutionVisitor ev) { + final Random random = new Random(); + final 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) { + final 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); + } + + @SuppressWarnings("unchecked") // ec is of type ArrayList + final + ArrayList oldchain = (ArrayList) (ec.clone()); + @SuppressWarnings("unchecked") // ec is of type ArrayList + final + 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. + final RET ret = (RET) (u.getInstruction().getInstruction()); + final ReturnaddressType t = (ReturnaddressType) u.getOutFrame(oldchain).getLocals().get(ret.getIndex()); + final 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 ((oldchain.get(ss)).getInstruction().getInstruction() instanceof JsrInstruction) { + if (skip_jsr == 0) { + lastJSR = oldchain.get(ss); + break; + } + skip_jsr--; + } + if ((oldchain.get(ss)).getInstruction().getInstruction() instanceof RET) { + skip_jsr++; + } + } + if (lastJSR == null) { + throw new AssertionViolatedException("RET without a JSR before in ExecutionChain?! EC: '"+oldchain+"'."); + } + final 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)) { + @SuppressWarnings("unchecked") // newchain is already of type ArrayList + final + ArrayList newchainClone = (ArrayList) newchain.clone(); + icq.add(theSuccessor, newchainClone); + } + } + else{// "not a ret" + + // Normal successors. Add them to the queue of successors. + final InstructionContext[] succs = u.getSuccessors(); + for (final InstructionContext v : succs) { + if (v.execute(u.getOutFrame(oldchain), newchain, icv, ev)) { + @SuppressWarnings("unchecked") // newchain is already of type ArrayList + final + ArrayList newchainClone = (ArrayList) newchain.clone(); + icq.add(v, newchainClone); + } + } + }// end "not a ret" + + // Exception Handlers. Add them to the queue of successors. + // [subroutines are never protected; mandated by JustIce] + final ExceptionHandler[] exc_hds = u.getExceptionHandlers(); + for (final ExceptionHandler exc_hd : exc_hds) { + final InstructionContext v = cfg.contextOf(exc_hd.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_hd.getExceptionType()==null? Type.THROWABLE : exc_hd.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)))) { + final InstructionContext ic = cfg.contextOf(ih); + // TODO: This is buggy, we check only the top-level return instructions this way. + // Maybe some maniac returns from a method when in a subroutine? + final Frame f = ic.getOutFrame(new ArrayList()); + final LocalVariables lvs = f.getLocals(); + for (int i=0; i= 1) { + returnedType = inStack.peek(); + } else { + returnedType = Type.VOID; + } + + if (returnedType != null) { + if (returnedType instanceof ReferenceType) { + try { + if (!((ReferenceType) returnedType).isCastableTo(m.getReturnType())) { + invalidReturnTypeError(returnedType, m); + } + } catch (final ClassNotFoundException e) { + // Don't know what do do now, so raise RuntimeException + throw new RuntimeException(e); + } + } else if (!returnedType.equals(m.getReturnType().normalizeForStackOrLocal())) { + invalidReturnTypeError(returnedType, m); + } + } + } + } while ((ih = ih.getNext()) != null); + + } + + /** + * Throws an exception indicating the returned type is not compatible with the return type of the given method + * @throws StructuralCodeConstraintException always + * @since 6.0 + */ + public void invalidReturnTypeError(final Type returnedType, final MethodGen m) { + throw new StructuralCodeConstraintException( + "Returned type "+returnedType+" does not match Method's return type "+m.getReturnType()); + } + + /** + * 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) + */ + @Override + 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; + try { + jc = Repository.lookupClass(myOwner.getClassName()); + } catch (final ClassNotFoundException e) { + // FIXME: maybe not the best way to handle this + throw new AssertionViolatedException("Missing class: " + e, e); + } + + final ConstantPoolGen constantPoolGen = new ConstantPoolGen(jc.getConstantPool()); + // Init Visitors + final InstConstraintVisitor icv = new InstConstraintVisitor(); + icv.setConstantPoolGen(constantPoolGen); + + final ExecutionVisitor ev = new ExecutionVisitor(); + ev.setConstantPoolGen(constantPoolGen); + + final Method[] methods = jc.getMethods(); // Method no "method_no" exists, we ran Pass3a before on it! + + try{ + + final 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) + + final ControlFlowGraph cfg = new ControlFlowGraph(mg); + + // Build the initial frame situation for this method. + final Frame f = new Frame(mg.getMaxLocals(),mg.getMaxStack()); + if ( !mg.isStatic() ) { + if (mg.getName().equals(Const.CONSTRUCTOR_NAME)) { + Frame.setThis(new UninitializedObjectType(ObjectType.getInstance(jc.getClassName()))); + f.getLocals().set(0, Frame.getThis()); + } + else{ + Frame.setThis(null); + f.getLocals().set(0, ObjectType.getInstance(jc.getClassName())); + } + } + final Type[] argtypes = mg.getArgumentTypes(); + int twoslotoffset = 0; + for (int j=0; jMust not be invoked on the 'top-level subroutine'. + */ + InstructionHandle[] getEnteringJsrInstructions(); + + /** + * Returns the one and only RET that leaves the subroutine. + * Note that JustIce has a pretty rigid notion of a subroutine. + * Must not be invoked on the 'top-level subroutine'. + * + * @see Subroutines + */ + 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). + */ + 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() + */ + 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() + */ + 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() + */ + int[] getRecursivelyAccessedLocalsIndices(); + + /** + * Returns the subroutines that are directly called from this subroutine. + */ + Subroutine[] subSubs(); +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/Subroutines.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/Subroutines.java new file mode 100644 index 00000000..21a76348 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/Subroutines.java @@ -0,0 +1,683 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.structurals; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.bcel.generic.ASTORE; +import org.apache.bcel.generic.ATHROW; +import org.apache.bcel.generic.BranchInstruction; +import org.apache.bcel.generic.CodeExceptionGen; +import org.apache.bcel.generic.GotoInstruction; +import org.apache.bcel.generic.IndexedInstruction; +import org.apache.bcel.generic.Instruction; +import org.apache.bcel.generic.InstructionHandle; +import org.apache.bcel.generic.JsrInstruction; +import org.apache.bcel.generic.LocalVariableInstruction; +import org.apache.bcel.generic.MethodGen; +import org.apache.bcel.generic.RET; +import org.apache.bcel.generic.ReturnInstruction; +import org.apache.bcel.generic.Select; +import org.apache.bcel.verifier.exc.AssertionViolatedException; +import org.apache.bcel.verifier.exc.StructuralCodeConstraintException; + +/** + * 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: Subroutines.java 1806200 2017-08-25 16:33:06Z ggregory $ + * @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 static 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 final Set instructions = new HashSet<>(); // Elements: InstructionHandle + + /* + * Refer to the Subroutine interface for documentation. + */ + @Override + public boolean contains(final InstructionHandle inst) { + return instructions.contains(inst); + } + + /** + * The JSR or JSR_W instructions that define this + * subroutine by targeting it. + */ + private final Set 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. + */ + @Override + public String toString() { + final StringBuilder ret = new StringBuilder(); + ret.append("Subroutine: Local variable is '").append(localVariable); + ret.append("', JSRs are '").append(theJSRs); + ret.append("', RET is '").append(theRET); + ret.append("', Instructions: '").append(instructions).append("'."); + + ret.append(" Accessed local variable slots: '"); + int[] alv = getAccessedLocalsIndices(); + for (final int element : alv) { + ret.append(element);ret.append(" "); + } + ret.append("'."); + + ret.append(" Recursively (via subsub...routines) accessed local variable slots: '"); + alv = getRecursivelyAccessedLocalsIndices(); + for (final int element : alv) { + ret.append(element);ret.append(" "); + } + ret.append("'."); + + return ret.toString(); + } + + /** + * 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."); + } + InstructionHandle ret = null; + for (final InstructionHandle actual : instructions) { + if (actual.getInstruction() instanceof RET) { + if (ret != null) { + throw new StructuralCodeConstraintException( + "Subroutine with more then one RET detected: '"+ret+"' and '"+actual+"'."); + } + 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. + */ + @Override + public InstructionHandle[] getEnteringJsrInstructions() { + if (this == getTopLevel()) { + throw new AssertionViolatedException("getLeavingRET() called on top level pseudo-subroutine."); + } + final InstructionHandle[] jsrs = new InstructionHandle[theJSRs.size()]; + return theJSRs.toArray(jsrs); + } + + /** + * Adds a new JSR or JSR_W that has this subroutine as its target. + */ + public void addEnteringJsrInstruction(final 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!"); + } + // 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. + */ + @Override + public InstructionHandle getLeavingRET() { + if (this == getTopLevel()) { + throw new AssertionViolatedException("getLeavingRET() called on top level pseudo-subroutine."); + } + return theRET; + } + + /* + * Refer to the Subroutine interface for documentation. + */ + @Override + public InstructionHandle[] getInstructions() { + final InstructionHandle[] ret = new InstructionHandle[instructions.size()]; + return instructions.toArray(ret); + } + + /* + * Adds an instruction to this subroutine. + * All instructions must have been added before invoking setLeavingRET(). + * @see #setLeavingRET + */ + void addInstruction(final InstructionHandle ih) { + if (theRET != null) { + throw new AssertionViolatedException("All instructions must have been added before invoking setLeavingRET()."); + } + instructions.add(ih); + } + + /* Satisfies Subroutine.getRecursivelyAccessedLocalsIndices(). */ + @Override + public int[] getRecursivelyAccessedLocalsIndices() { + final Set s = new HashSet<>(); + final int[] lvs = getAccessedLocalsIndices(); + for (final int lv : lvs) { + s.add(Integer.valueOf(lv)); + } + _getRecursivelyAccessedLocalsIndicesHelper(s, this.subSubs()); + final int[] ret = new int[s.size()]; + int j=-1; + for (final Integer index : s) { + j++; + ret[j] = index.intValue(); + } + return ret; + } + + /** + * A recursive helper method for getRecursivelyAccessedLocalsIndices(). + * @see #getRecursivelyAccessedLocalsIndices() + */ + private void _getRecursivelyAccessedLocalsIndicesHelper(final Set s, final Subroutine[] subs) { + for (final Subroutine sub : subs) { + final int[] lvs = sub.getAccessedLocalsIndices(); + for (final int lv : lvs) { + s.add(Integer.valueOf(lv)); + } + if(sub.subSubs().length != 0) { + _getRecursivelyAccessedLocalsIndicesHelper(s, sub.subSubs()); + } + } + } + + /* + * Satisfies Subroutine.getAccessedLocalIndices(). + */ + @Override + public int[] getAccessedLocalsIndices() { + //TODO: Implement caching. + final Set acc = new HashSet<>(); + if (theRET == null && this != getTopLevel()) { + throw new AssertionViolatedException( + "This subroutine object must be built up completely before calculating accessed locals."); + } + { + for (final InstructionHandle ih : instructions) { + // RET is not a LocalVariableInstruction in the current version of BCEL. + if (ih.getInstruction() instanceof LocalVariableInstruction || ih.getInstruction() instanceof RET) { + final int idx = ((IndexedInstruction) (ih.getInstruction())).getIndex(); + acc.add(Integer.valueOf(idx)); + // LONG? DOUBLE?. + try{ + // LocalVariableInstruction instances are typed without the need to look into + // the constant pool. + if (ih.getInstruction() instanceof LocalVariableInstruction) { + final int s = ((LocalVariableInstruction) ih.getInstruction()).getType(null).getSize(); + if (s==2) { + acc.add(Integer.valueOf(idx+1)); + } + } + } + catch(final RuntimeException re) { + throw new AssertionViolatedException("Oops. BCEL did not like NULL as a ConstantPoolGen object.", re); + } + } + } + } + + { + final int[] ret = new int[acc.size()]; + int j=-1; + for (final Integer accessedLocal : acc) { + j++; + ret[j] = accessedLocal.intValue(); + } + return ret; + } + } + + /* + * Satisfies Subroutine.subSubs(). + */ + @Override + public Subroutine[] subSubs() { + final Set h = new HashSet<>(); + + for (final InstructionHandle ih : instructions) { + final Instruction inst = ih.getInstruction(); + if (inst instanceof JsrInstruction) { + final InstructionHandle targ = ((JsrInstruction) inst).getTarget(); + h.add(getSubroutine(targ)); + } + } + final Subroutine[] ret = new Subroutine[h.size()]; + return 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(final int i) { + if (localVariable != UNSET) { + throw new AssertionViolatedException("localVariable set twice."); + } + localVariable = i; + } + + /** + * The default constructor. + */ + public SubroutineImpl() { + } + + }// end Inner Class SubrouteImpl + + //Node coloring constants + private enum ColourConstants{ + WHITE, + GRAY, + BLACK + } + + /** + * The map containing the subroutines found. + * Key: InstructionHandle of the leader of the subroutine. + * Elements: SubroutineImpl objects. + */ + private final Map subroutines = new HashMap<>(); + + /** + * 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. + */ + // CHECKSTYLE:OFF + public final Subroutine TOPLEVEL; // TODO can this be made private? + // CHECKSTYLE:ON + + /** + * Constructor. + * @param mg A MethodGen object representing method to + * create the Subroutine objects of. + * Assumes that JustIce strict checks are needed. + */ + public Subroutines(final MethodGen mg) { + this(mg, true); + } + + /** + * Constructor. + * @param mg A MethodGen object representing method to + * create the Subroutine objects of. + * @param enableJustIceCheck whether to enable additional JustIce checks + * @since 6.0 + */ + public Subroutines(final MethodGen mg, final boolean enableJustIceCheck) { + final InstructionHandle[] all = mg.getInstructionList().getInstructionHandles(); + final CodeExceptionGen[] handlers = mg.getExceptionHandlers(); + + // Define our "Toplevel" fake subroutine. + TOPLEVEL = new SubroutineImpl(); + + // Calculate "real" subroutines. + final Set sub_leaders = new HashSet<>(); // Elements: InstructionHandle + for (final InstructionHandle element : all) { + final Instruction inst = element.getInstruction(); + if (inst instanceof JsrInstruction) { + sub_leaders.add(((JsrInstruction) inst).getTarget()); + } + } + + // Build up the database. + for (final InstructionHandle astore : sub_leaders) { + final SubroutineImpl sr = new SubroutineImpl(); + 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 (final InstructionHandle element : all) { + final Instruction inst = element.getInstruction(); + if (inst instanceof JsrInstruction) { + final InstructionHandle leader = ((JsrInstruction) inst).getTarget(); + ((SubroutineImpl) getSubroutine(leader)).addEnteringJsrInstruction(element); + } + } + + // Now do a BFS from every subroutine leader to find all the + // instructions that belong to a subroutine. + // we don't want to assign an instruction to two or more Subroutine objects. + final Set instructions_assigned = new HashSet<>(); + + //Graph colouring. Key: InstructionHandle, Value: ColourConstants enum . + final Map colors = new HashMap<>(); + + final List Q = new ArrayList<>(); + for (final InstructionHandle actual : sub_leaders) { + // Do some BFS with "actual" as the root of the graph. + // Init colors + for (final InstructionHandle element : all) { + colors.put(element, ColourConstants.WHITE); + } + colors.put(actual, ColourConstants.GRAY); + // Init Queue + + Q.clear(); + 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 (final CodeExceptionGen handler : handlers) { + colors.put(handler.getHandlerPC(), ColourConstants.GRAY); + Q.add(handler.getHandlerPC()); + } + } + /* CONTINUE NORMAL BFS ALGORITHM */ + + // Loop until Queue is empty + while (Q.size() != 0) { + final InstructionHandle u = Q.remove(0); + final InstructionHandle[] successors = getSuccessors(u); + for (final InstructionHandle successor : successors) { + if (colors.get(successor) == ColourConstants.WHITE) { + colors.put(successor, ColourConstants.GRAY); + Q.add(successor); + } + } + colors.put(u, ColourConstants.BLACK); + } + // BFS ended above. + for (final InstructionHandle element : all) { + if (colors.get(element) == ColourConstants.BLACK) { + ((SubroutineImpl) (actual==all[0]?getTopLevel():getSubroutine(actual))).addInstruction(element); + if (instructions_assigned.contains(element)) { + throw new StructuralCodeConstraintException("Instruction '"+element+ + "' is part of more than one subroutine (or of the top level and a subroutine)."); + } + instructions_assigned.add(element); + } + } + if (actual != all[0]) {// If we don't deal with the top-level 'subroutine' + ((SubroutineImpl) getSubroutine(actual)).setLeavingRET(); + } + } + + if (enableJustIceCheck) { + // Now make sure no instruction of a Subroutine is protected by exception handling code + // as is mandated by JustIces notion of subroutines. + for (final CodeExceptionGen handler : handlers) { + InstructionHandle _protected = handler.getStartPC(); + while (_protected != handler.getEndPC().getNext()) { + // Note the inclusive/inclusive notation of "generic API" exception handlers! + for (final Subroutine sub : subroutines.values()) { + 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, '"+handler+ + "'. 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(final Subroutine sub, final Set set) { + final Subroutine[] subs = sub.subSubs(); + + for (final Subroutine sub2 : subs) { + final int index = ((RET) (sub2.getLeavingRET().getInstruction())).getIndex(); + + if (!set.add(Integer.valueOf(index))) { + // Don't use toString() here because of possibly infinite recursive subSubs() calls then. + final SubroutineImpl si = (SubroutineImpl) sub2; + 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(sub2, set); + + set.remove(Integer.valueOf(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(final InstructionHandle leader) { + final Subroutine ret = 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(final InstructionHandle any) { + for (final Subroutine s : subroutines.values()) { + if (s.contains(any)) { + return s; + } + } +System.err.println("DEBUG: Please verify '"+any.toString(true)+"' 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 not a + * subroutine, the top-level, is also modeled as a Subroutine + * object. + * It is a special Subroutine object where you must not invoke + * getEnteringJsrInstructions() or getLeavingRET(). + * + * @see Subroutine#getEnteringJsrInstructions() + * @see Subroutine#getLeavingRET() + */ + public Subroutine getTopLevel() { + return TOPLEVEL; + } + /** + * A utility method that calculates the successors of a given InstructionHandle + * in the same subroutine. 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(final InstructionHandle instruction) { + final InstructionHandle[] empty = new InstructionHandle[0]; + final InstructionHandle[] single = new InstructionHandle[1]; + + final 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. + final InstructionHandle[] matchTargets = ((Select) inst).getTargets(); + final InstructionHandle[] ret = new InstructionHandle[matchTargets.length+1]; + ret[0] = ((Select) inst).getTarget(); + System.arraycopy(matchTargets, 0, ret, 1, matchTargets.length); + return ret; + } + final InstructionHandle[] pair = new InstructionHandle[2]; + 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. + */ + @Override + public String toString() { + return "---\n"+subroutines+"\n---\n"; + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/UninitializedObjectType.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/UninitializedObjectType.java new file mode 100644 index 00000000..f83ce9d6 --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/UninitializedObjectType.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.bcel.verifier.structurals; + + +import org.apache.bcel.Const; +import org.apache.bcel.Constants; +import org.apache.bcel.generic.ObjectType; +import org.apache.bcel.generic.ReferenceType; + +/** + * 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: UninitializedObjectType.java 1806200 2017-08-25 16:33:06Z ggregory $ + */ +public class UninitializedObjectType extends ReferenceType implements Constants { + + /** The "initialized" version. */ + private final ObjectType initialized; + + /** Creates a new instance. */ + public UninitializedObjectType(final ObjectType t) { + super(Const.T_UNKNOWN, ""); + 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; + } + + /** @return a hash code value for the object. + */ + @Override + public int hashCode() { return initialized.hashCode(); } + + /** + * Returns true on equality of this and o. + * Equality means the ObjectType instances of "initialized" + * equal one another in this and the o instance. + * + */ + @Override + public boolean equals(final Object o) { + if (! (o instanceof UninitializedObjectType)) { + return false; + } + return initialized.equals(((UninitializedObjectType)o).initialized); + } +} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/package.html b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/package.html new file mode 100644 index 00000000..b8fafc6a --- /dev/null +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/package.html @@ -0,0 +1,36 @@ + + + + + + + + +Provides a PassVerifier class mostly used internally by JustIce, yielding a control flow graph for public use as +a nice side effect. + +

      Package Specification

      + +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". + + + diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/Constants.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/Constants.java deleted file mode 100755 index 3f1b39c6..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/Constants.java +++ /dev/null @@ -1,766 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0; - -/** - * Constants for the project, mostly defined in the JVM specification. - * - * @version $Id: Constants.java 410087 2006-05-29 12:12:19Z tcurdt $ - * @author M. Dahm - */ -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_1_4 = 48; - public final static short MINOR_1_4 = 0; - public final static short MAJOR_1_5 = 49; - public final static short MINOR_1_5 = 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_BRIDGE = 0x0040; - public final static short ACC_TRANSIENT = 0x0080; - public final static short ACC_VARARGS = 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; - - public final static short ACC_SYNTHETIC = 0x1000; - public final static short ACC_ANNOTATION = 0x2000; - public final static short ACC_ENUM = 0x4000; - - // Applies to classes compiled by new compilers only - public final static short ACC_SUPER = 0x0020; - - public final static short MAX_ACC_FLAG = ACC_ENUM; - - public final static String[] ACCESS_NAMES = { - "public", "private", "protected", "static", "final", "synchronized", - "volatile", "transient", "native", "interface", "abstract", "strictfp", - "synthetic", "annotation", "enum" - }; - - /** 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 "class - * initialization method" or "interface initialization - * method". This is "<clinit>". - */ - public final static String STATIC_INITIALIZER_NAME = ""; - - /** The name of every constructor method in a class, also called - * "instance initialization method". This is "<init>". - */ - public final static String CONSTRUCTOR_NAME = ""; - - /** 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 = ""; - public static final String 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; - - /** The primitive type names corresponding to the T_XX constants, - * e.g., TYPE_NAMES[T_INT] = "int" - */ - 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 - }; - - /** The primitive class names corresponding to the T_XX constants, - * e.g., CLASS_TYPE_NAMES[T_INT] = "java.lang.Integer" - */ - public static final String[] CLASS_TYPE_NAMES = { - ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, - "java.lang.Boolean", "java.lang.Character", "java.lang.Float", - "java.lang.Double", "java.lang.Byte", "java.lang.Short", - "java.lang.Integer", "java.lang.Long", "java.lang.Void", - ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE - }; - - /** The signature characters corresponding to primitive types, - * e.g., SHORT_TYPE_NAMES[T_INT] = "I" - */ - 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 byte ATTR_RUNTIMEVISIBLE_ANNOTATIONS = 12; - public static final byte ATTR_RUNTIMEINVISIBLE_ANNOTATIONS = 13; - public static final byte ATTR_RUNTIMEVISIBLE_PARAMETER_ANNOTATIONS = 14; - public static final byte ATTR_RUNTIMEINVISIBLE_PARAMETER_ANNOTATIONS = 15; - public static final byte ATTR_ANNOTATION_DEFAULT = 16; - - public static final short KNOWN_ATTRIBUTES = 12;//should be 17 - - public static final String[] ATTRIBUTE_NAMES = { - "SourceFile", "ConstantValue", "Code", "Exceptions", - "LineNumberTable", "LocalVariableTable", - "InnerClasses", "Synthetic", "Deprecated", - "PMGClass", "Signature", "StackMap", - "RuntimeVisibleAnnotations", "RuntimeInvisibleAnnotations", - "RuntimeVisibleParameterAnnotations", "RuntimeInvisibleParameterAnnotations", - "AnnotationDefault" - }; - - /** 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/ExceptionConstants.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/ExceptionConstants.java deleted file mode 100755 index e7a697c3..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/ExceptionConstants.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0; - -/** - * Exception constants. - * - * @version $Id: ExceptionConstants.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author E. Haase - */ -public interface ExceptionConstants { - - /** The mother of all exceptions - */ - public static final Class THROWABLE = Throwable.class; - /** Super class of any run-time exception - */ - public static final Class RUNTIME_EXCEPTION = RuntimeException.class; - /** Super class of any linking exception (aka Linkage Error) - */ - public static final Class LINKING_EXCEPTION = LinkageError.class; - /** Linking Exceptions - */ - public static final Class CLASS_CIRCULARITY_ERROR = ClassCircularityError.class; - public static final Class CLASS_FORMAT_ERROR = ClassFormatError.class; - public static final Class EXCEPTION_IN_INITIALIZER_ERROR = ExceptionInInitializerError.class; - public static final Class INCOMPATIBLE_CLASS_CHANGE_ERROR = IncompatibleClassChangeError.class; - public static final Class ABSTRACT_METHOD_ERROR = AbstractMethodError.class; - public static final Class ILLEGAL_ACCESS_ERROR = IllegalAccessError.class; - public static final Class INSTANTIATION_ERROR = InstantiationError.class; - public static final Class NO_SUCH_FIELD_ERROR = NoSuchFieldError.class; - public static final Class NO_SUCH_METHOD_ERROR = NoSuchMethodError.class; - public static final Class NO_CLASS_DEF_FOUND_ERROR = NoClassDefFoundError.class; - public static final Class UNSATISFIED_LINK_ERROR = UnsatisfiedLinkError.class; - public static final Class VERIFY_ERROR = VerifyError.class; - /* UnsupportedClassVersionError is new in JDK 1.2 */ - //public static final Class UnsupportedClassVersionError = UnsupportedClassVersionError.class; - /** Run-Time Exceptions - */ - public static final Class NULL_POINTER_EXCEPTION = NullPointerException.class; - public static final Class ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION = ArrayIndexOutOfBoundsException.class; - public static final Class ARITHMETIC_EXCEPTION = ArithmeticException.class; - public static final Class NEGATIVE_ARRAY_SIZE_EXCEPTION = NegativeArraySizeException.class; - public static final Class CLASS_CAST_EXCEPTION = ClassCastException.class; - public static final Class ILLEGAL_MONITOR_STATE = IllegalMonitorStateException.class; - /** Pre-defined exception arrays according to chapters 5.1-5.4 of the Java Virtual - * Machine Specification - */ - public static final Class[] EXCS_CLASS_AND_INTERFACE_RESOLUTION = { - NO_CLASS_DEF_FOUND_ERROR, CLASS_FORMAT_ERROR, VERIFY_ERROR, ABSTRACT_METHOD_ERROR, - EXCEPTION_IN_INITIALIZER_ERROR, ILLEGAL_ACCESS_ERROR - }; // Chapter 5.1 - public static final Class[] EXCS_FIELD_AND_METHOD_RESOLUTION = { - NO_SUCH_FIELD_ERROR, ILLEGAL_ACCESS_ERROR, NO_SUCH_METHOD_ERROR - }; // Chapter 5.2 - public static final Class[] EXCS_INTERFACE_METHOD_RESOLUTION = new Class[0]; // Chapter 5.3 (as below) - public static final Class[] EXCS_STRING_RESOLUTION = new Class[0]; - // Chapter 5.4 (no errors but the ones that _always_ could happen! How stupid.) - public static final Class[] EXCS_ARRAY_EXCEPTION = { - NULL_POINTER_EXCEPTION, ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION - }; -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/AccessFlags.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/AccessFlags.java deleted file mode 100755 index e903ea4a..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/AccessFlags.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import org.apache.bcel5_2_0.Constants; - -/** - * Super class for all objects that have modifiers like private, final, ... - * I.e. classes, fields, and methods. - * - * @version $Id: AccessFlags.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public abstract class AccessFlags implements java.io.Serializable { - - protected int access_flags; - - - public AccessFlags() { - } - - - /** - * @param a inital access flags - */ - public AccessFlags(int a) { - access_flags = a; - } - - - /** - * @return Access flags of the object aka. "modifiers". - */ - public final int getAccessFlags() { - return access_flags; - } - - - /** - * @return Access flags of the object aka. "modifiers". - */ - public final int getModifiers() { - return access_flags; - } - - - /** Set access flags aka "modifiers". - * @param access_flags Access flags of the object. - */ - public final void setAccessFlags( int access_flags ) { - this.access_flags = access_flags; - } - - - /** Set access flags aka "modifiers". - * @param access_flags Access flags of the object. - */ - public final void setModifiers( int access_flags ) { - setAccessFlags(access_flags); - } - - - private final void setFlag( int flag, boolean set ) { - if ((access_flags & flag) != 0) { // Flag is set already - if (!set) { - access_flags ^= flag; - } - } else { // Flag not set - if (set) { - access_flags |= flag; - } - } - } - - - public final void isPublic( boolean flag ) { - setFlag(Constants.ACC_PUBLIC, flag); - } - - - public final boolean isPublic() { - return (access_flags & Constants.ACC_PUBLIC) != 0; - } - - - public final void isPrivate( boolean flag ) { - setFlag(Constants.ACC_PRIVATE, flag); - } - - - public final boolean isPrivate() { - return (access_flags & Constants.ACC_PRIVATE) != 0; - } - - - public final void isProtected( boolean flag ) { - setFlag(Constants.ACC_PROTECTED, flag); - } - - - public final boolean isProtected() { - return (access_flags & Constants.ACC_PROTECTED) != 0; - } - - - public final void isStatic( boolean flag ) { - setFlag(Constants.ACC_STATIC, flag); - } - - - public final boolean isStatic() { - return (access_flags & Constants.ACC_STATIC) != 0; - } - - - public final void isFinal( boolean flag ) { - setFlag(Constants.ACC_FINAL, flag); - } - - - public final boolean isFinal() { - return (access_flags & Constants.ACC_FINAL) != 0; - } - - - public final void isSynchronized( boolean flag ) { - setFlag(Constants.ACC_SYNCHRONIZED, flag); - } - - - public final boolean isSynchronized() { - return (access_flags & Constants.ACC_SYNCHRONIZED) != 0; - } - - - public final void isVolatile( boolean flag ) { - setFlag(Constants.ACC_VOLATILE, flag); - } - - - public final boolean isVolatile() { - return (access_flags & Constants.ACC_VOLATILE) != 0; - } - - - public final void isTransient( boolean flag ) { - setFlag(Constants.ACC_TRANSIENT, flag); - } - - - public final boolean isTransient() { - return (access_flags & Constants.ACC_TRANSIENT) != 0; - } - - - public final void isNative( boolean flag ) { - setFlag(Constants.ACC_NATIVE, flag); - } - - - public final boolean isNative() { - return (access_flags & Constants.ACC_NATIVE) != 0; - } - - - public final void isInterface( boolean flag ) { - setFlag(Constants.ACC_INTERFACE, flag); - } - - - public final boolean isInterface() { - return (access_flags & Constants.ACC_INTERFACE) != 0; - } - - - public final void isAbstract( boolean flag ) { - setFlag(Constants.ACC_ABSTRACT, flag); - } - - - public final boolean isAbstract() { - return (access_flags & Constants.ACC_ABSTRACT) != 0; - } - - - public final void isStrictfp( boolean flag ) { - setFlag(Constants.ACC_STRICT, flag); - } - - - public final boolean isStrictfp() { - return (access_flags & Constants.ACC_STRICT) != 0; - } - - - public final void isSynthetic( boolean flag ) { - setFlag(Constants.ACC_SYNTHETIC, flag); - } - - - public final boolean isSynthetic() { - return (access_flags & Constants.ACC_SYNTHETIC) != 0; - } - - - public final void isAnnotation( boolean flag ) { - setFlag(Constants.ACC_ANNOTATION, flag); - } - - - public final boolean isAnnotation() { - return (access_flags & Constants.ACC_ANNOTATION) != 0; - } - - - public final void isEnum( boolean flag ) { - setFlag(Constants.ACC_ENUM, flag); - } - - - public final boolean isEnum() { - return (access_flags & Constants.ACC_ENUM) != 0; - } -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Attribute.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Attribute.java deleted file mode 100755 index ea450115..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Attribute.java +++ /dev/null @@ -1,279 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.apache.bcel5_2_0.Constants; - -/** - * Abstract super class for Attribute objects. Currently the - * ConstantValue, SourceFile, Code, - * Exceptiontable, LineNumberTable, - * LocalVariableTable, InnerClasses and - * Synthetic attributes are supported. The - * Unknown attribute stands for non-standard-attributes. - * - * @version $Id: Attribute.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @see ConstantValue - * @see SourceFile - * @see Code - * @see Unknown - * @see ExceptionTable - * @see LineNumberTable - * @see LocalVariableTable - * @see InnerClasses - * @see Synthetic - * @see Deprecated - * @see Signature - */ -public abstract class Attribute implements Cloneable, Node, Serializable { - - 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; - - - protected 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 - * @throws IOException - */ - public void dump( DataOutputStream file ) throws IOException { - file.writeShort(name_index); - file.writeInt(length); - } - - private static Map readers = new HashMap(); - - - /** Add an Attribute reader capable of parsing (user-defined) attributes - * named "name". You should not add readers for the standard attributes - * such as "LineNumberTable", because those are handled internally. - * - * @param name the name of the attribute as stored in the class file - * @param r the reader object - */ - public static void addAttributeReader( String name, AttributeReader r ) { - readers.put(name, r); - } - - - /** Remove attribute reader - * - * @param name the name of the attribute as stored in the class file - */ - public static void removeAttributeReader( String name ) { - readers.remove(name); - } - - - /* 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 - * @throws IOException - * @throws ClassFormatException - */ - public static final Attribute readAttribute( DataInputStream file, ConstantPool constant_pool ) - throws IOException, ClassFormatException { - 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 = 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: - AttributeReader r = (AttributeReader) readers.get(name); - if (r != null) { - return r.createAttribute(name_index, length, file, constant_pool); - } - 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); - // case Constants.ATTR_RUNTIMEVISIBLE_ANNOTATIONS: - // return new RuntimeVisibleAnnotations(name_index, length, file, constant_pool); - // case Constants.ATTR_RUNTIMEINVISIBLE_ANNOTATIONS: - // return new RuntimeInvisibleAnnotations(name_index, length, file, constant_pool); - // case Constants.ATTR_RUNTIMEVISIBLE_PARAMETER_ANNOTATIONS: - // return new RuntimeVisibleParameterAnnotations(name_index, length, file, constant_pool); - // case Constants.ATTR_RUNTIMEINVISIBLE_PARAMETER_ANNOTATIONS: - // return new RuntimeInvisibleParameterAnnotations(name_index, length, file, constant_pool); - // case Constants.ATTR_ANNOTATION_DEFAULT: - // return new AnnotationDefault(name_index, length, file, constant_pool); - default: // Never reached - throw new IllegalStateException("Ooops! default case reached."); - } - } - - - /** - * @return Length of attribute field in bytes. - */ - public final int getLength() { - return length; - } - - - /** - * @param length 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ClassFormatException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ClassFormatException.java deleted file mode 100755 index 4b4eea4a..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ClassFormatException.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -/** - * Thrown when the BCEL attempts to read a class file and determines - * that the file is malformed or otherwise cannot be interpreted as a - * class file. - * - * @version $Id: ClassFormatException.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class ClassFormatException extends RuntimeException { - - public ClassFormatException() { - super(); - } - - - public ClassFormatException(String s) { - super(s); - } -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Constant.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Constant.java deleted file mode 100755 index cbc213ad..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Constant.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.Serializable; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.util.BCELComparator; - -/** - * 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: Constant.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public abstract class Constant implements Cloneable, Node, Serializable { - - private static BCELComparator _cmp = new BCELComparator() { - - public boolean equals( Object o1, Object o2 ) { - Constant THIS = (Constant) o1; - Constant THAT = (Constant) o2; - return THIS.toString().equals(THAT.toString()); - } - - - public int hashCode( Object o ) { - Constant THIS = (Constant) o; - return THIS.toString().hashCode(); - } - }; - /* 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, - ClassFormatException { - 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 ClassFormatException("Invalid byte tag in constant pool: " + b); - } - } - - - /** - * @return Comparison strategy object - */ - public static BCELComparator getComparator() { - return _cmp; - } - - - /** - * @param comparator Comparison strategy object - */ - public static void setComparator( BCELComparator comparator ) { - _cmp = comparator; - } - - - /** - * Return value as defined by given BCELComparator strategy. - * By default two Constant objects are said to be equal when - * the result of toString() is equal. - * - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals( Object obj ) { - return _cmp.equals(this, obj); - } - - - /** - * Return value as defined by given BCELComparator strategy. - * By default return the hashcode of the result of toString(). - * - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - return _cmp.hashCode(this); - } -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantCP.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantCP.java deleted file mode 100755 index bec15e07..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantCP.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * Abstract super class for Fieldref and Methodref constants. - * - * @version $Id: ConstantCP.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 - * @throws 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 - * @throws 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantFieldref.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantFieldref.java deleted file mode 100755 index d06a59af..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantFieldref.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class represents a constant pool reference to a field. - * - * @version $Id: ConstantFieldref.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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 - * @throws 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantInterfaceMethodref.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantInterfaceMethodref.java deleted file mode 100755 index 2a6d4373..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantInterfaceMethodref.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class represents a constant pool reference to an interface method. - * - * @version $Id: ConstantInterfaceMethodref.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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 - * @throws 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantMethodref.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantMethodref.java deleted file mode 100755 index 2bbc76db..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantMethodref.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class represents a constant pool reference to a method. - * - * @version $Id: ConstantMethodref.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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 - * @throws 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantUtf8.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantUtf8.java deleted file mode 100755 index fcd833ec..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/ConstantUtf8.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * This class is derived from the abstract - * Constant class - * and represents a reference to a Utf8 encoded string. - * - * @version $Id: ConstantUtf8.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 - * @throws IOException - */ - ConstantUtf8(DataInputStream file) throws IOException { - super(Constants.CONSTANT_Utf8); - bytes = file.readUTF(); - } - - - /** - * @param bytes Data - */ - public ConstantUtf8(String bytes) { - super(Constants.CONSTANT_Utf8); - if (bytes == null) { - throw new IllegalArgumentException("bytes must not be null!"); - } - 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 - * @throws 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 the raw bytes of this Utf-8 - */ - 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/DescendingVisitor.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/DescendingVisitor.java deleted file mode 100755 index a1ec7938..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/DescendingVisitor.java +++ /dev/null @@ -1,356 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -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: DescendingVisitor.java 388707 2006-03-25 05:40:28Z tcurdt $ - * @author M. Dahm - */ -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 visitSignature( Signature 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/EmptyVisitor.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/EmptyVisitor.java deleted file mode 100755 index 340c4edf..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/EmptyVisitor.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -/** - * 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: EmptyVisitor.java 388707 2006-03-25 05:40:28Z tcurdt $ - * - */ -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 visitSignature( Signature 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/FieldOrMethod.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/FieldOrMethod.java deleted file mode 100755 index 6261057f..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/FieldOrMethod.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; - -/** - * Abstract super class for fields and methods. - * - * @version $Id: FieldOrMethod.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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 - * @throws IOException - * @throws ClassFormatException - */ - protected FieldOrMethod(DataInputStream file, ConstantPool constant_pool) throws IOException, - ClassFormatException { - 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 - * @throws 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 ) { - try { - FieldOrMethod c = (FieldOrMethod) clone(); - 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; - } catch (CloneNotSupportedException e) { - return null; - } - } -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Node.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Node.java deleted file mode 100755 index 59e3573f..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Node.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -/** - * Denote class to have an accept method(); - * - * @version $Id: Node.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public interface Node { - - public void accept( Visitor obj ); -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/StackMapEntry.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/StackMapEntry.java deleted file mode 100755 index 4216848c..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/StackMapEntry.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -/** - * 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 paragraph 5.3.1.2 - * - * @version $Id: StackMapEntry.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 - * @throws 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 - * @throws 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() { - StringBuilder buf = new StringBuilder(64); - buf.append("(offset=").append(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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Visitor.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Visitor.java deleted file mode 100755 index 39864b90..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/Visitor.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.classfile; - -/** - * 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. - * - * @version $Id: Visitor.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public interface Visitor { - - //public void visitAnnotation(Annotations obj); - //public void visitParameterAnnotation(ParameterAnnotations obj); - //public void visitAnnotationEntry(AnnotationEntry obj); - //public void visitAnnotationDefault(AnnotationDefault obj); - 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 visitSignature( Signature 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/package.html b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/package.html deleted file mode 100755 index 472c3999..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/classfile/package.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - -

      -This package contains the classes that describe the structure of a -Java class file and a class file parser. -

      - - diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/AllocationInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/AllocationInstruction.java deleted file mode 100755 index 15ef7d69..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/AllocationInstruction.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Denote family of instructions that allocates space in the heap. - * - * @version $Id: AllocationInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public interface AllocationInstruction { -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ArithmeticInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ArithmeticInstruction.java deleted file mode 100755 index 834117ad..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ArithmeticInstruction.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.Constants; - -/** - * Super class for the family of arithmetic instructions. - * - * @version $Id: ArithmeticInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ArrayInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ArrayInstruction.java deleted file mode 100755 index f43aeb6f..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ArrayInstruction.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Super class for instructions dealing with array access such as IALOAD. - * - * @version $Id: ArrayInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.ExceptionConstants.EXCS_ARRAY_EXCEPTION; - } - - - /** @return type associated with the instruction - */ - public Type getType( ConstantPoolGen cp ) { - switch (opcode) { - case org.apache.bcel5_2_0.Constants.IALOAD: - case org.apache.bcel5_2_0.Constants.IASTORE: - return Type.INT; - case org.apache.bcel5_2_0.Constants.CALOAD: - case org.apache.bcel5_2_0.Constants.CASTORE: - return Type.CHAR; - case org.apache.bcel5_2_0.Constants.BALOAD: - case org.apache.bcel5_2_0.Constants.BASTORE: - return Type.BYTE; - case org.apache.bcel5_2_0.Constants.SALOAD: - case org.apache.bcel5_2_0.Constants.SASTORE: - return Type.SHORT; - case org.apache.bcel5_2_0.Constants.LALOAD: - case org.apache.bcel5_2_0.Constants.LASTORE: - return Type.LONG; - case org.apache.bcel5_2_0.Constants.DALOAD: - case org.apache.bcel5_2_0.Constants.DASTORE: - return Type.DOUBLE; - case org.apache.bcel5_2_0.Constants.FALOAD: - case org.apache.bcel5_2_0.Constants.FASTORE: - return Type.FLOAT; - case org.apache.bcel5_2_0.Constants.AALOAD: - case org.apache.bcel5_2_0.Constants.AASTORE: - return Type.OBJECT; - default: - throw new ClassGenException("Oops: unknown case in switch" + opcode); - } - } -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/BasicType.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/BasicType.java deleted file mode 100755 index 8869f455..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/BasicType.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.Constants; - -/** - * Denotes basic type such as int. - * - * @version $Id: BasicType.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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 a hash code value for the object. - */ - public int hashCode() { - return 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ClassGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ClassGen.java deleted file mode 100755 index 803be1cd..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ClassGen.java +++ /dev/null @@ -1,542 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.classfile.AccessFlags; -import org.apache.bcel5_2_0.classfile.Attribute; -import org.apache.bcel5_2_0.classfile.ConstantPool; -import org.apache.bcel5_2_0.classfile.Field; -import org.apache.bcel5_2_0.classfile.JavaClass; -import org.apache.bcel5_2_0.classfile.Method; -import org.apache.bcel5_2_0.classfile.SourceFile; -import org.apache.bcel5_2_0.util.BCELComparator; - -/** - * Template class for building up a java class. May be initialized with an - * existing java class (file). - * - * @see JavaClass - * @version $Id: ClassGen.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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 List field_vec = new ArrayList(); - private List method_vec = new ArrayList(); - private List attribute_vec = new ArrayList(); - private List interface_vec = new ArrayList(); - private static BCELComparator _cmp = new BCELComparator() { - - public boolean equals( Object o1, Object o2 ) { - ClassGen THIS = (ClassGen) o1; - ClassGen THAT = (ClassGen) o2; - return THIS.getClassName().equals(THAT.getClassName()); - } - - - public int hashCode( Object o ) { - ClassGen THIS = (ClassGen) o; - return THIS.getClassName().hashCode(); - } - }; - - - /** 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 - * @param cp constant pool to use - */ - public ClassGen(String class_name, String super_class_name, String file_name, int access_flags, - String[] interfaces, ConstantPoolGen cp) { - this.class_name = class_name; - this.super_class_name = super_class_name; - this.file_name = file_name; - this.access_flags = access_flags; - this.cp = cp; - // Put everything needed by default into the constant pool and the vectors - if (file_name != null) { - 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]); - } - } - } - - - /** 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, super_class_name, file_name, access_flags, interfaces, - new ConstantPoolGen()); - } - - - /** - * 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_flags 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, "", "()V"))); - il.append(InstructionConstants.RETURN); - MethodGen mg = new MethodGen(access_flags, Type.VOID, Type.NO_ARGS, null, "", - 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() { - return (Method[]) method_vec.toArray(new Method[method_vec.size()]); - } - - - 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() { - return (Field[]) field_vec.toArray(new Field[field_vec.size()]); - } - - - public Attribute[] getAttributes() { - return (Attribute[]) attribute_vec.toArray(new Attribute[attribute_vec.size()]); - } - - - 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; - } - } - - - /** - * @return Comparison strategy object - */ - public static BCELComparator getComparator() { - return _cmp; - } - - - /** - * @param comparator Comparison strategy object - */ - public static void setComparator( BCELComparator comparator ) { - _cmp = comparator; - } - - - /** - * Return value as defined by given BCELComparator strategy. - * By default two ClassGen objects are said to be equal when - * their class names are equal. - * - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals( Object obj ) { - return _cmp.equals(this, obj); - } - - - /** - * Return value as defined by given BCELComparator strategy. - * By default return the hashcode of the class name. - * - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - return _cmp.hashCode(this); - } -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ClassGenException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ClassGenException.java deleted file mode 100755 index 696b31a6..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ClassGenException.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Thrown on internal errors. Extends RuntimeException so it hasn't to be declared - * in the throws clause every time. - * - * @version $Id: ClassGenException.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class ClassGenException extends RuntimeException { - - public ClassGenException() { - super(); - } - - - public ClassGenException(String s) { - super(s); - } -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ClassObserver.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ClassObserver.java deleted file mode 100755 index 37bcb2e5..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ClassObserver.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Implement this interface if you're interested in changes to a ClassGen object - * and register yourself with addObserver(). - * - * @version $Id: ClassObserver.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public interface ClassObserver { - - public void notify( ClassGen clazz ); -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ConstantPushInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ConstantPushInstruction.java deleted file mode 100755 index 91fa45d5..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ConstantPushInstruction.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Denotes a push instruction that produces a literal on the stack - * such as SIPUSH, BIPUSH, ICONST, etc. - * - * @version $Id: ConstantPushInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - - * @see ICONST - * @see SIPUSH - */ -public interface ConstantPushInstruction extends PushInstruction, TypedInstruction { - - public Number getValue(); -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ConversionInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ConversionInstruction.java deleted file mode 100755 index a89347f2..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ConversionInstruction.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.Constants; - -/** - * Super class for the x2y family of instructions. - * - * @version $Id: ConversionInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/EmptyVisitor.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/EmptyVisitor.java deleted file mode 100755 index ff2f111b..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/EmptyVisitor.java +++ /dev/null @@ -1,745 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Supplies empty method bodies to be overridden by subclasses. - * - * @version $Id: EmptyVisitor.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FieldGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FieldGen.java deleted file mode 100755 index 88718658..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FieldGen.java +++ /dev/null @@ -1,358 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.classfile.Attribute; -import org.apache.bcel5_2_0.classfile.Constant; -import org.apache.bcel5_2_0.classfile.ConstantObject; -import org.apache.bcel5_2_0.classfile.ConstantPool; -import org.apache.bcel5_2_0.classfile.ConstantValue; -import org.apache.bcel5_2_0.classfile.Field; -import org.apache.bcel5_2_0.classfile.Utility; -import org.apache.bcel5_2_0.util.BCELComparator; - -/** - * 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: FieldGen.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @see Field - */ -public class FieldGen extends FieldGenOrMethodGen { - - private Object value = null; - private static BCELComparator _cmp = new BCELComparator() { - - public boolean equals( Object o1, Object o2 ) { - FieldGen THIS = (FieldGen) o1; - FieldGen THAT = (FieldGen) o2; - return THIS.getName().equals(THAT.getName()) - && THIS.getSignature().equals(THAT.getSignature()); - } - - - public int hashCode( Object o ) { - FieldGen THIS = (FieldGen) o; - return THIS.getSignature().hashCode() ^ THIS.getName().hashCode(); - } - }; - - - /** - * 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 List 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(); - StringBuilder buf = new StringBuilder(32); - buf.append(access).append(signature).append(" ").append(name); - String value = getInitValue(); - if (value != null) { - buf.append(" = ").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; - } - - - /** - * @return Comparison strategy object - */ - public static BCELComparator getComparator() { - return _cmp; - } - - - /** - * @param comparator Comparison strategy object - */ - public static void setComparator( BCELComparator comparator ) { - _cmp = comparator; - } - - - /** - * Return value as defined by given BCELComparator strategy. - * By default two FieldGen objects are said to be equal when - * their names and signatures are equal. - * - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals( Object obj ) { - return _cmp.equals(this, obj); - } - - - /** - * Return value as defined by given BCELComparator strategy. - * By default return the hashcode of the field's name XOR signature. - * - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - return _cmp.hashCode(this); - } -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FieldGenOrMethodGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FieldGenOrMethodGen.java deleted file mode 100755 index 3fa734ee..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FieldGenOrMethodGen.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.classfile.AccessFlags; -import org.apache.bcel5_2_0.classfile.Attribute; - -/** - * Super class for FieldGen and MethodGen objects, since they have - * some methods in common! - * - * @version $Id: FieldGenOrMethodGen.java 410087 2006-05-29 12:12:19Z tcurdt $ - * @author M. Dahm - */ -public abstract class FieldGenOrMethodGen extends AccessFlags implements NamedAndTyped, Cloneable { - - protected String name; - protected Type type; - protected ConstantPoolGen cp; - private List attribute_vec = new ArrayList(); - - - protected FieldGenOrMethodGen() { - } - - - public void setType( Type type ) { - if (type.getType() == Constants.T_ADDRESS) { - throw new IllegalArgumentException("Type can not be " + 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FieldInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FieldInstruction.java deleted file mode 100755 index d76b99b0..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FieldInstruction.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.classfile.ConstantPool; - -/** - * Super class for the GET/PUTxxx family of instructions. - * - * @version $Id: FieldInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.Constants.OPCODE_NAMES[opcode] + " " - + cp.constantToString(index, org.apache.bcel5_2_0.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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FieldObserver.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FieldObserver.java deleted file mode 100755 index 1200110c..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FieldObserver.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Imnplement this interface if you're interested in changes to a FieldGen object - * and register yourself with addObserver(). - * - * @version $Id: FieldObserver.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public interface FieldObserver { - - public void notify( FieldGen field ); -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FieldOrMethod.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FieldOrMethod.java deleted file mode 100755 index 5ae63226..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/FieldOrMethod.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.classfile.ConstantCP; -import org.apache.bcel5_2_0.classfile.ConstantNameAndType; -import org.apache.bcel5_2_0.classfile.ConstantPool; -import org.apache.bcel5_2_0.classfile.ConstantUtf8; - -/** - * Super class for InvokeInstruction and FieldInstruction, since they have - * some methods in common! - * - * @version $Id: FieldOrMethod.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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 - * @deprecated If the instruction references an array class, - * this method will return "java.lang.Object". - * For code generated by Java 1.5, this answer is - * sometimes wrong (e.g., if the "clone()" method is - * called on an array). A better idea is to use - * the getReferenceType() method, which correctly distinguishes - * between class types and array types. - */ - public String getClassName( ConstantPoolGen cpg ) { - ConstantPool cp = cpg.getConstantPool(); - ConstantCP cmr = (ConstantCP) cp.getConstant(index); - String className = cp.getConstantString(cmr.getClassIndex(), - org.apache.bcel5_2_0.Constants.CONSTANT_Class); - if (className.startsWith("[")) { - // Turn array classes into java.lang.Object. - return "java.lang.Object"; - } - return className.replace('/', '.'); - } - - - /** @return type of the referenced class/interface - * @deprecated If the instruction references an array class, - * the ObjectType returned will be invalid. Use - * getReferenceType() instead. - */ - public ObjectType getClassType( ConstantPoolGen cpg ) { - return new ObjectType(getClassName(cpg)); - } - - - /** - * Return the reference type representing the class, interface, - * or array class referenced by the instruction. - * @param cpg the ConstantPoolGen used to create the instruction - * @return an ObjectType (if the referenced class type is a class - * or interface), or an ArrayType (if the referenced class - * type is an array class) - */ - public ReferenceType getReferenceType( ConstantPoolGen cpg ) { - ConstantPool cp = cpg.getConstantPool(); - ConstantCP cmr = (ConstantCP) cp.getConstant(index); - String className = cp.getConstantString(cmr.getClassIndex(), - org.apache.bcel5_2_0.Constants.CONSTANT_Class); - if (className.startsWith("[")) { - return (ArrayType) Type.getType(className); - } else { - className = className.replace('/', '.'); - return new ObjectType(className); - } - } - - - /** @return type of the referenced class/interface - */ - public ObjectType getLoadClassType( ConstantPoolGen cpg ) { - return getClassType(cpg); - } -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/GOTO.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/GOTO.java deleted file mode 100755 index 83a86a1e..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/GOTO.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.io.DataOutputStream; -import java.io.IOException; - -/** - * GOTO - Branch always (to relative offset, not absolute address) - * - * @version $Id: GOTO.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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.bcel5_2_0.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.bcel5_2_0.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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/GOTO_W.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/GOTO_W.java deleted file mode 100755 index 392d16cf..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/GOTO_W.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.util.ByteSequence; - -/** - * GOTO_W - Branch always (to relative offset, not absolute address) - * - * @version $Id: GOTO_W.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/GotoInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/GotoInstruction.java deleted file mode 100755 index ccd1a3d5..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/GotoInstruction.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Super class for GOTO - * - * @version $Id: GotoInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/INVOKESPECIAL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/INVOKESPECIAL.java deleted file mode 100755 index 1fc3c233..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/INVOKESPECIAL.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.ExceptionConstants; - -/** - * INVOKESPECIAL - Invoke instance method; special handling for superclass, private - * and instance initialization method invocations - * - *
      Stack: ..., objectref, [arg1, [arg2 ...]] -> ...
      - * - * @version $Id: INVOKESPECIAL.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/INVOKESTATIC.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/INVOKESTATIC.java deleted file mode 100755 index fc2b8f8f..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/INVOKESTATIC.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.ExceptionConstants; - -/** - * INVOKESTATIC - Invoke a class (static) method - * - *
      Stack: ..., [arg1, [arg2 ...]] -> ...
      - * - * @version $Id: INVOKESTATIC.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/INVOKEVIRTUAL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/INVOKEVIRTUAL.java deleted file mode 100755 index 9c7c1df5..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/INVOKEVIRTUAL.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.ExceptionConstants; - -/** - * INVOKEVIRTUAL - Invoke instance method; dispatch based on class - * - *
      Stack: ..., objectref, [arg1, [arg2 ...]] -> ...
      - * - * @version $Id: INVOKEVIRTUAL.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IndexedInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IndexedInstruction.java deleted file mode 100755 index 023de3fa..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/IndexedInstruction.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Denote entity that refers to an index, e.g. local variable instructions, - * RET, CPInstruction, etc. - * - * @version $Id: IndexedInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public interface IndexedInstruction { - - public int getIndex(); - - - public void setIndex( int index ); -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/Instruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/Instruction.java deleted file mode 100755 index d3be0bd8..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/Instruction.java +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.Serializable; -import java.util.Locale; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.classfile.ConstantPool; -import org.apache.bcel5_2_0.util.ByteSequence; - -/** - * Abstract super class for all Java byte codes. - * - * @version $Id: Instruction.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public abstract class Instruction implements Cloneable, Serializable { - - protected short length = 1; // Length of instruction in bytes - protected short opcode = -1; // Opcode number - private static InstructionComparator cmp = InstructionComparator.DEFAULT; - - - /** - * 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 - } - - - /** @return name of instruction, i.e., opcode name - */ - public String getName() { - return Constants.OPCODE_NAMES[opcode]; - } - - - /** - * Long output format: - * - * <name of opcode> "["<opcode number>"]" - * "("<length of instruction>")" - * - * @param verbose long/short format switch - * @return mnemonic for instruction - */ - public String toString( boolean verbose ) { - if (verbose) { - return getName() + "[" + opcode + "](" + length + ")"; - } else { - return getName(); - } - } - - - /** - * @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 bytes input stream bytes - * @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(Locale.ENGLISH); - /* 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")) { - 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 ); - - - /** Get Comparator object used in the equals() method to determine - * equality of instructions. - * - * @return currently used comparator for equals() - */ - public static InstructionComparator getComparator() { - return cmp; - } - - - /** Set comparator to be used for equals(). - */ - public static void setComparator( InstructionComparator c ) { - cmp = c; - } - - - /** Check for equality, delegated to comparator - * @return true if that is an Instruction and has the same opcode - */ - public boolean equals( Object that ) { - return (that instanceof Instruction) ? cmp.equals(this, (Instruction) that) : false; - } -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InstructionFactory.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InstructionFactory.java deleted file mode 100755 index d436e609..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InstructionFactory.java +++ /dev/null @@ -1,743 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.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: InstructionFactory.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @see Constants - */ -public class InstructionFactory implements InstructionConstants, java.io.Serializable { - - 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++) { - 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; - } - - - /** Uses PUSH to push a constant value onto the stack. - * @param value must be of type Number, Boolean, Character or String - */ - public Instruction createConstant( Object value ) { - PUSH push; - if (value instanceof Number) { - push = new PUSH(cp, (Number) value); - } else if (value instanceof String) { - push = new PUSH(cp, (String) value); - } else if (value instanceof Boolean) { - push = new PUSH(cp, (Boolean) value); - } else if (value instanceof Character) { - push = new PUSH(cp, (Character) value); - } else { - throw new ClassGenException("Illegal type: " + value.getClass()); - } - return push.getInstruction(); - } - - private static class MethodObject { - - Type[] arg_types; - Type result_type; - 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 INSTANCEOF createInstanceOf( ReferenceType t ) { - if (t instanceof ArrayType) { - return new INSTANCEOF(cp.addArrayClass((ArrayType) t)); - } else { - return new INSTANCEOF(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. - * @return an instruction that creates the corresponding array at runtime, i.e. is an AllocationInstruction - */ - public Instruction 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 compound 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InstructionList.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InstructionList.java deleted file mode 100755 index ca2ebdc9..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InstructionList.java +++ /dev/null @@ -1,1266 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.classfile.Constant; -import org.apache.bcel5_2_0.util.ByteSequence; - -/** - * This class is a container for a list of Instruction objects. Instructions can - * be appended, inserted, moved, deleted, etc.. Instructions are being - * wrapped into InstructionHandles 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 getByteCode. - * - * @version $Id: InstructionList.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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) { - return ihs[i]; - } else if (target < j) { - r = i - 1; - } else { - 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) { - 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) { - 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) { - 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 first appended instruction - */ - public InstructionHandle append( InstructionHandle ih, InstructionList il ) { - if (il == null) { - throw new ClassGenException("Appending null InstructionList"); - } - if (il.isEmpty()) { - return ih; - } - InstructionHandle next = ih.next, ret = il.start; - ih.next = il.start; - il.start.prev = ih; - il.end.next = next; - if (next != null) { - 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 first appended instruction - */ - public InstructionHandle append( Instruction i, InstructionList il ) { - InstructionHandle ih; - if ((ih = findInstruction2(i)) == null) { - 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 first appended instruction - */ - public InstructionHandle append( InstructionList il ) { - if (il == null) { - throw new ClassGenException("Appending null InstructionList"); - } - if (il.isEmpty()) { - 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 first 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 first 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 ih 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()) { - return ih; - } - InstructionHandle prev = ih.prev, ret = il.start; - ih.prev = il.end; - il.end.next = ih; - il.start.prev = prev; - if (prev != null) { - 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.
      - * 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) { - throw new ClassGenException("Invalid range: From " + start + " to " + end); - } else if (ih == target) { - 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 { - this.start = next; - } - if (next != null) { - next.prev = prev; - } else { - this.end = prev; - } - start.prev = end.next = null; - // Step 3: append after target - if (target == null) { // append to start of list - if (this.start != null) { - this.start.prev = end; - } - 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; - } else { - this.end = 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; - List target_vec = new ArrayList(); - for (InstructionHandle ih = first; ih != null; ih = ih.next) { - ih.getInstruction().dispose(); // e.g. BranchInstructions release their targets - } - StringBuilder buf = new StringBuilder("{ "); - 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()); - List instructions = new ArrayList(); - try { - while (bytes.available() > 0) { - instructions.add(Instruction.readInstruction(bytes)); - } - } catch (IOException e) { - throw new ClassGenException(e.toString()); - } - return (Instruction[]) instructions.toArray(new Instruction[instructions.size()]); - } - - - public String toString() { - return toString(true); - } - - - /** - * @param verbose toggle output format - * @return String containing all instructions in this list. - */ - public String toString( boolean verbose ) { - StringBuilder buf = new StringBuilder(); - for (InstructionHandle ih = start; ih != null; ih = ih.next) { - buf.append(ih.toString(verbose)).append("\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() { - Map 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 - * MethodGen.getMethod(). - */ - 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++) { - 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 List 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InstructionListObserver.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InstructionListObserver.java deleted file mode 100755 index bdbb7e03..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InstructionListObserver.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Implement this interface if you're interested in changes to an InstructionList object - * and register yourself with addObserver(). - * - * @version $Id: InstructionListObserver.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public interface InstructionListObserver { - - public void notify( InstructionList list ); -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InstructionTargeter.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InstructionTargeter.java deleted file mode 100755 index 0a817cfc..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InstructionTargeter.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Denote that a class targets InstructionHandles within an InstructionList. Namely - * the following implementers: - * - * @see BranchHandle - * @see LocalVariableGen - * @see CodeExceptionGen - * @version $Id: InstructionTargeter.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public interface InstructionTargeter { - - public boolean containsTarget( InstructionHandle ih ); - - - public void updateTarget( InstructionHandle old_ih, InstructionHandle new_ih ); -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InvokeInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InvokeInstruction.java deleted file mode 100755 index 32d7d17e..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/InvokeInstruction.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.util.StringTokenizer; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.classfile.Constant; -import org.apache.bcel5_2_0.classfile.ConstantPool; - -/** - * Super class for the INVOKExxx family of instructions. - * - * @version $Id: InvokeInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/JSR.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/JSR.java deleted file mode 100755 index 4e483bf0..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/JSR.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.io.DataOutputStream; -import java.io.IOException; - -/** - * JSR - Jump to subroutine - * - * @version $Id: JSR.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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.bcel5_2_0.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.bcel5_2_0.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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/JSR_W.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/JSR_W.java deleted file mode 100755 index 7913375d..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/JSR_W.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.util.ByteSequence; - -/** - * JSR_W - Jump to subroutine - * - * @version $Id: JSR_W.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LDC.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LDC.java deleted file mode 100755 index 88bd44ff..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LDC.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.util.ByteSequence; - -/** - * LDC - Push item from constant pool. - * - *
      Stack: ... -> ..., item
      - * - * @version $Id: LDC.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.Constants.LDC_W, index); - setSize(); - } - - - // Adjust to proper size - protected final void setSize() { - if (index <= org.apache.bcel5_2_0.Constants.MAX_BYTE) { // Fits in one byte? - opcode = org.apache.bcel5_2_0.Constants.LDC; - length = 2; - } else { - opcode = org.apache.bcel5_2_0.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 { - 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.bcel5_2_0.classfile.Constant c = cpg.getConstantPool().getConstant(index); - switch (c.getTag()) { - case org.apache.bcel5_2_0.Constants.CONSTANT_String: - int i = ((org.apache.bcel5_2_0.classfile.ConstantString) c).getStringIndex(); - c = cpg.getConstantPool().getConstant(i); - return ((org.apache.bcel5_2_0.classfile.ConstantUtf8) c).getBytes(); - case org.apache.bcel5_2_0.Constants.CONSTANT_Float: - return new Float(((org.apache.bcel5_2_0.classfile.ConstantFloat) c).getBytes()); - case org.apache.bcel5_2_0.Constants.CONSTANT_Integer: - return new Integer(((org.apache.bcel5_2_0.classfile.ConstantInteger) c).getBytes()); - case org.apache.bcel5_2_0.Constants.CONSTANT_Class: - return c; - 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.bcel5_2_0.Constants.CONSTANT_String: - return Type.STRING; - case org.apache.bcel5_2_0.Constants.CONSTANT_Float: - return Type.FLOAT; - case org.apache.bcel5_2_0.Constants.CONSTANT_Integer: - return Type.INT; - case org.apache.bcel5_2_0.Constants.CONSTANT_Class: - return Type.CLASS; - default: // Never reached - throw new RuntimeException("Unknown or invalid constant type at " + index); - } - } - - - public Class[] getExceptions() { - return org.apache.bcel5_2_0.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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LDC2_W.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LDC2_W.java deleted file mode 100755 index 8d670295..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LDC2_W.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * LDC2_W - Push long or double from constant pool - * - *
      Stack: ... -> ..., item.word1, item.word2
      - * - * @version $Id: LDC2_W.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.Constants.LDC2_W, index); - } - - - public Type getType( ConstantPoolGen cpg ) { - switch (cpg.getConstantPool().getConstant(index).getTag()) { - case org.apache.bcel5_2_0.Constants.CONSTANT_Long: - return Type.LONG; - case org.apache.bcel5_2_0.Constants.CONSTANT_Double: - return Type.DOUBLE; - default: // Never reached - throw new RuntimeException("Unknown constant type " + opcode); - } - } - - - public Number getValue( ConstantPoolGen cpg ) { - org.apache.bcel5_2_0.classfile.Constant c = cpg.getConstantPool().getConstant(index); - switch (c.getTag()) { - case org.apache.bcel5_2_0.Constants.CONSTANT_Long: - return new Long(((org.apache.bcel5_2_0.classfile.ConstantLong) c).getBytes()); - case org.apache.bcel5_2_0.Constants.CONSTANT_Double: - return new Double(((org.apache.bcel5_2_0.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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LDC_W.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LDC_W.java deleted file mode 100755 index 40402bce..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LDC_W.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.io.IOException; - -import org.apache.bcel5_2_0.util.ByteSequence; - -/** - * LDC_W - Push item from constant pool (wide index) - * - *
      Stack: ... -> ..., item.word1, item.word2
      - * - * @version $Id: LDC_W.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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()); - // Override just in case it has been changed - opcode = org.apache.bcel5_2_0.Constants.LDC_W; - length = 3; - } -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LLOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LLOAD.java deleted file mode 100755 index 0f7732b3..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LLOAD.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * LLOAD - Load long from local variable - *
      Stack ... -> ..., result.word1, result.word2
      - * - * @version $Id: LLOAD.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.Constants.LLOAD, org.apache.bcel5_2_0.Constants.LLOAD_0); - } - - - public LLOAD(int n) { - super(org.apache.bcel5_2_0.Constants.LLOAD, org.apache.bcel5_2_0.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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LOOKUPSWITCH.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LOOKUPSWITCH.java deleted file mode 100755 index d0eccdd5..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LOOKUPSWITCH.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.util.ByteSequence; - -/** - * LOOKUPSWITCH - Switch with unordered set of values - * - * @version $Id: LOOKUPSWITCH.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 defaultTarget) { - super(org.apache.bcel5_2_0.Constants.LOOKUPSWITCH, match, targets, defaultTarget); - 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LSTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LSTORE.java deleted file mode 100755 index f1e770d1..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LSTORE.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * LSTORE - Store long into local variable - *
      Stack: ..., value.word1, value.word2 -> ... 
      - * - * @version $Id: LSTORE.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.Constants.LSTORE, org.apache.bcel5_2_0.Constants.LSTORE_0); - } - - - public LSTORE(int n) { - super(org.apache.bcel5_2_0.Constants.LSTORE, org.apache.bcel5_2_0.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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LocalVariableGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LocalVariableGen.java deleted file mode 100755 index 2c93a342..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LocalVariableGen.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.classfile.LocalVariable; - -/** - * 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: LocalVariableGen.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @see LocalVariable - * @see MethodGen - */ -public class LocalVariableGen implements InstructionTargeter, NamedAndTyped, Cloneable, - java.io.Serializable { - - 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. - * - * Note that for local variables whose scope end at the last - * instruction of the method's code, the JVM specification is ambiguous: - * both a start_pc+length ending at the last instruction and - * start_pc+length ending at first index beyond the end of the code are - * valid. - * - * @param cp constant pool - */ - public LocalVariable getLocalVariable( ConstantPoolGen cp ) { - int start_pc = start.getPosition(); - int length = end.getPosition() - start_pc; - if (length > 0) { - length += end.getInstruction().getLength(); - } - 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); - } - - - /** @return a hash code value for the object. - */ - public int hashCode() { - //If the user changes the name or type, problems with the targeter hashmap will occur - int hc = index ^ name.hashCode() ^ type.hashCode(); - return hc; - } - - - /** - * 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LocalVariableInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LocalVariableInstruction.java deleted file mode 100755 index f63c604a..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/LocalVariableInstruction.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.util.ByteSequence; - -/** - * Abstract super class for instructions dealing with local variables. - * - * @version $Id: LocalVariableInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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()) { - 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: - * - * <name of opcode> "["<opcode number>"]" - * "("<length of instruction>")" "<"< local variable index>">" - * - * @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()) { - 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/MethodGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/MethodGen.java deleted file mode 100755 index b5e534c4..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/MethodGen.java +++ /dev/null @@ -1,1087 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Stack; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.classfile.Attribute; -import org.apache.bcel5_2_0.classfile.Code; -import org.apache.bcel5_2_0.classfile.CodeException; -import org.apache.bcel5_2_0.classfile.ExceptionTable; -import org.apache.bcel5_2_0.classfile.LineNumber; -import org.apache.bcel5_2_0.classfile.LineNumberTable; -import org.apache.bcel5_2_0.classfile.LocalVariable; -import org.apache.bcel5_2_0.classfile.LocalVariableTable; -import org.apache.bcel5_2_0.classfile.Method; -import org.apache.bcel5_2_0.classfile.Utility; -import org.apache.bcel5_2_0.util.BCELComparator; - -/** - * 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: MethodGen.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @author Patrick C. Beard [setMaxStack()] - * @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 List variable_vec = new ArrayList(); - private List line_number_vec = new ArrayList(); - private List exception_vec = new ArrayList(); - private List throws_vec = new ArrayList(); - private List code_attrs_vec = new ArrayList(); - private static BCELComparator _cmp = new BCELComparator() { - - public boolean equals( Object o1, Object o2 ) { - MethodGen THIS = (MethodGen) o1; - MethodGen THAT = (MethodGen) o2; - return THIS.getName().equals(THAT.getName()) - && THIS.getSignature().equals(THAT.getSignature()); - } - - - public int hashCode( Object o ) { - MethodGen THIS = (MethodGen) o; - return THIS.getSignature().hashCode() ^ THIS.getName().hashCode(); - } - }; - - - /** - * 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); - boolean abstract_ = isAbstract() || isNative(); - InstructionHandle start = null; - InstructionHandle end = null; - if (!abstract_) { - start = il.getStart(); - 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; - for (int i = 0; i < size; i++) { - if (Type.VOID == arg_types[i]) { - throw new ClassGenException("'void' is an illegal argument type for a method"); - } - } - 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); - } - if (!abstract_) { - 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]; - InstructionHandle ih = il.findHandle(l.getStartPC()); - if (ih != null) { - addLineNumber(ih, l.getLineNumber()); - } - } - } else if (a instanceof LocalVariableTable) { - LocalVariable[] lv = ((LocalVariableTable) a).getLocalVariableTable(); - removeLocalVariables(); - 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 (null == start) { - start = il.getStart(); - } - if (null == end) { - 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(); - if (t != Constants.T_ADDRESS) { - 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) { - variable_vec.set(i, l); - } else { - variable_vec.add(l); - } - return l; - } else { - throw new IllegalArgumentException("Can not use " + type - + " as type for local variable"); - } - } - - - /** - * 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 class type 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() && !isNative()) { - // Remove any stale code attribute - Attribute[] attributes = getAttributes(); - for (int i = 0; i < attributes.length; i++) { - Attribute a = attributes[i]; - if (a instanceof Code) { - removeAttribute(a); - } - } - 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. - */ - 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 List 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)); - StringBuilder buf = new StringBuilder(signature); - if (throws_vec.size() > 0) { - for (Iterator e = throws_vec.iterator(); e.hasNext();) { - buf.append("\n\t\tthrows ").append(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; - } - - - /** - * @return Comparison strategy object - */ - public static BCELComparator getComparator() { - return _cmp; - } - - - /** - * @param comparator Comparison strategy object - */ - public static void setComparator( BCELComparator comparator ) { - _cmp = comparator; - } - - - /** - * Return value as defined by given BCELComparator strategy. - * By default two MethodGen objects are said to be equal when - * their names and signatures are equal. - * - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals( Object obj ) { - return _cmp.equals(this, obj); - } - - - /** - * Return value as defined by given BCELComparator strategy. - * By default return the hashcode of the method's name XOR signature. - * - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - return _cmp.hashCode(this); - } -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/MethodObserver.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/MethodObserver.java deleted file mode 100755 index c224727b..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/MethodObserver.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Implement this interface if you're interested in changes to a MethodGen object - * and register yourself with addObserver(). - * - * @version $Id: MethodObserver.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public interface MethodObserver { - - public void notify( MethodGen method ); -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/NEW.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/NEW.java deleted file mode 100755 index 375ac406..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/NEW.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.ExceptionConstants; - -/** - * NEW - Create new object - *
      Stack: ... -> ..., objectref
      - * - * @version $Id: NEW.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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.bcel5_2_0.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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/NamedAndTyped.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/NamedAndTyped.java deleted file mode 100755 index 58b40af5..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/NamedAndTyped.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Denote entity that has both name and type. This is true for local variables, - * methods and fields. - * - * @version $Id: NamedAndTyped.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public interface NamedAndTyped { - - public String getName(); - - - public Type getType(); - - - public void setName( String name ); - - - public void setType( Type type ); -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/PUTFIELD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/PUTFIELD.java deleted file mode 100755 index 02ff3c18..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/PUTFIELD.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.ExceptionConstants; - -/** - * PUTFIELD - Put field in object - *
      Stack: ..., objectref, value -> ...
      - * OR - *
      Stack: ..., objectref, value.word1, value.word2 -> ...
      - * - * @version $Id: PUTFIELD.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class PUTFIELD extends FieldInstruction implements PopInstruction, 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.visitStackConsumer(this); - v.visitPopInstruction(this); - v.visitTypedInstruction(this); - v.visitLoadClass(this); - v.visitCPInstruction(this); - v.visitFieldOrMethod(this); - v.visitFieldInstruction(this); - v.visitPUTFIELD(this); - } -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/PopInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/PopInstruction.java deleted file mode 100755 index 46484a81..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/PopInstruction.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Denotes an unparameterized instruction to pop a value on top from the stack, - * such as ISTORE, POP, PUTSTATIC. - * - * @version $Id: PopInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @see ISTORE - * @see POP - */ -public interface PopInstruction extends StackConsumer { -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ReturnInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ReturnInstruction.java deleted file mode 100755 index bbdc89ac..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/ReturnInstruction.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.ExceptionConstants; - -/** - * Super class for the xRETURN family of instructions. - * - * @version $Id: ReturnInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/Select.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/Select.java deleted file mode 100755 index 6e43d274..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/Select.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.util.ByteSequence; - -/** - * Select - Abstract super class for LOOKUPSWITCH and TABLESWITCH instructions. - * - *

      We use our super's target property as the default target. - * - * @version $Id: Select.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 defaultTarget default instruction target - */ - Select(short opcode, int[] match, InstructionHandle[] targets, InstructionHandle defaultTarget) { - super(opcode, defaultTarget); - 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++) { - 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++) { - bytes.readByte(); - } - // Default branch target common for both cases (TABLESWITCH, LOOKUPSWITCH) - index = bytes.readInt(); - } - - - /** - * @return mnemonic for instruction - */ - public String toString( boolean verbose ) { - StringBuilder buf = new StringBuilder(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("(").append(match[i]).append(", ").append(s).append(" = {").append( - indices[i]).append("})"); - } - } 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; - } - - - protected Object clone() throws CloneNotSupportedException { - Select copy = (Select) super.clone(); - copy.match = (int[]) match.clone(); - copy.indices = (int[]) indices.clone(); - copy.targets = (InstructionHandle[]) targets.clone(); - return copy; - } - - - /** - * 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/StackConsumer.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/StackConsumer.java deleted file mode 100755 index db487703..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/StackConsumer.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Denote an instruction that may consume a value from the stack. - * - * @version $Id: StackConsumer.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public interface StackConsumer { - - /** @return how many words are consumed from stack - */ - public int consumeStack( ConstantPoolGen cpg ); -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/StackInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/StackInstruction.java deleted file mode 100755 index 393a11fe..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/StackInstruction.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Super class for stack operations like DUP and POP. - * - * @version $Id: StackInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/StackProducer.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/StackProducer.java deleted file mode 100755 index 5e549c16..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/StackProducer.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Denote an instruction that may produce a value on top of the stack - * (this excludes DUP_X1, e.g.) - * - * @version $Id: StackProducer.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public interface StackProducer { - - /** @return how many words are produced on stack - */ - public int produceStack( ConstantPoolGen cpg ); -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/TABLESWITCH.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/TABLESWITCH.java deleted file mode 100755 index 8db1620e..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/TABLESWITCH.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.bcel5_2_0.util.ByteSequence; - -/** - * TABLESWITCH - Switch within given range of values, i.e., low..high - * - * @version $Id: TABLESWITCH.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 defaultTarget default branch - */ - public TABLESWITCH(int[] match, InstructionHandle[] targets, InstructionHandle defaultTarget) { - super(org.apache.bcel5_2_0.Constants.TABLESWITCH, match, targets, defaultTarget); - 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++) { - 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/TargetLostException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/TargetLostException.java deleted file mode 100755 index 0d737694..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/TargetLostException.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * 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: - * - *

      - *     ...
      - *     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);
      - *       }
      - *     }
      - * 
      - * - * @see InstructionHandle - * @see InstructionList - * @see InstructionTargeter - * @version $Id: TargetLostException.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/Type.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/Type.java deleted file mode 100755 index 0002af56..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/Type.java +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.classfile.ClassFormatException; -import org.apache.bcel5_2_0.classfile.Utility; - -/** - * 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: Type.java 393344 2006-04-12 00:38:34Z tcurdt $ - * @author M. Dahm - */ -public abstract class Type implements java.io.Serializable { - - 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 CLASS = new ObjectType("java.lang.Class"); - 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, "") { - }; - - - protected Type(byte t, String s) { - type = t; - signature = s; - } - - - /** - * @return hashcode of Type - */ - public int hashCode() { - return type ^ signature.hashCode(); - } - - - /** - * @return whether the Types are equal - */ - public boolean equals(Object o) { - if (o instanceof Type) { - Type t = (Type)o; - return (type == t.type) && signature.equals(t.signature); - } - return false; - } - - - /** - * @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 ) { - StringBuilder buf = new StringBuilder("("); - 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 ThreadLocal consumed_chars = new ThreadLocal() { - - protected Object initialValue() { - return new Integer(0); - } - };//int consumed_chars=0; // Remember position in string, see getArgumentTypes - - - private static int unwrap( ThreadLocal tl ) { - return ((Integer) tl.get()).intValue(); - } - - - private static void wrap( ThreadLocal tl, int value ) { - tl.set(new Integer(value)); - } - - - /** - * 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) { - //corrected concurrent private static field acess - wrap(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)); - //corrected concurrent private static field acess - // consumed_chars += dim; // update counter - is replaced by - int _temp = unwrap(consumed_chars) + dim; - wrap(consumed_chars, _temp); - return new ArrayType(t, dim); - } else { // type == T_REFERENCE - int index = signature.indexOf(';'); // Look for closing `;' - if (index < 0) { - throw new ClassFormatException("Invalid signature: " + signature); - } - //corrected concurrent private static field acess - wrap(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 ClassFormatException("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 ) { - List vec = new ArrayList(); - int index; - Type[] types; - try { // Read all declarations between for `(' and `)' - if (signature.charAt(0) != '(') { - throw new ClassFormatException("Invalid method signature: " + signature); - } - index = 1; // current string position - while (signature.charAt(index) != ')') { - vec.add(getType(signature.substring(index))); - //corrected concurrent private static field acess - index += unwrap(consumed_chars); // update position - } - } catch (StringIndexOutOfBoundsException e) { // Should never occur - throw new ClassFormatException("Invalid method signature: " + signature); - } - types = new Type[vec.size()]; - vec.toArray(types); - return types; - } - - - /** Convert runtime java.lang.Class to BCEL Type object. - * @param cl Java class - * @return corresponding Type object - */ - public static Type getType( java.lang.Class cl ) { - if (cl == null) { - throw new IllegalArgumentException("Class must not be null"); - } - /* That's an amzingly easy case, because getName() returns - * the signature. That's what we would have liked anyway. - */ - if (cl.isArray()) { - return getType(cl.getName()); - } else if (cl.isPrimitive()) { - if (cl == Integer.TYPE) { - return INT; - } else if (cl == Void.TYPE) { - return VOID; - } else if (cl == Double.TYPE) { - return DOUBLE; - } else if (cl == Float.TYPE) { - return FLOAT; - } else if (cl == Boolean.TYPE) { - return BOOLEAN; - } else if (cl == Byte.TYPE) { - return BYTE; - } else if (cl == Short.TYPE) { - return SHORT; - } else if (cl == Byte.TYPE) { - return BYTE; - } else if (cl == Long.TYPE) { - return LONG; - } else if (cl == Character.TYPE) { - return CHAR; - } else { - throw new IllegalStateException("Ooops, what primitive type is " + cl); - } - } else { // "Real" class - return new ObjectType(cl.getName()); - } - } - - - /** - * Convert runtime java.lang.Class[] to BCEL Type objects. - * @param classes an array of runtime class objects - * @return array of corresponding Type objects - */ - public static Type[] getTypes( java.lang.Class[] classes ) { - Type[] ret = new Type[classes.length]; - for (int i = 0; i < ret.length; i++) { - ret[i] = getType(classes[i]); - } - return ret; - } - - - public static String getSignature( java.lang.reflect.Method meth ) { - StringBuilder sb = new StringBuilder("("); - Class[] params = meth.getParameterTypes(); // avoid clone - for (int j = 0; j < params.length; j++) { - sb.append(getType(params[j]).getSignature()); - } - sb.append(")"); - sb.append(getType(meth.getReturnType()).getSignature()); - return sb.toString(); - } -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/TypedInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/TypedInstruction.java deleted file mode 100755 index 9ae53842..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/TypedInstruction.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Get the type associated with an instruction, int for ILOAD, or the type - * of the field of a PUTFIELD instruction, e.g.. - * - * @version $Id: TypedInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public interface TypedInstruction { - - public Type getType( ConstantPoolGen cpg ); -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/UnconditionalBranch.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/UnconditionalBranch.java deleted file mode 100755 index a0f516e6..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/UnconditionalBranch.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Denotes an instruction to perform an unconditional branch, i.e., GOTO, JSR. - * - * @version $Id: UnconditionalBranch.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - - * @see GOTO - * @see JSR - */ -public interface UnconditionalBranch { -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/VariableLengthInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/VariableLengthInstruction.java deleted file mode 100755 index 4d4199e5..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/VariableLengthInstruction.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * Denotes an instruction to be a variable length instruction, such as - * GOTO, JSR, LOOKUPSWITCH and TABLESWITCH. - * - * @version $Id: VariableLengthInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - - * @see GOTO - * @see JSR - * @see LOOKUPSWITCH - * @see TABLESWITCH - */ -public interface VariableLengthInstruction { -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/Visitor.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/Visitor.java deleted file mode 100755 index 896b9267..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/Visitor.java +++ /dev/null @@ -1,568 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.generic; - -/** - * 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: Visitor.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/package.html b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/package.html deleted file mode 100755 index 201d573f..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/generic/package.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - -

      -This package contains the "generic" part of the -Byte Code Engineering -Library, i.e., classes to dynamically modify class objects and -byte code instructions. -

      - - diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/package.html b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/package.html deleted file mode 100755 index aaded505..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/package.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - -

      -This package contains basic classes for the -Byte Code Engineering Library - and constants defined by the - - JVM specification. -

      - - diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/BCELFactory.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/BCELFactory.java deleted file mode 100755 index 5dfddca2..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/BCELFactory.java +++ /dev/null @@ -1,327 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.util; - -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Map; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.classfile.Utility; -import org.apache.bcel5_2_0.generic.AllocationInstruction; -import org.apache.bcel5_2_0.generic.ArrayInstruction; -import org.apache.bcel5_2_0.generic.ArrayType; -import org.apache.bcel5_2_0.generic.BranchHandle; -import org.apache.bcel5_2_0.generic.BranchInstruction; -import org.apache.bcel5_2_0.generic.CHECKCAST; -import org.apache.bcel5_2_0.generic.CPInstruction; -import org.apache.bcel5_2_0.generic.CodeExceptionGen; -import org.apache.bcel5_2_0.generic.ConstantPoolGen; -import org.apache.bcel5_2_0.generic.ConstantPushInstruction; -import org.apache.bcel5_2_0.generic.EmptyVisitor; -import org.apache.bcel5_2_0.generic.FieldInstruction; -import org.apache.bcel5_2_0.generic.IINC; -import org.apache.bcel5_2_0.generic.INSTANCEOF; -import org.apache.bcel5_2_0.generic.Instruction; -import org.apache.bcel5_2_0.generic.InstructionConstants; -import org.apache.bcel5_2_0.generic.InstructionHandle; -import org.apache.bcel5_2_0.generic.InvokeInstruction; -import org.apache.bcel5_2_0.generic.LDC; -import org.apache.bcel5_2_0.generic.LDC2_W; -import org.apache.bcel5_2_0.generic.LocalVariableInstruction; -import org.apache.bcel5_2_0.generic.MULTIANEWARRAY; -import org.apache.bcel5_2_0.generic.MethodGen; -import org.apache.bcel5_2_0.generic.NEWARRAY; -import org.apache.bcel5_2_0.generic.ObjectType; -import org.apache.bcel5_2_0.generic.RET; -import org.apache.bcel5_2_0.generic.ReturnInstruction; -import org.apache.bcel5_2_0.generic.Select; -import org.apache.bcel5_2_0.generic.Type; - -/** - * Factory creates il.append() statements, and sets instruction targets. - * A helper class for BCELifier. - * - * @see BCELifier - * @version $Id: BCELFactory.java 410087 2006-05-29 12:12:19Z tcurdt $ - * @author M. Dahm - */ -class BCELFactory extends EmptyVisitor { - - private MethodGen _mg; - private PrintWriter _out; - private ConstantPoolGen _cp; - - - BCELFactory(MethodGen mg, PrintWriter out) { - _mg = mg; - _cp = mg.getConstantPool(); - _out = out; - } - - private Map branch_map = new HashMap(); // Map - - - public void start() { - if (!_mg.isAbstract() && !_mg.isNative()) { - for (InstructionHandle ih = _mg.getInstructionList().getStart(); ih != null; ih = ih - .getNext()) { - Instruction i = ih.getInstruction(); - if (i instanceof BranchInstruction) { - branch_map.put(i, ih); // memorize container - } - if (ih.hasTargeters()) { - if (i instanceof BranchInstruction) { - _out.println(" InstructionHandle ih_" + ih.getPosition() + ";"); - } else { - _out.print(" InstructionHandle ih_" + ih.getPosition() + " = "); - } - } else { - _out.print(" "); - } - if (!visitInstruction(i)) { - i.accept(this); - } - } - updateBranchTargets(); - updateExceptionHandlers(); - } - } - - - private boolean visitInstruction( Instruction i ) { - short opcode = i.getOpcode(); - if ((InstructionConstants.INSTRUCTIONS[opcode] != null) - && !(i instanceof ConstantPushInstruction) && !(i instanceof ReturnInstruction)) { // Handled below - _out.println("il.append(InstructionConstants." - + i.getName().toUpperCase(Locale.ENGLISH) + ");"); - return true; - } - return false; - } - - - public void visitLocalVariableInstruction( LocalVariableInstruction i ) { - short opcode = i.getOpcode(); - Type type = i.getType(_cp); - if (opcode == Constants.IINC) { - _out.println("il.append(new IINC(" + i.getIndex() + ", " + ((IINC) i).getIncrement() - + "));"); - } else { - String kind = (opcode < Constants.ISTORE) ? "Load" : "Store"; - _out.println("il.append(_factory.create" + kind + "(" + BCELifier.printType(type) - + ", " + i.getIndex() + "));"); - } - } - - - public void visitArrayInstruction( ArrayInstruction i ) { - short opcode = i.getOpcode(); - Type type = i.getType(_cp); - String kind = (opcode < Constants.IASTORE) ? "Load" : "Store"; - _out.println("il.append(_factory.createArray" + kind + "(" + BCELifier.printType(type) - + "));"); - } - - - public void visitFieldInstruction( FieldInstruction i ) { - short opcode = i.getOpcode(); - String class_name = i.getClassName(_cp); - String field_name = i.getFieldName(_cp); - Type type = i.getFieldType(_cp); - _out.println("il.append(_factory.createFieldAccess(\"" + class_name + "\", \"" + field_name - + "\", " + BCELifier.printType(type) + ", " + "Constants." - + Constants.OPCODE_NAMES[opcode].toUpperCase(Locale.ENGLISH) + "));"); - } - - - public void visitInvokeInstruction( InvokeInstruction i ) { - short opcode = i.getOpcode(); - String class_name = i.getClassName(_cp); - String method_name = i.getMethodName(_cp); - Type type = i.getReturnType(_cp); - Type[] arg_types = i.getArgumentTypes(_cp); - _out.println("il.append(_factory.createInvoke(\"" + class_name + "\", \"" + method_name - + "\", " + BCELifier.printType(type) + ", " - + BCELifier.printArgumentTypes(arg_types) + ", " + "Constants." - + Constants.OPCODE_NAMES[opcode].toUpperCase(Locale.ENGLISH) + "));"); - } - - - public void visitAllocationInstruction( AllocationInstruction i ) { - Type type; - if (i instanceof CPInstruction) { - type = ((CPInstruction) i).getType(_cp); - } else { - type = ((NEWARRAY) i).getType(); - } - short opcode = ((Instruction) i).getOpcode(); - int dim = 1; - switch (opcode) { - case Constants.NEW: - _out.println("il.append(_factory.createNew(\"" + ((ObjectType) type).getClassName() - + "\"));"); - break; - case Constants.MULTIANEWARRAY: - dim = ((MULTIANEWARRAY) i).getDimensions(); - case Constants.ANEWARRAY: - case Constants.NEWARRAY: - if (type instanceof ArrayType) { - type = ((ArrayType) type).getBasicType(); - } - _out.println("il.append(_factory.createNewArray(" + BCELifier.printType(type) - + ", (short) " + dim + "));"); - break; - default: - throw new RuntimeException("Oops: " + opcode); - } - } - - - private void createConstant( Object value ) { - String embed = value.toString(); - if (value instanceof String) { - embed = '"' + Utility.convertString(value.toString()) + '"'; - } else if (value instanceof Character) { - embed = "(char)0x" + Integer.toHexString(((Character) value).charValue()); - } - _out.println("il.append(new PUSH(_cp, " + embed + "));"); - } - - - public void visitLDC( LDC i ) { - createConstant(i.getValue(_cp)); - } - - - public void visitLDC2_W( LDC2_W i ) { - createConstant(i.getValue(_cp)); - } - - - public void visitConstantPushInstruction( ConstantPushInstruction i ) { - createConstant(i.getValue()); - } - - - public void visitINSTANCEOF( INSTANCEOF i ) { - Type type = i.getType(_cp); - _out.println("il.append(new INSTANCEOF(_cp.addClass(" + BCELifier.printType(type) + ")));"); - } - - - public void visitCHECKCAST( CHECKCAST i ) { - Type type = i.getType(_cp); - _out.println("il.append(_factory.createCheckCast(" + BCELifier.printType(type) + "));"); - } - - - public void visitReturnInstruction( ReturnInstruction i ) { - Type type = i.getType(_cp); - _out.println("il.append(_factory.createReturn(" + BCELifier.printType(type) + "));"); - } - - // Memorize BranchInstructions that need an update - private List branches = new ArrayList(); - - - public void visitBranchInstruction( BranchInstruction bi ) { - BranchHandle bh = (BranchHandle) branch_map.get(bi); - int pos = bh.getPosition(); - String name = bi.getName() + "_" + pos; - if (bi instanceof Select) { - Select s = (Select) bi; - branches.add(bi); - StringBuilder args = new StringBuilder("new int[] { "); - int[] matchs = s.getMatchs(); - for (int i = 0; i < matchs.length; i++) { - args.append(matchs[i]); - if (i < matchs.length - 1) { - args.append(", "); - } - } - args.append(" }"); - _out.print("Select " + name + " = new " + bi.getName().toUpperCase(Locale.ENGLISH) - + "(" + args + ", new InstructionHandle[] { "); - for (int i = 0; i < matchs.length; i++) { - _out.print("null"); - if (i < matchs.length - 1) { - _out.print(", "); - } - } - _out.println(" }, null);"); - } else { - int t_pos = bh.getTarget().getPosition(); - String target; - if (pos > t_pos) { - target = "ih_" + t_pos; - } else { - branches.add(bi); - target = "null"; - } - _out.println(" BranchInstruction " + name + " = _factory.createBranchInstruction(" - + "Constants." + bi.getName().toUpperCase(Locale.ENGLISH) + ", " + target - + ");"); - } - if (bh.hasTargeters()) { - _out.println(" ih_" + pos + " = il.append(" + name + ");"); - } else { - _out.println(" il.append(" + name + ");"); - } - } - - - public void visitRET( RET i ) { - _out.println("il.append(new RET(" + i.getIndex() + ")));"); - } - - - private void updateBranchTargets() { - for (Iterator i = branches.iterator(); i.hasNext();) { - BranchInstruction bi = (BranchInstruction) i.next(); - BranchHandle bh = (BranchHandle) branch_map.get(bi); - int pos = bh.getPosition(); - String name = bi.getName() + "_" + pos; - int t_pos = bh.getTarget().getPosition(); - _out.println(" " + name + ".setTarget(ih_" + t_pos + ");"); - if (bi instanceof Select) { - InstructionHandle[] ihs = ((Select) bi).getTargets(); - for (int j = 0; j < ihs.length; j++) { - t_pos = ihs[j].getPosition(); - _out.println(" " + name + ".setTarget(" + j + ", ih_" + t_pos + ");"); - } - } - } - } - - - private void updateExceptionHandlers() { - CodeExceptionGen[] handlers = _mg.getExceptionHandlers(); - for (int i = 0; i < handlers.length; i++) { - CodeExceptionGen h = handlers[i]; - String type = (h.getCatchType() == null) ? "null" : BCELifier.printType(h - .getCatchType()); - _out.println(" method.addExceptionHandler(" + "ih_" + h.getStartPC().getPosition() - + ", " + "ih_" + h.getEndPC().getPosition() + ", " + "ih_" - + h.getHandlerPC().getPosition() + ", " + type + ");"); - } - } -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/BCELifier.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/BCELifier.java deleted file mode 100755 index 59a82233..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/BCELifier.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.util; - -import java.io.OutputStream; -import java.io.PrintWriter; -import java.util.Locale; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.Repository; -import org.apache.bcel5_2_0.classfile.ClassParser; -import org.apache.bcel5_2_0.classfile.ConstantValue; -import org.apache.bcel5_2_0.classfile.Field; -import org.apache.bcel5_2_0.classfile.JavaClass; -import org.apache.bcel5_2_0.classfile.Method; -import org.apache.bcel5_2_0.classfile.Utility; -import org.apache.bcel5_2_0.generic.ArrayType; -import org.apache.bcel5_2_0.generic.ConstantPoolGen; -import org.apache.bcel5_2_0.generic.MethodGen; -import org.apache.bcel5_2_0.generic.Type; - -/** - * This class takes a given JavaClass object and converts it to a - * Java program that creates that very class using BCEL. This - * gives new users of BCEL a useful example showing how things - * are done with BCEL. It does not cover all features of BCEL, - * but tries to mimic hand-written code as close as possible. - * - * @version $Id: BCELifier.java 394939 2006-04-18 13:23:49Z tcurdt $ - * @author M. Dahm - */ -public class BCELifier extends org.apache.bcel5_2_0.classfile.EmptyVisitor { - - private static final int FLAG_FOR_UNKNOWN = -1; - private static final int FLAG_FOR_CLASS = 0; - private static final int FLAG_FOR_METHOD = 1; - private JavaClass _clazz; - private PrintWriter _out; - private ConstantPoolGen _cp; - - - /** @param clazz Java class to "decompile" - * @param out where to output Java program - */ - public BCELifier(JavaClass clazz, OutputStream out) { - _clazz = clazz; - _out = new PrintWriter(out); - _cp = new ConstantPoolGen(_clazz.getConstantPool()); - } - - - /** Start Java code generation - */ - public void start() { - visitJavaClass(_clazz); - _out.flush(); - } - - - public void visitJavaClass( JavaClass clazz ) { - String class_name = clazz.getClassName(); - String super_name = clazz.getSuperclassName(); - String package_name = clazz.getPackageName(); - String inter = Utility.printArray(clazz.getInterfaceNames(), false, true); - if (!"".equals(package_name)) { - class_name = class_name.substring(package_name.length() + 1); - _out.println("package " + package_name + ";"); - _out.println(); - } - _out.println("import org.apache.bcel.generic.*;"); - _out.println("import org.apache.bcel.classfile.*;"); - _out.println("import org.apache.bcel.*;"); - _out.println("import java.io.*;"); - _out.println(); - _out.println("public class " + class_name + "Creator implements Constants {"); - _out.println(" private InstructionFactory _factory;"); - _out.println(" private ConstantPoolGen _cp;"); - _out.println(" private ClassGen _cg;"); - _out.println(); - _out.println(" public " + class_name + "Creator() {"); - _out.println(" _cg = new ClassGen(\"" - + (("".equals(package_name)) ? class_name : package_name + "." + class_name) - + "\", \"" + super_name + "\", " + "\"" + clazz.getSourceFileName() + "\", " - + printFlags(clazz.getAccessFlags(), FLAG_FOR_CLASS) + ", " + "new String[] { " - + inter + " });"); - _out.println(); - _out.println(" _cp = _cg.getConstantPool();"); - _out.println(" _factory = new InstructionFactory(_cg, _cp);"); - _out.println(" }"); - _out.println(); - printCreate(); - Field[] fields = clazz.getFields(); - if (fields.length > 0) { - _out.println(" private void createFields() {"); - _out.println(" FieldGen field;"); - for (int i = 0; i < fields.length; i++) { - fields[i].accept(this); - } - _out.println(" }"); - _out.println(); - } - Method[] methods = clazz.getMethods(); - for (int i = 0; i < methods.length; i++) { - _out.println(" private void createMethod_" + i + "() {"); - methods[i].accept(this); - _out.println(" }"); - _out.println(); - } - printMain(); - _out.println("}"); - } - - - private void printCreate() { - _out.println(" public void create(OutputStream out) throws IOException {"); - Field[] fields = _clazz.getFields(); - if (fields.length > 0) { - _out.println(" createFields();"); - } - Method[] methods = _clazz.getMethods(); - for (int i = 0; i < methods.length; i++) { - _out.println(" createMethod_" + i + "();"); - } - _out.println(" _cg.getJavaClass().dump(out);"); - _out.println(" }"); - _out.println(); - } - - - private void printMain() { - String class_name = _clazz.getClassName(); - _out.println(" public static void main(String[] args) throws Exception {"); - _out.println(" " + class_name + "Creator creator = new " + class_name + "Creator();"); - _out.println(" creator.create(new FileOutputStream(\"" + class_name + ".class\"));"); - _out.println(" }"); - } - - - public void visitField( Field field ) { - _out.println(); - _out.println(" field = new FieldGen(" + printFlags(field.getAccessFlags()) + ", " - + printType(field.getSignature()) + ", \"" + field.getName() + "\", _cp);"); - ConstantValue cv = field.getConstantValue(); - if (cv != null) { - String value = cv.toString(); - _out.println(" field.setInitValue(" + value + ")"); - } - _out.println(" _cg.addField(field.getField());"); - } - - - public void visitMethod( Method method ) { - MethodGen mg = new MethodGen(method, _clazz.getClassName(), _cp); - Type result_type = mg.getReturnType(); - Type[] arg_types = mg.getArgumentTypes(); - _out.println(" InstructionList il = new InstructionList();"); - _out.println(" MethodGen method = new MethodGen(" - + printFlags(method.getAccessFlags(), FLAG_FOR_METHOD) + ", " - + printType(result_type) + ", " + printArgumentTypes(arg_types) + ", " - + "new String[] { " + Utility.printArray(mg.getArgumentNames(), false, true) - + " }, \"" + method.getName() + "\", \"" + _clazz.getClassName() + "\", il, _cp);"); - _out.println(); - BCELFactory factory = new BCELFactory(mg, _out); - factory.start(); - _out.println(" method.setMaxStack();"); - _out.println(" method.setMaxLocals();"); - _out.println(" _cg.addMethod(method.getMethod());"); - _out.println(" il.dispose();"); - } - - - static String printFlags( int flags ) { - return printFlags(flags, FLAG_FOR_UNKNOWN); - } - - - static String printFlags( int flags, int reason ) { - if (flags == 0) { - return "0"; - } - StringBuilder buf = new StringBuilder(); - for (int i = 0, pow = 1; pow <= Constants.MAX_ACC_FLAG; i++) { - if ((flags & pow) != 0) { - if ((pow == Constants.ACC_SYNCHRONIZED) && (reason == FLAG_FOR_CLASS)) { - buf.append("ACC_SUPER | "); - } else if ((pow == Constants.ACC_VOLATILE) && (reason == FLAG_FOR_METHOD)) { - buf.append("ACC_BRIDGE | "); - } else if ((pow == Constants.ACC_TRANSIENT) && (reason == FLAG_FOR_METHOD)) { - buf.append("ACC_VARARGS | "); - } else { - buf.append("ACC_") - .append(Constants.ACCESS_NAMES[i].toUpperCase(Locale.ENGLISH)).append( - " | "); - } - } - pow <<= 1; - } - String str = buf.toString(); - return str.substring(0, str.length() - 3); - } - - - static String printArgumentTypes( Type[] arg_types ) { - if (arg_types.length == 0) { - return "Type.NO_ARGS"; - } - StringBuilder args = new StringBuilder(); - for (int i = 0; i < arg_types.length; i++) { - args.append(printType(arg_types[i])); - if (i < arg_types.length - 1) { - args.append(", "); - } - } - return "new Type[] { " + args.toString() + " }"; - } - - - static String printType( Type type ) { - return printType(type.getSignature()); - } - - - static String printType( String signature ) { - Type type = Type.getType(signature); - byte t = type.getType(); - if (t <= Constants.T_VOID) { - return "Type." + Constants.TYPE_NAMES[t].toUpperCase(Locale.ENGLISH); - } else if (type.toString().equals("java.lang.String")) { - return "Type.STRING"; - } else if (type.toString().equals("java.lang.Object")) { - return "Type.OBJECT"; - } else if (type.toString().equals("java.lang.StringBuffer")) { - return "Type.STRINGBUFFER"; - } else if (type instanceof ArrayType) { - ArrayType at = (ArrayType) type; - return "new ArrayType(" + printType(at.getBasicType()) + ", " + at.getDimensions() - + ")"; - } else { - return "new ObjectType(\"" + Utility.signatureToString(signature, false) + "\")"; - } - } - - - /** Default main method - */ - public static void main( String[] argv ) throws Exception { - JavaClass java_class; - String name = argv[0]; - if ((java_class = Repository.lookupClass(name)) == null) { - java_class = new ClassParser(name).parse(); // May throw IOException - } - BCELifier bcelifier = new BCELifier(java_class, System.out); - bcelifier.start(); - } -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/Class2HTML.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/Class2HTML.java deleted file mode 100755 index 319cb223..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/Class2HTML.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.util; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintWriter; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.classfile.Attribute; -import org.apache.bcel5_2_0.classfile.ClassParser; -import org.apache.bcel5_2_0.classfile.ConstantPool; -import org.apache.bcel5_2_0.classfile.JavaClass; -import org.apache.bcel5_2_0.classfile.Method; -import org.apache.bcel5_2_0.classfile.Utility; - -/** - * 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. - * - *
        - *
      1. "package"."class".html as the main file which defines the frames for - * the following subfiles. - *
      2. "package"."class"_attributes.html contains all (known) attributes found in the file - *
      3. "package"."class"_cp.html contains the constant pool - *
      4. "package"."class"_code.html contains the byte code - *
      5. "package"."class"_methods.html contains references to all methods and fields of the class - *
      - * - * 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: Class2HTML.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -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 { - 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 "" + str - + ""; - } - - - 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? - String base_type = type; - if (index > -1) { - base_type = type.substring(0, index); // Tack of the `[' - } - // test for basic type - if (base_type.equals("int") || base_type.equals("short") || base_type.equals("boolean") - || base_type.equals("void") || base_type.equals("char") || base_type.equals("byte") - || base_type.equals("long") || base_type.equals("double") - || base_type.equals("float")) { - return "" + type + ""; - } else { - return "" + short_type + ""; - } - } - - - static String toHTML( String str ) { - StringBuilder buf = new StringBuilder(); - 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("<"); - break; - case '>': - buf.append(">"); - 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("\n" + "Documentation for " + class_name + "" - + "\n" + "\n" - + "\n" + "\n" - + "\n" + "\n" - + "\n" + "\n" - + "\n" - + ""); - file.close(); - for (int i = 0; i < attributes.length; i++) { - attribute_html.writeAttribute(attributes[i], "class" + i); - } - } -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassLoaderRepository.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassLoaderRepository.java deleted file mode 100755 index 577d2122..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassLoaderRepository.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.util; - -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; - -import org.apache.bcel5_2_0.classfile.ClassParser; -import org.apache.bcel5_2_0.classfile.JavaClass; - -/** - * The repository maintains information about which classes have - * been loaded. - * - * It loads its data from the ClassLoader implementation - * passed into its constructor. - * - * @see org.apache.bcel5_2_0.Repository - * - * @version $Id: ClassLoaderRepository.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @author David Dixon-Peugh - */ -public class ClassLoaderRepository implements Repository { - - private java.lang.ClassLoader loader; - private Map loadedClasses = new HashMap(); // CLASSNAME X JAVACLASS - - - public ClassLoaderRepository(java.lang.ClassLoader loader) { - this.loader = loader; - } - - - /** - * Store a new JavaClass into this Repository. - */ - public void storeClass( JavaClass clazz ) { - loadedClasses.put(clazz.getClassName(), clazz); - clazz.setRepository(this); - } - - - /** - * Remove class from repository - */ - public void removeClass( JavaClass clazz ) { - loadedClasses.remove(clazz.getClassName()); - } - - - /** - * Find an already defined JavaClass. - */ - public JavaClass findClass( String className ) { - if (loadedClasses.containsKey(className)) { - return (JavaClass) loadedClasses.get(className); - } else { - return null; - } - } - - - /** - * Lookup a JavaClass object from the Class Name provided. - */ - public JavaClass loadClass( String className ) throws ClassNotFoundException { - String classFile = className.replace('.', '/'); - JavaClass RC = findClass(className); - if (RC != null) { - return RC; - } - try { - InputStream is = loader.getResourceAsStream(classFile + ".class"); - if (is == null) { - throw new ClassNotFoundException(className + " not found."); - } - ClassParser parser = new ClassParser(is, className); - RC = parser.parse(); - storeClass(RC); - return RC; - } catch (IOException e) { - throw new ClassNotFoundException(e.toString()); - } - } - - - public JavaClass loadClass( Class clazz ) throws ClassNotFoundException { - return loadClass(clazz.getName()); - } - - - /** Clear all entries from cache. - */ - public void clear() { - loadedClasses.clear(); - } - - - /* - * @return null - */ - public ClassPath getClassPath() { - return null; - } -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassPath.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassPath.java deleted file mode 100755 index 4eeca844..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassPath.java +++ /dev/null @@ -1,396 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.util; - -import java.io.DataInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FilenameFilter; -import java.io.IOException; -import java.io.InputStream; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.StringTokenizer; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -/** - * Responsible for loading (class) files from the CLASSPATH. Inspired by - * sun.tools.ClassPath. - * - * @version $Id: ClassPath.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class ClassPath implements Serializable { - - public static final ClassPath SYSTEM_CLASS_PATH = new ClassPath(); - private PathEntry[] paths; - private String class_path; - - - /** - * Search for classes in given path. - */ - public ClassPath(String class_path) { - this.class_path = class_path; - List 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. - * @deprecated Use SYSTEM_CLASS_PATH constant - */ - public ClassPath() { - this(getClassPath()); - } - - - /** @return used class path string - */ - public String toString() { - return class_path; - } - - - public int hashCode() { - return class_path.hashCode(); - } - - - public boolean equals( Object o ) { - if (o instanceof ClassPath) { - return class_path.equals(((ClassPath) o).class_path); - } - return false; - } - - - private static final void getPathComponents( String path, List 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); - } - } - } - } - - - /** Checks for class path components in the following properties: - * "java.class.path", "sun.boot.class.path", "java.ext.dirs" - * - * @return class path as used by default by BCEL - */ - public 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"); - List list = new ArrayList(); - getPathComponents(class_path, list); - getPathComponents(boot_path, list); - List 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(Locale.ENGLISH); - return name.endsWith(".zip") || name.endsWith(".jar"); - } - }); - if (extensions != null) { - for (int i = 0; i < extensions.length; i++) { - list.add(ext_dir.getPath() + File.separatorChar + extensions[i]); - } - } - } - StringBuilder buf = new StringBuilder(); - for (Iterator e = list.iterator(); e.hasNext();) { - buf.append((String) e.next()); - if (e.hasNext()) { - buf.append(File.pathSeparatorChar); - } - } - return buf.toString().intern(); - } - - - /** - * @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.replace('.', '/'), ".class"); - } - - - /** - * Return stream for class or resource on CLASSPATH. - * - * @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 { - InputStream is = null; - try { - is = getClass().getClassLoader().getResourceAsStream(name + suffix); - } catch (Exception e) { - } - if (is != null) { - return is; - } - 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 { - DataInputStream dis = null; - try { - InputStream is = getInputStream(name, suffix); - if (is == null) { - throw new IOException("Couldn't find: " + name + suffix); - } - dis = new DataInputStream(is); - byte[] bytes = new byte[is.available()]; - dis.readFully(bytes); - return bytes; - } finally { - if (dis != null) { - dis.close(); - } - } - } - - - /** - * @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 implements Serializable { - - abstract ClassFile getClassFile( String name, String suffix ) throws IOException; - } - - /** Contains information about file/ZIP entry of the Java class. - */ - public interface ClassFile { - - /** @return input stream for class file. - */ - public abstract InputStream getInputStream() throws IOException; - - - /** @return canonical path to class file. - */ - public abstract String getPath(); - - - /** @return base path of found class, i.e. class is contained relative - * to that path, which may either denote a directory, or zip file - */ - public abstract String getBase(); - - - /** @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(); - } - - - public String getBase() { - return dir; - } - } : 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(); - } - - - public String getBase() { - return zip.getName(); - } - } : null; - } - } -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassQueue.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassQueue.java deleted file mode 100755 index 12f32446..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassQueue.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.util; - -import java.util.LinkedList; - -import org.apache.bcel5_2_0.classfile.JavaClass; - -/** - * Utility class implementing a (typesafe) queue of JavaClass - * objects. - * - * @version $Id: ClassQueue.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - */ -public class ClassQueue implements java.io.Serializable { - - protected LinkedList vec = new LinkedList(); - - - public void enqueue( JavaClass clazz ) { - vec.addLast(clazz); - } - - - public JavaClass dequeue() { - return (JavaClass) vec.removeFirst(); - } - - - public boolean empty() { - return vec.isEmpty(); - } - - - public String toString() { - return vec.toString(); - } -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassSet.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassSet.java deleted file mode 100755 index 4925e7b8..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassSet.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.util; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import org.apache.bcel5_2_0.classfile.JavaClass; - -/** - * Utility class implementing a (typesafe) set of JavaClass objects. - * Since JavaClass has no equals() method, the name of the class is - * used for comparison. - * - * @version $Id: ClassSet.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @see ClassStack - */ -public class ClassSet implements java.io.Serializable { - - private Map _map = new HashMap(); - - - public boolean add( JavaClass clazz ) { - boolean result = false; - if (!_map.containsKey(clazz.getClassName())) { - result = true; - _map.put(clazz.getClassName(), clazz); - } - return result; - } - - - public void remove( JavaClass clazz ) { - _map.remove(clazz.getClassName()); - } - - - public boolean empty() { - return _map.isEmpty(); - } - - - public JavaClass[] toArray() { - Collection values = _map.values(); - JavaClass[] classes = new JavaClass[values.size()]; - values.toArray(classes); - return classes; - } - - - public String[] getClassNames() { - return (String[]) _map.keySet().toArray(new String[_map.keySet().size()]); - } -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassStack.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassStack.java deleted file mode 100755 index 553014e9..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassStack.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.util; - -import java.util.Stack; - -import org.apache.bcel5_2_0.classfile.JavaClass; - -/** - * Utility class implementing a (typesafe) stack of JavaClass objects. - * - * @version $Id: ClassStack.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @see Stack - */ -public class ClassStack implements java.io.Serializable { - - 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassVector.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassVector.java deleted file mode 100755 index 237597f8..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/ClassVector.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.util; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.bcel5_2_0.classfile.JavaClass; - -/** - * Utility class implementing a (typesafe) collection of JavaClass - * objects. Contains the most important methods of a Vector. - * - * @version $Id: ClassVector.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * - * @deprecated as of 5.1.1 - 7/17/2005 - */ -public class ClassVector implements java.io.Serializable { - - protected List 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/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/InstructionFinder.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/InstructionFinder.java deleted file mode 100755 index 0668ce66..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/InstructionFinder.java +++ /dev/null @@ -1,473 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.util; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.bcel5_2_0.Constants; -import org.apache.bcel5_2_0.generic.ClassGenException; -import org.apache.bcel5_2_0.generic.Instruction; -import org.apache.bcel5_2_0.generic.InstructionHandle; -import org.apache.bcel5_2_0.generic.InstructionList; - -/** - * 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. - * - *

      - * This class internally uses the - * Regexp package to search for regular expressions. - * - * A typical application would look like this: - * - *

      - * 
      - *  
      - *   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]);
      - *   ...
      - *   }
      - *   
      - *  
      - * 
      - * - * @version $Id: InstructionFinder.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @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 Map map = new HashMap(); // Map - 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 ) { - //Bug: 38787 - Instructions are assumed to be english, to avoid odd Locale issues - String lower = pattern.toLowerCase(Locale.ENGLISH); - StringBuilder buf = new StringBuilder(); - int size = pattern.length(); - for (int i = 0; i < size; i++) { - char ch = lower.charAt(i); - if (Character.isLetterOrDigit(ch)) { - StringBuilder name = new StringBuilder(); - 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. - *

      - * Example pattern: - * - *

      -     * search("BranchInstruction NOP ((IfInstruction|GOTO)+ ISTORE Instruction)*");
      -     * 
      - * - *

      - * 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."); - } - Pattern regex = Pattern.compile(search); - List matches = new ArrayList(); - Matcher matcher = regex.matcher(il_string); - while (start < il_string.length() && matcher.find(start)) { - int startExpr = matcher.start(); - int endExpr = matcher.end(); - int lenExpr = (endExpr - startExpr) + 1; - InstructionHandle[] match = getMatch(startExpr, lenExpr); - if ((constraint == null) || constraint.checkCode(match)) { - matches.add(match); - } - start = endExpr; - } - return matches.iterator(); - } - - - /** - * 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 static 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 - StringBuilder buf = new StringBuilder("("); - 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 ) { - StringBuilder buf = new StringBuilder("("); - 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 ) { - StringBuilder buf = new StringBuilder(); - 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((ch - OFFSET)); - } - } else { - buf.append(ch); - } - } - return buf.toString(); - } -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/Repository.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/Repository.java deleted file mode 100755 index 1065e0fd..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/Repository.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.util; - -import org.apache.bcel5_2_0.classfile.JavaClass; - -/** - * Abstract definition of a class repository. Instances may be used - * to load classes from different sources and may be used in the - * Repository.setRepository method. - * - * @see org.apache.bcel5_2_0.Repository - * @version $Id: Repository.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @author David Dixon-Peugh - */ -public interface Repository extends java.io.Serializable { - - /** - * Store the provided class under "clazz.getClassName()" - */ - public void storeClass( JavaClass clazz ); - - - /** - * Remove class from repository - */ - public void removeClass( JavaClass clazz ); - - - /** - * Find the class with the name provided, if the class - * isn't there, return NULL. - */ - public JavaClass findClass( String className ); - - - /** - * Find the class with the name provided, if the class - * isn't there, make an attempt to load it. - */ - public JavaClass loadClass( String className ) throws java.lang.ClassNotFoundException; - - - /** - * Find the JavaClass instance for the given run-time class object - */ - public JavaClass loadClass( Class clazz ) throws java.lang.ClassNotFoundException; - - - /** Clear all entries from cache. - */ - public void clear(); - - - /** Get the ClassPath associated with this Repository - */ - public ClassPath getClassPath(); -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/SyntheticRepository.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/SyntheticRepository.java deleted file mode 100755 index c98a95fc..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/SyntheticRepository.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright 2000-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.bcel5_2_0.util; - -import java.io.IOException; -import java.io.InputStream; -import java.lang.ref.SoftReference; -import java.util.HashMap; -import java.util.Map; - -import org.apache.bcel5_2_0.classfile.ClassParser; -import org.apache.bcel5_2_0.classfile.JavaClass; - -/** - * This repository is used in situations where a Class is created - * outside the realm of a ClassLoader. Classes are loaded from - * the file systems using the paths specified in the given - * class path. By default, this is the value returned by - * ClassPath.getClassPath(). - *
      - * It is designed to be used as a singleton, however it - * can also be used with custom classpaths. - * - /** - * Abstract definition of a class repository. Instances may be used - * to load classes from different sources and may be used in the - * Repository.setRepository method. - * - * @see org.apache.bcel5_2_0.Repository - * - * @version $Id: SyntheticRepository.java 386056 2006-03-15 11:31:56Z tcurdt $ - * @author M. Dahm - * @author David Dixon-Peugh - */ -public class SyntheticRepository implements Repository { - - private static final String DEFAULT_PATH = ClassPath.getClassPath(); - private static Map _instances = new HashMap(); // CLASSPATH X REPOSITORY - private ClassPath _path = null; - private Map _loadedClasses = new HashMap(); // CLASSNAME X JAVACLASS - - - private SyntheticRepository(ClassPath path) { - _path = path; - } - - - public static SyntheticRepository getInstance() { - return getInstance(ClassPath.SYSTEM_CLASS_PATH); - } - - - public static SyntheticRepository getInstance( ClassPath classPath ) { - SyntheticRepository rep = (SyntheticRepository) _instances.get(classPath); - if (rep == null) { - rep = new SyntheticRepository(classPath); - _instances.put(classPath, rep); - } - return rep; - } - - - /** - * Store a new JavaClass instance into this Repository. - */ - public void storeClass( JavaClass clazz ) { - _loadedClasses.put(clazz.getClassName(), new SoftReference(clazz)); - clazz.setRepository(this); - } - - - /** - * Remove class from repository - */ - public void removeClass( JavaClass clazz ) { - _loadedClasses.remove(clazz.getClassName()); - } - - - /** - * Find an already defined (cached) JavaClass object by name. - */ - public JavaClass findClass( String className ) { - SoftReference ref = (SoftReference) _loadedClasses.get(className); - if (ref == null) { - return null; - } - return (JavaClass) ref.get(); - } - - - /** - * Find a JavaClass object by name. - * If it is already in this Repository, the Repository version - * is returned. Otherwise, the Repository's classpath is searched for - * the class (and it is added to the Repository if found). - * - * @param className the name of the class - * @return the JavaClass object - * @throws ClassNotFoundException if the class is not in the - * Repository, and could not be found on the classpath - */ - public JavaClass loadClass( String className ) throws ClassNotFoundException { - if (className == null || className.equals("")) { - throw new IllegalArgumentException("Invalid class name " + className); - } - className = className.replace('/', '.'); // Just in case, canonical form - JavaClass clazz = findClass(className); - if (clazz != null) { - return clazz; - } - try { - return loadClass(_path.getInputStream(className), className); - } catch (IOException e) { - throw new ClassNotFoundException("Exception while looking for class " + className - + ": " + e.toString()); - } - } - - - /** - * Find the JavaClass object for a runtime Class object. - * If a class with the same name is already in this Repository, - * the Repository version is returned. Otherwise, getResourceAsStream() - * is called on the Class object to find the class's representation. - * If the representation is found, it is added to the Repository. - * - * @see Class - * @param clazz the runtime Class object - * @return JavaClass object for given runtime class - * @throws ClassNotFoundException if the class is not in the - * Repository, and its representation could not be found - */ - public JavaClass loadClass( Class clazz ) throws ClassNotFoundException { - String className = clazz.getName(); - JavaClass repositoryClass = findClass(className); - if (repositoryClass != null) { - return repositoryClass; - } - String name = className; - int i = name.lastIndexOf('.'); - if (i > 0) { - name = name.substring(i + 1); - } - return loadClass(clazz.getResourceAsStream(name + ".class"), className); - } - - - private JavaClass loadClass( InputStream is, String className ) throws ClassNotFoundException { - try { - if (is != null) { - ClassParser parser = new ClassParser(is, className); - JavaClass clazz = parser.parse(); - storeClass(clazz); - return clazz; - } - } catch (IOException e) { - throw new ClassNotFoundException("Exception while looking for class " + className - + ": " + e.toString()); - } - throw new ClassNotFoundException("SyntheticRepository could not load " + className); - } - - - /** ClassPath associated with the Repository. - */ - public ClassPath getClassPath() { - return _path; - } - - - /** Clear all entries from cache. - */ - public void clear() { - _loadedClasses.clear(); - } -} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/package.html b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/package.html deleted file mode 100755 index a58b20f5..00000000 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel5_2_0/util/package.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -

      -This package contains utility classes for the -Byte Code Engineering -Library, namely: -

      -

      -

        -
      • Collection classes for JavaClass objects
      • -
      • A converter for class files to HTML
      • -
      • A tool to find instructions patterns via regular expressions
      • -
      • A class to find classes as defined in the CLASSPATH
      • -
      • A class loader that allows to create classes at run time
      • -
      - -

      - - diff --git a/Core/org.emftext.language.java.resource/src/org/emftext/language/java/resource/ClassFileModelLoader.java b/Core/org.emftext.language.java.resource/src/org/emftext/language/java/resource/ClassFileModelLoader.java index b1f83551..7dbb0322 100755 --- a/Core/org.emftext.language.java.resource/src/org/emftext/language/java/resource/ClassFileModelLoader.java +++ b/Core/org.emftext.language.java.resource/src/org/emftext/language/java/resource/ClassFileModelLoader.java @@ -21,11 +21,11 @@ import java.util.Arrays; import java.util.List; -import org.apache.bcel5_2_0.classfile.Attribute; -import org.apache.bcel5_2_0.classfile.ClassParser; -import org.apache.bcel5_2_0.classfile.JavaClass; -import org.apache.bcel5_2_0.classfile.Signature; -import org.apache.bcel5_2_0.classfile.Utility; +import org.apache.bcel.classfile.Attribute; +import org.apache.bcel.classfile.ClassParser; +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.Signature; +import org.apache.bcel.classfile.Utility; import org.eclipse.emf.common.util.BasicEList; import org.eclipse.emf.common.util.EList; import org.emftext.language.java.JavaClasspath; @@ -191,7 +191,7 @@ else if (clazz.isInterface()) { } } - for (org.apache.bcel5_2_0.classfile.Field field : clazz.getFields()) { + for (org.apache.bcel.classfile.Field field : clazz.getFields()) { if (field.isEnum() && emfClassifier instanceof Enumeration) { ((Enumeration)emfClassifier).getConstants().add(constructEnumConstant(field)); } @@ -200,7 +200,7 @@ else if (clazz.isInterface()) { } } - for (org.apache.bcel5_2_0.classfile.Method method : clazz.getMethods()) { + for (org.apache.bcel.classfile.Method method : clazz.getMethods()) { if (!method.isSynthetic()) { Member emfMember = constructMethod(method, emfClassifier, false); //If the last parameter has an array type it could also be a variable length parameter. @@ -227,7 +227,7 @@ else if (clazz.isInterface()) { return emfClassifier; } - protected Member constructMethod(org.apache.bcel5_2_0.classfile.Method method, ConcreteClassifier emfClassifier, boolean withVariableLength) { + protected Member constructMethod(org.apache.bcel.classfile.Method method, ConcreteClassifier emfClassifier, boolean withVariableLength) { Method emfMethod = null; if (emfClassifier instanceof Annotation) { emfMethod = annotationsFactory.createAnnotationAttribute(); @@ -270,7 +270,7 @@ protected Member constructMethod(org.apache.bcel5_2_0.classfile.Method method, C List parameterNames = extractParameterNames(method); for(int i = 0; i < method.getArgumentTypes().length; i++) { - org.apache.bcel5_2_0.generic.Type argType = method.getArgumentTypes()[i]; + org.apache.bcel.generic.Type argType = method.getArgumentTypes()[i]; String paramName; if (parameterNames.size() > i) { paramName = parameterNames.get(i); @@ -332,7 +332,7 @@ protected Member constructMethod(org.apache.bcel5_2_0.classfile.Method method, C return (Member) emfMethod; } - protected Parameter constructParameter(org.apache.bcel5_2_0.generic.Type attrType, String paramName) { + protected Parameter constructParameter(org.apache.bcel.generic.Type attrType, String paramName) { Parameter emfParameter = parametersFactory.createOrdinaryParameter(); String signature = attrType.getSignature(); TypeReference emfTypeReference = createReferenceToType(signature); @@ -348,7 +348,7 @@ protected Parameter constructParameter(org.apache.bcel5_2_0.generic.Type attrTyp return emfParameter; } - protected Parameter constructVariableLengthParameter(org.apache.bcel5_2_0.generic.Type attrType, String paramName) { + protected Parameter constructVariableLengthParameter(org.apache.bcel.generic.Type attrType, String paramName) { Parameter emfParameter = parametersFactory.createVariableLengthParameter(); String signature = attrType.getSignature(); TypeReference emfTypeReference = createReferenceToType(signature); @@ -364,7 +364,7 @@ protected Parameter constructVariableLengthParameter(org.apache.bcel5_2_0.generi return emfParameter; } - protected Field constructField(org.apache.bcel5_2_0.classfile.Field field, ConcreteClassifier emfClassifier) { + protected Field constructField(org.apache.bcel.classfile.Field field, ConcreteClassifier emfClassifier) { Field emfField = membersFactory.createField(); emfField.setName(field.getName()); String signature = field.getType().getSignature(); @@ -403,7 +403,7 @@ protected Field constructField(org.apache.bcel5_2_0.classfile.Field field, Concr return emfField; } - protected void constructModifiers(AnnotableAndModifiable emfMember, org.apache.bcel5_2_0.classfile.AccessFlags member) { + protected void constructModifiers(AnnotableAndModifiable emfMember, org.apache.bcel.classfile.AccessFlags member) { ModifiersFactory f = ModifiersFactory.eINSTANCE; if (member.isAbstract()) { emfMember.getAnnotationsAndModifiers().add(f.createAbstract()); @@ -447,7 +447,7 @@ protected void constructModifiers(AnnotableAndModifiable emfMember, org.apache.b } protected EnumConstant constructEnumConstant( - org.apache.bcel5_2_0.classfile.Field field) { + org.apache.bcel.classfile.Field field) { EnumConstant enumConstant = membersFactory.createEnumConstant(); enumConstant.setName(field.getName()); @@ -809,7 +809,7 @@ protected int getArrayDimension(String signature) { return arrayDimension; } - protected List extractParameterNames(final org.apache.bcel5_2_0.classfile.Method method) { + protected List extractParameterNames(final org.apache.bcel.classfile.Method method) { final List names = new ArrayList(); if (method.getLocalVariableTable() == null) { return names; @@ -818,7 +818,7 @@ protected List extractParameterNames(final org.apache.bcel5_2_0.classfil final int start = method.isStatic() ? 0 : 1; final int stop = method.isStatic() ? method.getArgumentTypes().length : method.getArgumentTypes().length + 1; - final org.apache.bcel5_2_0.classfile.LocalVariable[] variables = method + final org.apache.bcel.classfile.LocalVariable[] variables = method .getLocalVariableTable().getLocalVariableTable(); if (variables != null) { for (int i = start; i < stop && i < variables.length; i++) { From 2c1c5e91c792f682354dc9d23a80b52146bbf1c7 Mon Sep 17 00:00:00 2001 From: Admin Date: Thu, 8 Nov 2018 17:30:52 +0100 Subject: [PATCH 2/3] Minimum required Java version is 1.7 --- Core/org.emftext.language.java.resource.bcel/.classpath | 2 +- .../.settings/org.eclipse.jdt.core.prefs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Core/org.emftext.language.java.resource.bcel/.classpath b/Core/org.emftext.language.java.resource.bcel/.classpath index ea6ef586..805b2684 100644 --- a/Core/org.emftext.language.java.resource.bcel/.classpath +++ b/Core/org.emftext.language.java.resource.bcel/.classpath @@ -1,7 +1,7 @@ - + diff --git a/Core/org.emftext.language.java.resource.bcel/.settings/org.eclipse.jdt.core.prefs b/Core/org.emftext.language.java.resource.bcel/.settings/org.eclipse.jdt.core.prefs index 18860117..49320de9 100644 --- a/Core/org.emftext.language.java.resource.bcel/.settings/org.eclipse.jdt.core.prefs +++ b/Core/org.emftext.language.java.resource.bcel/.settings/org.eclipse.jdt.core.prefs @@ -1,8 +1,8 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -78,4 +78,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.source=1.7 From 7213e703326dc18f60ef280f17caeef458ce81bd Mon Sep 17 00:00:00 2001 From: Admin Date: Sat, 10 Nov 2018 20:24:23 +0100 Subject: [PATCH 3/3] Renamed the updated BCEL package to contain its version (6.2). --- .../org/apache/{bcel => bcel6_2_0}/Const.java | 2 +- .../apache/{bcel => bcel6_2_0}/Constants.java | 2 +- .../{bcel => bcel6_2_0}/ExceptionConst.java | 2 +- .../ExceptionConstants.java | 2 +- .../{bcel => bcel6_2_0}/Repository.java | 16 +- .../classfile/AccessFlags.java | 4 +- .../classfile/AnnotationDefault.java | 4 +- .../classfile/AnnotationElementValue.java | 2 +- .../classfile/AnnotationEntry.java | 4 +- .../classfile/Annotations.java | 2 +- .../classfile/ArrayElementValue.java | 2 +- .../classfile/Attribute.java | 4 +- .../classfile/AttributeReader.java | 2 +- .../classfile/BootstrapMethod.java | 4 +- .../classfile/BootstrapMethods.java | 4 +- .../classfile/ClassElementValue.java | 4 +- .../classfile/ClassFormatException.java | 2 +- .../classfile/ClassParser.java | 4 +- .../{bcel => bcel6_2_0}/classfile/Code.java | 4 +- .../classfile/CodeException.java | 6 +- .../classfile/Constant.java | 6 +- .../classfile/ConstantCP.java | 4 +- .../classfile/ConstantClass.java | 4 +- .../classfile/ConstantDouble.java | 4 +- .../classfile/ConstantFieldref.java | 4 +- .../classfile/ConstantFloat.java | 4 +- .../classfile/ConstantInteger.java | 4 +- .../classfile/ConstantInterfaceMethodref.java | 4 +- .../classfile/ConstantInvokeDynamic.java | 4 +- .../classfile/ConstantLong.java | 4 +- .../classfile/ConstantMethodHandle.java | 4 +- .../classfile/ConstantMethodType.java | 4 +- .../classfile/ConstantMethodref.java | 4 +- .../classfile/ConstantModule.java | 4 +- .../classfile/ConstantNameAndType.java | 4 +- .../classfile/ConstantObject.java | 2 +- .../classfile/ConstantPackage.java | 4 +- .../classfile/ConstantPool.java | 6 +- .../classfile/ConstantString.java | 4 +- .../classfile/ConstantUtf8.java | 4 +- .../classfile/ConstantValue.java | 4 +- .../classfile/Deprecated.java | 4 +- .../classfile/DescendingVisitor.java | 2 +- .../classfile/ElementValue.java | 2 +- .../classfile/ElementValuePair.java | 4 +- .../classfile/EmptyVisitor.java | 2 +- .../classfile/EnclosingMethod.java | 4 +- .../classfile/EnumElementValue.java | 4 +- .../classfile/ExceptionTable.java | 4 +- .../{bcel => bcel6_2_0}/classfile/Field.java | 8 +- .../classfile/FieldOrMethod.java | 4 +- .../classfile/InnerClass.java | 4 +- .../classfile/InnerClasses.java | 4 +- .../classfile/JavaClass.java | 20 +-- .../classfile/LineNumber.java | 2 +- .../classfile/LineNumberTable.java | 4 +- .../classfile/LocalVariable.java | 6 +- .../classfile/LocalVariableTable.java | 4 +- .../classfile/LocalVariableTypeTable.java | 4 +- .../{bcel => bcel6_2_0}/classfile/Method.java | 8 +- .../classfile/MethodParameter.java | 4 +- .../classfile/MethodParameters.java | 4 +- .../{bcel => bcel6_2_0}/classfile/Node.java | 2 +- .../classfile/PMGClass.java | 4 +- .../classfile/ParameterAnnotationEntry.java | 2 +- .../classfile/ParameterAnnotations.java | 2 +- .../RuntimeInvisibleAnnotations.java | 4 +- .../RuntimeInvisibleParameterAnnotations.java | 4 +- .../classfile/RuntimeVisibleAnnotations.java | 4 +- .../RuntimeVisibleParameterAnnotations.java | 4 +- .../classfile/Signature.java | 4 +- .../classfile/SimpleElementValue.java | 4 +- .../classfile/SourceFile.java | 4 +- .../classfile/StackMap.java | 4 +- .../classfile/StackMapEntry.java | 5 +- .../classfile/StackMapType.java | 4 +- .../classfile/Synthetic.java | 4 +- .../classfile/Unknown.java | 4 +- .../classfile/UnknownAttributeReader.java | 2 +- .../classfile/Utility.java | 6 +- .../classfile/Visitor.java | 2 +- .../classfile/package.html | 0 .../{bcel => bcel6_2_0}/generic/AALOAD.java | 4 +- .../{bcel => bcel6_2_0}/generic/AASTORE.java | 4 +- .../generic/ACONST_NULL.java | 4 +- .../{bcel => bcel6_2_0}/generic/ALOAD.java | 6 +- .../generic/ANEWARRAY.java | 6 +- .../{bcel => bcel6_2_0}/generic/ARETURN.java | 4 +- .../generic/ARRAYLENGTH.java | 6 +- .../{bcel => bcel6_2_0}/generic/ASTORE.java | 6 +- .../{bcel => bcel6_2_0}/generic/ATHROW.java | 6 +- .../generic/AllocationInstruction.java | 2 +- .../generic/AnnotationElementValueGen.java | 6 +- .../generic/AnnotationEntryGen.java | 18 +- .../generic/ArithmeticInstruction.java | 4 +- .../generic/ArrayElementValueGen.java | 6 +- .../generic/ArrayInstruction.java | 36 ++-- .../generic/ArrayType.java | 4 +- .../{bcel => bcel6_2_0}/generic/BALOAD.java | 4 +- .../{bcel => bcel6_2_0}/generic/BASTORE.java | 4 +- .../{bcel => bcel6_2_0}/generic/BIPUSH.java | 6 +- .../generic/BREAKPOINT.java | 4 +- .../generic/BasicType.java | 4 +- .../generic/BranchHandle.java | 2 +- .../generic/BranchInstruction.java | 4 +- .../{bcel => bcel6_2_0}/generic/CALOAD.java | 4 +- .../{bcel => bcel6_2_0}/generic/CASTORE.java | 4 +- .../generic/CHECKCAST.java | 6 +- .../generic/CPInstruction.java | 14 +- .../generic/ClassElementValueGen.java | 8 +- .../{bcel => bcel6_2_0}/generic/ClassGen.java | 28 +-- .../generic/ClassGenException.java | 2 +- .../generic/ClassObserver.java | 2 +- .../generic/CodeExceptionGen.java | 4 +- .../generic/CompoundInstruction.java | 2 +- .../generic/ConstantPoolGen.java | 38 ++-- .../generic/ConstantPushInstruction.java | 2 +- .../generic/ConversionInstruction.java | 4 +- .../{bcel => bcel6_2_0}/generic/D2F.java | 4 +- .../{bcel => bcel6_2_0}/generic/D2I.java | 4 +- .../{bcel => bcel6_2_0}/generic/D2L.java | 4 +- .../{bcel => bcel6_2_0}/generic/DADD.java | 4 +- .../{bcel => bcel6_2_0}/generic/DALOAD.java | 4 +- .../{bcel => bcel6_2_0}/generic/DASTORE.java | 4 +- .../{bcel => bcel6_2_0}/generic/DCMPG.java | 4 +- .../{bcel => bcel6_2_0}/generic/DCMPL.java | 4 +- .../{bcel => bcel6_2_0}/generic/DCONST.java | 8 +- .../{bcel => bcel6_2_0}/generic/DDIV.java | 4 +- .../{bcel => bcel6_2_0}/generic/DLOAD.java | 6 +- .../{bcel => bcel6_2_0}/generic/DMUL.java | 4 +- .../{bcel => bcel6_2_0}/generic/DNEG.java | 4 +- .../{bcel => bcel6_2_0}/generic/DREM.java | 4 +- .../{bcel => bcel6_2_0}/generic/DRETURN.java | 4 +- .../{bcel => bcel6_2_0}/generic/DSTORE.java | 6 +- .../{bcel => bcel6_2_0}/generic/DSUB.java | 4 +- .../{bcel => bcel6_2_0}/generic/DUP.java | 4 +- .../{bcel => bcel6_2_0}/generic/DUP2.java | 4 +- .../{bcel => bcel6_2_0}/generic/DUP2_X1.java | 4 +- .../{bcel => bcel6_2_0}/generic/DUP2_X2.java | 4 +- .../{bcel => bcel6_2_0}/generic/DUP_X1.java | 4 +- .../{bcel => bcel6_2_0}/generic/DUP_X2.java | 4 +- .../generic/ElementValueGen.java | 16 +- .../generic/ElementValuePairGen.java | 8 +- .../generic/EmptyVisitor.java | 2 +- .../generic/EnumElementValueGen.java | 8 +- .../generic/ExceptionThrower.java | 2 +- .../{bcel => bcel6_2_0}/generic/F2D.java | 4 +- .../{bcel => bcel6_2_0}/generic/F2I.java | 4 +- .../{bcel => bcel6_2_0}/generic/F2L.java | 4 +- .../{bcel => bcel6_2_0}/generic/FADD.java | 4 +- .../{bcel => bcel6_2_0}/generic/FALOAD.java | 4 +- .../{bcel => bcel6_2_0}/generic/FASTORE.java | 4 +- .../{bcel => bcel6_2_0}/generic/FCMPG.java | 4 +- .../{bcel => bcel6_2_0}/generic/FCMPL.java | 4 +- .../{bcel => bcel6_2_0}/generic/FCONST.java | 10 +- .../{bcel => bcel6_2_0}/generic/FDIV.java | 4 +- .../{bcel => bcel6_2_0}/generic/FLOAD.java | 6 +- .../{bcel => bcel6_2_0}/generic/FMUL.java | 4 +- .../{bcel => bcel6_2_0}/generic/FNEG.java | 4 +- .../{bcel => bcel6_2_0}/generic/FREM.java | 4 +- .../{bcel => bcel6_2_0}/generic/FRETURN.java | 4 +- .../{bcel => bcel6_2_0}/generic/FSTORE.java | 6 +- .../{bcel => bcel6_2_0}/generic/FSUB.java | 4 +- .../{bcel => bcel6_2_0}/generic/FieldGen.java | 24 +-- .../generic/FieldGenOrMethodGen.java | 8 +- .../generic/FieldInstruction.java | 8 +- .../generic/FieldObserver.java | 2 +- .../generic/FieldOrMethod.java | 12 +- .../{bcel => bcel6_2_0}/generic/GETFIELD.java | 6 +- .../generic/GETSTATIC.java | 6 +- .../{bcel => bcel6_2_0}/generic/GOTO.java | 8 +- .../{bcel => bcel6_2_0}/generic/GOTO_W.java | 6 +- .../generic/GotoInstruction.java | 2 +- .../{bcel => bcel6_2_0}/generic/I2B.java | 4 +- .../{bcel => bcel6_2_0}/generic/I2C.java | 4 +- .../{bcel => bcel6_2_0}/generic/I2D.java | 4 +- .../{bcel => bcel6_2_0}/generic/I2F.java | 4 +- .../{bcel => bcel6_2_0}/generic/I2L.java | 4 +- .../{bcel => bcel6_2_0}/generic/I2S.java | 4 +- .../{bcel => bcel6_2_0}/generic/IADD.java | 4 +- .../{bcel => bcel6_2_0}/generic/IALOAD.java | 4 +- .../{bcel => bcel6_2_0}/generic/IAND.java | 4 +- .../{bcel => bcel6_2_0}/generic/IASTORE.java | 4 +- .../{bcel => bcel6_2_0}/generic/ICONST.java | 6 +- .../{bcel => bcel6_2_0}/generic/IDIV.java | 6 +- .../{bcel => bcel6_2_0}/generic/IFEQ.java | 4 +- .../{bcel => bcel6_2_0}/generic/IFGE.java | 4 +- .../{bcel => bcel6_2_0}/generic/IFGT.java | 4 +- .../{bcel => bcel6_2_0}/generic/IFLE.java | 4 +- .../{bcel => bcel6_2_0}/generic/IFLT.java | 4 +- .../{bcel => bcel6_2_0}/generic/IFNE.java | 4 +- .../generic/IFNONNULL.java | 4 +- .../{bcel => bcel6_2_0}/generic/IFNULL.java | 4 +- .../generic/IF_ACMPEQ.java | 4 +- .../generic/IF_ACMPNE.java | 4 +- .../generic/IF_ICMPEQ.java | 4 +- .../generic/IF_ICMPGE.java | 4 +- .../generic/IF_ICMPGT.java | 4 +- .../generic/IF_ICMPLE.java | 4 +- .../generic/IF_ICMPLT.java | 4 +- .../generic/IF_ICMPNE.java | 4 +- .../{bcel => bcel6_2_0}/generic/IINC.java | 10 +- .../{bcel => bcel6_2_0}/generic/ILOAD.java | 6 +- .../{bcel => bcel6_2_0}/generic/IMPDEP1.java | 4 +- .../{bcel => bcel6_2_0}/generic/IMPDEP2.java | 4 +- .../{bcel => bcel6_2_0}/generic/IMUL.java | 4 +- .../{bcel => bcel6_2_0}/generic/INEG.java | 4 +- .../generic/INSTANCEOF.java | 6 +- .../generic/INVOKEDYNAMIC.java | 14 +- .../generic/INVOKEINTERFACE.java | 10 +- .../generic/INVOKESPECIAL.java | 6 +- .../generic/INVOKESTATIC.java | 6 +- .../generic/INVOKEVIRTUAL.java | 6 +- .../{bcel => bcel6_2_0}/generic/IOR.java | 4 +- .../{bcel => bcel6_2_0}/generic/IREM.java | 6 +- .../{bcel => bcel6_2_0}/generic/IRETURN.java | 4 +- .../{bcel => bcel6_2_0}/generic/ISHL.java | 4 +- .../{bcel => bcel6_2_0}/generic/ISHR.java | 4 +- .../{bcel => bcel6_2_0}/generic/ISTORE.java | 6 +- .../{bcel => bcel6_2_0}/generic/ISUB.java | 4 +- .../{bcel => bcel6_2_0}/generic/IUSHR.java | 4 +- .../{bcel => bcel6_2_0}/generic/IXOR.java | 4 +- .../generic/IfInstruction.java | 2 +- .../generic/IndexedInstruction.java | 2 +- .../generic/Instruction.java | 8 +- .../generic/InstructionComparator.java | 2 +- .../generic/InstructionConst.java | 4 +- .../generic/InstructionConstants.java | 4 +- .../generic/InstructionFactory.java | 4 +- .../generic/InstructionHandle.java | 4 +- .../generic/InstructionList.java | 8 +- .../generic/InstructionListObserver.java | 2 +- .../generic/InstructionTargeter.java | 2 +- .../generic/InvokeInstruction.java | 10 +- .../{bcel => bcel6_2_0}/generic/JSR.java | 8 +- .../{bcel => bcel6_2_0}/generic/JSR_W.java | 6 +- .../generic/JsrInstruction.java | 2 +- .../{bcel => bcel6_2_0}/generic/L2D.java | 4 +- .../{bcel => bcel6_2_0}/generic/L2F.java | 4 +- .../{bcel => bcel6_2_0}/generic/L2I.java | 4 +- .../{bcel => bcel6_2_0}/generic/LADD.java | 4 +- .../{bcel => bcel6_2_0}/generic/LALOAD.java | 4 +- .../{bcel => bcel6_2_0}/generic/LAND.java | 4 +- .../{bcel => bcel6_2_0}/generic/LASTORE.java | 4 +- .../{bcel => bcel6_2_0}/generic/LCMP.java | 4 +- .../{bcel => bcel6_2_0}/generic/LCONST.java | 8 +- .../{bcel => bcel6_2_0}/generic/LDC.java | 44 ++--- .../{bcel => bcel6_2_0}/generic/LDC2_W.java | 18 +- .../{bcel => bcel6_2_0}/generic/LDC_W.java | 6 +- .../{bcel => bcel6_2_0}/generic/LDIV.java | 6 +- .../{bcel => bcel6_2_0}/generic/LLOAD.java | 6 +- .../{bcel => bcel6_2_0}/generic/LMUL.java | 4 +- .../{bcel => bcel6_2_0}/generic/LNEG.java | 4 +- .../generic/LOOKUPSWITCH.java | 6 +- .../{bcel => bcel6_2_0}/generic/LOR.java | 4 +- .../{bcel => bcel6_2_0}/generic/LREM.java | 6 +- .../{bcel => bcel6_2_0}/generic/LRETURN.java | 4 +- .../{bcel => bcel6_2_0}/generic/LSHL.java | 4 +- .../{bcel => bcel6_2_0}/generic/LSHR.java | 4 +- .../{bcel => bcel6_2_0}/generic/LSTORE.java | 6 +- .../{bcel => bcel6_2_0}/generic/LSUB.java | 4 +- .../{bcel => bcel6_2_0}/generic/LUSHR.java | 4 +- .../{bcel => bcel6_2_0}/generic/LXOR.java | 4 +- .../generic/LineNumberGen.java | 4 +- .../generic/LoadClass.java | 2 +- .../generic/LoadInstruction.java | 2 +- .../generic/LocalVariableGen.java | 6 +- .../generic/LocalVariableInstruction.java | 6 +- .../generic/MONITORENTER.java | 6 +- .../generic/MONITOREXIT.java | 6 +- .../generic/MULTIANEWARRAY.java | 10 +- .../generic/MethodGen.java | 38 ++-- .../generic/MethodObserver.java | 2 +- .../{bcel => bcel6_2_0}/generic/NEW.java | 6 +- .../{bcel => bcel6_2_0}/generic/NEWARRAY.java | 10 +- .../{bcel => bcel6_2_0}/generic/NOP.java | 4 +- .../generic/NameSignatureInstruction.java | 10 +- .../generic/NamedAndTyped.java | 2 +- .../generic/ObjectType.java | 8 +- .../{bcel => bcel6_2_0}/generic/POP.java | 4 +- .../{bcel => bcel6_2_0}/generic/POP2.java | 4 +- .../{bcel => bcel6_2_0}/generic/PUSH.java | 4 +- .../{bcel => bcel6_2_0}/generic/PUTFIELD.java | 6 +- .../generic/PUTSTATIC.java | 6 +- .../generic/PopInstruction.java | 2 +- .../generic/PushInstruction.java | 2 +- .../{bcel => bcel6_2_0}/generic/RET.java | 10 +- .../{bcel => bcel6_2_0}/generic/RETURN.java | 4 +- .../generic/ReferenceType.java | 8 +- .../generic/ReturnInstruction.java | 6 +- .../generic/ReturnaddressType.java | 4 +- .../{bcel => bcel6_2_0}/generic/SALOAD.java | 4 +- .../{bcel => bcel6_2_0}/generic/SASTORE.java | 4 +- .../{bcel => bcel6_2_0}/generic/SIPUSH.java | 6 +- .../{bcel => bcel6_2_0}/generic/SWAP.java | 4 +- .../{bcel => bcel6_2_0}/generic/SWITCH.java | 2 +- .../{bcel => bcel6_2_0}/generic/Select.java | 4 +- .../generic/SimpleElementValueGen.java | 16 +- .../generic/StackConsumer.java | 2 +- .../generic/StackInstruction.java | 2 +- .../generic/StackProducer.java | 2 +- .../generic/StoreInstruction.java | 2 +- .../generic/TABLESWITCH.java | 6 +- .../generic/TargetLostException.java | 2 +- .../{bcel => bcel6_2_0}/generic/Type.java | 8 +- .../generic/TypedInstruction.java | 2 +- .../generic/UnconditionalBranch.java | 2 +- .../generic/VariableLengthInstruction.java | 2 +- .../{bcel => bcel6_2_0}/generic/Visitor.java | 2 +- .../{bcel => bcel6_2_0}/generic/package.html | 0 .../apache/{bcel => bcel6_2_0}/package.html | 0 .../util/AttributeHTML.java | 34 ++-- .../util/BCELComparator.java | 2 +- .../{bcel => bcel6_2_0}/util/BCELFactory.java | 64 +++---- .../{bcel => bcel6_2_0}/util/BCELifier.java | 28 +-- .../util/ByteSequence.java | 2 +- .../{bcel => bcel6_2_0}/util/Class2HTML.java | 18 +- .../{bcel => bcel6_2_0}/util/ClassLoader.java | 16 +- .../util/ClassLoaderRepository.java | 8 +- .../{bcel => bcel6_2_0}/util/ClassPath.java | 2 +- .../util/ClassPathRepository.java | 8 +- .../{bcel => bcel6_2_0}/util/ClassQueue.java | 4 +- .../{bcel => bcel6_2_0}/util/ClassSet.java | 4 +- .../{bcel => bcel6_2_0}/util/ClassStack.java | 4 +- .../{bcel => bcel6_2_0}/util/ClassVector.java | 4 +- .../{bcel => bcel6_2_0}/util/CodeHTML.java | 30 ++-- .../util/ConstantHTML.java | 24 +-- .../util/InstructionFinder.java | 12 +- .../{bcel => bcel6_2_0}/util/JavaWrapper.java | 2 +- .../MemorySensitiveClassPathRepository.java | 8 +- .../{bcel => bcel6_2_0}/util/MethodHTML.java | 18 +- .../{bcel => bcel6_2_0}/util/Repository.java | 6 +- .../util/SyntheticRepository.java | 4 +- .../{bcel => bcel6_2_0}/util/package.html | 0 .../verifier/GraphicalVerifier.java | 4 +- .../verifier/NativeVerifier.java | 2 +- .../verifier/PassVerifier.java | 2 +- .../verifier/TransitiveHull.java | 6 +- .../verifier/VerificationResult.java | 2 +- .../verifier/Verifier.java | 20 +-- .../verifier/VerifierAppFrame.java | 6 +- .../verifier/VerifierFactory.java | 2 +- .../verifier/VerifierFactoryListModel.java | 2 +- .../verifier/VerifierFactoryObserver.java | 2 +- .../verifier/VerifyDialog.java | 6 +- .../exc/AssertionViolatedException.java | 2 +- .../exc/ClassConstraintException.java | 2 +- .../verifier/exc/CodeConstraintException.java | 2 +- .../verifier/exc/InvalidMethodException.java | 2 +- .../exc/LinkingConstraintException.java | 2 +- .../verifier/exc/LoadingException.java | 2 +- ...ocalVariableInfoInconsistentException.java | 2 +- .../exc/StaticCodeConstraintException.java | 2 +- ...ticCodeInstructionConstraintException.java | 2 +- ...InstructionOperandConstraintException.java | 2 +- .../StructuralCodeConstraintException.java | 2 +- .../verifier/exc/Utility.java | 2 +- .../verifier/exc/VerificationException.java | 2 +- .../VerifierConstraintViolatedException.java | 2 +- .../verifier/exc/package.html | 0 .../{bcel => bcel6_2_0}/verifier/package.html | 0 .../verifier/statics/DOUBLE_Upper.java | 6 +- .../verifier/statics/IntList.java | 2 +- .../verifier/statics/LONG_Upper.java | 6 +- .../verifier/statics/LocalVariableInfo.java | 6 +- .../verifier/statics/LocalVariablesInfo.java | 8 +- .../verifier/statics/Pass1Verifier.java | 22 +-- .../verifier/statics/Pass2Verifier.java | 102 +++++------ .../verifier/statics/Pass3aVerifier.java | 170 +++++++++--------- .../statics/StringRepresentation.java | 100 +++++------ .../verifier/statics/package.html | 0 .../structurals/ControlFlowGraph.java | 26 +-- .../structurals/ExceptionHandler.java | 6 +- .../structurals/ExceptionHandlers.java | 8 +- .../structurals/ExecutionVisitor.java | 22 ++- .../verifier/structurals/Frame.java | 2 +- .../verifier/structurals/GenericArray.java | 2 +- .../structurals/InstConstraintVisitor.java | 44 +++-- .../structurals/InstructionContext.java | 4 +- .../verifier/structurals/LocalVariables.java | 10 +- .../verifier/structurals/OperandStack.java | 12 +- .../verifier/structurals/Pass3bVerifier.java | 48 ++--- .../verifier/structurals/Subroutine.java | 4 +- .../verifier/structurals/Subroutines.java | 34 ++-- .../structurals/UninitializedObjectType.java | 10 +- .../verifier/structurals/package.html | 0 .../java/resource/ClassFileModelLoader.java | 32 ++-- 387 files changed, 1348 insertions(+), 1351 deletions(-) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/Const.java (97%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/Constants.java (98%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/ExceptionConst.java (97%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/ExceptionConstants.java (97%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/Repository.java (91%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/AccessFlags.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/AnnotationDefault.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/AnnotationElementValue.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/AnnotationEntry.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/Annotations.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ArrayElementValue.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/Attribute.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/AttributeReader.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/BootstrapMethod.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/BootstrapMethods.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ClassElementValue.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ClassFormatException.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ClassParser.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/Code.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/CodeException.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/Constant.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ConstantCP.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ConstantClass.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ConstantDouble.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ConstantFieldref.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ConstantFloat.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ConstantInteger.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ConstantInterfaceMethodref.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ConstantInvokeDynamic.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ConstantLong.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ConstantMethodHandle.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ConstantMethodType.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ConstantMethodref.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ConstantModule.java (97%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ConstantNameAndType.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ConstantObject.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ConstantPackage.java (97%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ConstantPool.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ConstantString.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ConstantUtf8.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ConstantValue.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/Deprecated.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/DescendingVisitor.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ElementValue.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ElementValuePair.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/EmptyVisitor.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/EnclosingMethod.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/EnumElementValue.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ExceptionTable.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/Field.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/FieldOrMethod.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/InnerClass.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/InnerClasses.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/JavaClass.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/LineNumber.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/LineNumberTable.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/LocalVariable.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/LocalVariableTable.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/LocalVariableTypeTable.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/Method.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/MethodParameter.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/MethodParameters.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/Node.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/PMGClass.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ParameterAnnotationEntry.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/ParameterAnnotations.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/RuntimeInvisibleAnnotations.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/RuntimeInvisibleParameterAnnotations.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/RuntimeVisibleAnnotations.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/RuntimeVisibleParameterAnnotations.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/Signature.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/SimpleElementValue.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/SourceFile.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/StackMap.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/StackMapEntry.java (97%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/StackMapType.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/Synthetic.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/Unknown.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/UnknownAttributeReader.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/Utility.java (97%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/Visitor.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/classfile/package.html (100%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/AALOAD.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/AASTORE.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ACONST_NULL.java (91%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ALOAD.java (86%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ANEWARRAY.java (91%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ARETURN.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ARRAYLENGTH.java (90%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ASTORE.java (86%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ATHROW.java (89%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/AllocationInstruction.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/AnnotationElementValueGen.java (91%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/AnnotationEntryGen.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ArithmeticInstruction.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ArrayElementValueGen.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ArrayInstruction.java (68%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ArrayType.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/BALOAD.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/BASTORE.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/BIPUSH.java (91%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/BREAKPOINT.java (90%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/BasicType.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/BranchHandle.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/BranchInstruction.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/CALOAD.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/CASTORE.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/CHECKCAST.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/CPInstruction.java (88%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ClassElementValueGen.java (90%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ClassGen.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ClassGenException.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ClassObserver.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/CodeExceptionGen.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/CompoundInstruction.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ConstantPoolGen.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ConstantPushInstruction.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ConversionInstruction.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/D2F.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/D2I.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/D2L.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/DADD.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/DALOAD.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/DASTORE.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/DCMPG.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/DCMPL.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/DCONST.java (87%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/DDIV.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/DLOAD.java (86%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/DMUL.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/DNEG.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/DREM.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/DRETURN.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/DSTORE.java (86%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/DSUB.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/DUP.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/DUP2.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/DUP2_X1.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/DUP2_X2.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/DUP_X1.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/DUP_X2.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ElementValueGen.java (91%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ElementValuePairGen.java (91%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/EmptyVisitor.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/EnumElementValueGen.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ExceptionThrower.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/F2D.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/F2I.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/F2L.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/FADD.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/FALOAD.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/FASTORE.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/FCMPG.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/FCMPL.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/FCONST.java (85%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/FDIV.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/FLOAD.java (86%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/FMUL.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/FNEG.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/FREM.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/FRETURN.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/FSTORE.java (86%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/FSUB.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/FieldGen.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/FieldGenOrMethodGen.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/FieldInstruction.java (88%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/FieldObserver.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/FieldOrMethod.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/GETFIELD.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/GETSTATIC.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/GOTO.java (91%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/GOTO_W.java (91%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/GotoInstruction.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/I2B.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/I2C.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/I2D.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/I2F.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/I2L.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/I2S.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IADD.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IALOAD.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IAND.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IASTORE.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ICONST.java (88%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IDIV.java (90%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IFEQ.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IFGE.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IFGT.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IFLE.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IFLT.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IFNE.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IFNONNULL.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IFNULL.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IF_ACMPEQ.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IF_ACMPNE.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IF_ICMPEQ.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IF_ICMPGE.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IF_ICMPGT.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IF_ICMPLE.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IF_ICMPLT.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IF_ICMPNE.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IINC.java (90%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ILOAD.java (86%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IMPDEP1.java (90%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IMPDEP2.java (90%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IMUL.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/INEG.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/INSTANCEOF.java (91%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/INVOKEDYNAMIC.java (90%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/INVOKEINTERFACE.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/INVOKESPECIAL.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/INVOKESTATIC.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/INVOKEVIRTUAL.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IOR.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IREM.java (90%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IRETURN.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ISHL.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ISHR.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ISTORE.java (86%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ISUB.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IUSHR.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IXOR.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IfInstruction.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/IndexedInstruction.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/Instruction.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/InstructionComparator.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/InstructionConst.java (97%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/InstructionConstants.java (97%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/InstructionFactory.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/InstructionHandle.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/InstructionList.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/InstructionListObserver.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/InstructionTargeter.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/InvokeInstruction.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/JSR.java (89%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/JSR_W.java (91%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/JsrInstruction.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/L2D.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/L2F.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/L2I.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LADD.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LALOAD.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LAND.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LASTORE.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LCMP.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LCONST.java (87%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LDC.java (69%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LDC2_W.java (76%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LDC_W.java (88%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LDIV.java (90%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LLOAD.java (86%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LMUL.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LNEG.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LOOKUPSWITCH.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LOR.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LREM.java (90%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LRETURN.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LSHL.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LSHR.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LSTORE.java (85%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LSUB.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LUSHR.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LXOR.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LineNumberGen.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LoadClass.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LoadInstruction.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LocalVariableGen.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/LocalVariableInstruction.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/MONITORENTER.java (89%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/MONITOREXIT.java (89%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/MULTIANEWARRAY.java (91%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/MethodGen.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/MethodObserver.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/NEW.java (91%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/NEWARRAY.java (88%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/NOP.java (90%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/NameSignatureInstruction.java (89%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/NamedAndTyped.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ObjectType.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/POP.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/POP2.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/PUSH.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/PUTFIELD.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/PUTSTATIC.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/PopInstruction.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/PushInstruction.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/RET.java (89%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/RETURN.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ReferenceType.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ReturnInstruction.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/ReturnaddressType.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/SALOAD.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/SASTORE.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/SIPUSH.java (91%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/SWAP.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/SWITCH.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/Select.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/SimpleElementValueGen.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/StackConsumer.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/StackInstruction.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/StackProducer.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/StoreInstruction.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/TABLESWITCH.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/TargetLostException.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/Type.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/TypedInstruction.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/UnconditionalBranch.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/VariableLengthInstruction.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/Visitor.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/generic/package.html (100%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/package.html (100%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/util/AttributeHTML.java (89%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/util/BCELComparator.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/util/BCELFactory.java (85%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/util/BCELifier.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/util/ByteSequence.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/util/Class2HTML.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/util/ClassLoader.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/util/ClassLoaderRepository.java (91%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/util/ClassPath.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/util/ClassPathRepository.java (97%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/util/ClassQueue.java (91%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/util/ClassSet.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/util/ClassStack.java (90%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/util/ClassVector.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/util/CodeHTML.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/util/ConstantHTML.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/util/InstructionFinder.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/util/JavaWrapper.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/util/MemorySensitiveClassPathRepository.java (97%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/util/MethodHTML.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/util/Repository.java (91%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/util/SyntheticRepository.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/util/package.html (100%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/GraphicalVerifier.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/NativeVerifier.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/PassVerifier.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/TransitiveHull.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/VerificationResult.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/Verifier.java (90%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/VerifierAppFrame.java (97%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/VerifierFactory.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/VerifierFactoryListModel.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/VerifierFactoryObserver.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/VerifyDialog.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/exc/AssertionViolatedException.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/exc/ClassConstraintException.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/exc/CodeConstraintException.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/exc/InvalidMethodException.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/exc/LinkingConstraintException.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/exc/LoadingException.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/exc/LocalVariableInfoInconsistentException.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/exc/StaticCodeConstraintException.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/exc/StaticCodeInstructionConstraintException.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/exc/StaticCodeInstructionOperandConstraintException.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/exc/StructuralCodeConstraintException.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/exc/Utility.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/exc/VerificationException.java (95%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/exc/VerifierConstraintViolatedException.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/exc/package.html (100%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/package.html (100%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/statics/DOUBLE_Upper.java (89%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/statics/IntList.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/statics/LONG_Upper.java (89%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/statics/LocalVariableInfo.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/statics/LocalVariablesInfo.java (90%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/statics/Pass1Verifier.java (92%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/statics/Pass2Verifier.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/statics/Pass3aVerifier.java (91%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/statics/StringRepresentation.java (76%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/statics/package.html (100%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/structurals/ControlFlowGraph.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/structurals/ExceptionHandler.java (90%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/structurals/ExceptionHandlers.java (90%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/structurals/ExecutionVisitor.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/structurals/Frame.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/structurals/GenericArray.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/structurals/InstConstraintVisitor.java (96%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/structurals/InstructionContext.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/structurals/LocalVariables.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/structurals/OperandStack.java (93%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/structurals/Pass3bVerifier.java (91%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/structurals/Subroutine.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/structurals/Subroutines.java (94%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/structurals/UninitializedObjectType.java (88%) rename Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/{bcel => bcel6_2_0}/verifier/structurals/package.html (100%) diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/Const.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/Const.java similarity index 97% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/Const.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/Const.java index 98003940..f60769c6 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/Const.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/Const.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel; +package org.apache.bcel6_2_0; import java.util.Arrays; import java.util.Collections; diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/Constants.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/Constants.java similarity index 98% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/Constants.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/Constants.java index 951a7b1c..8562d0bb 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/Constants.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/Constants.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel; +package org.apache.bcel6_2_0; /** * Constants for the project, mostly defined in the JVM specification. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/ExceptionConst.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/ExceptionConst.java similarity index 97% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/ExceptionConst.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/ExceptionConst.java index b8345c9e..72355968 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/ExceptionConst.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/ExceptionConst.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel; +package org.apache.bcel6_2_0; /** * Exception constants. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/ExceptionConstants.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/ExceptionConstants.java similarity index 97% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/ExceptionConstants.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/ExceptionConstants.java index 262e3d45..b551008d 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/ExceptionConstants.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/ExceptionConstants.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel; +package org.apache.bcel6_2_0; /** * Exception constants. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/Repository.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/Repository.java similarity index 91% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/Repository.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/Repository.java index 44d6879a..9925709c 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/Repository.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/Repository.java @@ -15,39 +15,39 @@ * limitations under the License. * */ -package org.apache.bcel; +package org.apache.bcel6_2_0; import java.io.IOException; -import org.apache.bcel.classfile.JavaClass; -import org.apache.bcel.util.ClassPath; -import org.apache.bcel.util.SyntheticRepository; +import org.apache.bcel6_2_0.classfile.JavaClass; +import org.apache.bcel6_2_0.util.ClassPath; +import org.apache.bcel6_2_0.util.SyntheticRepository; /** * The repository maintains informations about class interdependencies, e.g., * whether a class is a sub-class of another. Delegates actual class loading * to SyntheticRepository with current class path by default. * - * @see org.apache.bcel.util.Repository + * @see org.apache.bcel6_2_0.util.Repository * @see SyntheticRepository * * @version $Id: Repository.java 1749603 2016-06-21 20:50:19Z ggregory $ */ public abstract class Repository { - private static org.apache.bcel.util.Repository repository = SyntheticRepository.getInstance(); + private static org.apache.bcel6_2_0.util.Repository repository = SyntheticRepository.getInstance(); /** @return currently used repository instance */ - public static org.apache.bcel.util.Repository getRepository() { + public static org.apache.bcel6_2_0.util.Repository getRepository() { return repository; } /** Set repository instance to be used for class loading */ - public static void setRepository( final org.apache.bcel.util.Repository rep ) { + public static void setRepository( final org.apache.bcel6_2_0.util.Repository rep ) { repository = rep; } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AccessFlags.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/AccessFlags.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AccessFlags.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/AccessFlags.java index 179274b2..3f92a88c 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AccessFlags.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/AccessFlags.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * Super class for all objects that have modifiers like private, final, ... I.e. classes, fields, and methods. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AnnotationDefault.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/AnnotationDefault.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AnnotationDefault.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/AnnotationDefault.java index 1ac4f921..bbfe58bc 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AnnotationDefault.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/AnnotationDefault.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * Represents the default value of a annotation for a method info diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AnnotationElementValue.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/AnnotationElementValue.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AnnotationElementValue.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/AnnotationElementValue.java index 2ad29998..43aa7a56 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AnnotationElementValue.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/AnnotationElementValue.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataOutputStream; import java.io.IOException; diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AnnotationEntry.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/AnnotationEntry.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AnnotationEntry.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/AnnotationEntry.java index 5d6d5578..107949fc 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AnnotationEntry.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/AnnotationEntry.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; @@ -24,7 +24,7 @@ import java.util.Collections; import java.util.List; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * represents one annotation in the annotation table diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Annotations.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Annotations.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Annotations.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Annotations.java index 878db32b..3590b6d7 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Annotations.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Annotations.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ArrayElementValue.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ArrayElementValue.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ArrayElementValue.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ArrayElementValue.java index 07d57ea7..2da4471a 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ArrayElementValue.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ArrayElementValue.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataOutputStream; import java.io.IOException; diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Attribute.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Attribute.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Attribute.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Attribute.java index 0afe641d..d0bcdd07 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Attribute.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Attribute.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataInputStream; @@ -24,7 +24,7 @@ import java.util.HashMap; import java.util.Map; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * Abstract super class for Attribute objects. Currently the diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AttributeReader.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/AttributeReader.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AttributeReader.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/AttributeReader.java index 7b897d62..6e2df1aa 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/AttributeReader.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/AttributeReader.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; /** * Unknown (non-standard) attributes may be read via user-defined factory diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/BootstrapMethod.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/BootstrapMethod.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/BootstrapMethod.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/BootstrapMethod.java index 988e15c9..c28a1252 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/BootstrapMethod.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/BootstrapMethod.java @@ -15,14 +15,14 @@ * limitations under the License. */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; import java.util.Arrays; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class represents a bootstrap method attribute, i.e., the bootstrap diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/BootstrapMethods.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/BootstrapMethods.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/BootstrapMethods.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/BootstrapMethods.java index 994cb759..ee611768 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/BootstrapMethods.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/BootstrapMethods.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class represents a BootstrapMethods attribute. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ClassElementValue.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ClassElementValue.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ClassElementValue.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ClassElementValue.java index 16820161..7e7fa3e3 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ClassElementValue.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ClassElementValue.java @@ -15,12 +15,12 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * @since 6.0 diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ClassFormatException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ClassFormatException.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ClassFormatException.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ClassFormatException.java index ec52dc27..93fa61eb 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ClassFormatException.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ClassFormatException.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; /** * Thrown when the BCEL attempts to read a class file and determines diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ClassParser.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ClassParser.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ClassParser.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ClassParser.java index 37d3a34e..96983efc 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ClassParser.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ClassParser.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.BufferedInputStream; import java.io.DataInputStream; @@ -25,7 +25,7 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * Wrapper class that parses a given Java .class file. The method Code diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Constant.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Constant.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Constant.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Constant.java index 7199dd1b..41795584 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Constant.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Constant.java @@ -15,14 +15,14 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; -import org.apache.bcel.util.BCELComparator; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.util.BCELComparator; /** * Abstract superclass for classes to represent the different constant types diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantCP.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantCP.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantCP.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantCP.java index 485fbc13..45caf61d 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantCP.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantCP.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * Abstract super class for Fieldref, Methodref, InterfaceMethodref and diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantClass.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantClass.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantClass.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantClass.java index 5b10110f..e870d3cd 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantClass.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantClass.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class is derived from the abstract {@link Constant} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantDouble.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantDouble.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantDouble.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantDouble.java index e2622332..95cf78e7 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantDouble.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantDouble.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class is derived from the abstract {@link Constant} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantFieldref.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantFieldref.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantFieldref.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantFieldref.java index 1b13742b..8777c78e 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantFieldref.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantFieldref.java @@ -15,12 +15,12 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class represents a constant pool reference to a field. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantFloat.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantFloat.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantFloat.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantFloat.java index 259fe48f..a41f01a2 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantFloat.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantFloat.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class is derived from the abstract {@link Constant} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantInteger.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantInteger.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantInteger.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantInteger.java index e5cab54b..5e3a9f63 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantInteger.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantInteger.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class is derived from the abstract {@link Constant} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantInterfaceMethodref.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantInterfaceMethodref.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantInterfaceMethodref.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantInterfaceMethodref.java index bf7620f8..b9d19389 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantInterfaceMethodref.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantInterfaceMethodref.java @@ -15,12 +15,12 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class represents a constant pool reference to an interface method. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantInvokeDynamic.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantInvokeDynamic.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantInvokeDynamic.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantInvokeDynamic.java index 5c23745f..375bec1b 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantInvokeDynamic.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantInvokeDynamic.java @@ -15,12 +15,12 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class is derived from the abstract {@link Constant} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantLong.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantLong.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantLong.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantLong.java index ec44efac..a13fb9be 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantLong.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantLong.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class is derived from the abstract {@link Constant} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantMethodHandle.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantMethodHandle.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantMethodHandle.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantMethodHandle.java index 29fc2248..59dc03ce 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantMethodHandle.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantMethodHandle.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class is derived from the abstract {@link Constant} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantMethodType.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantMethodType.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantMethodType.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantMethodType.java index 72234051..a43a5a9d 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantMethodType.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantMethodType.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class is derived from the abstract {@link Constant} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantMethodref.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantMethodref.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantMethodref.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantMethodref.java index 959c479b..a695cdf0 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantMethodref.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantMethodref.java @@ -15,12 +15,12 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class represents a constant pool reference to a method. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantModule.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantModule.java similarity index 97% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantModule.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantModule.java index 2d746aea..2a05abe7 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantModule.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantModule.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class is derived from the abstract {@link Constant} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantNameAndType.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantNameAndType.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantNameAndType.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantNameAndType.java index 3267fa60..b9b3ae9e 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantNameAndType.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantNameAndType.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class is derived from the abstract {@link Constant} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantObject.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantObject.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantObject.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantObject.java index 8c056e58..faf9e8e8 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantObject.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantObject.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; /** * This interface denotes those constants that have a "natural" value, diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantPackage.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantPackage.java similarity index 97% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantPackage.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantPackage.java index ed432847..78d16ca1 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantPackage.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantPackage.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class is derived from the abstract {@link Constant} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantPool.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantPool.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantPool.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantPool.java index 0ce9a528..00efa0e8 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantPool.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantPool.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class represents the constant pool, i.e., a table of constants, of @@ -33,7 +33,7 @@ * @version $Id: ConstantPool.java 1806200 2017-08-25 16:33:06Z ggregory $ * @see Constant - * @see org.apache.bcel.generic.ConstantPoolGen + * @see org.apache.bcel6_2_0.generic.ConstantPoolGen */ public class ConstantPool implements Cloneable, Node { diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantString.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantString.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantString.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantString.java index 17bc0b77..a12766ad 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantString.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantString.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class is derived from the abstract {@link Constant} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantUtf8.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantUtf8.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantUtf8.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantUtf8.java index 82d5aff6..5023b235 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantUtf8.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantUtf8.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; @@ -24,7 +24,7 @@ import java.util.LinkedHashMap; import java.util.Map; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class is derived from the abstract {@link Constant} diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantValue.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantValue.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantValue.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantValue.java index c5b0d2e6..0035ab31 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ConstantValue.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ConstantValue.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class is derived from Attribute and represents a constant diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Deprecated.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Deprecated.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Deprecated.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Deprecated.java index a5aba52c..e9acfc2e 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Deprecated.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Deprecated.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class is derived from Attribute and denotes that this is a diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/DescendingVisitor.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/DescendingVisitor.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/DescendingVisitor.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/DescendingVisitor.java index 1c3f70f6..b8a91cf1 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/DescendingVisitor.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/DescendingVisitor.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.util.Stack; diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ElementValue.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ElementValue.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ElementValue.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ElementValue.java index ffd7bb96..a7082a3e 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ElementValue.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ElementValue.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ElementValuePair.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ElementValuePair.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ElementValuePair.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ElementValuePair.java index 672aebe5..20c9cca2 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ElementValuePair.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ElementValuePair.java @@ -15,12 +15,12 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * an annotation's element value pair diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/EmptyVisitor.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/EmptyVisitor.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/EmptyVisitor.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/EmptyVisitor.java index 89b343b5..7b17f279 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/EmptyVisitor.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/EmptyVisitor.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; /** * Visitor with empty method bodies, can be extended and used in conjunction diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/EnclosingMethod.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/EnclosingMethod.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/EnclosingMethod.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/EnclosingMethod.java index 88cbd507..6f71294f 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/EnclosingMethod.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/EnclosingMethod.java @@ -14,13 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This attribute exists for local or diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/EnumElementValue.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/EnumElementValue.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/EnumElementValue.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/EnumElementValue.java index ec5d82dc..0b863fb5 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/EnumElementValue.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/EnumElementValue.java @@ -15,12 +15,12 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * @since 6.0 diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ExceptionTable.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ExceptionTable.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ExceptionTable.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ExceptionTable.java index db7bb8b3..af0b4606 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ExceptionTable.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ExceptionTable.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class represents the table of exceptions that are thrown by a diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Field.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Field.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Field.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Field.java index 96da080a..d6679945 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Field.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Field.java @@ -15,14 +15,14 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.IOException; -import org.apache.bcel.Const; -import org.apache.bcel.generic.Type; -import org.apache.bcel.util.BCELComparator; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.generic.Type; +import org.apache.bcel6_2_0.util.BCELComparator; /** * This class represents the field info structure, i.e., the representation diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/FieldOrMethod.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/FieldOrMethod.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/FieldOrMethod.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/FieldOrMethod.java index 331d9835..ebd2ccd1 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/FieldOrMethod.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/FieldOrMethod.java @@ -15,14 +15,14 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * Abstract super class for fields and methods. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/InnerClass.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/InnerClass.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/InnerClass.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/InnerClass.java index ca34f1c8..04da9146 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/InnerClass.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/InnerClass.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class represents a inner class attribute, i.e., the class diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/InnerClasses.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/InnerClasses.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/InnerClasses.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/InnerClasses.java index 9faaf6ab..094c78cd 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/InnerClasses.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/InnerClasses.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class is derived from Attribute and denotes that this class diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/JavaClass.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/JavaClass.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/JavaClass.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/JavaClass.java index fe615c8a..4e40035a 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/JavaClass.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/JavaClass.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; @@ -29,11 +29,11 @@ import java.util.StringTokenizer; import java.util.TreeSet; -import org.apache.bcel.Const; -import org.apache.bcel.generic.Type; -import org.apache.bcel.util.BCELComparator; -import org.apache.bcel.util.ClassQueue; -import org.apache.bcel.util.SyntheticRepository; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.generic.Type; +import org.apache.bcel6_2_0.util.BCELComparator; +import org.apache.bcel6_2_0.util.ClassQueue; +import org.apache.bcel6_2_0.util.SyntheticRepository; /** * Represents a Java class, i.e., the data structures, constant pool, @@ -44,7 +44,7 @@ * should see the ClassGen class. * @version $Id: JavaClass.java 1806200 2017-08-25 16:33:06Z ggregory $ - * @see org.apache.bcel.generic.ClassGen + * @see org.apache.bcel6_2_0.generic.ClassGen */ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparable { @@ -94,7 +94,7 @@ public int hashCode( final Object o ) { * use the default SyntheticRepository, because we * don't know any better. */ - private transient org.apache.bcel.util.Repository repository = SyntheticRepository + private transient org.apache.bcel6_2_0.util.Repository repository = SyntheticRepository .getInstance(); @@ -750,7 +750,7 @@ public final byte getSource() { * Gets the ClassRepository which holds its definition. By default * this is the same as SyntheticRepository.getInstance(); */ - public org.apache.bcel.util.Repository getRepository() { + public org.apache.bcel6_2_0.util.Repository getRepository() { return repository; } @@ -759,7 +759,7 @@ public org.apache.bcel.util.Repository getRepository() { * Sets the ClassRepository which loaded the JavaClass. * Should be called immediately after parsing is done. */ - public void setRepository( final org.apache.bcel.util.Repository repository ) { // TODO make protected? + public void setRepository( final org.apache.bcel6_2_0.util.Repository repository ) { // TODO make protected? this.repository = repository; } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LineNumber.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/LineNumber.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LineNumber.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/LineNumber.java index 6d6f86b9..2ac82ba3 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LineNumber.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/LineNumber.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LineNumberTable.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/LineNumberTable.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LineNumberTable.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/LineNumberTable.java index 698b37cb..38711a3c 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LineNumberTable.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/LineNumberTable.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class represents a table of line numbers for debugging diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LocalVariable.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/LocalVariable.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LocalVariable.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/LocalVariable.java index 5c14904d..b9e91c8c 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LocalVariable.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/LocalVariable.java @@ -15,14 +15,14 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; -import org.apache.bcel.Constants; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.Constants; /** * This class represents a local variable within a method. It contains its diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LocalVariableTable.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/LocalVariableTable.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LocalVariableTable.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/LocalVariableTable.java index 9e9822c8..330f0df2 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LocalVariableTable.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/LocalVariableTable.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class represents colection of local variables in a diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LocalVariableTypeTable.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/LocalVariableTypeTable.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LocalVariableTypeTable.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/LocalVariableTypeTable.java index 1ed60ba9..de222617 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/LocalVariableTypeTable.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/LocalVariableTypeTable.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; // The new table is used when generic types are about... diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Method.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Method.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Method.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Method.java index a490f11f..2c422b4b 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Method.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Method.java @@ -15,14 +15,14 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.IOException; -import org.apache.bcel.Const; -import org.apache.bcel.generic.Type; -import org.apache.bcel.util.BCELComparator; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.generic.Type; +import org.apache.bcel6_2_0.util.BCELComparator; /** * This class represents the method info structure, i.e., the representation diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/MethodParameter.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/MethodParameter.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/MethodParameter.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/MethodParameter.java index 4d2a1481..9d19ffa0 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/MethodParameter.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/MethodParameter.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * Entry of the parameters table. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/MethodParameters.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/MethodParameters.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/MethodParameters.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/MethodParameters.java index f27ccba4..8264a0cd 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/MethodParameters.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/MethodParameters.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class represents a MethodParameters attribute. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Node.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Node.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Node.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Node.java index 32c27907..e3c53ba5 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Node.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Node.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; /** * Denote class to have an accept method(); diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/PMGClass.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/PMGClass.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/PMGClass.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/PMGClass.java index 40ede360..e3c90e94 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/PMGClass.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/PMGClass.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class is derived from Attribute and represents a reference diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ParameterAnnotationEntry.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ParameterAnnotationEntry.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ParameterAnnotationEntry.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ParameterAnnotationEntry.java index 339ef7be..fb94f2d7 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ParameterAnnotationEntry.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ParameterAnnotationEntry.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ParameterAnnotations.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ParameterAnnotations.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ParameterAnnotations.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ParameterAnnotations.java index 83cc95d2..8a9643a6 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/ParameterAnnotations.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/ParameterAnnotations.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeInvisibleAnnotations.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/RuntimeInvisibleAnnotations.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeInvisibleAnnotations.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/RuntimeInvisibleAnnotations.java index b71d720e..e832b93a 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeInvisibleAnnotations.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/RuntimeInvisibleAnnotations.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * represents an annotation that is represented in the class file but is not diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeInvisibleParameterAnnotations.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/RuntimeInvisibleParameterAnnotations.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeInvisibleParameterAnnotations.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/RuntimeInvisibleParameterAnnotations.java index 1910bd7b..6941e89b 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeInvisibleParameterAnnotations.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/RuntimeInvisibleParameterAnnotations.java @@ -15,12 +15,12 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * Represents a parameter annotation that is represented in the class file diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeVisibleAnnotations.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/RuntimeVisibleAnnotations.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeVisibleAnnotations.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/RuntimeVisibleAnnotations.java index 3cfdcf60..a99968dc 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeVisibleAnnotations.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/RuntimeVisibleAnnotations.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * represents an annotation that is represented in the class file and is diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeVisibleParameterAnnotations.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/RuntimeVisibleParameterAnnotations.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeVisibleParameterAnnotations.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/RuntimeVisibleParameterAnnotations.java index 306bdee0..6488662e 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/RuntimeVisibleParameterAnnotations.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/RuntimeVisibleParameterAnnotations.java @@ -15,12 +15,12 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * Represents a parameter annotation that is represented in the class file diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Signature.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Signature.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Signature.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Signature.java index 82ff4574..fbf4bcb6 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Signature.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Signature.java @@ -15,14 +15,14 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.ByteArrayInputStream; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class is derived from Attribute and represents a reference diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/SimpleElementValue.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/SimpleElementValue.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/SimpleElementValue.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/SimpleElementValue.java index 5572452a..8293b26e 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/SimpleElementValue.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/SimpleElementValue.java @@ -15,12 +15,12 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * @since 6.0 diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/SourceFile.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/SourceFile.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/SourceFile.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/SourceFile.java index 2b183327..e9d97c86 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/SourceFile.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/SourceFile.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class is derived from Attribute and represents a reference diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/StackMap.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/StackMap.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/StackMap.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/StackMap.java index d83e1c2a..c7aa78c4 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/StackMap.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/StackMap.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class represents a stack map attribute used for diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/StackMapEntry.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/StackMapEntry.java similarity index 97% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/StackMapEntry.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/StackMapEntry.java index 4c1ec29e..e4a608d5 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/StackMapEntry.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/StackMapEntry.java @@ -15,12 +15,13 @@ * limitations under the License. */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; + +import org.apache.bcel6_2_0.Const; /** * This class represents a stack map entry recording the types of diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/StackMapType.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/StackMapType.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/StackMapType.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/StackMapType.java index a7bda56d..7f0886cb 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/StackMapType.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/StackMapType.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class represents the type of a local variable or item on stack diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Synthetic.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Synthetic.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Synthetic.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Synthetic.java index c3503265..92c51859 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Synthetic.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Synthetic.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class is derived from Attribute and declares this class as diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Unknown.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Unknown.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Unknown.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Unknown.java index c53511d2..dbf24f6b 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Unknown.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Unknown.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.DataInput; import java.io.DataOutputStream; @@ -23,7 +23,7 @@ import java.util.HashMap; import java.util.Map; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This class represents a reference to an unknown (i.e., diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/UnknownAttributeReader.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/UnknownAttributeReader.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/UnknownAttributeReader.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/UnknownAttributeReader.java index a7f56c96..8b60a7b9 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/UnknownAttributeReader.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/UnknownAttributeReader.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; /** * Unknown (non-standard) attributes may be read via user-defined factory diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Utility.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Utility.java similarity index 97% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Utility.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Utility.java index 1e324c16..0c0ef9ce 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Utility.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Utility.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -34,8 +34,8 @@ import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; -import org.apache.bcel.Const; -import org.apache.bcel.util.ByteSequence; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.util.ByteSequence; /** * Utility functions that do not really belong to any class in particular. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Visitor.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Visitor.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Visitor.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Visitor.java index 15004a5b..e1023853 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/Visitor.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/Visitor.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.classfile; +package org.apache.bcel6_2_0.classfile; /** * Interface to make use of the Visitor pattern programming style. I.e. a class diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/package.html b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/package.html similarity index 100% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/classfile/package.html rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/classfile/package.html diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AALOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/AALOAD.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AALOAD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/AALOAD.java index 55b791b4..f0b185fd 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AALOAD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/AALOAD.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * AALOAD - Load reference from array @@ -28,7 +28,7 @@ public class AALOAD extends ArrayInstruction implements StackProducer { /** Load reference from array */ public AALOAD() { - super(org.apache.bcel.Const.AALOAD); + super(org.apache.bcel6_2_0.Const.AALOAD); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AASTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/AASTORE.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AASTORE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/AASTORE.java index 5afe322c..a13cf63a 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AASTORE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/AASTORE.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * AASTORE - Store into reference array @@ -28,7 +28,7 @@ public class AASTORE extends ArrayInstruction implements StackConsumer { /** Store into reference array */ public AASTORE() { - super(org.apache.bcel.Const.AASTORE); + super(org.apache.bcel6_2_0.Const.AASTORE); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ACONST_NULL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ACONST_NULL.java similarity index 91% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ACONST_NULL.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ACONST_NULL.java index cabad429..a8502160 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ACONST_NULL.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ACONST_NULL.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * ACONST_NULL - Push null reference @@ -29,7 +29,7 @@ public class ACONST_NULL extends Instruction implements PushInstruction, TypedIn * Push null reference */ public ACONST_NULL() { - super(org.apache.bcel.Const.ACONST_NULL, (short) 1); + super(org.apache.bcel6_2_0.Const.ACONST_NULL, (short) 1); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ALOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ALOAD.java similarity index 86% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ALOAD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ALOAD.java index 5971c0e1..df115232 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ALOAD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ALOAD.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * ALOAD - Load reference from local variable @@ -30,7 +30,7 @@ public class ALOAD extends LoadInstruction { * Not to be used otherwise. */ ALOAD() { - super(org.apache.bcel.Const.ALOAD, org.apache.bcel.Const.ALOAD_0); + super(org.apache.bcel6_2_0.Const.ALOAD, org.apache.bcel6_2_0.Const.ALOAD_0); } @@ -38,7 +38,7 @@ public class ALOAD extends LoadInstruction { * @param n index of local variable */ public ALOAD(final int n) { - super(org.apache.bcel.Const.ALOAD, org.apache.bcel.Const.ALOAD_0, n); + super(org.apache.bcel6_2_0.Const.ALOAD, org.apache.bcel6_2_0.Const.ALOAD_0, n); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ANEWARRAY.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ANEWARRAY.java similarity index 91% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ANEWARRAY.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ANEWARRAY.java index 3f91b8b6..b68a475d 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ANEWARRAY.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ANEWARRAY.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.ExceptionConst; +import org.apache.bcel6_2_0.ExceptionConst; /** * ANEWARRAY - Create new array of references @@ -37,7 +37,7 @@ public class ANEWARRAY extends CPInstruction implements LoadClass, AllocationIns public ANEWARRAY(final int index) { - super(org.apache.bcel.Const.ANEWARRAY, index); + super(org.apache.bcel6_2_0.Const.ANEWARRAY, index); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ARETURN.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ARETURN.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ARETURN.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ARETURN.java index bea418e3..e5d160fd 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ARETURN.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ARETURN.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * ARETURN - Return reference from method @@ -29,7 +29,7 @@ public class ARETURN extends ReturnInstruction { * Return reference from method */ public ARETURN() { - super(org.apache.bcel.Const.ARETURN); + super(org.apache.bcel6_2_0.Const.ARETURN); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ARRAYLENGTH.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ARRAYLENGTH.java similarity index 90% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ARRAYLENGTH.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ARRAYLENGTH.java index fb7f897f..719edc78 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ARRAYLENGTH.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ARRAYLENGTH.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.ExceptionConst; +import org.apache.bcel6_2_0.ExceptionConst; /** * ARRAYLENGTH - Get length of array @@ -30,7 +30,7 @@ public class ARRAYLENGTH extends Instruction implements ExceptionThrower, StackP /** Get length of array */ public ARRAYLENGTH() { - super(org.apache.bcel.Const.ARRAYLENGTH, (short) 1); + super(org.apache.bcel6_2_0.Const.ARRAYLENGTH, (short) 1); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ASTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ASTORE.java similarity index 86% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ASTORE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ASTORE.java index 546fe665..4be10131 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ASTORE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ASTORE.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * ASTORE - Store reference into local variable @@ -30,7 +30,7 @@ public class ASTORE extends StoreInstruction { * Not to be used otherwise. */ ASTORE() { - super(org.apache.bcel.Const.ASTORE, org.apache.bcel.Const.ASTORE_0); + super(org.apache.bcel6_2_0.Const.ASTORE, org.apache.bcel6_2_0.Const.ASTORE_0); } @@ -38,7 +38,7 @@ public class ASTORE extends StoreInstruction { * @param n index of local variable */ public ASTORE(final int n) { - super(org.apache.bcel.Const.ASTORE, org.apache.bcel.Const.ASTORE_0, n); + super(org.apache.bcel6_2_0.Const.ASTORE, org.apache.bcel6_2_0.Const.ASTORE_0, n); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ATHROW.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ATHROW.java similarity index 89% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ATHROW.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ATHROW.java index 8cf2b608..d094a4ea 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ATHROW.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ATHROW.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.ExceptionConst; +import org.apache.bcel6_2_0.ExceptionConst; /** * ATHROW - Throw exception @@ -31,7 +31,7 @@ public class ATHROW extends Instruction implements UnconditionalBranch, Exceptio * Throw exception */ public ATHROW() { - super(org.apache.bcel.Const.ATHROW, (short) 1); + super(org.apache.bcel6_2_0.Const.ATHROW, (short) 1); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AllocationInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/AllocationInstruction.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AllocationInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/AllocationInstruction.java index 09f2559c..bc6c4a02 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AllocationInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/AllocationInstruction.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Denote family of instructions that allocates space in the heap. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AnnotationElementValueGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/AnnotationElementValueGen.java similarity index 91% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AnnotationElementValueGen.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/AnnotationElementValueGen.java index c5461bbb..e128a8d3 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AnnotationElementValueGen.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/AnnotationElementValueGen.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.classfile.AnnotationElementValue; -import org.apache.bcel.classfile.ElementValue; +import org.apache.bcel6_2_0.classfile.AnnotationElementValue; +import org.apache.bcel6_2_0.classfile.ElementValue; /** * @since 6.0 diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AnnotationEntryGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/AnnotationEntryGen.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AnnotationEntryGen.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/AnnotationEntryGen.java index 34e75626..c15459c9 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/AnnotationEntryGen.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/AnnotationEntryGen.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -26,14 +26,14 @@ import java.util.ArrayList; import java.util.List; -import org.apache.bcel.classfile.AnnotationEntry; -import org.apache.bcel.classfile.Attribute; -import org.apache.bcel.classfile.ConstantUtf8; -import org.apache.bcel.classfile.ElementValuePair; -import org.apache.bcel.classfile.RuntimeInvisibleAnnotations; -import org.apache.bcel.classfile.RuntimeInvisibleParameterAnnotations; -import org.apache.bcel.classfile.RuntimeVisibleAnnotations; -import org.apache.bcel.classfile.RuntimeVisibleParameterAnnotations; +import org.apache.bcel6_2_0.classfile.AnnotationEntry; +import org.apache.bcel6_2_0.classfile.Attribute; +import org.apache.bcel6_2_0.classfile.ConstantUtf8; +import org.apache.bcel6_2_0.classfile.ElementValuePair; +import org.apache.bcel6_2_0.classfile.RuntimeInvisibleAnnotations; +import org.apache.bcel6_2_0.classfile.RuntimeInvisibleParameterAnnotations; +import org.apache.bcel6_2_0.classfile.RuntimeVisibleAnnotations; +import org.apache.bcel6_2_0.classfile.RuntimeVisibleParameterAnnotations; /** * @since 6.0 diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArithmeticInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ArithmeticInstruction.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArithmeticInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ArithmeticInstruction.java index 585b7dd4..51fd07e9 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArithmeticInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ArithmeticInstruction.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * Super class for the family of arithmetic instructions. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArrayElementValueGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ArrayElementValueGen.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArrayElementValueGen.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ArrayElementValueGen.java index 0ffd3ce9..d476a050 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArrayElementValueGen.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ArrayElementValueGen.java @@ -15,15 +15,15 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import org.apache.bcel.classfile.ArrayElementValue; -import org.apache.bcel.classfile.ElementValue; +import org.apache.bcel6_2_0.classfile.ArrayElementValue; +import org.apache.bcel6_2_0.classfile.ElementValue; /** * @since 6.0 diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArrayInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ArrayInstruction.java similarity index 68% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArrayInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ArrayInstruction.java index a5becc55..60a807cb 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArrayInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ArrayInstruction.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.ExceptionConst; +import org.apache.bcel6_2_0.ExceptionConst; /** * Super class for instructions dealing with array access such as IALOAD. @@ -55,29 +55,29 @@ public Class[] getExceptions() { public Type getType( final ConstantPoolGen cp ) { final short _opcode = super.getOpcode(); switch (_opcode) { - case org.apache.bcel.Const.IALOAD: - case org.apache.bcel.Const.IASTORE: + case org.apache.bcel6_2_0.Const.IALOAD: + case org.apache.bcel6_2_0.Const.IASTORE: return Type.INT; - case org.apache.bcel.Const.CALOAD: - case org.apache.bcel.Const.CASTORE: + case org.apache.bcel6_2_0.Const.CALOAD: + case org.apache.bcel6_2_0.Const.CASTORE: return Type.CHAR; - case org.apache.bcel.Const.BALOAD: - case org.apache.bcel.Const.BASTORE: + case org.apache.bcel6_2_0.Const.BALOAD: + case org.apache.bcel6_2_0.Const.BASTORE: return Type.BYTE; - case org.apache.bcel.Const.SALOAD: - case org.apache.bcel.Const.SASTORE: + case org.apache.bcel6_2_0.Const.SALOAD: + case org.apache.bcel6_2_0.Const.SASTORE: return Type.SHORT; - case org.apache.bcel.Const.LALOAD: - case org.apache.bcel.Const.LASTORE: + case org.apache.bcel6_2_0.Const.LALOAD: + case org.apache.bcel6_2_0.Const.LASTORE: return Type.LONG; - case org.apache.bcel.Const.DALOAD: - case org.apache.bcel.Const.DASTORE: + case org.apache.bcel6_2_0.Const.DALOAD: + case org.apache.bcel6_2_0.Const.DASTORE: return Type.DOUBLE; - case org.apache.bcel.Const.FALOAD: - case org.apache.bcel.Const.FASTORE: + case org.apache.bcel6_2_0.Const.FALOAD: + case org.apache.bcel6_2_0.Const.FASTORE: return Type.FLOAT; - case org.apache.bcel.Const.AALOAD: - case org.apache.bcel.Const.AASTORE: + case org.apache.bcel6_2_0.Const.AALOAD: + case org.apache.bcel6_2_0.Const.AASTORE: return Type.OBJECT; default: throw new ClassGenException("Oops: unknown case in switch" + _opcode); diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArrayType.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ArrayType.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArrayType.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ArrayType.java index 54dad25b..8dad4eb5 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ArrayType.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ArrayType.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * Denotes array type, such as int[][] diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BALOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/BALOAD.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BALOAD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/BALOAD.java index 6dbac273..9aa6a3fc 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BALOAD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/BALOAD.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * BALOAD - Load byte or boolean from array @@ -28,7 +28,7 @@ public class BALOAD extends ArrayInstruction implements StackProducer { /** Load byte or boolean from array */ public BALOAD() { - super(org.apache.bcel.Const.BALOAD); + super(org.apache.bcel6_2_0.Const.BALOAD); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BASTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/BASTORE.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BASTORE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/BASTORE.java index 16d63632..22ca274d 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BASTORE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/BASTORE.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * BASTORE - Store into byte or boolean array @@ -28,7 +28,7 @@ public class BASTORE extends ArrayInstruction implements StackConsumer { /** Store byte or boolean into array */ public BASTORE() { - super(org.apache.bcel.Const.BASTORE); + super(org.apache.bcel6_2_0.Const.BASTORE); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BIPUSH.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/BIPUSH.java similarity index 91% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BIPUSH.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/BIPUSH.java index 859fa442..b8a0a90c 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BIPUSH.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/BIPUSH.java @@ -15,12 +15,12 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.util.ByteSequence; +import org.apache.bcel6_2_0.util.ByteSequence; /** * BIPUSH - Push byte on stack @@ -45,7 +45,7 @@ public class BIPUSH extends Instruction implements ConstantPushInstruction { /** Push byte on stack */ public BIPUSH(final byte b) { - super(org.apache.bcel.Const.BIPUSH, (short) 2); + super(org.apache.bcel6_2_0.Const.BIPUSH, (short) 2); this.b = b; } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BREAKPOINT.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/BREAKPOINT.java similarity index 90% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BREAKPOINT.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/BREAKPOINT.java index 7ffb1faf..c6d800d7 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BREAKPOINT.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/BREAKPOINT.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * BREAKPOINT, JVM dependent, ignored by default @@ -25,7 +25,7 @@ public class BREAKPOINT extends Instruction { public BREAKPOINT() { - super(org.apache.bcel.Const.BREAKPOINT, (short) 1); + super(org.apache.bcel6_2_0.Const.BREAKPOINT, (short) 1); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BasicType.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/BasicType.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BasicType.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/BasicType.java index 8afc6f8b..aaa822f6 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BasicType.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/BasicType.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * Denotes basic type such as int. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BranchHandle.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/BranchHandle.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BranchHandle.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/BranchHandle.java index a6a06890..9c25f9d1 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BranchHandle.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/BranchHandle.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * BranchHandle is returned by specialized InstructionList.append() whenever a diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BranchInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/BranchInstruction.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BranchInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/BranchInstruction.java index 0f64be16..06a2c450 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/BranchInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/BranchInstruction.java @@ -15,12 +15,12 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.util.ByteSequence; +import org.apache.bcel6_2_0.util.ByteSequence; /** * Abstract super class for branching instructions like GOTO, IFEQ, etc.. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CALOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/CALOAD.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CALOAD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/CALOAD.java index 97ca1931..e0d94639 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CALOAD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/CALOAD.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * CALOAD - Load char from array @@ -28,7 +28,7 @@ public class CALOAD extends ArrayInstruction implements StackProducer { /** Load char from array */ public CALOAD() { - super(org.apache.bcel.Const.CALOAD); + super(org.apache.bcel6_2_0.Const.CALOAD); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CASTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/CASTORE.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CASTORE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/CASTORE.java index 91a4600d..2ea5fb6f 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CASTORE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/CASTORE.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * CASTORE - Store into char array @@ -28,7 +28,7 @@ public class CASTORE extends ArrayInstruction implements StackConsumer { /** Store char into array */ public CASTORE() { - super(org.apache.bcel.Const.CASTORE); + super(org.apache.bcel6_2_0.Const.CASTORE); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CHECKCAST.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/CHECKCAST.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CHECKCAST.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/CHECKCAST.java index 142adcd5..7723254b 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CHECKCAST.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/CHECKCAST.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.ExceptionConst; +import org.apache.bcel6_2_0.ExceptionConst; /** * CHECKCAST - Check whether object is of given type @@ -40,7 +40,7 @@ public class CHECKCAST extends CPInstruction implements LoadClass, ExceptionThro * @param index index to class in constant pool */ public CHECKCAST(final int index) { - super(org.apache.bcel.Const.CHECKCAST, index); + super(org.apache.bcel6_2_0.Const.CHECKCAST, index); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CPInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/CPInstruction.java similarity index 88% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CPInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/CPInstruction.java index df789e8f..82743421 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CPInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/CPInstruction.java @@ -15,15 +15,15 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.classfile.Constant; -import org.apache.bcel.classfile.ConstantClass; -import org.apache.bcel.classfile.ConstantPool; -import org.apache.bcel.util.ByteSequence; +import org.apache.bcel6_2_0.classfile.Constant; +import org.apache.bcel6_2_0.classfile.ConstantClass; +import org.apache.bcel6_2_0.classfile.ConstantPool; +import org.apache.bcel6_2_0.util.ByteSequence; /** * Abstract super class for instructions that use an index into the @@ -98,7 +98,7 @@ public String toString( final ConstantPool cp ) { if (c instanceof ConstantClass) { str = str.replace('.', '/'); } - return org.apache.bcel.Const.getOpcodeName(super.getOpcode()) + " " + str; + return org.apache.bcel6_2_0.Const.getOpcodeName(super.getOpcode()) + " " + str; } @@ -141,7 +141,7 @@ public void setIndex( final int index ) { // TODO could be package-protected? @Override public Type getType( final ConstantPoolGen cpg ) { final ConstantPool cp = cpg.getConstantPool(); - String name = cp.getConstantString(index, org.apache.bcel.Const.CONSTANT_Class); + String name = cp.getConstantString(index, org.apache.bcel6_2_0.Const.CONSTANT_Class); if (!name.startsWith("[")) { name = "L" + name + ";"; } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassElementValueGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ClassElementValueGen.java similarity index 90% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassElementValueGen.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ClassElementValueGen.java index 7317150e..07a1a0f5 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassElementValueGen.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ClassElementValueGen.java @@ -15,14 +15,14 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.classfile.ClassElementValue; -import org.apache.bcel.classfile.ConstantUtf8; -import org.apache.bcel.classfile.ElementValue; +import org.apache.bcel6_2_0.classfile.ClassElementValue; +import org.apache.bcel6_2_0.classfile.ConstantUtf8; +import org.apache.bcel6_2_0.classfile.ElementValue; /** * @since 6.0 diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ClassGen.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassGen.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ClassGen.java index 8cc378fc..000e087d 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassGen.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ClassGen.java @@ -15,24 +15,24 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.util.ArrayList; import java.util.List; -import org.apache.bcel.Const; -import org.apache.bcel.classfile.AccessFlags; -import org.apache.bcel.classfile.AnnotationEntry; -import org.apache.bcel.classfile.Annotations; -import org.apache.bcel.classfile.Attribute; -import org.apache.bcel.classfile.ConstantPool; -import org.apache.bcel.classfile.Field; -import org.apache.bcel.classfile.JavaClass; -import org.apache.bcel.classfile.Method; -import org.apache.bcel.classfile.RuntimeInvisibleAnnotations; -import org.apache.bcel.classfile.RuntimeVisibleAnnotations; -import org.apache.bcel.classfile.SourceFile; -import org.apache.bcel.util.BCELComparator; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.classfile.AccessFlags; +import org.apache.bcel6_2_0.classfile.AnnotationEntry; +import org.apache.bcel6_2_0.classfile.Annotations; +import org.apache.bcel6_2_0.classfile.Attribute; +import org.apache.bcel6_2_0.classfile.ConstantPool; +import org.apache.bcel6_2_0.classfile.Field; +import org.apache.bcel6_2_0.classfile.JavaClass; +import org.apache.bcel6_2_0.classfile.Method; +import org.apache.bcel6_2_0.classfile.RuntimeInvisibleAnnotations; +import org.apache.bcel6_2_0.classfile.RuntimeVisibleAnnotations; +import org.apache.bcel6_2_0.classfile.SourceFile; +import org.apache.bcel6_2_0.util.BCELComparator; /** * Template class for building up a java class. May be initialized with an diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassGenException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ClassGenException.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassGenException.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ClassGenException.java index 55fb2147..0cfa9b1d 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassGenException.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ClassGenException.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Thrown on internal errors. Extends RuntimeException so it hasn't to be declared diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassObserver.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ClassObserver.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassObserver.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ClassObserver.java index cddb9f6b..64bee609 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ClassObserver.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ClassObserver.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Implement this interface if you're interested in changes to a ClassGen object diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CodeExceptionGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/CodeExceptionGen.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CodeExceptionGen.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/CodeExceptionGen.java index dc7a9c6c..8c27efc3 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CodeExceptionGen.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/CodeExceptionGen.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.classfile.CodeException; +import org.apache.bcel6_2_0.classfile.CodeException; /** * This class represents an exception handler, i.e., specifies the region where diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CompoundInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/CompoundInstruction.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CompoundInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/CompoundInstruction.java index 4e3a55e5..b8d6f35d 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/CompoundInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/CompoundInstruction.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Wrapper class for `compound' operations, virtual instructions that diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ConstantPoolGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ConstantPoolGen.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ConstantPoolGen.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ConstantPoolGen.java index afc106c5..dda057a4 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ConstantPoolGen.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ConstantPoolGen.java @@ -15,27 +15,27 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.util.HashMap; import java.util.Map; -import org.apache.bcel.Const; -import org.apache.bcel.classfile.Constant; -import org.apache.bcel.classfile.ConstantCP; -import org.apache.bcel.classfile.ConstantClass; -import org.apache.bcel.classfile.ConstantDouble; -import org.apache.bcel.classfile.ConstantFieldref; -import org.apache.bcel.classfile.ConstantFloat; -import org.apache.bcel.classfile.ConstantInteger; -import org.apache.bcel.classfile.ConstantInterfaceMethodref; -import org.apache.bcel.classfile.ConstantInvokeDynamic; -import org.apache.bcel.classfile.ConstantLong; -import org.apache.bcel.classfile.ConstantMethodref; -import org.apache.bcel.classfile.ConstantNameAndType; -import org.apache.bcel.classfile.ConstantPool; -import org.apache.bcel.classfile.ConstantString; -import org.apache.bcel.classfile.ConstantUtf8; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.classfile.Constant; +import org.apache.bcel6_2_0.classfile.ConstantCP; +import org.apache.bcel6_2_0.classfile.ConstantClass; +import org.apache.bcel6_2_0.classfile.ConstantDouble; +import org.apache.bcel6_2_0.classfile.ConstantFieldref; +import org.apache.bcel6_2_0.classfile.ConstantFloat; +import org.apache.bcel6_2_0.classfile.ConstantInteger; +import org.apache.bcel6_2_0.classfile.ConstantInterfaceMethodref; +import org.apache.bcel6_2_0.classfile.ConstantInvokeDynamic; +import org.apache.bcel6_2_0.classfile.ConstantLong; +import org.apache.bcel6_2_0.classfile.ConstantMethodref; +import org.apache.bcel6_2_0.classfile.ConstantNameAndType; +import org.apache.bcel6_2_0.classfile.ConstantPool; +import org.apache.bcel6_2_0.classfile.ConstantString; +import org.apache.bcel6_2_0.classfile.ConstantUtf8; /** * This class is used to build up a constant pool. The user adds @@ -190,9 +190,9 @@ public ConstantPoolGen(final Constant[] cs) { // nothing to do } else if (c instanceof ConstantDouble) { // nothing to do - } else if (c instanceof org.apache.bcel.classfile.ConstantMethodType) { + } else if (c instanceof org.apache.bcel6_2_0.classfile.ConstantMethodType) { // TODO should this be handled somehow? - } else if (c instanceof org.apache.bcel.classfile.ConstantMethodHandle) { + } else if (c instanceof org.apache.bcel6_2_0.classfile.ConstantMethodHandle) { // TODO should this be handled somehow? } else { assert false : "Unexpected constant type: " + c.getClass().getName(); diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ConstantPushInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ConstantPushInstruction.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ConstantPushInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ConstantPushInstruction.java index bcfd8402..a0f471c3 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ConstantPushInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ConstantPushInstruction.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Denotes a push instruction that produces a literal on the stack diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ConversionInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ConversionInstruction.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ConversionInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ConversionInstruction.java index febbc906..d9c04df5 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ConversionInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ConversionInstruction.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * Super class for the x2y family of instructions. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/D2F.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/D2F.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/D2F.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/D2F.java index 6726669a..c1a1e0f4 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/D2F.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/D2F.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * D2F - Convert double to float @@ -28,7 +28,7 @@ public class D2F extends ConversionInstruction { /** Convert double to float */ public D2F() { - super(org.apache.bcel.Const.D2F); + super(org.apache.bcel6_2_0.Const.D2F); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/D2I.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/D2I.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/D2I.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/D2I.java index 1f96d874..dc8776cb 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/D2I.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/D2I.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * D2I - Convert double to int @@ -28,7 +28,7 @@ public class D2I extends ConversionInstruction { /** Convert double to int */ public D2I() { - super(org.apache.bcel.Const.D2I); + super(org.apache.bcel6_2_0.Const.D2I); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/D2L.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/D2L.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/D2L.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/D2L.java index 213949b0..6ae2f935 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/D2L.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/D2L.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * D2L - Convert double to long @@ -28,7 +28,7 @@ public class D2L extends ConversionInstruction { /** Convert double to long */ public D2L() { - super(org.apache.bcel.Const.D2L); + super(org.apache.bcel6_2_0.Const.D2L); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DADD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DADD.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DADD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DADD.java index fcbab2d7..c12f511e 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DADD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DADD.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * DADD - Add doubles @@ -29,7 +29,7 @@ public class DADD extends ArithmeticInstruction { /** Add doubles */ public DADD() { - super(org.apache.bcel.Const.DADD); + super(org.apache.bcel6_2_0.Const.DADD); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DALOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DALOAD.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DALOAD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DALOAD.java index 1668d9cd..4583c8f0 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DALOAD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DALOAD.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * DALOAD - Load double from array @@ -28,7 +28,7 @@ public class DALOAD extends ArrayInstruction implements StackProducer { /** Load double from array */ public DALOAD() { - super(org.apache.bcel.Const.DALOAD); + super(org.apache.bcel6_2_0.Const.DALOAD); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DASTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DASTORE.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DASTORE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DASTORE.java index d87db262..192ebdd2 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DASTORE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DASTORE.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * DASTORE - Store into double array @@ -28,7 +28,7 @@ public class DASTORE extends ArrayInstruction implements StackConsumer { /** Store double into array */ public DASTORE() { - super(org.apache.bcel.Const.DASTORE); + super(org.apache.bcel6_2_0.Const.DASTORE); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DCMPG.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DCMPG.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DCMPG.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DCMPG.java index 53baea63..a64befe1 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DCMPG.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DCMPG.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * DCMPG - Compare doubles: value1 > value2 @@ -26,7 +26,7 @@ public class DCMPG extends Instruction implements TypedInstruction, StackProducer, StackConsumer { public DCMPG() { - super(org.apache.bcel.Const.DCMPG, (short) 1); + super(org.apache.bcel6_2_0.Const.DCMPG, (short) 1); } /** @return Type.DOUBLE diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DCMPL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DCMPL.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DCMPL.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DCMPL.java index 26c32804..49d53d14 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DCMPL.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DCMPL.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * DCMPL - Compare doubles: value1 < value2 @@ -26,7 +26,7 @@ public class DCMPL extends Instruction implements TypedInstruction, StackProducer, StackConsumer { public DCMPL() { - super(org.apache.bcel.Const.DCMPL, (short) 1); + super(org.apache.bcel6_2_0.Const.DCMPL, (short) 1); } /** @return Type.DOUBLE diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DCONST.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DCONST.java similarity index 87% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DCONST.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DCONST.java index 6a8dda30..16faf895 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DCONST.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DCONST.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * DCONST - Push 0.0 or 1.0, other values cause an exception @@ -38,11 +38,11 @@ public class DCONST extends Instruction implements ConstantPushInstruction { public DCONST(final double f) { - super(org.apache.bcel.Const.DCONST_0, (short) 1); + super(org.apache.bcel6_2_0.Const.DCONST_0, (short) 1); if (f == 0.0) { - super.setOpcode(org.apache.bcel.Const.DCONST_0); + super.setOpcode(org.apache.bcel6_2_0.Const.DCONST_0); } else if (f == 1.0) { - super.setOpcode(org.apache.bcel.Const.DCONST_1); + super.setOpcode(org.apache.bcel6_2_0.Const.DCONST_1); } else { throw new ClassGenException("DCONST can be used only for 0.0 and 1.0: " + f); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DDIV.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DDIV.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DDIV.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DDIV.java index 68c3cca2..3934b295 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DDIV.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DDIV.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * DDIV - Divide doubles @@ -29,7 +29,7 @@ public class DDIV extends ArithmeticInstruction { /** Divide doubles */ public DDIV() { - super(org.apache.bcel.Const.DDIV); + super(org.apache.bcel6_2_0.Const.DDIV); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DLOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DLOAD.java similarity index 86% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DLOAD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DLOAD.java index dc9aad54..04fb2e67 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DLOAD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DLOAD.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * DLOAD - Load double from local variable @@ -30,7 +30,7 @@ public class DLOAD extends LoadInstruction { * Not to be used otherwise. */ DLOAD() { - super(org.apache.bcel.Const.DLOAD, org.apache.bcel.Const.DLOAD_0); + super(org.apache.bcel6_2_0.Const.DLOAD, org.apache.bcel6_2_0.Const.DLOAD_0); } @@ -38,7 +38,7 @@ public class DLOAD extends LoadInstruction { * @param n index of local variable */ public DLOAD(final int n) { - super(org.apache.bcel.Const.DLOAD, org.apache.bcel.Const.DLOAD_0, n); + super(org.apache.bcel6_2_0.Const.DLOAD, org.apache.bcel6_2_0.Const.DLOAD_0, n); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DMUL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DMUL.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DMUL.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DMUL.java index 8b4edd65..3956b9a5 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DMUL.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DMUL.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * DMUL - Multiply doubles @@ -29,7 +29,7 @@ public class DMUL extends ArithmeticInstruction { /** Multiply doubles */ public DMUL() { - super(org.apache.bcel.Const.DMUL); + super(org.apache.bcel6_2_0.Const.DMUL); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DNEG.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DNEG.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DNEG.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DNEG.java index 566b6aba..0666000a 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DNEG.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DNEG.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * DNEG - Negate double @@ -26,7 +26,7 @@ public class DNEG extends ArithmeticInstruction { public DNEG() { - super(org.apache.bcel.Const.DNEG); + super(org.apache.bcel6_2_0.Const.DNEG); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DREM.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DREM.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DREM.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DREM.java index 37fcfdd1..21e4ba55 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DREM.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DREM.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * DREM - Remainder of doubles @@ -29,7 +29,7 @@ public class DREM extends ArithmeticInstruction { /** Remainder of doubles */ public DREM() { - super(org.apache.bcel.Const.DREM); + super(org.apache.bcel6_2_0.Const.DREM); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DRETURN.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DRETURN.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DRETURN.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DRETURN.java index ff87dd27..eee8688c 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DRETURN.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DRETURN.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * DRETURN - Return double from method @@ -28,7 +28,7 @@ public class DRETURN extends ReturnInstruction { /** Return double from method */ public DRETURN() { - super(org.apache.bcel.Const.DRETURN); + super(org.apache.bcel6_2_0.Const.DRETURN); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DSTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DSTORE.java similarity index 86% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DSTORE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DSTORE.java index 77d0f879..6db5af47 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DSTORE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DSTORE.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * DSTORE - Store double into local variable @@ -30,7 +30,7 @@ public class DSTORE extends StoreInstruction { * Not to be used otherwise. */ DSTORE() { - super(org.apache.bcel.Const.DSTORE, org.apache.bcel.Const.DSTORE_0); + super(org.apache.bcel6_2_0.Const.DSTORE, org.apache.bcel6_2_0.Const.DSTORE_0); } @@ -38,7 +38,7 @@ public class DSTORE extends StoreInstruction { * @param n index of local variable */ public DSTORE(final int n) { - super(org.apache.bcel.Const.DSTORE, org.apache.bcel.Const.DSTORE_0, n); + super(org.apache.bcel6_2_0.Const.DSTORE, org.apache.bcel6_2_0.Const.DSTORE_0, n); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DSUB.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DSUB.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DSUB.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DSUB.java index 04445c9d..955f9d34 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DSUB.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DSUB.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * DSUB - Substract doubles @@ -29,7 +29,7 @@ public class DSUB extends ArithmeticInstruction { /** Substract doubles */ public DSUB() { - super(org.apache.bcel.Const.DSUB); + super(org.apache.bcel6_2_0.Const.DSUB); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DUP.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DUP.java index 8061764e..37f9735f 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DUP.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * DUP - Duplicate top operand stack word @@ -26,7 +26,7 @@ public class DUP extends StackInstruction implements PushInstruction { public DUP() { - super(org.apache.bcel.Const.DUP); + super(org.apache.bcel6_2_0.Const.DUP); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP2.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DUP2.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP2.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DUP2.java index 4fb58329..c7f0d307 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP2.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DUP2.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * DUP2 - Duplicate two top operand stack words @@ -26,7 +26,7 @@ public class DUP2 extends StackInstruction implements PushInstruction { public DUP2() { - super(org.apache.bcel.Const.DUP2); + super(org.apache.bcel6_2_0.Const.DUP2); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP2_X1.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DUP2_X1.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP2_X1.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DUP2_X1.java index 75488539..776957d6 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP2_X1.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DUP2_X1.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * DUP2_X1 - Duplicate two top operand stack words and put three down @@ -26,7 +26,7 @@ public class DUP2_X1 extends StackInstruction { public DUP2_X1() { - super(org.apache.bcel.Const.DUP2_X1); + super(org.apache.bcel6_2_0.Const.DUP2_X1); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP2_X2.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DUP2_X2.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP2_X2.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DUP2_X2.java index 0ebb2075..91db9953 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP2_X2.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DUP2_X2.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * DUP2_X2 - Duplicate two top operand stack words and put four down @@ -26,7 +26,7 @@ public class DUP2_X2 extends StackInstruction { public DUP2_X2() { - super(org.apache.bcel.Const.DUP2_X2); + super(org.apache.bcel6_2_0.Const.DUP2_X2); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP_X1.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DUP_X1.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP_X1.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DUP_X1.java index b3bab424..609b9a75 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP_X1.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DUP_X1.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * DUP_X1 - Duplicate top operand stack word and put two down @@ -26,7 +26,7 @@ public class DUP_X1 extends StackInstruction { public DUP_X1() { - super(org.apache.bcel.Const.DUP_X1); + super(org.apache.bcel6_2_0.Const.DUP_X1); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP_X2.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DUP_X2.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP_X2.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DUP_X2.java index e33d95d5..63c3d451 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/DUP_X2.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/DUP_X2.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * DUP_X2 - Duplicate top operand stack word and put three down @@ -26,7 +26,7 @@ public class DUP_X2 extends StackInstruction { public DUP_X2() { - super(org.apache.bcel.Const.DUP_X2); + super(org.apache.bcel6_2_0.Const.DUP_X2); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ElementValueGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ElementValueGen.java similarity index 91% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ElementValueGen.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ElementValueGen.java index e357b3eb..293dcb9f 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ElementValueGen.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ElementValueGen.java @@ -15,19 +15,19 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.classfile.AnnotationElementValue; -import org.apache.bcel.classfile.AnnotationEntry; -import org.apache.bcel.classfile.ArrayElementValue; -import org.apache.bcel.classfile.ClassElementValue; -import org.apache.bcel.classfile.ElementValue; -import org.apache.bcel.classfile.EnumElementValue; -import org.apache.bcel.classfile.SimpleElementValue; +import org.apache.bcel6_2_0.classfile.AnnotationElementValue; +import org.apache.bcel6_2_0.classfile.AnnotationEntry; +import org.apache.bcel6_2_0.classfile.ArrayElementValue; +import org.apache.bcel6_2_0.classfile.ClassElementValue; +import org.apache.bcel6_2_0.classfile.ElementValue; +import org.apache.bcel6_2_0.classfile.EnumElementValue; +import org.apache.bcel6_2_0.classfile.SimpleElementValue; /** * @since 6.0 diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ElementValuePairGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ElementValuePairGen.java similarity index 91% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ElementValuePairGen.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ElementValuePairGen.java index 7fcb0c8e..b9e7026c 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ElementValuePairGen.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ElementValuePairGen.java @@ -15,14 +15,14 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.classfile.ConstantUtf8; -import org.apache.bcel.classfile.ElementValue; -import org.apache.bcel.classfile.ElementValuePair; +import org.apache.bcel6_2_0.classfile.ConstantUtf8; +import org.apache.bcel6_2_0.classfile.ElementValue; +import org.apache.bcel6_2_0.classfile.ElementValuePair; /** * @since 6.0 diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/EmptyVisitor.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/EmptyVisitor.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/EmptyVisitor.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/EmptyVisitor.java index 49ebebdb..68d9abe4 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/EmptyVisitor.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/EmptyVisitor.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Supplies empty method bodies to be overridden by subclasses. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/EnumElementValueGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/EnumElementValueGen.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/EnumElementValueGen.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/EnumElementValueGen.java index 2d390bfa..8f085aa4 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/EnumElementValueGen.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/EnumElementValueGen.java @@ -15,14 +15,14 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.classfile.ConstantUtf8; -import org.apache.bcel.classfile.ElementValue; -import org.apache.bcel.classfile.EnumElementValue; +import org.apache.bcel6_2_0.classfile.ConstantUtf8; +import org.apache.bcel6_2_0.classfile.ElementValue; +import org.apache.bcel6_2_0.classfile.EnumElementValue; /** * @since 6.0 diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ExceptionThrower.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ExceptionThrower.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ExceptionThrower.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ExceptionThrower.java index 8dfcb5d3..50a2bbde 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ExceptionThrower.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ExceptionThrower.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Denote an instruction that may throw a run-time or a linking diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/F2D.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/F2D.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/F2D.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/F2D.java index 430e30d9..75f59d1e 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/F2D.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/F2D.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * F2D - Convert float to double @@ -28,7 +28,7 @@ public class F2D extends ConversionInstruction { /** Convert float to double */ public F2D() { - super(org.apache.bcel.Const.F2D); + super(org.apache.bcel6_2_0.Const.F2D); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/F2I.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/F2I.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/F2I.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/F2I.java index 8b0dbe50..648aaf61 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/F2I.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/F2I.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * F2I - Convert float to int @@ -28,7 +28,7 @@ public class F2I extends ConversionInstruction { /** Convert float to int */ public F2I() { - super(org.apache.bcel.Const.F2I); + super(org.apache.bcel6_2_0.Const.F2I); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/F2L.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/F2L.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/F2L.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/F2L.java index fb749419..db6aeb4d 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/F2L.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/F2L.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * F2L - Convert float to long @@ -28,7 +28,7 @@ public class F2L extends ConversionInstruction { /** Convert float to long */ public F2L() { - super(org.apache.bcel.Const.F2L); + super(org.apache.bcel6_2_0.Const.F2L); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FADD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FADD.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FADD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FADD.java index 44a10c8b..036d39fa 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FADD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FADD.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * FADD - Add floats @@ -28,7 +28,7 @@ public class FADD extends ArithmeticInstruction { /** Add floats */ public FADD() { - super(org.apache.bcel.Const.FADD); + super(org.apache.bcel6_2_0.Const.FADD); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FALOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FALOAD.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FALOAD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FALOAD.java index 4f8d0add..2e8b22c0 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FALOAD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FALOAD.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * FALOAD - Load float from array @@ -28,7 +28,7 @@ public class FALOAD extends ArrayInstruction implements StackProducer { /** Load float from array */ public FALOAD() { - super(org.apache.bcel.Const.FALOAD); + super(org.apache.bcel6_2_0.Const.FALOAD); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FASTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FASTORE.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FASTORE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FASTORE.java index 1d19b20f..319543ee 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FASTORE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FASTORE.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * FASTORE - Store into float array @@ -28,7 +28,7 @@ public class FASTORE extends ArrayInstruction implements StackConsumer { /** Store float into array */ public FASTORE() { - super(org.apache.bcel.Const.FASTORE); + super(org.apache.bcel6_2_0.Const.FASTORE); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FCMPG.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FCMPG.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FCMPG.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FCMPG.java index c660f867..2ad96798 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FCMPG.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FCMPG.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * FCMPG - Compare floats: value1 > value2 @@ -26,7 +26,7 @@ public class FCMPG extends Instruction implements TypedInstruction, StackProducer, StackConsumer { public FCMPG() { - super(org.apache.bcel.Const.FCMPG, (short) 1); + super(org.apache.bcel6_2_0.Const.FCMPG, (short) 1); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FCMPL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FCMPL.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FCMPL.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FCMPL.java index 19212643..62eb67dd 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FCMPL.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FCMPL.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * FCMPL - Compare floats: value1 < value2 @@ -26,7 +26,7 @@ public class FCMPL extends Instruction implements TypedInstruction, StackProducer, StackConsumer { public FCMPL() { - super(org.apache.bcel.Const.FCMPL, (short) 1); + super(org.apache.bcel6_2_0.Const.FCMPL, (short) 1); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FCONST.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FCONST.java similarity index 85% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FCONST.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FCONST.java index d4537dfe..054801e7 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FCONST.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FCONST.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * FCONST - Push 0.0, 1.0 or 2.0, other values cause an exception @@ -38,13 +38,13 @@ public class FCONST extends Instruction implements ConstantPushInstruction { public FCONST(final float f) { - super(org.apache.bcel.Const.FCONST_0, (short) 1); + super(org.apache.bcel6_2_0.Const.FCONST_0, (short) 1); if (f == 0.0) { - super.setOpcode(org.apache.bcel.Const.FCONST_0); + super.setOpcode(org.apache.bcel6_2_0.Const.FCONST_0); } else if (f == 1.0) { - super.setOpcode(org.apache.bcel.Const.FCONST_1); + super.setOpcode(org.apache.bcel6_2_0.Const.FCONST_1); } else if (f == 2.0) { - super.setOpcode(org.apache.bcel.Const.FCONST_2); + super.setOpcode(org.apache.bcel6_2_0.Const.FCONST_2); } else { throw new ClassGenException("FCONST can be used only for 0.0, 1.0 and 2.0: " + f); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FDIV.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FDIV.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FDIV.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FDIV.java index db716f92..cb16848a 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FDIV.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FDIV.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * FDIV - Divide floats @@ -28,7 +28,7 @@ public class FDIV extends ArithmeticInstruction { /** Divide floats */ public FDIV() { - super(org.apache.bcel.Const.FDIV); + super(org.apache.bcel6_2_0.Const.FDIV); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FLOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FLOAD.java similarity index 86% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FLOAD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FLOAD.java index 2f249afb..403391f8 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FLOAD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FLOAD.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * FLOAD - Load float from local variable @@ -30,7 +30,7 @@ public class FLOAD extends LoadInstruction { * Not to be used otherwise. */ FLOAD() { - super(org.apache.bcel.Const.FLOAD, org.apache.bcel.Const.FLOAD_0); + super(org.apache.bcel6_2_0.Const.FLOAD, org.apache.bcel6_2_0.Const.FLOAD_0); } @@ -38,7 +38,7 @@ public class FLOAD extends LoadInstruction { * @param n index of local variable */ public FLOAD(final int n) { - super(org.apache.bcel.Const.FLOAD, org.apache.bcel.Const.FLOAD_0, n); + super(org.apache.bcel6_2_0.Const.FLOAD, org.apache.bcel6_2_0.Const.FLOAD_0, n); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FMUL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FMUL.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FMUL.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FMUL.java index 526f3091..108a23b3 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FMUL.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FMUL.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * FMUL - Multiply floats @@ -28,7 +28,7 @@ public class FMUL extends ArithmeticInstruction { /** Multiply floats */ public FMUL() { - super(org.apache.bcel.Const.FMUL); + super(org.apache.bcel6_2_0.Const.FMUL); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FNEG.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FNEG.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FNEG.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FNEG.java index db1dc36a..81ca6179 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FNEG.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FNEG.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * FNEG - Negate float @@ -26,7 +26,7 @@ public class FNEG extends ArithmeticInstruction { public FNEG() { - super(org.apache.bcel.Const.FNEG); + super(org.apache.bcel6_2_0.Const.FNEG); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FREM.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FREM.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FREM.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FREM.java index 38e0609e..36a5dd0a 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FREM.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FREM.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * FREM - Remainder of floats @@ -28,7 +28,7 @@ public class FREM extends ArithmeticInstruction { /** Remainder of floats */ public FREM() { - super(org.apache.bcel.Const.FREM); + super(org.apache.bcel6_2_0.Const.FREM); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FRETURN.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FRETURN.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FRETURN.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FRETURN.java index 5fde2263..146ca0e9 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FRETURN.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FRETURN.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * FRETURN - Return float from method @@ -28,7 +28,7 @@ public class FRETURN extends ReturnInstruction { /** Return float from method */ public FRETURN() { - super(org.apache.bcel.Const.FRETURN); + super(org.apache.bcel6_2_0.Const.FRETURN); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FSTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FSTORE.java similarity index 86% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FSTORE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FSTORE.java index d5878c6d..9eef44de 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FSTORE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FSTORE.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * FSTORE - Store float into local variable @@ -30,7 +30,7 @@ public class FSTORE extends StoreInstruction { * Not to be used otherwise. */ FSTORE() { - super(org.apache.bcel.Const.FSTORE, org.apache.bcel.Const.FSTORE_0); + super(org.apache.bcel6_2_0.Const.FSTORE, org.apache.bcel6_2_0.Const.FSTORE_0); } @@ -38,7 +38,7 @@ public class FSTORE extends StoreInstruction { * @param n index of local variable */ public FSTORE(final int n) { - super(org.apache.bcel.Const.FSTORE, org.apache.bcel.Const.FSTORE_0, n); + super(org.apache.bcel6_2_0.Const.FSTORE, org.apache.bcel6_2_0.Const.FSTORE_0, n); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FSUB.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FSUB.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FSUB.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FSUB.java index a0de0109..3e0f05fb 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FSUB.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FSUB.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * FSUB - Substract floats @@ -28,7 +28,7 @@ public class FSUB extends ArithmeticInstruction { /** Substract floats */ public FSUB() { - super(org.apache.bcel.Const.FSUB); + super(org.apache.bcel6_2_0.Const.FSUB); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FieldGen.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldGen.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FieldGen.java index 263abdad..b47dbd1d 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldGen.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FieldGen.java @@ -15,22 +15,22 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.util.ArrayList; import java.util.List; -import org.apache.bcel.Const; -import org.apache.bcel.classfile.AnnotationEntry; -import org.apache.bcel.classfile.Annotations; -import org.apache.bcel.classfile.Attribute; -import org.apache.bcel.classfile.Constant; -import org.apache.bcel.classfile.ConstantObject; -import org.apache.bcel.classfile.ConstantPool; -import org.apache.bcel.classfile.ConstantValue; -import org.apache.bcel.classfile.Field; -import org.apache.bcel.classfile.Utility; -import org.apache.bcel.util.BCELComparator; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.classfile.AnnotationEntry; +import org.apache.bcel6_2_0.classfile.Annotations; +import org.apache.bcel6_2_0.classfile.Attribute; +import org.apache.bcel6_2_0.classfile.Constant; +import org.apache.bcel6_2_0.classfile.ConstantObject; +import org.apache.bcel6_2_0.classfile.ConstantPool; +import org.apache.bcel6_2_0.classfile.ConstantValue; +import org.apache.bcel6_2_0.classfile.Field; +import org.apache.bcel6_2_0.classfile.Utility; +import org.apache.bcel6_2_0.util.BCELComparator; /** * Template class for building up a field. The only extraordinary thing diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldGenOrMethodGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FieldGenOrMethodGen.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldGenOrMethodGen.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FieldGenOrMethodGen.java index 7e9a0d42..cec3b61d 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldGenOrMethodGen.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FieldGenOrMethodGen.java @@ -15,14 +15,14 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.util.ArrayList; import java.util.List; -import org.apache.bcel.Const; -import org.apache.bcel.classfile.AccessFlags; -import org.apache.bcel.classfile.Attribute; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.classfile.AccessFlags; +import org.apache.bcel6_2_0.classfile.Attribute; /** * Super class for FieldGen and MethodGen objects, since they have diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FieldInstruction.java similarity index 88% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FieldInstruction.java index a61a679f..4004261f 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FieldInstruction.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.classfile.ConstantPool; +import org.apache.bcel6_2_0.classfile.ConstantPool; /** * Super class for the GET/PUTxxx family of instructions. @@ -47,8 +47,8 @@ protected FieldInstruction(final short opcode, final int index) { */ @Override public String toString( final ConstantPool cp ) { - return org.apache.bcel.Const.getOpcodeName(super.getOpcode()) + " " - + cp.constantToString(super.getIndex(), org.apache.bcel.Const.CONSTANT_Fieldref); + return org.apache.bcel6_2_0.Const.getOpcodeName(super.getOpcode()) + " " + + cp.constantToString(super.getIndex(), org.apache.bcel6_2_0.Const.CONSTANT_Fieldref); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldObserver.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FieldObserver.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldObserver.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FieldObserver.java index c82c3c91..7bf3f006 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldObserver.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FieldObserver.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Imnplement this interface if you're interested in changes to a FieldGen object diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldOrMethod.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FieldOrMethod.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldOrMethod.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FieldOrMethod.java index 0a952b00..d630c8be 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/FieldOrMethod.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/FieldOrMethod.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.Const; -import org.apache.bcel.classfile.ConstantCP; -import org.apache.bcel.classfile.ConstantNameAndType; -import org.apache.bcel.classfile.ConstantPool; -import org.apache.bcel.classfile.ConstantUtf8; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.classfile.ConstantCP; +import org.apache.bcel6_2_0.classfile.ConstantNameAndType; +import org.apache.bcel6_2_0.classfile.ConstantPool; +import org.apache.bcel6_2_0.classfile.ConstantUtf8; /** * Super class for InvokeInstruction and FieldInstruction, since they have diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GETFIELD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/GETFIELD.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GETFIELD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/GETFIELD.java index c6136430..c6ae178a 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GETFIELD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/GETFIELD.java @@ -15,10 +15,10 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.Const; -import org.apache.bcel.ExceptionConst; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.ExceptionConst; /** * GETFIELD - Fetch field from object diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GETSTATIC.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/GETSTATIC.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GETSTATIC.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/GETSTATIC.java index 7323fc04..dd244d29 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GETSTATIC.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/GETSTATIC.java @@ -15,10 +15,10 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.Const; -import org.apache.bcel.ExceptionConst; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.ExceptionConst; /** * GETSTATIC - Fetch static field from class diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GOTO.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/GOTO.java similarity index 91% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GOTO.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/GOTO.java index 15ded296..c93296cc 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GOTO.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/GOTO.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; @@ -36,7 +36,7 @@ public class GOTO extends GotoInstruction implements VariableLengthInstruction { public GOTO(final InstructionHandle target) { - super(org.apache.bcel.Const.GOTO, target); + super(org.apache.bcel6_2_0.Const.GOTO, target); } @@ -48,7 +48,7 @@ public GOTO(final InstructionHandle target) { public void dump( final DataOutputStream out ) throws IOException { super.setIndex(getTargetOffset()); final short _opcode = getOpcode(); - if (_opcode == org.apache.bcel.Const.GOTO) { + if (_opcode == org.apache.bcel6_2_0.Const.GOTO) { super.dump(out); } else { // GOTO_W super.setIndex(getTargetOffset()); @@ -71,7 +71,7 @@ protected int updatePosition( final int offset, final int max_offset ) { final int i = getTargetOffset(); // Depending on old position value setPosition(getPosition() + offset); // Position may be shifted by preceding expansions if (Math.abs(i) >= (Short.MAX_VALUE - max_offset)) { // to large for short (estimate) - super.setOpcode(org.apache.bcel.Const.GOTO_W); + super.setOpcode(org.apache.bcel6_2_0.Const.GOTO_W); final short old_length = (short) super.getLength(); super.setLength(5); return super.getLength() - old_length; diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GOTO_W.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/GOTO_W.java similarity index 91% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GOTO_W.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/GOTO_W.java index 9955e9d1..3991160a 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GOTO_W.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/GOTO_W.java @@ -15,12 +15,12 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.util.ByteSequence; +import org.apache.bcel6_2_0.util.ByteSequence; /** * GOTO_W - Branch always (to relative offset, not absolute address) @@ -38,7 +38,7 @@ public class GOTO_W extends GotoInstruction { public GOTO_W(final InstructionHandle target) { - super(org.apache.bcel.Const.GOTO_W, target); + super(org.apache.bcel6_2_0.Const.GOTO_W, target); super.setLength(5); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GotoInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/GotoInstruction.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GotoInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/GotoInstruction.java index 1a5afa65..3734f8a9 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/GotoInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/GotoInstruction.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Super class for GOTO diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2B.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/I2B.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2B.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/I2B.java index 5a027644..a7dd6ab7 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2B.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/I2B.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * I2B - Convert int to byte @@ -28,7 +28,7 @@ public class I2B extends ConversionInstruction { /** Convert int to byte */ public I2B() { - super(org.apache.bcel.Const.I2B); + super(org.apache.bcel6_2_0.Const.I2B); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2C.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/I2C.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2C.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/I2C.java index df97da64..c488f4d7 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2C.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/I2C.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * I2C - Convert int to char @@ -28,7 +28,7 @@ public class I2C extends ConversionInstruction { /** Convert int to char */ public I2C() { - super(org.apache.bcel.Const.I2C); + super(org.apache.bcel6_2_0.Const.I2C); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2D.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/I2D.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2D.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/I2D.java index 7d12f659..999fa075 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2D.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/I2D.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * I2D - Convert int to double @@ -28,7 +28,7 @@ public class I2D extends ConversionInstruction { /** Convert int to double */ public I2D() { - super(org.apache.bcel.Const.I2D); + super(org.apache.bcel6_2_0.Const.I2D); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2F.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/I2F.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2F.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/I2F.java index 730dbb80..8285f377 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2F.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/I2F.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * I2F - Convert int to float @@ -28,7 +28,7 @@ public class I2F extends ConversionInstruction { /** Convert int to float */ public I2F() { - super(org.apache.bcel.Const.I2F); + super(org.apache.bcel6_2_0.Const.I2F); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2L.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/I2L.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2L.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/I2L.java index 70997c13..8a7cb26e 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2L.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/I2L.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * I2L - Convert int to long @@ -28,7 +28,7 @@ public class I2L extends ConversionInstruction { /** Convert int to long */ public I2L() { - super(org.apache.bcel.Const.I2L); + super(org.apache.bcel6_2_0.Const.I2L); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2S.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/I2S.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2S.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/I2S.java index c2952a17..54b71746 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/I2S.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/I2S.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * I2S - Convert int to short @@ -26,7 +26,7 @@ public class I2S extends ConversionInstruction { public I2S() { - super(org.apache.bcel.Const.I2S); + super(org.apache.bcel6_2_0.Const.I2S); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IADD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IADD.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IADD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IADD.java index d8d1e07d..08b90e34 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IADD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IADD.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IADD - Add ints @@ -28,7 +28,7 @@ public class IADD extends ArithmeticInstruction { /** Add ints */ public IADD() { - super(org.apache.bcel.Const.IADD); + super(org.apache.bcel6_2_0.Const.IADD); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IALOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IALOAD.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IALOAD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IALOAD.java index ceab7fcd..43dfabeb 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IALOAD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IALOAD.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IALOAD - Load int from array @@ -29,7 +29,7 @@ public class IALOAD extends ArrayInstruction implements StackProducer { * Load int from array */ public IALOAD() { - super(org.apache.bcel.Const.IALOAD); + super(org.apache.bcel6_2_0.Const.IALOAD); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IAND.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IAND.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IAND.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IAND.java index e2f4a2d1..0b8dfd9e 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IAND.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IAND.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IAND - Bitwise AND int @@ -26,7 +26,7 @@ public class IAND extends ArithmeticInstruction { public IAND() { - super(org.apache.bcel.Const.IAND); + super(org.apache.bcel6_2_0.Const.IAND); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IASTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IASTORE.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IASTORE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IASTORE.java index 97695196..654022eb 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IASTORE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IASTORE.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IASTORE - Store into int array @@ -29,7 +29,7 @@ public class IASTORE extends ArrayInstruction implements StackConsumer { * Store into int array */ public IASTORE() { - super(org.apache.bcel.Const.IASTORE); + super(org.apache.bcel6_2_0.Const.IASTORE); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ICONST.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ICONST.java similarity index 88% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ICONST.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ICONST.java index cc602854..44ef90de 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ICONST.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ICONST.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * ICONST - Push value between -1, ..., 5, other values cause an exception @@ -38,9 +38,9 @@ public class ICONST extends Instruction implements ConstantPushInstruction { public ICONST(final int i) { - super(org.apache.bcel.Const.ICONST_0, (short) 1); + super(org.apache.bcel6_2_0.Const.ICONST_0, (short) 1); if ((i >= -1) && (i <= 5)) { - super.setOpcode((short) (org.apache.bcel.Const.ICONST_0 + i)); // Even works for i == -1 + super.setOpcode((short) (org.apache.bcel6_2_0.Const.ICONST_0 + i)); // Even works for i == -1 } else { throw new ClassGenException("ICONST can be used only for value between -1 and 5: " + i); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IDIV.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IDIV.java similarity index 90% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IDIV.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IDIV.java index 8c169e24..6dc51115 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IDIV.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IDIV.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.ExceptionConst; +import org.apache.bcel6_2_0.ExceptionConst; /** * IDIV - Divide ints @@ -30,7 +30,7 @@ public class IDIV extends ArithmeticInstruction implements ExceptionThrower { /** Divide ints */ public IDIV() { - super(org.apache.bcel.Const.IDIV); + super(org.apache.bcel6_2_0.Const.IDIV); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFEQ.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IFEQ.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFEQ.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IFEQ.java index e6f1378b..bd2b753c 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFEQ.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IFEQ.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IFEQ - Branch if int comparison with zero succeeds @@ -35,7 +35,7 @@ public class IFEQ extends IfInstruction { public IFEQ(final InstructionHandle target) { - super(org.apache.bcel.Const.IFEQ, target); + super(org.apache.bcel6_2_0.Const.IFEQ, target); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFGE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IFGE.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFGE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IFGE.java index edd6a6a7..c98964be 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFGE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IFGE.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IFGE - Branch if int comparison with zero succeeds @@ -35,7 +35,7 @@ public class IFGE extends IfInstruction { public IFGE(final InstructionHandle target) { - super(org.apache.bcel.Const.IFGE, target); + super(org.apache.bcel6_2_0.Const.IFGE, target); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFGT.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IFGT.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFGT.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IFGT.java index 0e37a531..798b72df 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFGT.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IFGT.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IFGT - Branch if int comparison with zero succeeds @@ -35,7 +35,7 @@ public class IFGT extends IfInstruction { public IFGT(final InstructionHandle target) { - super(org.apache.bcel.Const.IFGT, target); + super(org.apache.bcel6_2_0.Const.IFGT, target); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFLE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IFLE.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFLE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IFLE.java index 7b696e20..280be130 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFLE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IFLE.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IFLE - Branch if int comparison with zero succeeds @@ -35,7 +35,7 @@ public class IFLE extends IfInstruction { public IFLE(final InstructionHandle target) { - super(org.apache.bcel.Const.IFLE, target); + super(org.apache.bcel6_2_0.Const.IFLE, target); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFLT.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IFLT.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFLT.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IFLT.java index 520b67e1..43c774fb 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFLT.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IFLT.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IFLT - Branch if int comparison with zero succeeds @@ -35,7 +35,7 @@ public class IFLT extends IfInstruction { public IFLT(final InstructionHandle target) { - super(org.apache.bcel.Const.IFLT, target); + super(org.apache.bcel6_2_0.Const.IFLT, target); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFNE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IFNE.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFNE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IFNE.java index 7b4d536e..06bfc13a 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFNE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IFNE.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IFNE - Branch if int comparison with zero succeeds @@ -35,7 +35,7 @@ public class IFNE extends IfInstruction { public IFNE(final InstructionHandle target) { - super(org.apache.bcel.Const.IFNE, target); + super(org.apache.bcel6_2_0.Const.IFNE, target); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFNONNULL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IFNONNULL.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFNONNULL.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IFNONNULL.java index 25e62b50..aa2521df 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFNONNULL.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IFNONNULL.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IFNONNULL - Branch if reference is not null @@ -35,7 +35,7 @@ public class IFNONNULL extends IfInstruction { public IFNONNULL(final InstructionHandle target) { - super(org.apache.bcel.Const.IFNONNULL, target); + super(org.apache.bcel6_2_0.Const.IFNONNULL, target); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFNULL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IFNULL.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFNULL.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IFNULL.java index 702d469a..7b22161a 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IFNULL.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IFNULL.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IFNULL - Branch if reference is not null @@ -35,7 +35,7 @@ public class IFNULL extends IfInstruction { public IFNULL(final InstructionHandle target) { - super(org.apache.bcel.Const.IFNULL, target); + super(org.apache.bcel6_2_0.Const.IFNULL, target); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ACMPEQ.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IF_ACMPEQ.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ACMPEQ.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IF_ACMPEQ.java index ce5a8594..30974a45 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ACMPEQ.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IF_ACMPEQ.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IF_ACMPEQ - Branch if reference comparison succeeds @@ -35,7 +35,7 @@ public class IF_ACMPEQ extends IfInstruction { public IF_ACMPEQ(final InstructionHandle target) { - super(org.apache.bcel.Const.IF_ACMPEQ, target); + super(org.apache.bcel6_2_0.Const.IF_ACMPEQ, target); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ACMPNE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IF_ACMPNE.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ACMPNE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IF_ACMPNE.java index 1ad7c2f5..df6b676e 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ACMPNE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IF_ACMPNE.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IF_ACMPNE - Branch if reference comparison doesn't succeed @@ -35,7 +35,7 @@ public class IF_ACMPNE extends IfInstruction { public IF_ACMPNE(final InstructionHandle target) { - super(org.apache.bcel.Const.IF_ACMPNE, target); + super(org.apache.bcel6_2_0.Const.IF_ACMPNE, target); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPEQ.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IF_ICMPEQ.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPEQ.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IF_ICMPEQ.java index f1018140..6d49cdfb 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPEQ.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IF_ICMPEQ.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IF_ICMPEQ - Branch if int comparison succeeds @@ -35,7 +35,7 @@ public class IF_ICMPEQ extends IfInstruction { public IF_ICMPEQ(final InstructionHandle target) { - super(org.apache.bcel.Const.IF_ICMPEQ, target); + super(org.apache.bcel6_2_0.Const.IF_ICMPEQ, target); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPGE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IF_ICMPGE.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPGE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IF_ICMPGE.java index a31dda68..8e3a5440 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPGE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IF_ICMPGE.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IF_ICMPGE - Branch if int comparison succeeds @@ -35,7 +35,7 @@ public class IF_ICMPGE extends IfInstruction { public IF_ICMPGE(final InstructionHandle target) { - super(org.apache.bcel.Const.IF_ICMPGE, target); + super(org.apache.bcel6_2_0.Const.IF_ICMPGE, target); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPGT.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IF_ICMPGT.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPGT.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IF_ICMPGT.java index 64af7dbc..c56692ea 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPGT.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IF_ICMPGT.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IF_ICMPGT - Branch if int comparison succeeds @@ -35,7 +35,7 @@ public class IF_ICMPGT extends IfInstruction { public IF_ICMPGT(final InstructionHandle target) { - super(org.apache.bcel.Const.IF_ICMPGT, target); + super(org.apache.bcel6_2_0.Const.IF_ICMPGT, target); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPLE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IF_ICMPLE.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPLE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IF_ICMPLE.java index 0cd2db5e..8004ab29 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPLE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IF_ICMPLE.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IF_ICMPLE - Branch if int comparison succeeds @@ -35,7 +35,7 @@ public class IF_ICMPLE extends IfInstruction { public IF_ICMPLE(final InstructionHandle target) { - super(org.apache.bcel.Const.IF_ICMPLE, target); + super(org.apache.bcel6_2_0.Const.IF_ICMPLE, target); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPLT.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IF_ICMPLT.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPLT.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IF_ICMPLT.java index ce5cec1b..503a8f5e 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPLT.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IF_ICMPLT.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IF_ICMPLT - Branch if int comparison succeeds @@ -35,7 +35,7 @@ public class IF_ICMPLT extends IfInstruction { public IF_ICMPLT(final InstructionHandle target) { - super(org.apache.bcel.Const.IF_ICMPLT, target); + super(org.apache.bcel6_2_0.Const.IF_ICMPLT, target); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPNE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IF_ICMPNE.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPNE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IF_ICMPNE.java index e9e139b4..b7fe4b4b 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IF_ICMPNE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IF_ICMPNE.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IF_ICMPNE - Branch if int comparison doesn't succeed @@ -35,7 +35,7 @@ public class IF_ICMPNE extends IfInstruction { public IF_ICMPNE(final InstructionHandle target) { - super(org.apache.bcel.Const.IF_ICMPNE, target); + super(org.apache.bcel6_2_0.Const.IF_ICMPNE, target); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IINC.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IINC.java similarity index 90% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IINC.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IINC.java index bc4411e8..91334278 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IINC.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IINC.java @@ -15,12 +15,12 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.util.ByteSequence; +import org.apache.bcel6_2_0.util.ByteSequence; /** * IINC - Increment local variable by constant @@ -47,7 +47,7 @@ public class IINC extends LocalVariableInstruction { */ public IINC(final int n, final int c) { super(); // Default behaviour of LocalVariableInstruction causes error - super.setOpcode(org.apache.bcel.Const.IINC); + super.setOpcode(org.apache.bcel6_2_0.Const.IINC); super.setLength((short) 3); setIndex(n); // May set wide as side effect setIncrement(c); @@ -61,7 +61,7 @@ public IINC(final int n, final int c) { @Override public void dump( final DataOutputStream out ) throws IOException { if (wide) { - out.writeByte(org.apache.bcel.Const.WIDE); + out.writeByte(org.apache.bcel6_2_0.Const.WIDE); } out.writeByte(super.getOpcode()); if (wide) { @@ -75,7 +75,7 @@ public void dump( final DataOutputStream out ) throws IOException { private void setWide() { - wide = super.getIndex() > org.apache.bcel.Const.MAX_BYTE; + wide = super.getIndex() > org.apache.bcel6_2_0.Const.MAX_BYTE; if (c > 0) { wide = wide || (c > Byte.MAX_VALUE); } else { diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ILOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ILOAD.java similarity index 86% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ILOAD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ILOAD.java index 44c3391b..58985aa7 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ILOAD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ILOAD.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * ILOAD - Load int from local variable onto stack @@ -30,7 +30,7 @@ public class ILOAD extends LoadInstruction { * Not to be used otherwise. */ ILOAD() { - super(org.apache.bcel.Const.ILOAD, org.apache.bcel.Const.ILOAD_0); + super(org.apache.bcel6_2_0.Const.ILOAD, org.apache.bcel6_2_0.Const.ILOAD_0); } @@ -38,7 +38,7 @@ public class ILOAD extends LoadInstruction { * @param n index of local variable */ public ILOAD(final int n) { - super(org.apache.bcel.Const.ILOAD, org.apache.bcel.Const.ILOAD_0, n); + super(org.apache.bcel6_2_0.Const.ILOAD, org.apache.bcel6_2_0.Const.ILOAD_0, n); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IMPDEP1.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IMPDEP1.java similarity index 90% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IMPDEP1.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IMPDEP1.java index 05241539..815f2ad1 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IMPDEP1.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IMPDEP1.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IMPDEP1 - Implementation dependent @@ -25,7 +25,7 @@ public class IMPDEP1 extends Instruction { public IMPDEP1() { - super(org.apache.bcel.Const.IMPDEP1, (short) 1); + super(org.apache.bcel6_2_0.Const.IMPDEP1, (short) 1); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IMPDEP2.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IMPDEP2.java similarity index 90% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IMPDEP2.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IMPDEP2.java index dbf9402a..11651fbf 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IMPDEP2.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IMPDEP2.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IMPDEP2 - Implementation dependent @@ -25,7 +25,7 @@ public class IMPDEP2 extends Instruction { public IMPDEP2() { - super(org.apache.bcel.Const.IMPDEP2, (short) 1); + super(org.apache.bcel6_2_0.Const.IMPDEP2, (short) 1); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IMUL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IMUL.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IMUL.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IMUL.java index 29699a61..69f53068 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IMUL.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IMUL.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IMUL - Multiply ints @@ -28,7 +28,7 @@ public class IMUL extends ArithmeticInstruction { /** Multiply ints */ public IMUL() { - super(org.apache.bcel.Const.IMUL); + super(org.apache.bcel6_2_0.Const.IMUL); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INEG.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/INEG.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INEG.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/INEG.java index e2c71717..6ca1e2d4 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INEG.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/INEG.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * INEG - Negate int @@ -26,7 +26,7 @@ public class INEG extends ArithmeticInstruction { public INEG() { - super(org.apache.bcel.Const.INEG); + super(org.apache.bcel6_2_0.Const.INEG); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INSTANCEOF.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/INSTANCEOF.java similarity index 91% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INSTANCEOF.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/INSTANCEOF.java index 19f42b88..d6446e28 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INSTANCEOF.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/INSTANCEOF.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.ExceptionConst; +import org.apache.bcel6_2_0.ExceptionConst; /** * INSTANCEOF - Determine if object is of given type @@ -37,7 +37,7 @@ public class INSTANCEOF extends CPInstruction implements LoadClass, ExceptionThr public INSTANCEOF(final int index) { - super(org.apache.bcel.Const.INSTANCEOF, index); + super(org.apache.bcel6_2_0.Const.INSTANCEOF, index); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKEDYNAMIC.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/INVOKEDYNAMIC.java similarity index 90% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKEDYNAMIC.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/INVOKEDYNAMIC.java index d512574e..86a50e0e 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKEDYNAMIC.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/INVOKEDYNAMIC.java @@ -15,17 +15,17 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; -import org.apache.bcel.ExceptionConst; -import org.apache.bcel.classfile.ConstantInvokeDynamic; -import org.apache.bcel.classfile.ConstantNameAndType; -import org.apache.bcel.classfile.ConstantPool; -import org.apache.bcel.util.ByteSequence; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.ExceptionConst; +import org.apache.bcel6_2_0.classfile.ConstantInvokeDynamic; +import org.apache.bcel6_2_0.classfile.ConstantNameAndType; +import org.apache.bcel6_2_0.classfile.ConstantPool; +import org.apache.bcel6_2_0.util.ByteSequence; /** * Class for INVOKEDYNAMIC. Not an instance of InvokeInstruction, since that class diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKEINTERFACE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/INVOKEINTERFACE.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKEINTERFACE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/INVOKEINTERFACE.java index f2660704..10ff2024 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKEINTERFACE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/INVOKEINTERFACE.java @@ -15,15 +15,15 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; -import org.apache.bcel.ExceptionConst; -import org.apache.bcel.classfile.ConstantPool; -import org.apache.bcel.util.ByteSequence; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.ExceptionConst; +import org.apache.bcel6_2_0.classfile.ConstantPool; +import org.apache.bcel6_2_0.util.ByteSequence; /** * INVOKEINTERFACE - Invoke interface method diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKESPECIAL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/INVOKESPECIAL.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKESPECIAL.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/INVOKESPECIAL.java index 9fe379bc..f5650f4a 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKESPECIAL.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/INVOKESPECIAL.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; -import org.apache.bcel.ExceptionConst; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.ExceptionConst; /** * INVOKESPECIAL - Invoke instance method; special handling for superclass, private diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKESTATIC.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/INVOKESTATIC.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKESTATIC.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/INVOKESTATIC.java index bdeb328b..783af65d 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKESTATIC.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/INVOKESTATIC.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; -import org.apache.bcel.ExceptionConst; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.ExceptionConst; /** * INVOKESTATIC - Invoke a class (static) method diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKEVIRTUAL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/INVOKEVIRTUAL.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKEVIRTUAL.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/INVOKEVIRTUAL.java index f6b0d905..4a883bb1 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/INVOKEVIRTUAL.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/INVOKEVIRTUAL.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; -import org.apache.bcel.ExceptionConst; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.ExceptionConst; /** * INVOKEVIRTUAL - Invoke instance method; dispatch based on class diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IOR.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IOR.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IOR.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IOR.java index 9ec1f823..e2701a4c 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IOR.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IOR.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IOR - Bitwise OR int @@ -26,7 +26,7 @@ public class IOR extends ArithmeticInstruction { public IOR() { - super(org.apache.bcel.Const.IOR); + super(org.apache.bcel6_2_0.Const.IOR); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IREM.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IREM.java similarity index 90% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IREM.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IREM.java index 9c71111a..e2a56f03 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IREM.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IREM.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.ExceptionConst; +import org.apache.bcel6_2_0.ExceptionConst; /** * IREM - Remainder of int @@ -30,7 +30,7 @@ public class IREM extends ArithmeticInstruction implements ExceptionThrower { /** Remainder of ints */ public IREM() { - super(org.apache.bcel.Const.IREM); + super(org.apache.bcel6_2_0.Const.IREM); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IRETURN.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IRETURN.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IRETURN.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IRETURN.java index 8bea094f..f3100f0b 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IRETURN.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IRETURN.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IRETURN - Return int from method @@ -28,7 +28,7 @@ public class IRETURN extends ReturnInstruction { /** Return int from method */ public IRETURN() { - super(org.apache.bcel.Const.IRETURN); + super(org.apache.bcel6_2_0.Const.IRETURN); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ISHL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ISHL.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ISHL.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ISHL.java index 1060c188..b5928122 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ISHL.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ISHL.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * ISHL - Arithmetic shift left int @@ -26,7 +26,7 @@ public class ISHL extends ArithmeticInstruction { public ISHL() { - super(org.apache.bcel.Const.ISHL); + super(org.apache.bcel6_2_0.Const.ISHL); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ISHR.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ISHR.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ISHR.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ISHR.java index 00f17eee..04820eb6 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ISHR.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ISHR.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * ISHR - Arithmetic shift right int @@ -26,7 +26,7 @@ public class ISHR extends ArithmeticInstruction { public ISHR() { - super(org.apache.bcel.Const.ISHR); + super(org.apache.bcel6_2_0.Const.ISHR); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ISTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ISTORE.java similarity index 86% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ISTORE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ISTORE.java index 289fc405..d9e4c4f4 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ISTORE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ISTORE.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * ISTORE - Store int from stack into local variable @@ -30,7 +30,7 @@ public class ISTORE extends StoreInstruction { * Not to be used otherwise. */ ISTORE() { - super(org.apache.bcel.Const.ISTORE, org.apache.bcel.Const.ISTORE_0); + super(org.apache.bcel6_2_0.Const.ISTORE, org.apache.bcel6_2_0.Const.ISTORE_0); } @@ -38,7 +38,7 @@ public class ISTORE extends StoreInstruction { * @param n index of local variable */ public ISTORE(final int n) { - super(org.apache.bcel.Const.ISTORE, org.apache.bcel.Const.ISTORE_0, n); + super(org.apache.bcel6_2_0.Const.ISTORE, org.apache.bcel6_2_0.Const.ISTORE_0, n); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ISUB.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ISUB.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ISUB.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ISUB.java index 537bc22b..6f88bd6f 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ISUB.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ISUB.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * ISUB - Substract ints @@ -28,7 +28,7 @@ public class ISUB extends ArithmeticInstruction { /** Substract ints */ public ISUB() { - super(org.apache.bcel.Const.ISUB); + super(org.apache.bcel6_2_0.Const.ISUB); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IUSHR.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IUSHR.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IUSHR.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IUSHR.java index 2d134769..76d2833d 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IUSHR.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IUSHR.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IUSHR - Logical shift right int @@ -26,7 +26,7 @@ public class IUSHR extends ArithmeticInstruction { public IUSHR() { - super(org.apache.bcel.Const.IUSHR); + super(org.apache.bcel6_2_0.Const.IUSHR); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IXOR.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IXOR.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IXOR.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IXOR.java index 8b83c13b..5b680c25 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IXOR.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IXOR.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * IXOR - Bitwise XOR int @@ -26,7 +26,7 @@ public class IXOR extends ArithmeticInstruction { public IXOR() { - super(org.apache.bcel.Const.IXOR); + super(org.apache.bcel6_2_0.Const.IXOR); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IfInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IfInstruction.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IfInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IfInstruction.java index bab15627..e5b6ff1b 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IfInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IfInstruction.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Super class for the IFxxx family of instructions. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IndexedInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IndexedInstruction.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IndexedInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IndexedInstruction.java index 2a40694d..2ab0d9d4 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/IndexedInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/IndexedInstruction.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Denote entity that refers to an index, e.g. local variable instructions, diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Instruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/Instruction.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Instruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/Instruction.java index 2fe0f407..7de63e5f 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Instruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/Instruction.java @@ -15,14 +15,14 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; -import org.apache.bcel.classfile.ConstantPool; -import org.apache.bcel.util.ByteSequence; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.classfile.ConstantPool; +import org.apache.bcel6_2_0.util.ByteSequence; /** * Abstract super class for all Java byte codes. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionComparator.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InstructionComparator.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionComparator.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InstructionComparator.java index 65efe70e..347ffd16 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionComparator.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InstructionComparator.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Equality of instructions isn't clearly to be defined. You might diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionConst.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InstructionConst.java similarity index 97% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionConst.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InstructionConst.java index df198194..b240804d 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionConst.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InstructionConst.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This interface contains shareable instruction objects. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionConstants.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InstructionConstants.java similarity index 97% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionConstants.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InstructionConstants.java index 2fb0521f..b49a6bb6 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionConstants.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InstructionConstants.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * This interface contains shareable instruction objects. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionFactory.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InstructionFactory.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionFactory.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InstructionFactory.java index f53d1df1..5ed8ec54 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionFactory.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InstructionFactory.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * Instances of this class may be used, e.g., to generate typed diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionHandle.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InstructionHandle.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionHandle.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InstructionHandle.java index 457fe4c4..1d6c2efa 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionHandle.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InstructionHandle.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.util.Collection; import java.util.HashMap; @@ -23,7 +23,7 @@ import java.util.Map; import java.util.Set; -import org.apache.bcel.classfile.Utility; +import org.apache.bcel6_2_0.classfile.Utility; /** * Instances of this class give users a handle to the instructions contained in diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionList.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InstructionList.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionList.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InstructionList.java index cfee431c..ef10f40f 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionList.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InstructionList.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; @@ -27,9 +27,9 @@ import java.util.Map; import java.util.NoSuchElementException; -import org.apache.bcel.Const; -import org.apache.bcel.classfile.Constant; -import org.apache.bcel.util.ByteSequence; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.classfile.Constant; +import org.apache.bcel6_2_0.util.ByteSequence; /** * This class is a container for a list of Instruction objects. Instructions can be appended, inserted, moved, deleted, etc.. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionListObserver.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InstructionListObserver.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionListObserver.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InstructionListObserver.java index 32e00628..3b9fc765 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionListObserver.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InstructionListObserver.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Implement this interface if you're interested in changes to an InstructionList object diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionTargeter.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InstructionTargeter.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionTargeter.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InstructionTargeter.java index 9a487f65..0cccb925 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InstructionTargeter.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InstructionTargeter.java @@ -16,7 +16,7 @@ * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Denote that a class targets InstructionHandles within an InstructionList. Namely diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InvokeInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InvokeInstruction.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InvokeInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InvokeInstruction.java index 6f835e8f..f02fdff7 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/InvokeInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/InvokeInstruction.java @@ -15,14 +15,14 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.util.StringTokenizer; -import org.apache.bcel.Const; -import org.apache.bcel.classfile.Constant; -import org.apache.bcel.classfile.ConstantCP; -import org.apache.bcel.classfile.ConstantPool; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.classfile.Constant; +import org.apache.bcel6_2_0.classfile.ConstantCP; +import org.apache.bcel6_2_0.classfile.ConstantPool; /** * Super class for the INVOKExxx family of instructions. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/JSR.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/JSR.java similarity index 89% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/JSR.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/JSR.java index d1e83430..28136db6 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/JSR.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/JSR.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; @@ -36,7 +36,7 @@ public class JSR extends JsrInstruction implements VariableLengthInstruction { public JSR(final InstructionHandle target) { - super(org.apache.bcel.Const.JSR, target); + super(org.apache.bcel6_2_0.Const.JSR, target); } @@ -47,7 +47,7 @@ public JSR(final InstructionHandle target) { @Override public void dump( final DataOutputStream out ) throws IOException { super.setIndex(getTargetOffset()); - if (super.getOpcode() == org.apache.bcel.Const.JSR) { + if (super.getOpcode() == org.apache.bcel6_2_0.Const.JSR) { super.dump(out); } else { // JSR_W super.setIndex(getTargetOffset()); @@ -62,7 +62,7 @@ protected int updatePosition( final int offset, final int max_offset ) { final int i = getTargetOffset(); // Depending on old position value setPosition(getPosition() + offset); // Position may be shifted by preceding expansions if (Math.abs(i) >= (Short.MAX_VALUE - max_offset)) { // to large for short (estimate) - super.setOpcode(org.apache.bcel.Const.JSR_W); + super.setOpcode(org.apache.bcel6_2_0.Const.JSR_W); final short old_length = (short) super.getLength(); super.setLength(5); return super.getLength() - old_length; diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/JSR_W.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/JSR_W.java similarity index 91% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/JSR_W.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/JSR_W.java index 954d7c7f..b01ea554 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/JSR_W.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/JSR_W.java @@ -15,12 +15,12 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.util.ByteSequence; +import org.apache.bcel6_2_0.util.ByteSequence; /** * JSR_W - Jump to subroutine @@ -38,7 +38,7 @@ public class JSR_W extends JsrInstruction { public JSR_W(final InstructionHandle target) { - super(org.apache.bcel.Const.JSR_W, target); + super(org.apache.bcel6_2_0.Const.JSR_W, target); super.setLength(5); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/JsrInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/JsrInstruction.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/JsrInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/JsrInstruction.java index 409971f8..9a1fc053 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/JsrInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/JsrInstruction.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Super class for JSR - Jump to subroutine diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/L2D.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/L2D.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/L2D.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/L2D.java index 2b91cf23..9a227e4b 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/L2D.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/L2D.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * L2D - Convert long to double @@ -26,7 +26,7 @@ public class L2D extends ConversionInstruction { public L2D() { - super(org.apache.bcel.Const.L2D); + super(org.apache.bcel6_2_0.Const.L2D); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/L2F.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/L2F.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/L2F.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/L2F.java index b44f542c..200bf8f9 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/L2F.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/L2F.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * L2F - Convert long to float @@ -26,7 +26,7 @@ public class L2F extends ConversionInstruction { public L2F() { - super(org.apache.bcel.Const.L2F); + super(org.apache.bcel6_2_0.Const.L2F); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/L2I.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/L2I.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/L2I.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/L2I.java index e1223b5b..64d0993a 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/L2I.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/L2I.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * L2I - Convert long to int @@ -26,7 +26,7 @@ public class L2I extends ConversionInstruction { public L2I() { - super(org.apache.bcel.Const.L2I); + super(org.apache.bcel6_2_0.Const.L2I); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LADD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LADD.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LADD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LADD.java index d3dc450a..7eec4379 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LADD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LADD.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * LADD - Add longs @@ -27,7 +27,7 @@ public class LADD extends ArithmeticInstruction { public LADD() { - super(org.apache.bcel.Const.LADD); + super(org.apache.bcel6_2_0.Const.LADD); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LALOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LALOAD.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LALOAD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LALOAD.java index 24a4e48c..8e132114 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LALOAD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LALOAD.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * LALOAD - Load long from array @@ -28,7 +28,7 @@ public class LALOAD extends ArrayInstruction implements StackProducer { /** Load long from array */ public LALOAD() { - super(org.apache.bcel.Const.LALOAD); + super(org.apache.bcel6_2_0.Const.LALOAD); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LAND.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LAND.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LAND.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LAND.java index 38183598..601c8252 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LAND.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LAND.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * LAND - Bitwise AND longs @@ -27,7 +27,7 @@ public class LAND extends ArithmeticInstruction { public LAND() { - super(org.apache.bcel.Const.LAND); + super(org.apache.bcel6_2_0.Const.LAND); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LASTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LASTORE.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LASTORE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LASTORE.java index 821c71c4..0464221d 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LASTORE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LASTORE.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * LASTORE - Store into long array @@ -28,7 +28,7 @@ public class LASTORE extends ArrayInstruction implements StackConsumer { /** Store long into array */ public LASTORE() { - super(org.apache.bcel.Const.LASTORE); + super(org.apache.bcel6_2_0.Const.LASTORE); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LCMP.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LCMP.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LCMP.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LCMP.java index b8563695..203acd27 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LCMP.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LCMP.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * LCMP - Compare longs: @@ -27,7 +27,7 @@ public class LCMP extends Instruction implements TypedInstruction, StackProducer, StackConsumer { public LCMP() { - super(org.apache.bcel.Const.LCMP, (short) 1); + super(org.apache.bcel6_2_0.Const.LCMP, (short) 1); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LCONST.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LCONST.java similarity index 87% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LCONST.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LCONST.java index c2b5d2fa..dd7e7624 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LCONST.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LCONST.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * LCONST - Push 0 or 1, other values cause an exception @@ -38,11 +38,11 @@ public class LCONST extends Instruction implements ConstantPushInstruction { public LCONST(final long l) { - super(org.apache.bcel.Const.LCONST_0, (short) 1); + super(org.apache.bcel6_2_0.Const.LCONST_0, (short) 1); if (l == 0) { - super.setOpcode(org.apache.bcel.Const.LCONST_0); + super.setOpcode(org.apache.bcel6_2_0.Const.LCONST_0); } else if (l == 1) { - super.setOpcode(org.apache.bcel.Const.LCONST_1); + super.setOpcode(org.apache.bcel6_2_0.Const.LCONST_1); } else { throw new ClassGenException("LCONST can be used only for 0 and 1: " + l); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDC.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LDC.java similarity index 69% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDC.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LDC.java index df574300..951effbd 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDC.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LDC.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.ExceptionConst; -import org.apache.bcel.util.ByteSequence; +import org.apache.bcel6_2_0.ExceptionConst; +import org.apache.bcel6_2_0.util.ByteSequence; /** * LDC - Push item from constant pool. @@ -41,18 +41,18 @@ public class LDC extends CPInstruction implements PushInstruction, ExceptionThro public LDC(final int index) { - super(org.apache.bcel.Const.LDC_W, index); + super(org.apache.bcel6_2_0.Const.LDC_W, index); setSize(); } // Adjust to proper size protected final void setSize() { - if (super.getIndex() <= org.apache.bcel.Const.MAX_BYTE) { // Fits in one byte? - super.setOpcode(org.apache.bcel.Const.LDC); + if (super.getIndex() <= org.apache.bcel6_2_0.Const.MAX_BYTE) { // Fits in one byte? + super.setOpcode(org.apache.bcel6_2_0.Const.LDC); super.setLength(2); } else { - super.setOpcode(org.apache.bcel.Const.LDC_W); + super.setOpcode(org.apache.bcel6_2_0.Const.LDC_W); super.setLength(3); } } @@ -94,20 +94,20 @@ protected void initFromFile( final ByteSequence bytes, final boolean wide ) thro public Object getValue( final ConstantPoolGen cpg ) { - org.apache.bcel.classfile.Constant c = cpg.getConstantPool().getConstant(super.getIndex()); + org.apache.bcel6_2_0.classfile.Constant c = cpg.getConstantPool().getConstant(super.getIndex()); switch (c.getTag()) { - case org.apache.bcel.Const.CONSTANT_String: - final int i = ((org.apache.bcel.classfile.ConstantString) c).getStringIndex(); + case org.apache.bcel6_2_0.Const.CONSTANT_String: + final int i = ((org.apache.bcel6_2_0.classfile.ConstantString) c).getStringIndex(); c = cpg.getConstantPool().getConstant(i); - return ((org.apache.bcel.classfile.ConstantUtf8) c).getBytes(); - case org.apache.bcel.Const.CONSTANT_Float: - return new Float(((org.apache.bcel.classfile.ConstantFloat) c).getBytes()); - case org.apache.bcel.Const.CONSTANT_Integer: - return Integer.valueOf(((org.apache.bcel.classfile.ConstantInteger) c).getBytes()); - case org.apache.bcel.Const.CONSTANT_Class: - final int nameIndex = ((org.apache.bcel.classfile.ConstantClass) c).getNameIndex(); + return ((org.apache.bcel6_2_0.classfile.ConstantUtf8) c).getBytes(); + case org.apache.bcel6_2_0.Const.CONSTANT_Float: + return new Float(((org.apache.bcel6_2_0.classfile.ConstantFloat) c).getBytes()); + case org.apache.bcel6_2_0.Const.CONSTANT_Integer: + return Integer.valueOf(((org.apache.bcel6_2_0.classfile.ConstantInteger) c).getBytes()); + case org.apache.bcel6_2_0.Const.CONSTANT_Class: + final int nameIndex = ((org.apache.bcel6_2_0.classfile.ConstantClass) c).getNameIndex(); c = cpg.getConstantPool().getConstant(nameIndex); - return new ObjectType(((org.apache.bcel.classfile.ConstantUtf8) c).getBytes()); + return new ObjectType(((org.apache.bcel6_2_0.classfile.ConstantUtf8) c).getBytes()); default: // Never reached throw new RuntimeException("Unknown or invalid constant type at " + super.getIndex()); } @@ -117,13 +117,13 @@ public Object getValue( final ConstantPoolGen cpg ) { @Override public Type getType( final ConstantPoolGen cpg ) { switch (cpg.getConstantPool().getConstant(super.getIndex()).getTag()) { - case org.apache.bcel.Const.CONSTANT_String: + case org.apache.bcel6_2_0.Const.CONSTANT_String: return Type.STRING; - case org.apache.bcel.Const.CONSTANT_Float: + case org.apache.bcel6_2_0.Const.CONSTANT_Float: return Type.FLOAT; - case org.apache.bcel.Const.CONSTANT_Integer: + case org.apache.bcel6_2_0.Const.CONSTANT_Integer: return Type.INT; - case org.apache.bcel.Const.CONSTANT_Class: + case org.apache.bcel6_2_0.Const.CONSTANT_Class: return Type.CLASS; default: // Never reached throw new RuntimeException("Unknown or invalid constant type at " + super.getIndex()); diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDC2_W.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LDC2_W.java similarity index 76% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDC2_W.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LDC2_W.java index f020ff32..5cde6481 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDC2_W.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LDC2_W.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * LDC2_W - Push long or double from constant pool @@ -35,16 +35,16 @@ public class LDC2_W extends CPInstruction implements PushInstruction { public LDC2_W(final int index) { - super(org.apache.bcel.Const.LDC2_W, index); + super(org.apache.bcel6_2_0.Const.LDC2_W, index); } @Override public Type getType( final ConstantPoolGen cpg ) { switch (cpg.getConstantPool().getConstant(super.getIndex()).getTag()) { - case org.apache.bcel.Const.CONSTANT_Long: + case org.apache.bcel6_2_0.Const.CONSTANT_Long: return Type.LONG; - case org.apache.bcel.Const.CONSTANT_Double: + case org.apache.bcel6_2_0.Const.CONSTANT_Double: return Type.DOUBLE; default: // Never reached throw new RuntimeException("Unknown constant type " + super.getOpcode()); @@ -53,12 +53,12 @@ public Type getType( final ConstantPoolGen cpg ) { public Number getValue( final ConstantPoolGen cpg ) { - final org.apache.bcel.classfile.Constant c = cpg.getConstantPool().getConstant(super.getIndex()); + final org.apache.bcel6_2_0.classfile.Constant c = cpg.getConstantPool().getConstant(super.getIndex()); switch (c.getTag()) { - case org.apache.bcel.Const.CONSTANT_Long: - return Long.valueOf(((org.apache.bcel.classfile.ConstantLong) c).getBytes()); - case org.apache.bcel.Const.CONSTANT_Double: - return new Double(((org.apache.bcel.classfile.ConstantDouble) c).getBytes()); + case org.apache.bcel6_2_0.Const.CONSTANT_Long: + return Long.valueOf(((org.apache.bcel6_2_0.classfile.ConstantLong) c).getBytes()); + case org.apache.bcel6_2_0.Const.CONSTANT_Double: + return new Double(((org.apache.bcel6_2_0.classfile.ConstantDouble) c).getBytes()); default: // Never reached throw new RuntimeException("Unknown or invalid constant type at " + super.getIndex()); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDC_W.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LDC_W.java similarity index 88% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDC_W.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LDC_W.java index f0c0a836..78c66e2b 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDC_W.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LDC_W.java @@ -15,11 +15,11 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.IOException; -import org.apache.bcel.util.ByteSequence; +import org.apache.bcel6_2_0.util.ByteSequence; /** * LDC_W - Push item from constant pool (wide index) @@ -50,7 +50,7 @@ public LDC_W(final int index) { protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException { setIndex(bytes.readUnsignedShort()); // Override just in case it has been changed - super.setOpcode(org.apache.bcel.Const.LDC_W); + super.setOpcode(org.apache.bcel6_2_0.Const.LDC_W); super.setLength(3); } } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDIV.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LDIV.java similarity index 90% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDIV.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LDIV.java index eddd4340..a4b661af 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LDIV.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LDIV.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.ExceptionConst; +import org.apache.bcel6_2_0.ExceptionConst; /** * LDIV - Divide longs @@ -29,7 +29,7 @@ public class LDIV extends ArithmeticInstruction implements ExceptionThrower { public LDIV() { - super(org.apache.bcel.Const.LDIV); + super(org.apache.bcel6_2_0.Const.LDIV); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LLOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LLOAD.java similarity index 86% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LLOAD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LLOAD.java index a84aaeaa..ec745863 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LLOAD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LLOAD.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * LLOAD - Load long from local variable @@ -30,12 +30,12 @@ public class LLOAD extends LoadInstruction { * Not to be used otherwise. */ LLOAD() { - super(org.apache.bcel.Const.LLOAD, org.apache.bcel.Const.LLOAD_0); + super(org.apache.bcel6_2_0.Const.LLOAD, org.apache.bcel6_2_0.Const.LLOAD_0); } public LLOAD(final int n) { - super(org.apache.bcel.Const.LLOAD, org.apache.bcel.Const.LLOAD_0, n); + super(org.apache.bcel6_2_0.Const.LLOAD, org.apache.bcel6_2_0.Const.LLOAD_0, n); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LMUL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LMUL.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LMUL.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LMUL.java index 6a642a89..1eb48395 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LMUL.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LMUL.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * LMUL - Multiply longs @@ -27,7 +27,7 @@ public class LMUL extends ArithmeticInstruction { public LMUL() { - super(org.apache.bcel.Const.LMUL); + super(org.apache.bcel6_2_0.Const.LMUL); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LNEG.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LNEG.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LNEG.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LNEG.java index 03327603..b4029d0e 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LNEG.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LNEG.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * LNEG - Negate long @@ -26,7 +26,7 @@ public class LNEG extends ArithmeticInstruction { public LNEG() { - super(org.apache.bcel.Const.LNEG); + super(org.apache.bcel6_2_0.Const.LNEG); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LOOKUPSWITCH.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LOOKUPSWITCH.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LOOKUPSWITCH.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LOOKUPSWITCH.java index b34db911..31276411 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LOOKUPSWITCH.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LOOKUPSWITCH.java @@ -15,12 +15,12 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.util.ByteSequence; +import org.apache.bcel6_2_0.util.ByteSequence; /** * LOOKUPSWITCH - Switch with unordered set of values @@ -39,7 +39,7 @@ public class LOOKUPSWITCH extends Select { public LOOKUPSWITCH(final int[] match, final InstructionHandle[] targets, final InstructionHandle defaultTarget) { - super(org.apache.bcel.Const.LOOKUPSWITCH, match, targets, defaultTarget); + super(org.apache.bcel6_2_0.Const.LOOKUPSWITCH, match, targets, defaultTarget); /* alignment remainder assumed 0 here, until dump time. */ final short _length = (short) (9 + getMatch_length() * 8); super.setLength(_length); diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LOR.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LOR.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LOR.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LOR.java index 876aa4b6..71570563 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LOR.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LOR.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * LOR - Bitwise OR long @@ -26,7 +26,7 @@ public class LOR extends ArithmeticInstruction { public LOR() { - super(org.apache.bcel.Const.LOR); + super(org.apache.bcel6_2_0.Const.LOR); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LREM.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LREM.java similarity index 90% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LREM.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LREM.java index 513d120c..983b0b2f 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LREM.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LREM.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.ExceptionConst; +import org.apache.bcel6_2_0.ExceptionConst; /** * LREM - Remainder of long @@ -28,7 +28,7 @@ public class LREM extends ArithmeticInstruction implements ExceptionThrower { public LREM() { - super(org.apache.bcel.Const.LREM); + super(org.apache.bcel6_2_0.Const.LREM); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LRETURN.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LRETURN.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LRETURN.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LRETURN.java index 1708c5dd..eea2c4d8 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LRETURN.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LRETURN.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * LRETURN - Return long from method @@ -26,7 +26,7 @@ public class LRETURN extends ReturnInstruction { public LRETURN() { - super(org.apache.bcel.Const.LRETURN); + super(org.apache.bcel6_2_0.Const.LRETURN); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LSHL.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LSHL.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LSHL.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LSHL.java index 5a853a3d..0eddedd2 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LSHL.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LSHL.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * LSHL - Arithmetic shift left long @@ -26,7 +26,7 @@ public class LSHL extends ArithmeticInstruction { public LSHL() { - super(org.apache.bcel.Const.LSHL); + super(org.apache.bcel6_2_0.Const.LSHL); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LSHR.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LSHR.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LSHR.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LSHR.java index 035136eb..2495db19 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LSHR.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LSHR.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * LSHR - Arithmetic shift right long @@ -26,7 +26,7 @@ public class LSHR extends ArithmeticInstruction { public LSHR() { - super(org.apache.bcel.Const.LSHR); + super(org.apache.bcel6_2_0.Const.LSHR); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LSTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LSTORE.java similarity index 85% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LSTORE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LSTORE.java index 03844774..4a5d56da 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LSTORE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LSTORE.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * LSTORE - Store long into local variable @@ -30,12 +30,12 @@ public class LSTORE extends StoreInstruction { * Not to be used otherwise. */ LSTORE() { - super(org.apache.bcel.Const.LSTORE, org.apache.bcel.Const.LSTORE_0); + super(org.apache.bcel6_2_0.Const.LSTORE, org.apache.bcel6_2_0.Const.LSTORE_0); } public LSTORE(final int n) { - super(org.apache.bcel.Const.LSTORE, org.apache.bcel.Const.LSTORE_0, n); + super(org.apache.bcel6_2_0.Const.LSTORE, org.apache.bcel6_2_0.Const.LSTORE_0, n); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LSUB.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LSUB.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LSUB.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LSUB.java index 9303cfc3..4c64c812 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LSUB.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LSUB.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * LSUB - Substract longs @@ -27,7 +27,7 @@ public class LSUB extends ArithmeticInstruction { public LSUB() { - super(org.apache.bcel.Const.LSUB); + super(org.apache.bcel6_2_0.Const.LSUB); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LUSHR.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LUSHR.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LUSHR.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LUSHR.java index bc33a52b..29a95299 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LUSHR.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LUSHR.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * LUSHR - Logical shift right long @@ -26,7 +26,7 @@ public class LUSHR extends ArithmeticInstruction { public LUSHR() { - super(org.apache.bcel.Const.LUSHR); + super(org.apache.bcel6_2_0.Const.LUSHR); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LXOR.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LXOR.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LXOR.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LXOR.java index a614d300..c8ebb391 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LXOR.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LXOR.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * LXOR - Bitwise XOR long @@ -26,7 +26,7 @@ public class LXOR extends ArithmeticInstruction { public LXOR() { - super(org.apache.bcel.Const.LXOR); + super(org.apache.bcel6_2_0.Const.LXOR); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LineNumberGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LineNumberGen.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LineNumberGen.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LineNumberGen.java index e9c325c7..fc6956b1 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LineNumberGen.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LineNumberGen.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.classfile.LineNumber; +import org.apache.bcel6_2_0.classfile.LineNumber; /** * This class represents a line number within a method, i.e., give an instruction diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LoadClass.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LoadClass.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LoadClass.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LoadClass.java index a034be26..e91b2a5e 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LoadClass.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LoadClass.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Denotes that an instruction may start the process of loading and resolving diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LoadInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LoadInstruction.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LoadInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LoadInstruction.java index aaf5a2f6..da53982f 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LoadInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LoadInstruction.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Denotes an unparameterized instruction to load a value from a local diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LocalVariableGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LocalVariableGen.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LocalVariableGen.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LocalVariableGen.java index 8b15eb59..da25e214 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LocalVariableGen.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LocalVariableGen.java @@ -15,10 +15,10 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.Const; -import org.apache.bcel.classfile.LocalVariable; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.classfile.LocalVariable; /** * This class represents a local variable within a method. It contains its diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LocalVariableInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LocalVariableInstruction.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LocalVariableInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LocalVariableInstruction.java index 4f407f79..54c8dfe1 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/LocalVariableInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/LocalVariableInstruction.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.Const; -import org.apache.bcel.util.ByteSequence; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.util.ByteSequence; /** * Abstract super class for instructions dealing with local variables. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MONITORENTER.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/MONITORENTER.java similarity index 89% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MONITORENTER.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/MONITORENTER.java index 099a065c..33400c26 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MONITORENTER.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/MONITORENTER.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.ExceptionConst; +import org.apache.bcel6_2_0.ExceptionConst; /** * MONITORENTER - Enter monitor for object @@ -28,7 +28,7 @@ public class MONITORENTER extends Instruction implements ExceptionThrower, StackConsumer { public MONITORENTER() { - super(org.apache.bcel.Const.MONITORENTER, (short) 1); + super(org.apache.bcel6_2_0.Const.MONITORENTER, (short) 1); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MONITOREXIT.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/MONITOREXIT.java similarity index 89% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MONITOREXIT.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/MONITOREXIT.java index 67b92872..4c227955 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MONITOREXIT.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/MONITOREXIT.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.ExceptionConst; +import org.apache.bcel6_2_0.ExceptionConst; /** * MONITOREXIT - Exit monitor for object @@ -28,7 +28,7 @@ public class MONITOREXIT extends Instruction implements ExceptionThrower, StackConsumer { public MONITOREXIT() { - super(org.apache.bcel.Const.MONITOREXIT, (short) 1); + super(org.apache.bcel6_2_0.Const.MONITOREXIT, (short) 1); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MULTIANEWARRAY.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/MULTIANEWARRAY.java similarity index 91% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MULTIANEWARRAY.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/MULTIANEWARRAY.java index 6b91efe2..8e209b66 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MULTIANEWARRAY.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/MULTIANEWARRAY.java @@ -15,14 +15,14 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.ExceptionConst; -import org.apache.bcel.classfile.ConstantPool; -import org.apache.bcel.util.ByteSequence; +import org.apache.bcel6_2_0.ExceptionConst; +import org.apache.bcel6_2_0.classfile.ConstantPool; +import org.apache.bcel6_2_0.util.ByteSequence; /** * MULTIANEWARRAY - Create new mutidimensional array of references @@ -45,7 +45,7 @@ public class MULTIANEWARRAY extends CPInstruction implements LoadClass, Allocati public MULTIANEWARRAY(final int index, final short dimensions) { - super(org.apache.bcel.Const.MULTIANEWARRAY, index); + super(org.apache.bcel6_2_0.Const.MULTIANEWARRAY, index); if (dimensions < 1) { throw new ClassGenException("Invalid dimensions value: " + dimensions); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MethodGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/MethodGen.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MethodGen.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/MethodGen.java index a0e0b54f..3bc175eb 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MethodGen.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/MethodGen.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.util.ArrayList; import java.util.Arrays; @@ -24,24 +24,24 @@ import java.util.List; import java.util.Stack; -import org.apache.bcel.Const; -import org.apache.bcel.classfile.AnnotationEntry; -import org.apache.bcel.classfile.Annotations; -import org.apache.bcel.classfile.Attribute; -import org.apache.bcel.classfile.Code; -import org.apache.bcel.classfile.CodeException; -import org.apache.bcel.classfile.ExceptionTable; -import org.apache.bcel.classfile.LineNumber; -import org.apache.bcel.classfile.LineNumberTable; -import org.apache.bcel.classfile.LocalVariable; -import org.apache.bcel.classfile.LocalVariableTable; -import org.apache.bcel.classfile.LocalVariableTypeTable; -import org.apache.bcel.classfile.Method; -import org.apache.bcel.classfile.ParameterAnnotationEntry; -import org.apache.bcel.classfile.ParameterAnnotations; -import org.apache.bcel.classfile.RuntimeVisibleParameterAnnotations; -import org.apache.bcel.classfile.Utility; -import org.apache.bcel.util.BCELComparator; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.classfile.AnnotationEntry; +import org.apache.bcel6_2_0.classfile.Annotations; +import org.apache.bcel6_2_0.classfile.Attribute; +import org.apache.bcel6_2_0.classfile.Code; +import org.apache.bcel6_2_0.classfile.CodeException; +import org.apache.bcel6_2_0.classfile.ExceptionTable; +import org.apache.bcel6_2_0.classfile.LineNumber; +import org.apache.bcel6_2_0.classfile.LineNumberTable; +import org.apache.bcel6_2_0.classfile.LocalVariable; +import org.apache.bcel6_2_0.classfile.LocalVariableTable; +import org.apache.bcel6_2_0.classfile.LocalVariableTypeTable; +import org.apache.bcel6_2_0.classfile.Method; +import org.apache.bcel6_2_0.classfile.ParameterAnnotationEntry; +import org.apache.bcel6_2_0.classfile.ParameterAnnotations; +import org.apache.bcel6_2_0.classfile.RuntimeVisibleParameterAnnotations; +import org.apache.bcel6_2_0.classfile.Utility; +import org.apache.bcel6_2_0.util.BCELComparator; /** * Template class for building up a method. This is done by defining exception diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MethodObserver.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/MethodObserver.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MethodObserver.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/MethodObserver.java index cec658f2..c6204900 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/MethodObserver.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/MethodObserver.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Implement this interface if you're interested in changes to a MethodGen object diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NEW.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/NEW.java similarity index 91% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NEW.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/NEW.java index 4df9b93d..0ab2c1d5 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NEW.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/NEW.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.ExceptionConst; +import org.apache.bcel6_2_0.ExceptionConst; /** * NEW - Create new object @@ -37,7 +37,7 @@ public class NEW extends CPInstruction implements LoadClass, AllocationInstructi public NEW(final int index) { - super(org.apache.bcel.Const.NEW, index); + super(org.apache.bcel6_2_0.Const.NEW, index); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NEWARRAY.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/NEWARRAY.java similarity index 88% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NEWARRAY.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/NEWARRAY.java index cf30fe34..ee878e26 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NEWARRAY.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/NEWARRAY.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.ExceptionConst; -import org.apache.bcel.util.ByteSequence; +import org.apache.bcel6_2_0.ExceptionConst; +import org.apache.bcel6_2_0.util.ByteSequence; /** * NEWARRAY - Create new array of basic type (int, short, ...) @@ -45,7 +45,7 @@ public class NEWARRAY extends Instruction implements AllocationInstruction, Exce public NEWARRAY(final byte type) { - super(org.apache.bcel.Const.NEWARRAY, (short) 2); + super(org.apache.bcel6_2_0.Const.NEWARRAY, (short) 2); this.type = type; } @@ -87,7 +87,7 @@ public final Type getType() { */ @Override public String toString( final boolean verbose ) { - return super.toString(verbose) + " " + org.apache.bcel.Const.getTypeName(type); + return super.toString(verbose) + " " + org.apache.bcel6_2_0.Const.getTypeName(type); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NOP.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/NOP.java similarity index 90% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NOP.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/NOP.java index fc9cf86c..24cb3773 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NOP.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/NOP.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * NOP - Do nothing @@ -25,7 +25,7 @@ public class NOP extends Instruction { public NOP() { - super(org.apache.bcel.Const.NOP, (short) 1); + super(org.apache.bcel6_2_0.Const.NOP, (short) 1); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NameSignatureInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/NameSignatureInstruction.java similarity index 89% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NameSignatureInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/NameSignatureInstruction.java index 32231c7a..5f7f48e3 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NameSignatureInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/NameSignatureInstruction.java @@ -15,12 +15,12 @@ * limitations under the License. */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.classfile.ConstantCP; -import org.apache.bcel.classfile.ConstantNameAndType; -import org.apache.bcel.classfile.ConstantPool; -import org.apache.bcel.classfile.ConstantUtf8; +import org.apache.bcel6_2_0.classfile.ConstantCP; +import org.apache.bcel6_2_0.classfile.ConstantNameAndType; +import org.apache.bcel6_2_0.classfile.ConstantPool; +import org.apache.bcel6_2_0.classfile.ConstantUtf8; /** * Super class for FieldOrMethod and INVOKEDYNAMIC, since they both have diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NamedAndTyped.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/NamedAndTyped.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NamedAndTyped.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/NamedAndTyped.java index df14562e..bf40cf63 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/NamedAndTyped.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/NamedAndTyped.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Denote entity that has both name and type. This is true for local variables, diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ObjectType.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ObjectType.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ObjectType.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ObjectType.java index bcee3daf..10a85197 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ObjectType.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ObjectType.java @@ -15,11 +15,11 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.Const; -import org.apache.bcel.Repository; -import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.Repository; +import org.apache.bcel6_2_0.classfile.JavaClass; /** * Denotes reference such as java.lang.String. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/POP.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/POP.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/POP.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/POP.java index b308d7bb..48cbe09e 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/POP.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/POP.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * POP - Pop top operand stack word @@ -27,7 +27,7 @@ public class POP extends StackInstruction implements PopInstruction { public POP() { - super(org.apache.bcel.Const.POP); + super(org.apache.bcel6_2_0.Const.POP); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/POP2.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/POP2.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/POP2.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/POP2.java index 6627ab09..c0f8a940 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/POP2.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/POP2.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * POP2 - Pop two top operand stack words @@ -27,7 +27,7 @@ public class POP2 extends StackInstruction implements PopInstruction { public POP2() { - super(org.apache.bcel.Const.POP2); + super(org.apache.bcel6_2_0.Const.POP2); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PUSH.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/PUSH.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PUSH.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/PUSH.java index 23c941c4..ba4a1a94 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PUSH.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/PUSH.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * Wrapper class for push operations, which are implemented either as BIPUSH, diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PUTFIELD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/PUTFIELD.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PUTFIELD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/PUTFIELD.java index a4ede188..46dd308d 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PUTFIELD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/PUTFIELD.java @@ -15,10 +15,10 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.Const; -import org.apache.bcel.ExceptionConst; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.ExceptionConst; /** * PUTFIELD - Put field in object diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PUTSTATIC.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/PUTSTATIC.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PUTSTATIC.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/PUTSTATIC.java index 928b42a7..5f26ea07 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PUTSTATIC.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/PUTSTATIC.java @@ -15,10 +15,10 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.Const; -import org.apache.bcel.ExceptionConst; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.ExceptionConst; /** * PUTSTATIC - Put static field in class diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PopInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/PopInstruction.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PopInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/PopInstruction.java index 7f8a9149..59b640fd 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PopInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/PopInstruction.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Denotes an unparameterized instruction to pop a value on top from the stack, diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PushInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/PushInstruction.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PushInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/PushInstruction.java index b0429f53..40c8deda 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/PushInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/PushInstruction.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Denotes an unparameterized instruction to produce a value on top of the stack, diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/RET.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/RET.java similarity index 89% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/RET.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/RET.java index b0ad0c27..fc1291b7 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/RET.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/RET.java @@ -15,12 +15,12 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.util.ByteSequence; +import org.apache.bcel6_2_0.util.ByteSequence; /** * RET - Return from subroutine @@ -44,7 +44,7 @@ public class RET extends Instruction implements IndexedInstruction, TypedInstruc public RET(final int index) { - super(org.apache.bcel.Const.RET, (short) 2); + super(org.apache.bcel6_2_0.Const.RET, (short) 2); setIndex(index); // May set wide as side effect } @@ -56,7 +56,7 @@ public RET(final int index) { @Override public void dump( final DataOutputStream out ) throws IOException { if (wide) { - out.writeByte(org.apache.bcel.Const.WIDE); + out.writeByte(org.apache.bcel6_2_0.Const.WIDE); } out.writeByte(super.getOpcode()); if (wide) { @@ -68,7 +68,7 @@ public void dump( final DataOutputStream out ) throws IOException { private void setWide() { - wide = index > org.apache.bcel.Const.MAX_BYTE; + wide = index > org.apache.bcel6_2_0.Const.MAX_BYTE; if (wide) { super.setLength(4); // Including the wide byte } else { diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/RETURN.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/RETURN.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/RETURN.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/RETURN.java index ca4fdeb5..e36b3ef1 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/RETURN.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/RETURN.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * RETURN - Return from void method @@ -26,7 +26,7 @@ public class RETURN extends ReturnInstruction { public RETURN() { - super(org.apache.bcel.Const.RETURN); + super(org.apache.bcel6_2_0.Const.RETURN); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ReferenceType.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ReferenceType.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ReferenceType.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ReferenceType.java index 6fdcda50..4d62833a 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ReferenceType.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ReferenceType.java @@ -15,11 +15,11 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.Const; -import org.apache.bcel.Repository; -import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.Repository; +import org.apache.bcel6_2_0.classfile.JavaClass; /** * Super class for object and array types. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ReturnInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ReturnInstruction.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ReturnInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ReturnInstruction.java index cbd18183..3908d5cc 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ReturnInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ReturnInstruction.java @@ -15,10 +15,10 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.Const; -import org.apache.bcel.ExceptionConst; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.ExceptionConst; /** * Super class for the xRETURN family of instructions. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ReturnaddressType.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ReturnaddressType.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ReturnaddressType.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ReturnaddressType.java index 7d7373a1..5ee35746 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/ReturnaddressType.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/ReturnaddressType.java @@ -15,9 +15,9 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; -import org.apache.bcel.Const; +import org.apache.bcel6_2_0.Const; /** * Returnaddress, the type JSR or JSR_W instructions push upon the stack. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SALOAD.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/SALOAD.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SALOAD.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/SALOAD.java index 8ed4fbcd..0c6275ad 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SALOAD.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/SALOAD.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * SALOAD - Load short from array @@ -26,7 +26,7 @@ public class SALOAD extends ArrayInstruction implements StackProducer { public SALOAD() { - super(org.apache.bcel.Const.SALOAD); + super(org.apache.bcel6_2_0.Const.SALOAD); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SASTORE.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/SASTORE.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SASTORE.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/SASTORE.java index 00b679bb..be8a47e1 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SASTORE.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/SASTORE.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * SASTORE - Store into short array @@ -26,7 +26,7 @@ public class SASTORE extends ArrayInstruction implements StackConsumer { public SASTORE() { - super(org.apache.bcel.Const.SASTORE); + super(org.apache.bcel6_2_0.Const.SASTORE); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SIPUSH.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/SIPUSH.java similarity index 91% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SIPUSH.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/SIPUSH.java index 6410c131..f476b881 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SIPUSH.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/SIPUSH.java @@ -15,12 +15,12 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.util.ByteSequence; +import org.apache.bcel6_2_0.util.ByteSequence; /** * SIPUSH - Push short @@ -43,7 +43,7 @@ public class SIPUSH extends Instruction implements ConstantPushInstruction { public SIPUSH(final short b) { - super(org.apache.bcel.Const.SIPUSH, (short) 3); + super(org.apache.bcel6_2_0.Const.SIPUSH, (short) 3); this.b = b; } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SWAP.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/SWAP.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SWAP.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/SWAP.java index 2211f497..a5a75bd3 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SWAP.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/SWAP.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * SWAP - Swa top operand stack word @@ -26,7 +26,7 @@ public class SWAP extends StackInstruction implements StackConsumer, StackProducer { public SWAP() { - super(org.apache.bcel.Const.SWAP); + super(org.apache.bcel6_2_0.Const.SWAP); } diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SWITCH.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/SWITCH.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SWITCH.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/SWITCH.java index 7e2773db..026e40f0 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SWITCH.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/SWITCH.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * SWITCH - Branch depending on int value, generates either LOOKUPSWITCH or diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Select.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/Select.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Select.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/Select.java index f3a2865f..949fcc99 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Select.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/Select.java @@ -15,12 +15,12 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.util.ByteSequence; +import org.apache.bcel6_2_0.util.ByteSequence; /** * Select - Abstract super class for LOOKUPSWITCH and TABLESWITCH instructions. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SimpleElementValueGen.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/SimpleElementValueGen.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SimpleElementValueGen.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/SimpleElementValueGen.java index 99ed6d40..4ea87b03 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/SimpleElementValueGen.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/SimpleElementValueGen.java @@ -15,18 +15,18 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -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.ConstantUtf8; -import org.apache.bcel.classfile.ElementValue; -import org.apache.bcel.classfile.SimpleElementValue; +import org.apache.bcel6_2_0.classfile.ConstantDouble; +import org.apache.bcel6_2_0.classfile.ConstantFloat; +import org.apache.bcel6_2_0.classfile.ConstantInteger; +import org.apache.bcel6_2_0.classfile.ConstantLong; +import org.apache.bcel6_2_0.classfile.ConstantUtf8; +import org.apache.bcel6_2_0.classfile.ElementValue; +import org.apache.bcel6_2_0.classfile.SimpleElementValue; /** * @since 6.0 diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StackConsumer.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/StackConsumer.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StackConsumer.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/StackConsumer.java index 21150fa6..222a4b40 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StackConsumer.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/StackConsumer.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Denote an instruction that may consume a value from the stack. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StackInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/StackInstruction.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StackInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/StackInstruction.java index b12630b3..04560f33 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StackInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/StackInstruction.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Super class for stack operations like DUP and POP. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StackProducer.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/StackProducer.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StackProducer.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/StackProducer.java index d07a5f85..3a0fbf8c 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StackProducer.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/StackProducer.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Denote an instruction that may produce a value on top of the stack diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StoreInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/StoreInstruction.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StoreInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/StoreInstruction.java index c53e6edb..ee6b2801 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/StoreInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/StoreInstruction.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Denotes an unparameterized instruction to store a value into a local variable, diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/TABLESWITCH.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/TABLESWITCH.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/TABLESWITCH.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/TABLESWITCH.java index 78f0deb8..726b1235 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/TABLESWITCH.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/TABLESWITCH.java @@ -15,12 +15,12 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.bcel.util.ByteSequence; +import org.apache.bcel6_2_0.util.ByteSequence; /** * TABLESWITCH - Switch within given range of values, i.e., low..high @@ -45,7 +45,7 @@ public class TABLESWITCH extends Select { * @param defaultTarget default branch */ public TABLESWITCH(final int[] match, final InstructionHandle[] targets, final InstructionHandle defaultTarget) { - super(org.apache.bcel.Const.TABLESWITCH, match, targets, defaultTarget); + super(org.apache.bcel6_2_0.Const.TABLESWITCH, match, targets, defaultTarget); /* Alignment remainder assumed 0 here, until dump time */ final short _length = (short) (13 + getMatch_length() * 4); super.setLength(_length); diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/TargetLostException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/TargetLostException.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/TargetLostException.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/TargetLostException.java index a0f2e023..68f69fc5 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/TargetLostException.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/TargetLostException.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Thrown by InstructionList.remove() when one or multiple disposed instructions diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Type.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/Type.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Type.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/Type.java index d98cc734..e7ec3be4 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Type.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/Type.java @@ -15,14 +15,14 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; import java.util.ArrayList; import java.util.List; -import org.apache.bcel.Const; -import org.apache.bcel.classfile.ClassFormatException; -import org.apache.bcel.classfile.Utility; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.classfile.ClassFormatException; +import org.apache.bcel6_2_0.classfile.Utility; /** * Abstract super class for all possible java types, namely basic types diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/TypedInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/TypedInstruction.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/TypedInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/TypedInstruction.java index c2b7c1a7..1c69f7b7 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/TypedInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/TypedInstruction.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Get the type associated with an instruction, int for ILOAD, or the type diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/UnconditionalBranch.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/UnconditionalBranch.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/UnconditionalBranch.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/UnconditionalBranch.java index 9268481f..d1d55cba 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/UnconditionalBranch.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/UnconditionalBranch.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Denotes an instruction to perform an unconditional branch, i.e., GOTO, JSR. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/VariableLengthInstruction.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/VariableLengthInstruction.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/VariableLengthInstruction.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/VariableLengthInstruction.java index 3c0ede2f..316ebc48 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/VariableLengthInstruction.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/VariableLengthInstruction.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Denotes an instruction to be a variable length instruction, such as diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Visitor.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/Visitor.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Visitor.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/Visitor.java index c4ae31c1..11863bfb 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/Visitor.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/Visitor.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.generic; +package org.apache.bcel6_2_0.generic; /** * Interface implementing the Visitor pattern programming style. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/package.html b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/package.html similarity index 100% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/generic/package.html rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/generic/package.html diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/package.html b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/package.html similarity index 100% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/package.html rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/package.html diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/AttributeHTML.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/AttributeHTML.java similarity index 89% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/AttributeHTML.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/AttributeHTML.java index 01ea4be7..d7a583e1 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/AttributeHTML.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/AttributeHTML.java @@ -15,28 +15,28 @@ * limitations under the License. * */ -package org.apache.bcel.util; +package org.apache.bcel6_2_0.util; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintWriter; -import org.apache.bcel.Const; -import org.apache.bcel.classfile.Attribute; -import org.apache.bcel.classfile.Code; -import org.apache.bcel.classfile.CodeException; -import org.apache.bcel.classfile.ConstantPool; -import org.apache.bcel.classfile.ConstantUtf8; -import org.apache.bcel.classfile.ConstantValue; -import org.apache.bcel.classfile.ExceptionTable; -import org.apache.bcel.classfile.InnerClass; -import org.apache.bcel.classfile.InnerClasses; -import org.apache.bcel.classfile.LineNumber; -import org.apache.bcel.classfile.LineNumberTable; -import org.apache.bcel.classfile.LocalVariable; -import org.apache.bcel.classfile.LocalVariableTable; -import org.apache.bcel.classfile.SourceFile; -import org.apache.bcel.classfile.Utility; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.classfile.Attribute; +import org.apache.bcel6_2_0.classfile.Code; +import org.apache.bcel6_2_0.classfile.CodeException; +import org.apache.bcel6_2_0.classfile.ConstantPool; +import org.apache.bcel6_2_0.classfile.ConstantUtf8; +import org.apache.bcel6_2_0.classfile.ConstantValue; +import org.apache.bcel6_2_0.classfile.ExceptionTable; +import org.apache.bcel6_2_0.classfile.InnerClass; +import org.apache.bcel6_2_0.classfile.InnerClasses; +import org.apache.bcel6_2_0.classfile.LineNumber; +import org.apache.bcel6_2_0.classfile.LineNumberTable; +import org.apache.bcel6_2_0.classfile.LocalVariable; +import org.apache.bcel6_2_0.classfile.LocalVariableTable; +import org.apache.bcel6_2_0.classfile.SourceFile; +import org.apache.bcel6_2_0.classfile.Utility; /** * Convert found attributes into HTML file. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/BCELComparator.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/BCELComparator.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/BCELComparator.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/BCELComparator.java index 4f6dbfbf..a3fd0fab 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/BCELComparator.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/BCELComparator.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.util; +package org.apache.bcel6_2_0.util; /** * Used for BCEL comparison strategy diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/BCELFactory.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/BCELFactory.java similarity index 85% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/BCELFactory.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/BCELFactory.java index b350b0e5..a1e732e2 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/BCELFactory.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/BCELFactory.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.util; +package org.apache.bcel6_2_0.util; import java.io.PrintWriter; import java.util.ArrayList; @@ -24,37 +24,37 @@ import java.util.Locale; import java.util.Map; -import org.apache.bcel.Const; -import org.apache.bcel.classfile.Utility; -import org.apache.bcel.generic.AllocationInstruction; -import org.apache.bcel.generic.ArrayInstruction; -import org.apache.bcel.generic.ArrayType; -import org.apache.bcel.generic.BranchHandle; -import org.apache.bcel.generic.BranchInstruction; -import org.apache.bcel.generic.CHECKCAST; -import org.apache.bcel.generic.CPInstruction; -import org.apache.bcel.generic.CodeExceptionGen; -import org.apache.bcel.generic.ConstantPoolGen; -import org.apache.bcel.generic.ConstantPushInstruction; -import org.apache.bcel.generic.EmptyVisitor; -import org.apache.bcel.generic.FieldInstruction; -import org.apache.bcel.generic.IINC; -import org.apache.bcel.generic.INSTANCEOF; -import org.apache.bcel.generic.Instruction; -import org.apache.bcel.generic.InstructionConst; -import org.apache.bcel.generic.InstructionHandle; -import org.apache.bcel.generic.InvokeInstruction; -import org.apache.bcel.generic.LDC; -import org.apache.bcel.generic.LDC2_W; -import org.apache.bcel.generic.LocalVariableInstruction; -import org.apache.bcel.generic.MULTIANEWARRAY; -import org.apache.bcel.generic.MethodGen; -import org.apache.bcel.generic.NEWARRAY; -import org.apache.bcel.generic.ObjectType; -import org.apache.bcel.generic.RET; -import org.apache.bcel.generic.ReturnInstruction; -import org.apache.bcel.generic.Select; -import org.apache.bcel.generic.Type; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.classfile.Utility; +import org.apache.bcel6_2_0.generic.AllocationInstruction; +import org.apache.bcel6_2_0.generic.ArrayInstruction; +import org.apache.bcel6_2_0.generic.ArrayType; +import org.apache.bcel6_2_0.generic.BranchHandle; +import org.apache.bcel6_2_0.generic.BranchInstruction; +import org.apache.bcel6_2_0.generic.CHECKCAST; +import org.apache.bcel6_2_0.generic.CPInstruction; +import org.apache.bcel6_2_0.generic.CodeExceptionGen; +import org.apache.bcel6_2_0.generic.ConstantPoolGen; +import org.apache.bcel6_2_0.generic.ConstantPushInstruction; +import org.apache.bcel6_2_0.generic.EmptyVisitor; +import org.apache.bcel6_2_0.generic.FieldInstruction; +import org.apache.bcel6_2_0.generic.IINC; +import org.apache.bcel6_2_0.generic.INSTANCEOF; +import org.apache.bcel6_2_0.generic.Instruction; +import org.apache.bcel6_2_0.generic.InstructionConst; +import org.apache.bcel6_2_0.generic.InstructionHandle; +import org.apache.bcel6_2_0.generic.InvokeInstruction; +import org.apache.bcel6_2_0.generic.LDC; +import org.apache.bcel6_2_0.generic.LDC2_W; +import org.apache.bcel6_2_0.generic.LocalVariableInstruction; +import org.apache.bcel6_2_0.generic.MULTIANEWARRAY; +import org.apache.bcel6_2_0.generic.MethodGen; +import org.apache.bcel6_2_0.generic.NEWARRAY; +import org.apache.bcel6_2_0.generic.ObjectType; +import org.apache.bcel6_2_0.generic.RET; +import org.apache.bcel6_2_0.generic.ReturnInstruction; +import org.apache.bcel6_2_0.generic.Select; +import org.apache.bcel6_2_0.generic.Type; /** * Factory creates il.append() statements, and sets instruction targets. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/BCELifier.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/BCELifier.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/BCELifier.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/BCELifier.java index 6b85577f..c7efab07 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/BCELifier.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/BCELifier.java @@ -15,25 +15,25 @@ * limitations under the License. * */ -package org.apache.bcel.util; +package org.apache.bcel6_2_0.util; import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Locale; -import org.apache.bcel.Const; -import org.apache.bcel.Repository; -import org.apache.bcel.classfile.ClassParser; -import org.apache.bcel.classfile.ConstantValue; -import org.apache.bcel.classfile.Field; -import org.apache.bcel.classfile.JavaClass; -import org.apache.bcel.classfile.Method; -import org.apache.bcel.classfile.Utility; -import org.apache.bcel.generic.ArrayType; -import org.apache.bcel.generic.ConstantPoolGen; -import org.apache.bcel.generic.MethodGen; -import org.apache.bcel.generic.Type; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.Repository; +import org.apache.bcel6_2_0.classfile.ClassParser; +import org.apache.bcel6_2_0.classfile.ConstantValue; +import org.apache.bcel6_2_0.classfile.Field; +import org.apache.bcel6_2_0.classfile.JavaClass; +import org.apache.bcel6_2_0.classfile.Method; +import org.apache.bcel6_2_0.classfile.Utility; +import org.apache.bcel6_2_0.generic.ArrayType; +import org.apache.bcel6_2_0.generic.ConstantPoolGen; +import org.apache.bcel6_2_0.generic.MethodGen; +import org.apache.bcel6_2_0.generic.Type; /** * This class takes a given JavaClass object and converts it to a @@ -44,7 +44,7 @@ * * @version $Id: BCELifier.java 1806200 2017-08-25 16:33:06Z ggregory $ */ -public class BCELifier extends org.apache.bcel.classfile.EmptyVisitor { +public class BCELifier extends org.apache.bcel6_2_0.classfile.EmptyVisitor { /** * Enum corresponding to flag source. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ByteSequence.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ByteSequence.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ByteSequence.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ByteSequence.java index 55825523..a21a547c 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ByteSequence.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ByteSequence.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.util; +package org.apache.bcel6_2_0.util; import java.io.ByteArrayInputStream; import java.io.DataInputStream; diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/Class2HTML.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/Class2HTML.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/Class2HTML.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/Class2HTML.java index 0b56034f..4245b406 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/Class2HTML.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/Class2HTML.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.util; +package org.apache.bcel6_2_0.util; import java.io.File; import java.io.FileOutputStream; @@ -24,14 +24,14 @@ import java.util.HashSet; import java.util.Set; -import org.apache.bcel.Const; -import org.apache.bcel.Constants; -import org.apache.bcel.classfile.Attribute; -import org.apache.bcel.classfile.ClassParser; -import org.apache.bcel.classfile.ConstantPool; -import org.apache.bcel.classfile.JavaClass; -import org.apache.bcel.classfile.Method; -import org.apache.bcel.classfile.Utility; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.Constants; +import org.apache.bcel6_2_0.classfile.Attribute; +import org.apache.bcel6_2_0.classfile.ClassParser; +import org.apache.bcel6_2_0.classfile.ConstantPool; +import org.apache.bcel6_2_0.classfile.JavaClass; +import org.apache.bcel6_2_0.classfile.Method; +import org.apache.bcel6_2_0.classfile.Utility; /** * Read class file(s) and convert them into HTML files. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassLoader.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ClassLoader.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassLoader.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ClassLoader.java index cd430071..af5a848b 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassLoader.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ClassLoader.java @@ -15,19 +15,19 @@ * limitations under the License. * */ -package org.apache.bcel.util; +package org.apache.bcel6_2_0.util; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.Hashtable; -import org.apache.bcel.Constants; -import org.apache.bcel.classfile.ClassParser; -import org.apache.bcel.classfile.ConstantClass; -import org.apache.bcel.classfile.ConstantPool; -import org.apache.bcel.classfile.ConstantUtf8; -import org.apache.bcel.classfile.JavaClass; -import org.apache.bcel.classfile.Utility; +import org.apache.bcel6_2_0.Constants; +import org.apache.bcel6_2_0.classfile.ClassParser; +import org.apache.bcel6_2_0.classfile.ConstantClass; +import org.apache.bcel6_2_0.classfile.ConstantPool; +import org.apache.bcel6_2_0.classfile.ConstantUtf8; +import org.apache.bcel6_2_0.classfile.JavaClass; +import org.apache.bcel6_2_0.classfile.Utility; /** *

      Drop in replacement for the standard class loader of the JVM. You can use it diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassLoaderRepository.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ClassLoaderRepository.java similarity index 91% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassLoaderRepository.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ClassLoaderRepository.java index 829a70a0..5f91c419 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassLoaderRepository.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ClassLoaderRepository.java @@ -15,15 +15,15 @@ * limitations under the License. * */ -package org.apache.bcel.util; +package org.apache.bcel6_2_0.util; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; -import org.apache.bcel.classfile.ClassParser; -import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel6_2_0.classfile.ClassParser; +import org.apache.bcel6_2_0.classfile.JavaClass; /** * The repository maintains information about which classes have @@ -32,7 +32,7 @@ * It loads its data from the ClassLoader implementation * passed into its constructor. * - * @see org.apache.bcel.Repository + * @see org.apache.bcel6_2_0.Repository * * @version $Id: ClassLoaderRepository.java 1749603 2016-06-21 20:50:19Z ggregory $ */ diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassPath.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ClassPath.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassPath.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ClassPath.java index 5095e876..f2198275 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassPath.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ClassPath.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.util; +package org.apache.bcel6_2_0.util; import java.io.DataInputStream; import java.io.File; diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassPathRepository.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ClassPathRepository.java similarity index 97% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassPathRepository.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ClassPathRepository.java index f58d1b11..d89385ee 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassPathRepository.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ClassPathRepository.java @@ -15,21 +15,21 @@ * limitations under the License. * */ -package org.apache.bcel.util; +package org.apache.bcel6_2_0.util; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; -import org.apache.bcel.classfile.ClassParser; -import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel6_2_0.classfile.ClassParser; +import org.apache.bcel6_2_0.classfile.JavaClass; /** * This repository is used in situations where a Class is created outside the realm of a ClassLoader. Classes are loaded from the file systems using the paths * specified in the given class path. By default, this is the value returned by ClassPath.getClassPath().
      * - * @see org.apache.bcel.Repository + * @see org.apache.bcel6_2_0.Repository */ public class ClassPathRepository implements Repository { diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassQueue.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ClassQueue.java similarity index 91% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassQueue.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ClassQueue.java index f8fa1edd..c7b71aae 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassQueue.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ClassQueue.java @@ -15,11 +15,11 @@ * limitations under the License. * */ -package org.apache.bcel.util; +package org.apache.bcel6_2_0.util; import java.util.LinkedList; -import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel6_2_0.classfile.JavaClass; /** * Utility class implementing a (typesafe) queue of JavaClass diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassSet.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ClassSet.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassSet.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ClassSet.java index 706c4835..350c6ef8 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassSet.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ClassSet.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.util; +package org.apache.bcel6_2_0.util; import java.util.Collection; import java.util.HashMap; import java.util.Map; -import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel6_2_0.classfile.JavaClass; /** * Utility class implementing a (typesafe) set of JavaClass objects. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassStack.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ClassStack.java similarity index 90% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassStack.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ClassStack.java index d8051970..c10b4810 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassStack.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ClassStack.java @@ -15,11 +15,11 @@ * limitations under the License. * */ -package org.apache.bcel.util; +package org.apache.bcel6_2_0.util; import java.util.Stack; -import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel6_2_0.classfile.JavaClass; /** * Utility class implementing a (typesafe) stack of JavaClass objects. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassVector.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ClassVector.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassVector.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ClassVector.java index bfb291c8..218f3edc 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ClassVector.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ClassVector.java @@ -15,12 +15,12 @@ * limitations under the License. * */ -package org.apache.bcel.util; +package org.apache.bcel6_2_0.util; import java.util.ArrayList; import java.util.List; -import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel6_2_0.classfile.JavaClass; /** * Utility class implementing a (typesafe) collection of JavaClass diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/CodeHTML.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/CodeHTML.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/CodeHTML.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/CodeHTML.java index 5b582737..2f454ff7 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/CodeHTML.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/CodeHTML.java @@ -15,27 +15,27 @@ * limitations under the License. * */ -package org.apache.bcel.util; +package org.apache.bcel6_2_0.util; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.BitSet; -import org.apache.bcel.Const; -import org.apache.bcel.classfile.Attribute; -import org.apache.bcel.classfile.Code; -import org.apache.bcel.classfile.CodeException; -import org.apache.bcel.classfile.ConstantFieldref; -import org.apache.bcel.classfile.ConstantInterfaceMethodref; -import org.apache.bcel.classfile.ConstantInvokeDynamic; -import org.apache.bcel.classfile.ConstantMethodref; -import org.apache.bcel.classfile.ConstantNameAndType; -import org.apache.bcel.classfile.ConstantPool; -import org.apache.bcel.classfile.LocalVariable; -import org.apache.bcel.classfile.LocalVariableTable; -import org.apache.bcel.classfile.Method; -import org.apache.bcel.classfile.Utility; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.classfile.Attribute; +import org.apache.bcel6_2_0.classfile.Code; +import org.apache.bcel6_2_0.classfile.CodeException; +import org.apache.bcel6_2_0.classfile.ConstantFieldref; +import org.apache.bcel6_2_0.classfile.ConstantInterfaceMethodref; +import org.apache.bcel6_2_0.classfile.ConstantInvokeDynamic; +import org.apache.bcel6_2_0.classfile.ConstantMethodref; +import org.apache.bcel6_2_0.classfile.ConstantNameAndType; +import org.apache.bcel6_2_0.classfile.ConstantPool; +import org.apache.bcel6_2_0.classfile.LocalVariable; +import org.apache.bcel6_2_0.classfile.LocalVariableTable; +import org.apache.bcel6_2_0.classfile.Method; +import org.apache.bcel6_2_0.classfile.Utility; /** * Convert code into HTML file. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ConstantHTML.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ConstantHTML.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ConstantHTML.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ConstantHTML.java index a1af88d9..8b4829e9 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/ConstantHTML.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/ConstantHTML.java @@ -15,23 +15,23 @@ * limitations under the License. * */ -package org.apache.bcel.util; +package org.apache.bcel6_2_0.util; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintWriter; -import org.apache.bcel.Const; -import org.apache.bcel.classfile.Constant; -import org.apache.bcel.classfile.ConstantClass; -import org.apache.bcel.classfile.ConstantFieldref; -import org.apache.bcel.classfile.ConstantInterfaceMethodref; -import org.apache.bcel.classfile.ConstantMethodref; -import org.apache.bcel.classfile.ConstantNameAndType; -import org.apache.bcel.classfile.ConstantPool; -import org.apache.bcel.classfile.ConstantString; -import org.apache.bcel.classfile.Method; -import org.apache.bcel.classfile.Utility; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.classfile.Constant; +import org.apache.bcel6_2_0.classfile.ConstantClass; +import org.apache.bcel6_2_0.classfile.ConstantFieldref; +import org.apache.bcel6_2_0.classfile.ConstantInterfaceMethodref; +import org.apache.bcel6_2_0.classfile.ConstantMethodref; +import org.apache.bcel6_2_0.classfile.ConstantNameAndType; +import org.apache.bcel6_2_0.classfile.ConstantPool; +import org.apache.bcel6_2_0.classfile.ConstantString; +import org.apache.bcel6_2_0.classfile.Method; +import org.apache.bcel6_2_0.classfile.Utility; /** * Convert constant pool into HTML file. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/InstructionFinder.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/InstructionFinder.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/InstructionFinder.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/InstructionFinder.java index 0a02af08..3d3993b4 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/InstructionFinder.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/InstructionFinder.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.util; +package org.apache.bcel6_2_0.util; import java.util.ArrayList; import java.util.HashMap; @@ -26,10 +26,10 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.bcel.Const; -import org.apache.bcel.generic.ClassGenException; -import org.apache.bcel.generic.InstructionHandle; -import org.apache.bcel.generic.InstructionList; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.generic.ClassGenException; +import org.apache.bcel6_2_0.generic.InstructionHandle; +import org.apache.bcel6_2_0.generic.InstructionList; /** * InstructionFinder is a tool to search for given instructions patterns, i.e., @@ -61,7 +61,7 @@ * * * @version $Id: InstructionFinder.java 1806200 2017-08-25 16:33:06Z ggregory $ - * @see org.apache.bcel.generic.Instruction + * @see org.apache.bcel6_2_0.generic.Instruction * @see InstructionList */ public class InstructionFinder { diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/JavaWrapper.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/JavaWrapper.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/JavaWrapper.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/JavaWrapper.java index 0349536a..362fa338 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/JavaWrapper.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/JavaWrapper.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.util; +package org.apache.bcel6_2_0.util; import java.lang.reflect.Method; import java.lang.reflect.Modifier; diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/MemorySensitiveClassPathRepository.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/MemorySensitiveClassPathRepository.java similarity index 97% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/MemorySensitiveClassPathRepository.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/MemorySensitiveClassPathRepository.java index 4251d035..9ad592ce 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/MemorySensitiveClassPathRepository.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/MemorySensitiveClassPathRepository.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.util; +package org.apache.bcel6_2_0.util; import java.io.IOException; import java.io.InputStream; @@ -23,15 +23,15 @@ import java.util.HashMap; import java.util.Map; -import org.apache.bcel.classfile.ClassParser; -import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel6_2_0.classfile.ClassParser; +import org.apache.bcel6_2_0.classfile.JavaClass; /** * This repository is used in situations where a Class is created outside the realm of a ClassLoader. Classes are loaded from the file systems using the paths * specified in the given class path. By default, this is the value returned by ClassPath.getClassPath(). This repository holds onto classes with * SoftReferences, and will reload as needed, in cases where memory sizes are important.
      * - * @see org.apache.bcel.Repository + * @see org.apache.bcel6_2_0.Repository */ public class MemorySensitiveClassPathRepository implements Repository { diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/MethodHTML.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/MethodHTML.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/MethodHTML.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/MethodHTML.java index 92b7c7fa..5ba59b32 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/MethodHTML.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/MethodHTML.java @@ -15,20 +15,20 @@ * limitations under the License. * */ -package org.apache.bcel.util; +package org.apache.bcel6_2_0.util; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintWriter; -import org.apache.bcel.Const; -import org.apache.bcel.classfile.Attribute; -import org.apache.bcel.classfile.Code; -import org.apache.bcel.classfile.ConstantValue; -import org.apache.bcel.classfile.ExceptionTable; -import org.apache.bcel.classfile.Field; -import org.apache.bcel.classfile.Method; -import org.apache.bcel.classfile.Utility; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.classfile.Attribute; +import org.apache.bcel6_2_0.classfile.Code; +import org.apache.bcel6_2_0.classfile.ConstantValue; +import org.apache.bcel6_2_0.classfile.ExceptionTable; +import org.apache.bcel6_2_0.classfile.Field; +import org.apache.bcel6_2_0.classfile.Method; +import org.apache.bcel6_2_0.classfile.Utility; /** * Convert methods and fields into HTML file. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/Repository.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/Repository.java similarity index 91% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/Repository.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/Repository.java index 86fd57b2..182b4cb6 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/Repository.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/Repository.java @@ -15,16 +15,16 @@ * limitations under the License. * */ -package org.apache.bcel.util; +package org.apache.bcel6_2_0.util; -import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel6_2_0.classfile.JavaClass; /** * Abstract definition of a class repository. Instances may be used * to load classes from different sources and may be used in the * Repository.setRepository method. * - * @see org.apache.bcel.Repository + * @see org.apache.bcel6_2_0.Repository * @version $Id: Repository.java 1806200 2017-08-25 16:33:06Z ggregory $ */ public interface Repository { diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/SyntheticRepository.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/SyntheticRepository.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/SyntheticRepository.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/SyntheticRepository.java index 9efae63b..626a8286 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/SyntheticRepository.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/SyntheticRepository.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.util; +package org.apache.bcel6_2_0.util; import java.util.HashMap; import java.util.Map; @@ -26,7 +26,7 @@ * This repository uses a factory design, allowing it to maintain a collection of different classpaths, and as such It is designed to be used as a singleton per * classpath. * - * @see org.apache.bcel.Repository + * @see org.apache.bcel6_2_0.Repository * * @version $Id: SyntheticRepository.java 1748124 2016-06-13 08:02:16Z ggregory $ */ diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/package.html b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/package.html similarity index 100% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/util/package.html rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/util/package.html diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/GraphicalVerifier.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/GraphicalVerifier.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/GraphicalVerifier.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/GraphicalVerifier.java index 7e8d9a43..0c8aca72 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/GraphicalVerifier.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/GraphicalVerifier.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.verifier; +package org.apache.bcel6_2_0.verifier; import java.awt.Dimension; import java.awt.Toolkit; import javax.swing.UIManager; -import org.apache.bcel.generic.Type; +import org.apache.bcel6_2_0.generic.Type; /** * A graphical user interface application demonstrating JustIce. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/NativeVerifier.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/NativeVerifier.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/NativeVerifier.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/NativeVerifier.java index 2d5d56dd..4dbba426 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/NativeVerifier.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/NativeVerifier.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier; +package org.apache.bcel6_2_0.verifier; /** * The NativeVerifier class implements a main(String[] args) method that's diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/PassVerifier.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/PassVerifier.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/PassVerifier.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/PassVerifier.java index 972480ec..eb8a88ac 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/PassVerifier.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/PassVerifier.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier; +package org.apache.bcel6_2_0.verifier; import java.util.ArrayList; import java.util.List; diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/TransitiveHull.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/TransitiveHull.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/TransitiveHull.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/TransitiveHull.java index a50ecf49..52b6cdcd 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/TransitiveHull.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/TransitiveHull.java @@ -15,10 +15,10 @@ * limitations under the License. * */ -package org.apache.bcel.verifier; +package org.apache.bcel6_2_0.verifier; -import org.apache.bcel.Repository; -import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel6_2_0.Repository; +import org.apache.bcel6_2_0.classfile.JavaClass; /** * This class has a main method implementing a demonstration program diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerificationResult.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/VerificationResult.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerificationResult.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/VerificationResult.java index 753e0dca..d0070a07 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerificationResult.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/VerificationResult.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier; +package org.apache.bcel6_2_0.verifier; /** * A VerificationResult is what a PassVerifier returns diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/Verifier.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/Verifier.java similarity index 90% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/Verifier.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/Verifier.java index 8a85f75c..a1e3c1b1 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/Verifier.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/Verifier.java @@ -15,18 +15,18 @@ * limitations under the License. * */ -package org.apache.bcel.verifier; +package org.apache.bcel6_2_0.verifier; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.bcel.classfile.JavaClass; -import org.apache.bcel.verifier.statics.Pass1Verifier; -import org.apache.bcel.verifier.statics.Pass2Verifier; -import org.apache.bcel.verifier.statics.Pass3aVerifier; -import org.apache.bcel.verifier.structurals.Pass3bVerifier; +import org.apache.bcel6_2_0.classfile.JavaClass; +import org.apache.bcel6_2_0.verifier.statics.Pass1Verifier; +import org.apache.bcel6_2_0.verifier.statics.Pass2Verifier; +import org.apache.bcel6_2_0.verifier.statics.Pass3aVerifier; +import org.apache.bcel6_2_0.verifier.structurals.Pass3bVerifier; /** * A Verifier instance is there to verify a class file according to The Java Virtual @@ -163,7 +163,7 @@ public String[] getMessages() throws ClassNotFoundException { final int meth = pv.getMethodNo(); for (final String element : p3am) { messages.add("Pass 3a, method " + meth + " ('" - + org.apache.bcel.Repository.lookupClass(classname).getMethods()[meth] + + org.apache.bcel6_2_0.Repository.lookupClass(classname).getMethods()[meth] + "'): " + element); } } @@ -172,7 +172,7 @@ public String[] getMessages() throws ClassNotFoundException { final int meth = pv.getMethodNo(); for (final String element : p3bm) { messages.add("Pass 3b, method " + meth + " ('" - + org.apache.bcel.Repository.lookupClass(classname).getMethods()[meth] + + org.apache.bcel6_2_0.Repository.lookupClass(classname).getMethods()[meth] + "'): " + element); } } @@ -211,7 +211,7 @@ public static void main( final String[] args ) { vr = v.doPass2(); System.out.println("Pass 2:\n" + vr); if (vr == VerificationResult.VR_OK) { - final JavaClass jc = org.apache.bcel.Repository.lookupClass(args[k]); + final JavaClass jc = org.apache.bcel6_2_0.Repository.lookupClass(args[k]); for (int i = 0; i < jc.getMethods().length; i++) { vr = v.doPass3a(i); System.out.println("Pass 3a, method number " + i + " ['" @@ -232,7 +232,7 @@ public static void main( final String[] args ) { System.out.println("\n"); // avoid swapping. v.flush(); - org.apache.bcel.Repository.clearCache(); + org.apache.bcel6_2_0.Repository.clearCache(); System.gc(); } catch (final ClassNotFoundException e) { e.printStackTrace(); diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierAppFrame.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/VerifierAppFrame.java similarity index 97% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierAppFrame.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/VerifierAppFrame.java index 6e4a823a..d0e826a9 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierAppFrame.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/VerifierAppFrame.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier; +package org.apache.bcel6_2_0.verifier; import java.awt.AWTEvent; import java.awt.CardLayout; @@ -39,8 +39,8 @@ import javax.swing.ListSelectionModel; import javax.swing.event.ListSelectionEvent; -import org.apache.bcel.Repository; -import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel6_2_0.Repository; +import org.apache.bcel6_2_0.classfile.JavaClass; /** * This class implements a machine-generated frame for use with diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierFactory.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/VerifierFactory.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierFactory.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/VerifierFactory.java index 48e0be63..d1455b5a 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierFactory.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/VerifierFactory.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier; +package org.apache.bcel6_2_0.verifier; import java.util.HashMap; import java.util.List; diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierFactoryListModel.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/VerifierFactoryListModel.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierFactoryListModel.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/VerifierFactoryListModel.java index 1fc5336f..d2c342c9 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierFactoryListModel.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/VerifierFactoryListModel.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier; +package org.apache.bcel6_2_0.verifier; import java.util.ArrayList; import java.util.List; diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierFactoryObserver.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/VerifierFactoryObserver.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierFactoryObserver.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/VerifierFactoryObserver.java index 1637c524..991cdd1a 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifierFactoryObserver.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/VerifierFactoryObserver.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier; +package org.apache.bcel6_2_0.verifier; /** * VerifierFactoryObserver instances are notified when new Verifier diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifyDialog.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/VerifyDialog.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifyDialog.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/VerifyDialog.java index 8025f2d8..89bd3afe 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/VerifyDialog.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/VerifyDialog.java @@ -15,12 +15,12 @@ * limitations under the License. */ -package org.apache.bcel.verifier; +package org.apache.bcel6_2_0.verifier; import java.awt.Color; -import org.apache.bcel.Repository; -import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel6_2_0.Repository; +import org.apache.bcel6_2_0.classfile.JavaClass; /** * A class for simple graphical class file verification. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/AssertionViolatedException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/AssertionViolatedException.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/AssertionViolatedException.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/AssertionViolatedException.java index fa876050..5aa8e181 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/AssertionViolatedException.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/AssertionViolatedException.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.exc; +package org.apache.bcel6_2_0.verifier.exc; /** diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/ClassConstraintException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/ClassConstraintException.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/ClassConstraintException.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/ClassConstraintException.java index c4beafbd..defae225 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/ClassConstraintException.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/ClassConstraintException.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.exc; +package org.apache.bcel6_2_0.verifier.exc; /** diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/CodeConstraintException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/CodeConstraintException.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/CodeConstraintException.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/CodeConstraintException.java index 6e692e5d..68b85dd1 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/CodeConstraintException.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/CodeConstraintException.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.exc; +package org.apache.bcel6_2_0.verifier.exc; /** * Instances of this class are thrown by BCEL's class file verifier "JustIce" when diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/InvalidMethodException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/InvalidMethodException.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/InvalidMethodException.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/InvalidMethodException.java index f04aaeb2..f8ac6320 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/InvalidMethodException.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/InvalidMethodException.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.exc; +package org.apache.bcel6_2_0.verifier.exc; /** * Instances of this class are thrown by BCEL's class file verifier "JustIce" diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/LinkingConstraintException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/LinkingConstraintException.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/LinkingConstraintException.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/LinkingConstraintException.java index 7defb5fe..f79a0507 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/LinkingConstraintException.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/LinkingConstraintException.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.exc; +package org.apache.bcel6_2_0.verifier.exc; /** * Instances of this class are thrown by BCEL's class file verifier "JustIce" when diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/LoadingException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/LoadingException.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/LoadingException.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/LoadingException.java index 6ff0c8df..2543395c 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/LoadingException.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/LoadingException.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.exc; +package org.apache.bcel6_2_0.verifier.exc; /** diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/LocalVariableInfoInconsistentException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/LocalVariableInfoInconsistentException.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/LocalVariableInfoInconsistentException.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/LocalVariableInfoInconsistentException.java index 8e2a2034..de392142 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/LocalVariableInfoInconsistentException.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/LocalVariableInfoInconsistentException.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.exc; +package org.apache.bcel6_2_0.verifier.exc; /** diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StaticCodeConstraintException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/StaticCodeConstraintException.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StaticCodeConstraintException.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/StaticCodeConstraintException.java index 7ebe32a1..7ee5f39a 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StaticCodeConstraintException.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/StaticCodeConstraintException.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.exc; +package org.apache.bcel6_2_0.verifier.exc; /** diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StaticCodeInstructionConstraintException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/StaticCodeInstructionConstraintException.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StaticCodeInstructionConstraintException.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/StaticCodeInstructionConstraintException.java index 251f2019..47a1add2 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StaticCodeInstructionConstraintException.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/StaticCodeInstructionConstraintException.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.exc; +package org.apache.bcel6_2_0.verifier.exc; /** diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StaticCodeInstructionOperandConstraintException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/StaticCodeInstructionOperandConstraintException.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StaticCodeInstructionOperandConstraintException.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/StaticCodeInstructionOperandConstraintException.java index 43d4203f..d5ddccfc 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StaticCodeInstructionOperandConstraintException.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/StaticCodeInstructionOperandConstraintException.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.exc; +package org.apache.bcel6_2_0.verifier.exc; /** diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StructuralCodeConstraintException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/StructuralCodeConstraintException.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StructuralCodeConstraintException.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/StructuralCodeConstraintException.java index c7174643..00168a5c 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/StructuralCodeConstraintException.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/StructuralCodeConstraintException.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.exc; +package org.apache.bcel6_2_0.verifier.exc; /** * Instances of this class are thrown by BCEL's class file verifier "JustIce" when diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/Utility.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/Utility.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/Utility.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/Utility.java index a888c11c..e29b5e04 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/Utility.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/Utility.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.exc; +package org.apache.bcel6_2_0.verifier.exc; import java.io.PrintWriter; diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/VerificationException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/VerificationException.java similarity index 95% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/VerificationException.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/VerificationException.java index 3fb46ad8..d1499f4f 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/VerificationException.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/VerificationException.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.exc; +package org.apache.bcel6_2_0.verifier.exc; /** diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/VerifierConstraintViolatedException.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/VerifierConstraintViolatedException.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/VerifierConstraintViolatedException.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/VerifierConstraintViolatedException.java index f0c09f0d..def1f270 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/VerifierConstraintViolatedException.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/VerifierConstraintViolatedException.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.exc; +package org.apache.bcel6_2_0.verifier.exc; /** diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/package.html b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/package.html similarity index 100% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/exc/package.html rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/exc/package.html diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/package.html b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/package.html similarity index 100% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/package.html rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/package.html diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/DOUBLE_Upper.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/DOUBLE_Upper.java similarity index 89% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/DOUBLE_Upper.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/DOUBLE_Upper.java index 7ac24ddf..3b14db03 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/DOUBLE_Upper.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/DOUBLE_Upper.java @@ -15,11 +15,11 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.statics; +package org.apache.bcel6_2_0.verifier.statics; -import org.apache.bcel.Const; -import org.apache.bcel.generic.Type; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.generic.Type; /** * This class represents the upper half of a DOUBLE variable. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/IntList.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/IntList.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/IntList.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/IntList.java index 306acebc..f4a4600d 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/IntList.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/IntList.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.statics; +package org.apache.bcel6_2_0.verifier.statics; import java.util.ArrayList; diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/LONG_Upper.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/LONG_Upper.java similarity index 89% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/LONG_Upper.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/LONG_Upper.java index f7b7d641..b970cbc7 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/LONG_Upper.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/LONG_Upper.java @@ -15,11 +15,11 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.statics; +package org.apache.bcel6_2_0.verifier.statics; -import org.apache.bcel.Const; -import org.apache.bcel.generic.Type; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.generic.Type; /** * This class represents the upper half of a LONG variable. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/LocalVariableInfo.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/LocalVariableInfo.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/LocalVariableInfo.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/LocalVariableInfo.java index 3c8e0cc2..65a3cbca 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/LocalVariableInfo.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/LocalVariableInfo.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.statics; +package org.apache.bcel6_2_0.verifier.statics; import java.util.Hashtable; -import org.apache.bcel.generic.Type; -import org.apache.bcel.verifier.exc.LocalVariableInfoInconsistentException; +import org.apache.bcel6_2_0.generic.Type; +import org.apache.bcel6_2_0.verifier.exc.LocalVariableInfoInconsistentException; /** * A utility class holding the information about diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/LocalVariablesInfo.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/LocalVariablesInfo.java similarity index 90% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/LocalVariablesInfo.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/LocalVariablesInfo.java index 4b3d53bc..9ec5e679 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/LocalVariablesInfo.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/LocalVariablesInfo.java @@ -15,12 +15,12 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.statics; +package org.apache.bcel6_2_0.verifier.statics; -import org.apache.bcel.generic.Type; -import org.apache.bcel.verifier.exc.AssertionViolatedException; -import org.apache.bcel.verifier.exc.LocalVariableInfoInconsistentException; +import org.apache.bcel6_2_0.generic.Type; +import org.apache.bcel6_2_0.verifier.exc.AssertionViolatedException; +import org.apache.bcel6_2_0.verifier.exc.LocalVariableInfoInconsistentException; /** * A utility class holding the information about diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/Pass1Verifier.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/Pass1Verifier.java similarity index 92% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/Pass1Verifier.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/Pass1Verifier.java index b188608b..1ee416a1 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/Pass1Verifier.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/Pass1Verifier.java @@ -15,17 +15,17 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.statics; +package org.apache.bcel6_2_0.verifier.statics; -import org.apache.bcel.Repository; -import org.apache.bcel.classfile.ClassFormatException; -import org.apache.bcel.classfile.JavaClass; -import org.apache.bcel.verifier.PassVerifier; -import org.apache.bcel.verifier.VerificationResult; -import org.apache.bcel.verifier.Verifier; -import org.apache.bcel.verifier.exc.LoadingException; -import org.apache.bcel.verifier.exc.Utility; +import org.apache.bcel6_2_0.Repository; +import org.apache.bcel6_2_0.classfile.ClassFormatException; +import org.apache.bcel6_2_0.classfile.JavaClass; +import org.apache.bcel6_2_0.verifier.PassVerifier; +import org.apache.bcel6_2_0.verifier.VerificationResult; +import org.apache.bcel6_2_0.verifier.Verifier; +import org.apache.bcel6_2_0.verifier.exc.LoadingException; +import org.apache.bcel6_2_0.verifier.exc.Utility; /** * This PassVerifier verifies a class file according to pass 1 as @@ -140,8 +140,8 @@ public Pass1Verifier(final Verifier owner) { * (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 - * @see org.apache.bcel.Const#JVM_CLASSFILE_MAGIC + * @see org.apache.bcel6_2_0.Repository + * @see org.apache.bcel6_2_0.Const#JVM_CLASSFILE_MAGIC */ @Override public VerificationResult do_verify() { diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/Pass2Verifier.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/Pass2Verifier.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/Pass2Verifier.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/Pass2Verifier.java index f98e348d..1ba747b5 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/Pass2Verifier.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/Pass2Verifier.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.statics; +package org.apache.bcel6_2_0.verifier.statics; import java.util.HashMap; @@ -24,54 +24,54 @@ import java.util.Map; import java.util.Set; -import org.apache.bcel.Const; -import org.apache.bcel.Constants; -import org.apache.bcel.Repository; -import org.apache.bcel.classfile.Attribute; -import org.apache.bcel.classfile.ClassFormatException; -import org.apache.bcel.classfile.Code; -import org.apache.bcel.classfile.CodeException; -import org.apache.bcel.classfile.Constant; -import org.apache.bcel.classfile.ConstantClass; -import org.apache.bcel.classfile.ConstantDouble; -import org.apache.bcel.classfile.ConstantFieldref; -import org.apache.bcel.classfile.ConstantFloat; -import org.apache.bcel.classfile.ConstantInteger; -import org.apache.bcel.classfile.ConstantInterfaceMethodref; -import org.apache.bcel.classfile.ConstantLong; -import org.apache.bcel.classfile.ConstantMethodref; -import org.apache.bcel.classfile.ConstantNameAndType; -import org.apache.bcel.classfile.ConstantPool; -import org.apache.bcel.classfile.ConstantString; -import org.apache.bcel.classfile.ConstantUtf8; -import org.apache.bcel.classfile.ConstantValue; -import org.apache.bcel.classfile.Deprecated; -import org.apache.bcel.classfile.DescendingVisitor; -import org.apache.bcel.classfile.EmptyVisitor; -import org.apache.bcel.classfile.ExceptionTable; -import org.apache.bcel.classfile.Field; -import org.apache.bcel.classfile.InnerClass; -import org.apache.bcel.classfile.InnerClasses; -import org.apache.bcel.classfile.JavaClass; -import org.apache.bcel.classfile.LineNumber; -import org.apache.bcel.classfile.LineNumberTable; -import org.apache.bcel.classfile.LocalVariable; -import org.apache.bcel.classfile.LocalVariableTable; -import org.apache.bcel.classfile.Method; -import org.apache.bcel.classfile.Node; -import org.apache.bcel.classfile.SourceFile; -import org.apache.bcel.classfile.Synthetic; -import org.apache.bcel.classfile.Unknown; -import org.apache.bcel.generic.ArrayType; -import org.apache.bcel.generic.ObjectType; -import org.apache.bcel.generic.Type; -import org.apache.bcel.verifier.PassVerifier; -import org.apache.bcel.verifier.VerificationResult; -import org.apache.bcel.verifier.Verifier; -import org.apache.bcel.verifier.VerifierFactory; -import org.apache.bcel.verifier.exc.AssertionViolatedException; -import org.apache.bcel.verifier.exc.ClassConstraintException; -import org.apache.bcel.verifier.exc.LocalVariableInfoInconsistentException; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.Constants; +import org.apache.bcel6_2_0.Repository; +import org.apache.bcel6_2_0.classfile.Attribute; +import org.apache.bcel6_2_0.classfile.ClassFormatException; +import org.apache.bcel6_2_0.classfile.Code; +import org.apache.bcel6_2_0.classfile.CodeException; +import org.apache.bcel6_2_0.classfile.Constant; +import org.apache.bcel6_2_0.classfile.ConstantClass; +import org.apache.bcel6_2_0.classfile.ConstantDouble; +import org.apache.bcel6_2_0.classfile.ConstantFieldref; +import org.apache.bcel6_2_0.classfile.ConstantFloat; +import org.apache.bcel6_2_0.classfile.ConstantInteger; +import org.apache.bcel6_2_0.classfile.ConstantInterfaceMethodref; +import org.apache.bcel6_2_0.classfile.ConstantLong; +import org.apache.bcel6_2_0.classfile.ConstantMethodref; +import org.apache.bcel6_2_0.classfile.ConstantNameAndType; +import org.apache.bcel6_2_0.classfile.ConstantPool; +import org.apache.bcel6_2_0.classfile.ConstantString; +import org.apache.bcel6_2_0.classfile.ConstantUtf8; +import org.apache.bcel6_2_0.classfile.ConstantValue; +import org.apache.bcel6_2_0.classfile.Deprecated; +import org.apache.bcel6_2_0.classfile.DescendingVisitor; +import org.apache.bcel6_2_0.classfile.EmptyVisitor; +import org.apache.bcel6_2_0.classfile.ExceptionTable; +import org.apache.bcel6_2_0.classfile.Field; +import org.apache.bcel6_2_0.classfile.InnerClass; +import org.apache.bcel6_2_0.classfile.InnerClasses; +import org.apache.bcel6_2_0.classfile.JavaClass; +import org.apache.bcel6_2_0.classfile.LineNumber; +import org.apache.bcel6_2_0.classfile.LineNumberTable; +import org.apache.bcel6_2_0.classfile.LocalVariable; +import org.apache.bcel6_2_0.classfile.LocalVariableTable; +import org.apache.bcel6_2_0.classfile.Method; +import org.apache.bcel6_2_0.classfile.Node; +import org.apache.bcel6_2_0.classfile.SourceFile; +import org.apache.bcel6_2_0.classfile.Synthetic; +import org.apache.bcel6_2_0.classfile.Unknown; +import org.apache.bcel6_2_0.generic.ArrayType; +import org.apache.bcel6_2_0.generic.ObjectType; +import org.apache.bcel6_2_0.generic.Type; +import org.apache.bcel6_2_0.verifier.PassVerifier; +import org.apache.bcel6_2_0.verifier.VerificationResult; +import org.apache.bcel6_2_0.verifier.Verifier; +import org.apache.bcel6_2_0.verifier.VerifierFactory; +import org.apache.bcel6_2_0.verifier.exc.AssertionViolatedException; +import org.apache.bcel6_2_0.verifier.exc.ClassConstraintException; +import org.apache.bcel6_2_0.verifier.exc.LocalVariableInfoInconsistentException; /** * This PassVerifier verifies a class file according to @@ -314,7 +314,7 @@ private void constant_pool_entries_satisfy_static_constraints() { * * @see #constant_pool_entries_satisfy_static_constraints() */ - private final class CPESSC_Visitor extends org.apache.bcel.classfile.EmptyVisitor{ + private final class CPESSC_Visitor extends org.apache.bcel6_2_0.classfile.EmptyVisitor{ private final Class CONST_Class; /* private Class CONST_Fieldref; @@ -1303,7 +1303,7 @@ private void field_and_method_refs_are_valid() { * pool must be valid. * * @see #constant_pool_entries_satisfy_static_constraints() - * @see org.apache.bcel.classfile.ConstantCP + * @see org.apache.bcel6_2_0.classfile.ConstantCP */ private final class FAMRAV_Visitor extends EmptyVisitor{ private final ConstantPool cp; // ==jc.getConstantPool() -- only here to save typing work. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/Pass3aVerifier.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/Pass3aVerifier.java similarity index 91% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/Pass3aVerifier.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/Pass3aVerifier.java index cd9bc2af..160a0162 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/Pass3aVerifier.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/Pass3aVerifier.java @@ -15,90 +15,90 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.statics; - - -import org.apache.bcel.Const; -import org.apache.bcel.Repository; -import org.apache.bcel.classfile.Attribute; -import org.apache.bcel.classfile.Code; -import org.apache.bcel.classfile.CodeException; -import org.apache.bcel.classfile.Constant; -import org.apache.bcel.classfile.ConstantClass; -import org.apache.bcel.classfile.ConstantDouble; -import org.apache.bcel.classfile.ConstantFieldref; -import org.apache.bcel.classfile.ConstantFloat; -import org.apache.bcel.classfile.ConstantInteger; -import org.apache.bcel.classfile.ConstantInterfaceMethodref; -import org.apache.bcel.classfile.ConstantLong; -import org.apache.bcel.classfile.ConstantMethodref; -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.classfile.LineNumber; -import org.apache.bcel.classfile.LineNumberTable; -import org.apache.bcel.classfile.LocalVariable; -import org.apache.bcel.classfile.LocalVariableTable; -import org.apache.bcel.classfile.Method; -import org.apache.bcel.generic.ALOAD; -import org.apache.bcel.generic.ANEWARRAY; -import org.apache.bcel.generic.ASTORE; -import org.apache.bcel.generic.ATHROW; -import org.apache.bcel.generic.ArrayType; -import org.apache.bcel.generic.BREAKPOINT; -import org.apache.bcel.generic.CHECKCAST; -import org.apache.bcel.generic.ConstantPoolGen; -import org.apache.bcel.generic.DLOAD; -import org.apache.bcel.generic.DSTORE; -import org.apache.bcel.generic.FLOAD; -import org.apache.bcel.generic.FSTORE; -import org.apache.bcel.generic.FieldInstruction; -import org.apache.bcel.generic.GETSTATIC; -import org.apache.bcel.generic.GotoInstruction; -import org.apache.bcel.generic.IINC; -import org.apache.bcel.generic.ILOAD; -import org.apache.bcel.generic.IMPDEP1; -import org.apache.bcel.generic.IMPDEP2; -import org.apache.bcel.generic.INSTANCEOF; -import org.apache.bcel.generic.INVOKEDYNAMIC; -import org.apache.bcel.generic.INVOKEINTERFACE; -import org.apache.bcel.generic.INVOKESPECIAL; -import org.apache.bcel.generic.INVOKESTATIC; -import org.apache.bcel.generic.INVOKEVIRTUAL; -import org.apache.bcel.generic.ISTORE; -import org.apache.bcel.generic.Instruction; -import org.apache.bcel.generic.InstructionHandle; -import org.apache.bcel.generic.InstructionList; -import org.apache.bcel.generic.InvokeInstruction; -import org.apache.bcel.generic.JsrInstruction; -import org.apache.bcel.generic.LDC; -import org.apache.bcel.generic.LDC2_W; -import org.apache.bcel.generic.LLOAD; -import org.apache.bcel.generic.LOOKUPSWITCH; -import org.apache.bcel.generic.LSTORE; -import org.apache.bcel.generic.LoadClass; -import org.apache.bcel.generic.MULTIANEWARRAY; -import org.apache.bcel.generic.NEW; -import org.apache.bcel.generic.NEWARRAY; -import org.apache.bcel.generic.ObjectType; -import org.apache.bcel.generic.PUTSTATIC; -import org.apache.bcel.generic.RET; -import org.apache.bcel.generic.ReferenceType; -import org.apache.bcel.generic.ReturnInstruction; -import org.apache.bcel.generic.TABLESWITCH; -import org.apache.bcel.generic.Type; -import org.apache.bcel.verifier.PassVerifier; -import org.apache.bcel.verifier.VerificationResult; -import org.apache.bcel.verifier.Verifier; -import org.apache.bcel.verifier.VerifierFactory; -import org.apache.bcel.verifier.exc.AssertionViolatedException; -import org.apache.bcel.verifier.exc.ClassConstraintException; -import org.apache.bcel.verifier.exc.InvalidMethodException; -import org.apache.bcel.verifier.exc.StaticCodeConstraintException; -import org.apache.bcel.verifier.exc.StaticCodeInstructionConstraintException; -import org.apache.bcel.verifier.exc.StaticCodeInstructionOperandConstraintException; +package org.apache.bcel6_2_0.verifier.statics; + + +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.Repository; +import org.apache.bcel6_2_0.classfile.Attribute; +import org.apache.bcel6_2_0.classfile.Code; +import org.apache.bcel6_2_0.classfile.CodeException; +import org.apache.bcel6_2_0.classfile.Constant; +import org.apache.bcel6_2_0.classfile.ConstantClass; +import org.apache.bcel6_2_0.classfile.ConstantDouble; +import org.apache.bcel6_2_0.classfile.ConstantFieldref; +import org.apache.bcel6_2_0.classfile.ConstantFloat; +import org.apache.bcel6_2_0.classfile.ConstantInteger; +import org.apache.bcel6_2_0.classfile.ConstantInterfaceMethodref; +import org.apache.bcel6_2_0.classfile.ConstantLong; +import org.apache.bcel6_2_0.classfile.ConstantMethodref; +import org.apache.bcel6_2_0.classfile.ConstantNameAndType; +import org.apache.bcel6_2_0.classfile.ConstantString; +import org.apache.bcel6_2_0.classfile.ConstantUtf8; +import org.apache.bcel6_2_0.classfile.Field; +import org.apache.bcel6_2_0.classfile.JavaClass; +import org.apache.bcel6_2_0.classfile.LineNumber; +import org.apache.bcel6_2_0.classfile.LineNumberTable; +import org.apache.bcel6_2_0.classfile.LocalVariable; +import org.apache.bcel6_2_0.classfile.LocalVariableTable; +import org.apache.bcel6_2_0.classfile.Method; +import org.apache.bcel6_2_0.generic.ALOAD; +import org.apache.bcel6_2_0.generic.ANEWARRAY; +import org.apache.bcel6_2_0.generic.ASTORE; +import org.apache.bcel6_2_0.generic.ATHROW; +import org.apache.bcel6_2_0.generic.ArrayType; +import org.apache.bcel6_2_0.generic.BREAKPOINT; +import org.apache.bcel6_2_0.generic.CHECKCAST; +import org.apache.bcel6_2_0.generic.ConstantPoolGen; +import org.apache.bcel6_2_0.generic.DLOAD; +import org.apache.bcel6_2_0.generic.DSTORE; +import org.apache.bcel6_2_0.generic.FLOAD; +import org.apache.bcel6_2_0.generic.FSTORE; +import org.apache.bcel6_2_0.generic.FieldInstruction; +import org.apache.bcel6_2_0.generic.GETSTATIC; +import org.apache.bcel6_2_0.generic.GotoInstruction; +import org.apache.bcel6_2_0.generic.IINC; +import org.apache.bcel6_2_0.generic.ILOAD; +import org.apache.bcel6_2_0.generic.IMPDEP1; +import org.apache.bcel6_2_0.generic.IMPDEP2; +import org.apache.bcel6_2_0.generic.INSTANCEOF; +import org.apache.bcel6_2_0.generic.INVOKEDYNAMIC; +import org.apache.bcel6_2_0.generic.INVOKEINTERFACE; +import org.apache.bcel6_2_0.generic.INVOKESPECIAL; +import org.apache.bcel6_2_0.generic.INVOKESTATIC; +import org.apache.bcel6_2_0.generic.INVOKEVIRTUAL; +import org.apache.bcel6_2_0.generic.ISTORE; +import org.apache.bcel6_2_0.generic.Instruction; +import org.apache.bcel6_2_0.generic.InstructionHandle; +import org.apache.bcel6_2_0.generic.InstructionList; +import org.apache.bcel6_2_0.generic.InvokeInstruction; +import org.apache.bcel6_2_0.generic.JsrInstruction; +import org.apache.bcel6_2_0.generic.LDC; +import org.apache.bcel6_2_0.generic.LDC2_W; +import org.apache.bcel6_2_0.generic.LLOAD; +import org.apache.bcel6_2_0.generic.LOOKUPSWITCH; +import org.apache.bcel6_2_0.generic.LSTORE; +import org.apache.bcel6_2_0.generic.LoadClass; +import org.apache.bcel6_2_0.generic.MULTIANEWARRAY; +import org.apache.bcel6_2_0.generic.NEW; +import org.apache.bcel6_2_0.generic.NEWARRAY; +import org.apache.bcel6_2_0.generic.ObjectType; +import org.apache.bcel6_2_0.generic.PUTSTATIC; +import org.apache.bcel6_2_0.generic.RET; +import org.apache.bcel6_2_0.generic.ReferenceType; +import org.apache.bcel6_2_0.generic.ReturnInstruction; +import org.apache.bcel6_2_0.generic.TABLESWITCH; +import org.apache.bcel6_2_0.generic.Type; +import org.apache.bcel6_2_0.verifier.PassVerifier; +import org.apache.bcel6_2_0.verifier.VerificationResult; +import org.apache.bcel6_2_0.verifier.Verifier; +import org.apache.bcel6_2_0.verifier.VerifierFactory; +import org.apache.bcel6_2_0.verifier.exc.AssertionViolatedException; +import org.apache.bcel6_2_0.verifier.exc.ClassConstraintException; +import org.apache.bcel6_2_0.verifier.exc.InvalidMethodException; +import org.apache.bcel6_2_0.verifier.exc.StaticCodeConstraintException; +import org.apache.bcel6_2_0.verifier.exc.StaticCodeInstructionConstraintException; +import org.apache.bcel6_2_0.verifier.exc.StaticCodeInstructionOperandConstraintException; /** * This PassVerifier verifies a class file according to @@ -470,7 +470,7 @@ public int getMethodNo() { * This visitor class does the actual checking for the instruction * operand's constraints. */ - private class InstOperandConstraintVisitor extends org.apache.bcel.generic.EmptyVisitor{ + private class InstOperandConstraintVisitor extends org.apache.bcel6_2_0.generic.EmptyVisitor{ /** The ConstantPoolGen instance this Visitor operates on. */ private final ConstantPoolGen cpg; diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/StringRepresentation.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/StringRepresentation.java similarity index 76% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/StringRepresentation.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/StringRepresentation.java index bfcafdc4..57ac6dea 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/StringRepresentation.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/StringRepresentation.java @@ -15,55 +15,55 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.statics; - - -import org.apache.bcel.classfile.AnnotationDefault; -import org.apache.bcel.classfile.AnnotationEntry; -import org.apache.bcel.classfile.Annotations; -import org.apache.bcel.classfile.BootstrapMethods; -import org.apache.bcel.classfile.Code; -import org.apache.bcel.classfile.CodeException; -import org.apache.bcel.classfile.ConstantClass; -import org.apache.bcel.classfile.ConstantDouble; -import org.apache.bcel.classfile.ConstantFieldref; -import org.apache.bcel.classfile.ConstantFloat; -import org.apache.bcel.classfile.ConstantInteger; -import org.apache.bcel.classfile.ConstantInterfaceMethodref; -import org.apache.bcel.classfile.ConstantInvokeDynamic; -import org.apache.bcel.classfile.ConstantLong; -import org.apache.bcel.classfile.ConstantMethodHandle; -import org.apache.bcel.classfile.ConstantMethodType; -import org.apache.bcel.classfile.ConstantMethodref; -import org.apache.bcel.classfile.ConstantNameAndType; -import org.apache.bcel.classfile.ConstantPool; -import org.apache.bcel.classfile.ConstantString; -import org.apache.bcel.classfile.ConstantUtf8; -import org.apache.bcel.classfile.ConstantValue; -import org.apache.bcel.classfile.Deprecated; -import org.apache.bcel.classfile.EnclosingMethod; -import org.apache.bcel.classfile.ExceptionTable; -import org.apache.bcel.classfile.Field; -import org.apache.bcel.classfile.InnerClass; -import org.apache.bcel.classfile.InnerClasses; -import org.apache.bcel.classfile.JavaClass; -import org.apache.bcel.classfile.LineNumber; -import org.apache.bcel.classfile.LineNumberTable; -import org.apache.bcel.classfile.LocalVariable; -import org.apache.bcel.classfile.LocalVariableTable; -import org.apache.bcel.classfile.LocalVariableTypeTable; -import org.apache.bcel.classfile.Method; -import org.apache.bcel.classfile.MethodParameters; -import org.apache.bcel.classfile.Node; -import org.apache.bcel.classfile.ParameterAnnotationEntry; -import org.apache.bcel.classfile.ParameterAnnotations; -import org.apache.bcel.classfile.Signature; -import org.apache.bcel.classfile.SourceFile; -import org.apache.bcel.classfile.StackMap; -import org.apache.bcel.classfile.StackMapEntry; -import org.apache.bcel.classfile.Synthetic; -import org.apache.bcel.classfile.Unknown; -import org.apache.bcel.verifier.exc.AssertionViolatedException; +package org.apache.bcel6_2_0.verifier.statics; + + +import org.apache.bcel6_2_0.classfile.AnnotationDefault; +import org.apache.bcel6_2_0.classfile.AnnotationEntry; +import org.apache.bcel6_2_0.classfile.Annotations; +import org.apache.bcel6_2_0.classfile.BootstrapMethods; +import org.apache.bcel6_2_0.classfile.Code; +import org.apache.bcel6_2_0.classfile.CodeException; +import org.apache.bcel6_2_0.classfile.ConstantClass; +import org.apache.bcel6_2_0.classfile.ConstantDouble; +import org.apache.bcel6_2_0.classfile.ConstantFieldref; +import org.apache.bcel6_2_0.classfile.ConstantFloat; +import org.apache.bcel6_2_0.classfile.ConstantInteger; +import org.apache.bcel6_2_0.classfile.ConstantInterfaceMethodref; +import org.apache.bcel6_2_0.classfile.ConstantInvokeDynamic; +import org.apache.bcel6_2_0.classfile.ConstantLong; +import org.apache.bcel6_2_0.classfile.ConstantMethodHandle; +import org.apache.bcel6_2_0.classfile.ConstantMethodType; +import org.apache.bcel6_2_0.classfile.ConstantMethodref; +import org.apache.bcel6_2_0.classfile.ConstantNameAndType; +import org.apache.bcel6_2_0.classfile.ConstantPool; +import org.apache.bcel6_2_0.classfile.ConstantString; +import org.apache.bcel6_2_0.classfile.ConstantUtf8; +import org.apache.bcel6_2_0.classfile.ConstantValue; +import org.apache.bcel6_2_0.classfile.Deprecated; +import org.apache.bcel6_2_0.classfile.EnclosingMethod; +import org.apache.bcel6_2_0.classfile.ExceptionTable; +import org.apache.bcel6_2_0.classfile.Field; +import org.apache.bcel6_2_0.classfile.InnerClass; +import org.apache.bcel6_2_0.classfile.InnerClasses; +import org.apache.bcel6_2_0.classfile.JavaClass; +import org.apache.bcel6_2_0.classfile.LineNumber; +import org.apache.bcel6_2_0.classfile.LineNumberTable; +import org.apache.bcel6_2_0.classfile.LocalVariable; +import org.apache.bcel6_2_0.classfile.LocalVariableTable; +import org.apache.bcel6_2_0.classfile.LocalVariableTypeTable; +import org.apache.bcel6_2_0.classfile.Method; +import org.apache.bcel6_2_0.classfile.MethodParameters; +import org.apache.bcel6_2_0.classfile.Node; +import org.apache.bcel6_2_0.classfile.ParameterAnnotationEntry; +import org.apache.bcel6_2_0.classfile.ParameterAnnotations; +import org.apache.bcel6_2_0.classfile.Signature; +import org.apache.bcel6_2_0.classfile.SourceFile; +import org.apache.bcel6_2_0.classfile.StackMap; +import org.apache.bcel6_2_0.classfile.StackMapEntry; +import org.apache.bcel6_2_0.classfile.Synthetic; +import org.apache.bcel6_2_0.classfile.Unknown; +import org.apache.bcel6_2_0.verifier.exc.AssertionViolatedException; /** * BCEL's Node classes (those from the classfile API that accept() Visitor @@ -79,7 +79,7 @@ * * @version $Id: StringRepresentation.java 1806200 2017-08-25 16:33:06Z ggregory $ */ -public class StringRepresentation extends org.apache.bcel.classfile.EmptyVisitor { +public class StringRepresentation extends org.apache.bcel6_2_0.classfile.EmptyVisitor { /** The string representation, created by a visitXXX() method, output by toString(). */ private String tostring; /** The node we ask for its string representation. Not really needed; only for debug output. */ diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/package.html b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/package.html similarity index 100% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/statics/package.html rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/statics/package.html diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ControlFlowGraph.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/ControlFlowGraph.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ControlFlowGraph.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/ControlFlowGraph.java index 911817b4..773f39a3 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ControlFlowGraph.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/ControlFlowGraph.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.structurals; +package org.apache.bcel6_2_0.verifier.structurals; import java.util.ArrayList; @@ -23,18 +23,18 @@ import java.util.List; import java.util.Map; -import org.apache.bcel.generic.ATHROW; -import org.apache.bcel.generic.BranchInstruction; -import org.apache.bcel.generic.GotoInstruction; -import org.apache.bcel.generic.Instruction; -import org.apache.bcel.generic.InstructionHandle; -import org.apache.bcel.generic.JsrInstruction; -import org.apache.bcel.generic.MethodGen; -import org.apache.bcel.generic.RET; -import org.apache.bcel.generic.ReturnInstruction; -import org.apache.bcel.generic.Select; -import org.apache.bcel.verifier.exc.AssertionViolatedException; -import org.apache.bcel.verifier.exc.StructuralCodeConstraintException; +import org.apache.bcel6_2_0.generic.ATHROW; +import org.apache.bcel6_2_0.generic.BranchInstruction; +import org.apache.bcel6_2_0.generic.GotoInstruction; +import org.apache.bcel6_2_0.generic.Instruction; +import org.apache.bcel6_2_0.generic.InstructionHandle; +import org.apache.bcel6_2_0.generic.JsrInstruction; +import org.apache.bcel6_2_0.generic.MethodGen; +import org.apache.bcel6_2_0.generic.RET; +import org.apache.bcel6_2_0.generic.ReturnInstruction; +import org.apache.bcel6_2_0.generic.Select; +import org.apache.bcel6_2_0.verifier.exc.AssertionViolatedException; +import org.apache.bcel6_2_0.verifier.exc.StructuralCodeConstraintException; /** * This class represents a control flow graph of a method. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ExceptionHandler.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/ExceptionHandler.java similarity index 90% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ExceptionHandler.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/ExceptionHandler.java index ddbe1e50..1c84b219 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ExceptionHandler.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/ExceptionHandler.java @@ -15,11 +15,11 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.structurals; +package org.apache.bcel6_2_0.verifier.structurals; -import org.apache.bcel.generic.InstructionHandle; -import org.apache.bcel.generic.ObjectType; +import org.apache.bcel6_2_0.generic.InstructionHandle; +import org.apache.bcel6_2_0.generic.ObjectType; /** * This class represents an exception handler; that is, an ObjectType diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ExceptionHandlers.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/ExceptionHandlers.java similarity index 90% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ExceptionHandlers.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/ExceptionHandlers.java index 052045e0..5f0b1d7d 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ExceptionHandlers.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/ExceptionHandlers.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.structurals; +package org.apache.bcel6_2_0.verifier.structurals; import java.util.HashMap; @@ -23,9 +23,9 @@ import java.util.Map; import java.util.Set; -import org.apache.bcel.generic.CodeExceptionGen; -import org.apache.bcel.generic.InstructionHandle; -import org.apache.bcel.generic.MethodGen; +import org.apache.bcel6_2_0.generic.CodeExceptionGen; +import org.apache.bcel6_2_0.generic.InstructionHandle; +import org.apache.bcel6_2_0.generic.MethodGen; /** * This class allows easy access to ExceptionHandler objects. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ExecutionVisitor.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/ExecutionVisitor.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ExecutionVisitor.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/ExecutionVisitor.java index 784bbf78..edf2a476 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/ExecutionVisitor.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/ExecutionVisitor.java @@ -15,20 +15,18 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.structurals; +package org.apache.bcel6_2_0.verifier.structurals; -import org.apache.bcel.Const; -import org.apache.bcel.classfile.Constant; -import org.apache.bcel.classfile.ConstantClass; -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; -// CHECKSTYLE:OFF (there are lots of references!) -import org.apache.bcel.generic.*; -//CHECKSTYLE:ON +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.classfile.Constant; +import org.apache.bcel6_2_0.classfile.ConstantClass; +import org.apache.bcel6_2_0.classfile.ConstantDouble; +import org.apache.bcel6_2_0.classfile.ConstantFloat; +import org.apache.bcel6_2_0.classfile.ConstantInteger; +import org.apache.bcel6_2_0.classfile.ConstantLong; +import org.apache.bcel6_2_0.classfile.ConstantString; +import org.apache.bcel6_2_0.generic.*; /** * This Visitor class may be used for a type-based Java Virtual Machine diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/Frame.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/Frame.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/Frame.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/Frame.java index acbcaa66..3cb03cb4 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/Frame.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/Frame.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.structurals; +package org.apache.bcel6_2_0.verifier.structurals; diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/GenericArray.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/GenericArray.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/GenericArray.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/GenericArray.java index 9994ca4c..bdf91d4a 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/GenericArray.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/GenericArray.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.structurals; +package org.apache.bcel6_2_0.verifier.structurals; /** diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/InstConstraintVisitor.java similarity index 96% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/InstConstraintVisitor.java index 74ea2329..07f58073 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/InstConstraintVisitor.java @@ -15,29 +15,27 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.structurals; - - -import org.apache.bcel.Const; -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.ConstantFieldref; -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.classfile.Field; -import org.apache.bcel.classfile.JavaClass; -//CHECKSTYLE:OFF (there are lots of references!) -import org.apache.bcel.generic.*; -//CHECKSTYLE:ON -import org.apache.bcel.verifier.VerificationResult; -import org.apache.bcel.verifier.Verifier; -import org.apache.bcel.verifier.VerifierFactory; -import org.apache.bcel.verifier.exc.AssertionViolatedException; -import org.apache.bcel.verifier.exc.StructuralCodeConstraintException; +package org.apache.bcel6_2_0.verifier.structurals; + + +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.Repository; +import org.apache.bcel6_2_0.classfile.Constant; +import org.apache.bcel6_2_0.classfile.ConstantClass; +import org.apache.bcel6_2_0.classfile.ConstantDouble; +import org.apache.bcel6_2_0.classfile.ConstantFieldref; +import org.apache.bcel6_2_0.classfile.ConstantFloat; +import org.apache.bcel6_2_0.classfile.ConstantInteger; +import org.apache.bcel6_2_0.classfile.ConstantLong; +import org.apache.bcel6_2_0.classfile.ConstantString; +import org.apache.bcel6_2_0.classfile.Field; +import org.apache.bcel6_2_0.classfile.JavaClass; +import org.apache.bcel6_2_0.generic.*; +import org.apache.bcel6_2_0.verifier.VerificationResult; +import org.apache.bcel6_2_0.verifier.Verifier; +import org.apache.bcel6_2_0.verifier.VerifierFactory; +import org.apache.bcel6_2_0.verifier.exc.AssertionViolatedException; +import org.apache.bcel6_2_0.verifier.exc.StructuralCodeConstraintException; /** diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/InstructionContext.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/InstructionContext.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/InstructionContext.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/InstructionContext.java index df812d10..007445a4 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/InstructionContext.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/InstructionContext.java @@ -15,12 +15,12 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.structurals; +package org.apache.bcel6_2_0.verifier.structurals; import java.util.ArrayList; -import org.apache.bcel.generic.InstructionHandle; +import org.apache.bcel6_2_0.generic.InstructionHandle; /** * An InstructionContext offers convenient access diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/LocalVariables.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/LocalVariables.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/LocalVariables.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/LocalVariables.java index 2b1172a0..5031cd36 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/LocalVariables.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/LocalVariables.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.structurals; +package org.apache.bcel6_2_0.verifier.structurals; -import org.apache.bcel.generic.ReferenceType; -import org.apache.bcel.generic.Type; -import org.apache.bcel.verifier.exc.AssertionViolatedException; -import org.apache.bcel.verifier.exc.StructuralCodeConstraintException; +import org.apache.bcel6_2_0.generic.ReferenceType; +import org.apache.bcel6_2_0.generic.Type; +import org.apache.bcel6_2_0.verifier.exc.AssertionViolatedException; +import org.apache.bcel6_2_0.verifier.exc.StructuralCodeConstraintException; /** * This class implements an array of local variables used for symbolic JVM diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/OperandStack.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/OperandStack.java similarity index 93% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/OperandStack.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/OperandStack.java index f7e95c09..eb9040c2 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/OperandStack.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/OperandStack.java @@ -15,16 +15,16 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.structurals; +package org.apache.bcel6_2_0.verifier.structurals; import java.util.ArrayList; -import org.apache.bcel.generic.ObjectType; -import org.apache.bcel.generic.ReferenceType; -import org.apache.bcel.generic.Type; -import org.apache.bcel.verifier.exc.AssertionViolatedException; -import org.apache.bcel.verifier.exc.StructuralCodeConstraintException; +import org.apache.bcel6_2_0.generic.ObjectType; +import org.apache.bcel6_2_0.generic.ReferenceType; +import org.apache.bcel6_2_0.generic.Type; +import org.apache.bcel6_2_0.verifier.exc.AssertionViolatedException; +import org.apache.bcel6_2_0.verifier.exc.StructuralCodeConstraintException; /** * This class implements a stack used for symbolic JVM stack simulation. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/Pass3bVerifier.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/Pass3bVerifier.java similarity index 91% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/Pass3bVerifier.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/Pass3bVerifier.java index dea59498..626192af 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/Pass3bVerifier.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/Pass3bVerifier.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.structurals; +package org.apache.bcel6_2_0.verifier.structurals; import java.io.PrintWriter; @@ -25,26 +25,26 @@ import java.util.Random; import java.util.Vector; -import org.apache.bcel.Const; -import org.apache.bcel.Repository; -import org.apache.bcel.classfile.JavaClass; -import org.apache.bcel.classfile.Method; -import org.apache.bcel.generic.ConstantPoolGen; -import org.apache.bcel.generic.InstructionHandle; -import org.apache.bcel.generic.JsrInstruction; -import org.apache.bcel.generic.MethodGen; -import org.apache.bcel.generic.ObjectType; -import org.apache.bcel.generic.RET; -import org.apache.bcel.generic.ReferenceType; -import org.apache.bcel.generic.ReturnInstruction; -import org.apache.bcel.generic.ReturnaddressType; -import org.apache.bcel.generic.Type; -import org.apache.bcel.verifier.PassVerifier; -import org.apache.bcel.verifier.VerificationResult; -import org.apache.bcel.verifier.Verifier; -import org.apache.bcel.verifier.exc.AssertionViolatedException; -import org.apache.bcel.verifier.exc.StructuralCodeConstraintException; -import org.apache.bcel.verifier.exc.VerifierConstraintViolatedException; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.Repository; +import org.apache.bcel6_2_0.classfile.JavaClass; +import org.apache.bcel6_2_0.classfile.Method; +import org.apache.bcel6_2_0.generic.ConstantPoolGen; +import org.apache.bcel6_2_0.generic.InstructionHandle; +import org.apache.bcel6_2_0.generic.JsrInstruction; +import org.apache.bcel6_2_0.generic.MethodGen; +import org.apache.bcel6_2_0.generic.ObjectType; +import org.apache.bcel6_2_0.generic.RET; +import org.apache.bcel6_2_0.generic.ReferenceType; +import org.apache.bcel6_2_0.generic.ReturnInstruction; +import org.apache.bcel6_2_0.generic.ReturnaddressType; +import org.apache.bcel6_2_0.generic.Type; +import org.apache.bcel6_2_0.verifier.PassVerifier; +import org.apache.bcel6_2_0.verifier.VerificationResult; +import org.apache.bcel6_2_0.verifier.Verifier; +import org.apache.bcel6_2_0.verifier.exc.AssertionViolatedException; +import org.apache.bcel6_2_0.verifier.exc.StructuralCodeConstraintException; +import org.apache.bcel6_2_0.verifier.exc.VerifierConstraintViolatedException; /** * This PassVerifier verifies a method of class file according to pass 3, @@ -112,7 +112,7 @@ public int size() { /** * This class should only be instantiated by a Verifier. * - * @see org.apache.bcel.verifier.Verifier + * @see org.apache.bcel6_2_0.verifier.Verifier */ public Pass3bVerifier(final Verifier owner, final int method_no) { myOwner = owner; @@ -310,8 +310,8 @@ public void invalidReturnTypeError(final Type returnedType, final MethodGen m) { * 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) + * @see org.apache.bcel6_2_0.verifier.statics.LocalVariablesInfo + * @see org.apache.bcel6_2_0.verifier.statics.Pass2Verifier#getLocalVariablesInfo(int) */ @Override public VerificationResult do_verify() { diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/Subroutine.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/Subroutine.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/Subroutine.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/Subroutine.java index 363adf2b..50c41309 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/Subroutine.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/Subroutine.java @@ -15,10 +15,10 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.structurals; +package org.apache.bcel6_2_0.verifier.structurals; -import org.apache.bcel.generic.InstructionHandle; +import org.apache.bcel6_2_0.generic.InstructionHandle; /** * This interface defines properties of JVM bytecode subroutines. diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/Subroutines.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/Subroutines.java similarity index 94% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/Subroutines.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/Subroutines.java index 21a76348..4b7f7b6e 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/Subroutines.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/Subroutines.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.structurals; +package org.apache.bcel6_2_0.verifier.structurals; import java.util.ArrayList; import java.util.HashMap; @@ -24,22 +24,22 @@ import java.util.Map; import java.util.Set; -import org.apache.bcel.generic.ASTORE; -import org.apache.bcel.generic.ATHROW; -import org.apache.bcel.generic.BranchInstruction; -import org.apache.bcel.generic.CodeExceptionGen; -import org.apache.bcel.generic.GotoInstruction; -import org.apache.bcel.generic.IndexedInstruction; -import org.apache.bcel.generic.Instruction; -import org.apache.bcel.generic.InstructionHandle; -import org.apache.bcel.generic.JsrInstruction; -import org.apache.bcel.generic.LocalVariableInstruction; -import org.apache.bcel.generic.MethodGen; -import org.apache.bcel.generic.RET; -import org.apache.bcel.generic.ReturnInstruction; -import org.apache.bcel.generic.Select; -import org.apache.bcel.verifier.exc.AssertionViolatedException; -import org.apache.bcel.verifier.exc.StructuralCodeConstraintException; +import org.apache.bcel6_2_0.generic.ASTORE; +import org.apache.bcel6_2_0.generic.ATHROW; +import org.apache.bcel6_2_0.generic.BranchInstruction; +import org.apache.bcel6_2_0.generic.CodeExceptionGen; +import org.apache.bcel6_2_0.generic.GotoInstruction; +import org.apache.bcel6_2_0.generic.IndexedInstruction; +import org.apache.bcel6_2_0.generic.Instruction; +import org.apache.bcel6_2_0.generic.InstructionHandle; +import org.apache.bcel6_2_0.generic.JsrInstruction; +import org.apache.bcel6_2_0.generic.LocalVariableInstruction; +import org.apache.bcel6_2_0.generic.MethodGen; +import org.apache.bcel6_2_0.generic.RET; +import org.apache.bcel6_2_0.generic.ReturnInstruction; +import org.apache.bcel6_2_0.generic.Select; +import org.apache.bcel6_2_0.verifier.exc.AssertionViolatedException; +import org.apache.bcel6_2_0.verifier.exc.StructuralCodeConstraintException; /** * Instances of this class contain information about the subroutines diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/UninitializedObjectType.java b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/UninitializedObjectType.java similarity index 88% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/UninitializedObjectType.java rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/UninitializedObjectType.java index f83ce9d6..4441fe74 100644 --- a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/UninitializedObjectType.java +++ b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/UninitializedObjectType.java @@ -15,13 +15,13 @@ * limitations under the License. * */ -package org.apache.bcel.verifier.structurals; +package org.apache.bcel6_2_0.verifier.structurals; -import org.apache.bcel.Const; -import org.apache.bcel.Constants; -import org.apache.bcel.generic.ObjectType; -import org.apache.bcel.generic.ReferenceType; +import org.apache.bcel6_2_0.Const; +import org.apache.bcel6_2_0.Constants; +import org.apache.bcel6_2_0.generic.ObjectType; +import org.apache.bcel6_2_0.generic.ReferenceType; /** * This class represents an uninitialized object type; see The Java diff --git a/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/package.html b/Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/package.html similarity index 100% rename from Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel/verifier/structurals/package.html rename to Core/org.emftext.language.java.resource.bcel/src-bcel/org/apache/bcel6_2_0/verifier/structurals/package.html diff --git a/Core/org.emftext.language.java.resource/src/org/emftext/language/java/resource/ClassFileModelLoader.java b/Core/org.emftext.language.java.resource/src/org/emftext/language/java/resource/ClassFileModelLoader.java index 7dbb0322..2960365c 100755 --- a/Core/org.emftext.language.java.resource/src/org/emftext/language/java/resource/ClassFileModelLoader.java +++ b/Core/org.emftext.language.java.resource/src/org/emftext/language/java/resource/ClassFileModelLoader.java @@ -21,11 +21,11 @@ import java.util.Arrays; import java.util.List; -import org.apache.bcel.classfile.Attribute; -import org.apache.bcel.classfile.ClassParser; -import org.apache.bcel.classfile.JavaClass; -import org.apache.bcel.classfile.Signature; -import org.apache.bcel.classfile.Utility; +import org.apache.bcel6_2_0.classfile.Attribute; +import org.apache.bcel6_2_0.classfile.ClassParser; +import org.apache.bcel6_2_0.classfile.JavaClass; +import org.apache.bcel6_2_0.classfile.Signature; +import org.apache.bcel6_2_0.classfile.Utility; import org.eclipse.emf.common.util.BasicEList; import org.eclipse.emf.common.util.EList; import org.emftext.language.java.JavaClasspath; @@ -191,7 +191,7 @@ else if (clazz.isInterface()) { } } - for (org.apache.bcel.classfile.Field field : clazz.getFields()) { + for (org.apache.bcel6_2_0.classfile.Field field : clazz.getFields()) { if (field.isEnum() && emfClassifier instanceof Enumeration) { ((Enumeration)emfClassifier).getConstants().add(constructEnumConstant(field)); } @@ -200,7 +200,7 @@ else if (clazz.isInterface()) { } } - for (org.apache.bcel.classfile.Method method : clazz.getMethods()) { + for (org.apache.bcel6_2_0.classfile.Method method : clazz.getMethods()) { if (!method.isSynthetic()) { Member emfMember = constructMethod(method, emfClassifier, false); //If the last parameter has an array type it could also be a variable length parameter. @@ -227,7 +227,7 @@ else if (clazz.isInterface()) { return emfClassifier; } - protected Member constructMethod(org.apache.bcel.classfile.Method method, ConcreteClassifier emfClassifier, boolean withVariableLength) { + protected Member constructMethod(org.apache.bcel6_2_0.classfile.Method method, ConcreteClassifier emfClassifier, boolean withVariableLength) { Method emfMethod = null; if (emfClassifier instanceof Annotation) { emfMethod = annotationsFactory.createAnnotationAttribute(); @@ -270,7 +270,7 @@ protected Member constructMethod(org.apache.bcel.classfile.Method method, Concre List parameterNames = extractParameterNames(method); for(int i = 0; i < method.getArgumentTypes().length; i++) { - org.apache.bcel.generic.Type argType = method.getArgumentTypes()[i]; + org.apache.bcel6_2_0.generic.Type argType = method.getArgumentTypes()[i]; String paramName; if (parameterNames.size() > i) { paramName = parameterNames.get(i); @@ -332,7 +332,7 @@ protected Member constructMethod(org.apache.bcel.classfile.Method method, Concre return (Member) emfMethod; } - protected Parameter constructParameter(org.apache.bcel.generic.Type attrType, String paramName) { + protected Parameter constructParameter(org.apache.bcel6_2_0.generic.Type attrType, String paramName) { Parameter emfParameter = parametersFactory.createOrdinaryParameter(); String signature = attrType.getSignature(); TypeReference emfTypeReference = createReferenceToType(signature); @@ -348,7 +348,7 @@ protected Parameter constructParameter(org.apache.bcel.generic.Type attrType, St return emfParameter; } - protected Parameter constructVariableLengthParameter(org.apache.bcel.generic.Type attrType, String paramName) { + protected Parameter constructVariableLengthParameter(org.apache.bcel6_2_0.generic.Type attrType, String paramName) { Parameter emfParameter = parametersFactory.createVariableLengthParameter(); String signature = attrType.getSignature(); TypeReference emfTypeReference = createReferenceToType(signature); @@ -364,7 +364,7 @@ protected Parameter constructVariableLengthParameter(org.apache.bcel.generic.Typ return emfParameter; } - protected Field constructField(org.apache.bcel.classfile.Field field, ConcreteClassifier emfClassifier) { + protected Field constructField(org.apache.bcel6_2_0.classfile.Field field, ConcreteClassifier emfClassifier) { Field emfField = membersFactory.createField(); emfField.setName(field.getName()); String signature = field.getType().getSignature(); @@ -403,7 +403,7 @@ protected Field constructField(org.apache.bcel.classfile.Field field, ConcreteCl return emfField; } - protected void constructModifiers(AnnotableAndModifiable emfMember, org.apache.bcel.classfile.AccessFlags member) { + protected void constructModifiers(AnnotableAndModifiable emfMember, org.apache.bcel6_2_0.classfile.AccessFlags member) { ModifiersFactory f = ModifiersFactory.eINSTANCE; if (member.isAbstract()) { emfMember.getAnnotationsAndModifiers().add(f.createAbstract()); @@ -447,7 +447,7 @@ protected void constructModifiers(AnnotableAndModifiable emfMember, org.apache.b } protected EnumConstant constructEnumConstant( - org.apache.bcel.classfile.Field field) { + org.apache.bcel6_2_0.classfile.Field field) { EnumConstant enumConstant = membersFactory.createEnumConstant(); enumConstant.setName(field.getName()); @@ -809,7 +809,7 @@ protected int getArrayDimension(String signature) { return arrayDimension; } - protected List extractParameterNames(final org.apache.bcel.classfile.Method method) { + protected List extractParameterNames(final org.apache.bcel6_2_0.classfile.Method method) { final List names = new ArrayList(); if (method.getLocalVariableTable() == null) { return names; @@ -818,7 +818,7 @@ protected List extractParameterNames(final org.apache.bcel.classfile.Met final int start = method.isStatic() ? 0 : 1; final int stop = method.isStatic() ? method.getArgumentTypes().length : method.getArgumentTypes().length + 1; - final org.apache.bcel.classfile.LocalVariable[] variables = method + final org.apache.bcel6_2_0.classfile.LocalVariable[] variables = method .getLocalVariableTable().getLocalVariableTable(); if (variables != null) { for (int i = start; i < stop && i < variables.length; i++) {